gtkgesturezoom.go RawHistoryFolder
1// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package gtk
3
4import (
5 "structs"
6 "unsafe"
7
8 "github.com/ebitengine/purego"
9
10 "github.com/bnema/puregotk/pkg/core"
11 "github.com/bnema/puregotk/v4/glib"
12 "github.com/bnema/puregotk/v4/gobject"
13 "github.com/bnema/puregotk/v4/gobject/types"
14)
15
16type GestureZoomClass struct {
17 _ structs.HostLayout
18}
19
20func (x *GestureZoomClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// Recognizes 2-finger pinch/zoom gestures.
25//
26// Whenever the distance between both tracked sequences changes, the
27// [signal@Gtk.GestureZoom::scale-changed] signal is emitted to report
28// the scale factor.
29type GestureZoom struct {
30 Gesture
31}
32
33var xGestureZoomGLibType func() types.GType
34
35func GestureZoomGLibType() types.GType {
36 return xGestureZoomGLibType()
37}
38
39func GestureZoomNewFromInternalPtr(ptr uintptr) *GestureZoom {
40 cls := &GestureZoom{}
41 cls.Ptr = ptr
42 return cls
43}
44
45var xNewGestureZoom func() uintptr
46
47// Returns a newly created `GtkGesture` that recognizes
48// pinch/zoom gestures.
49func NewGestureZoom() *GestureZoom {
50 var cls *GestureZoom
51
52 cret := xNewGestureZoom()
53
54 if cret == 0 {
55 return nil
56 }
57 cls = &GestureZoom{}
58 cls.Ptr = cret
59 return cls
60}
61
62var xGestureZoomGetScaleDelta func(uintptr) float64
63
64// Gets the scale delta.
65//
66// If @gesture is active, this function returns the zooming
67// difference since the gesture was recognized (hence the
68// starting point is considered 1:1). If @gesture is not
69// active, 1 is returned.
70func (x *GestureZoom) GetScaleDelta() float64 {
71
72 cret := xGestureZoomGetScaleDelta(x.GoPointer())
73 return cret
74}
75
76func (c *GestureZoom) GoPointer() uintptr {
77 if c == nil {
78 return 0
79 }
80 return c.Ptr
81}
82
83func (c *GestureZoom) SetGoPointer(ptr uintptr) {
84 c.Ptr = ptr
85}
86
87// Emitted whenever the distance between both tracked sequences changes.
88func (x *GestureZoom) ConnectScaleChanged(cb *func(GestureZoom, float64)) uint {
89 cbPtr := uintptr(unsafe.Pointer(cb))
90 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
91 handlerID := gobject.SignalConnect(x.GoPointer(), "scale-changed", cbRefPtr)
92 glib.SaveHandlerMapping(handlerID, cbPtr)
93 return handlerID
94 }
95
96 fcb := func(clsPtr uintptr, ScaleVarp float64) {
97 fa := GestureZoom{}
98 fa.Ptr = clsPtr
99 cbFn := *cb
100
101 cbFn(fa, ScaleVarp)
102
103 }
104 cbRefPtr := purego.NewCallback(fcb)
105 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
106 handlerID := gobject.SignalConnect(x.GoPointer(), "scale-changed", cbRefPtr)
107 glib.SaveHandlerMapping(handlerID, cbPtr)
108 return handlerID
109}
110
111func init() {
112 core.SetPackageName("GTK", "gtk4")
113 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
114 var libs []uintptr
115 for _, libPath := range core.GetPaths("GTK") {
116 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
117 if err != nil {
118 panic(err)
119 }
120 libs = append(libs, lib)
121 }
122
123 core.PuregoSafeRegister(&xGestureZoomGLibType, libs, "gtk_gesture_zoom_get_type")
124
125 core.PuregoSafeRegister(&xNewGestureZoom, libs, "gtk_gesture_zoom_new")
126
127 core.PuregoSafeRegister(&xGestureZoomGetScaleDelta, libs, "gtk_gesture_zoom_get_scale_delta")
128
129}