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 GesturePanClass struct {
17 _ structs.HostLayout
18}
19
20func (x *GesturePanClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// Recognizes pan gestures.
25//
26// These are drags that are locked to happen along one axis. The axis
27// that a `GtkGesturePan` handles is defined at construct time, and
28// can be changed through [method@Gtk.GesturePan.set_orientation].
29//
30// When the gesture starts to be recognized, `GtkGesturePan` will
31// attempt to determine as early as possible whether the sequence
32// is moving in the expected direction, and denying the sequence if
33// this does not happen.
34//
35// Once a panning gesture along the expected axis is recognized,
36// the [signal@Gtk.GesturePan::pan] signal will be emitted as input
37// events are received, containing the offset in the given axis.
38type GesturePan struct {
39 GestureDrag
40}
41
42var xGesturePanGLibType func() types.GType
43
44func GesturePanGLibType() types.GType {
45 return xGesturePanGLibType()
46}
47
48func GesturePanNewFromInternalPtr(ptr uintptr) *GesturePan {
49 cls := &GesturePan{}
50 cls.Ptr = ptr
51 return cls
52}
53
54var xNewGesturePan func(Orientation) uintptr
55
56// Returns a newly created `GtkGesture` that recognizes pan gestures.
57func NewGesturePan(OrientationVar Orientation) *GesturePan {
58 var cls *GesturePan
59
60 cret := xNewGesturePan(OrientationVar)
61
62 if cret == 0 {
63 return nil
64 }
65 cls = &GesturePan{}
66 cls.Ptr = cret
67 return cls
68}
69
70var xGesturePanGetOrientation func(uintptr) Orientation
71
72// Returns the orientation of the pan gestures that this @gesture expects.
73func (x *GesturePan) GetOrientation() Orientation {
74
75 cret := xGesturePanGetOrientation(x.GoPointer())
76 return cret
77}
78
79var xGesturePanSetOrientation func(uintptr, Orientation)
80
81// Sets the orientation to be expected on pan gestures.
82func (x *GesturePan) SetOrientation(OrientationVar Orientation) {
83
84 xGesturePanSetOrientation(x.GoPointer(), OrientationVar)
85
86}
87
88func (c *GesturePan) GoPointer() uintptr {
89 if c == nil {
90 return 0
91 }
92 return c.Ptr
93}
94
95func (c *GesturePan) SetGoPointer(ptr uintptr) {
96 c.Ptr = ptr
97}
98
99// Emitted once a panning gesture along the expected axis is detected.
100func (x *GesturePan) ConnectPan(cb *func(GesturePan, PanDirection, float64)) uint {
101 cbPtr := uintptr(unsafe.Pointer(cb))
102 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
103 handlerID := gobject.SignalConnect(x.GoPointer(), "pan", cbRefPtr)
104 glib.SaveHandlerMapping(handlerID, cbPtr)
105 return handlerID
106 }
107
108 fcb := func(clsPtr uintptr, DirectionVarp PanDirection, OffsetVarp float64) {
109 fa := GesturePan{}
110 fa.Ptr = clsPtr
111 cbFn := *cb
112
113 cbFn(fa, DirectionVarp, OffsetVarp)
114
115 }
116 cbRefPtr := purego.NewCallback(fcb)
117 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
118 handlerID := gobject.SignalConnect(x.GoPointer(), "pan", cbRefPtr)
119 glib.SaveHandlerMapping(handlerID, cbPtr)
120 return handlerID
121}
122
123func init() {
124 core.SetPackageName("GTK", "gtk4")
125 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
126 var libs []uintptr
127 for _, libPath := range core.GetPaths("GTK") {
128 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
129 if err != nil {
130 panic(err)
131 }
132 libs = append(libs, lib)
133 }
134
135 core.PuregoSafeRegister(&xGesturePanGLibType, libs, "gtk_gesture_pan_get_type")
136
137 core.PuregoSafeRegister(&xNewGesturePan, libs, "gtk_gesture_pan_new")
138
139 core.PuregoSafeRegister(&xGesturePanGetOrientation, libs, "gtk_gesture_pan_get_orientation")
140 core.PuregoSafeRegister(&xGesturePanSetOrientation, libs, "gtk_gesture_pan_set_orientation")
141
142}