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 GestureSwipeClass struct {
17 _ structs.HostLayout
18}
19
20func (x *GestureSwipeClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// Recognizes swipe gestures.
25//
26// After a press/move/.../move/release sequence happens, the
27// [signal@Gtk.GestureSwipe::swipe] signal will be emitted,
28// providing the velocity and directionality of the sequence
29// at the time it was lifted.
30//
31// If the velocity is desired in intermediate points,
32// [method@Gtk.GestureSwipe.get_velocity] can be called in a
33// [signal@Gtk.Gesture::update] handler.
34//
35// All velocities are reported in pixels/sec units.
36type GestureSwipe struct {
37 GestureSingle
38}
39
40var xGestureSwipeGLibType func() types.GType
41
42func GestureSwipeGLibType() types.GType {
43 return xGestureSwipeGLibType()
44}
45
46func GestureSwipeNewFromInternalPtr(ptr uintptr) *GestureSwipe {
47 cls := &GestureSwipe{}
48 cls.Ptr = ptr
49 return cls
50}
51
52var xNewGestureSwipe func() uintptr
53
54// Returns a newly created `GtkGesture` that recognizes swipes.
55func NewGestureSwipe() *GestureSwipe {
56 var cls *GestureSwipe
57
58 cret := xNewGestureSwipe()
59
60 if cret == 0 {
61 return nil
62 }
63 cls = &GestureSwipe{}
64 cls.Ptr = cret
65 return cls
66}
67
68var xGestureSwipeGetVelocity func(uintptr, *float64, *float64) bool
69
70// Gets the current velocity.
71//
72// If the gesture is recognized, this function returns %TRUE and fills
73// in @velocity_x and @velocity_y with the recorded velocity, as per the
74// last events processed.
75func (x *GestureSwipe) GetVelocity(VelocityXVar *float64, VelocityYVar *float64) bool {
76
77 cret := xGestureSwipeGetVelocity(x.GoPointer(), VelocityXVar, VelocityYVar)
78 return cret
79}
80
81func (c *GestureSwipe) GoPointer() uintptr {
82 if c == nil {
83 return 0
84 }
85 return c.Ptr
86}
87
88func (c *GestureSwipe) SetGoPointer(ptr uintptr) {
89 c.Ptr = ptr
90}
91
92// Emitted when the recognized gesture is finished.
93//
94// Velocity and direction are a product of previously recorded events.
95func (x *GestureSwipe) ConnectSwipe(cb *func(GestureSwipe, float64, float64)) uint {
96 cbPtr := uintptr(unsafe.Pointer(cb))
97 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
98 handlerID := gobject.SignalConnect(x.GoPointer(), "swipe", cbRefPtr)
99 glib.SaveHandlerMapping(handlerID, cbPtr)
100 return handlerID
101 }
102
103 fcb := func(clsPtr uintptr, VelocityXVarp float64, VelocityYVarp float64) {
104 fa := GestureSwipe{}
105 fa.Ptr = clsPtr
106 cbFn := *cb
107
108 cbFn(fa, VelocityXVarp, VelocityYVarp)
109
110 }
111 cbRefPtr := purego.NewCallback(fcb)
112 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
113 handlerID := gobject.SignalConnect(x.GoPointer(), "swipe", cbRefPtr)
114 glib.SaveHandlerMapping(handlerID, cbPtr)
115 return handlerID
116}
117
118func init() {
119 core.SetPackageName("GTK", "gtk4")
120 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
121 var libs []uintptr
122 for _, libPath := range core.GetPaths("GTK") {
123 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
124 if err != nil {
125 panic(err)
126 }
127 libs = append(libs, lib)
128 }
129
130 core.PuregoSafeRegister(&xGestureSwipeGLibType, libs, "gtk_gesture_swipe_get_type")
131
132 core.PuregoSafeRegister(&xNewGestureSwipe, libs, "gtk_gesture_swipe_new")
133
134 core.PuregoSafeRegister(&xGestureSwipeGetVelocity, libs, "gtk_gesture_swipe_get_velocity")
135
136}