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/gdk"
12 "github.com/bnema/puregotk/v4/glib"
13 "github.com/bnema/puregotk/v4/gobject"
14 "github.com/bnema/puregotk/v4/gobject/types"
15)
16
17type DropControllerMotionClass struct {
18 _ structs.HostLayout
19}
20
21func (x *DropControllerMotionClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// An event controller tracking the pointer during Drag-and-Drop operations.
26//
27// It is modeled after [class@Gtk.EventControllerMotion] so if you
28// have used that, this should feel really familiar.
29//
30// This controller is not able to accept drops, use [class@Gtk.DropTarget]
31// for that purpose.
32type DropControllerMotion struct {
33 EventController
34}
35
36var xDropControllerMotionGLibType func() types.GType
37
38func DropControllerMotionGLibType() types.GType {
39 return xDropControllerMotionGLibType()
40}
41
42func DropControllerMotionNewFromInternalPtr(ptr uintptr) *DropControllerMotion {
43 cls := &DropControllerMotion{}
44 cls.Ptr = ptr
45 return cls
46}
47
48var xNewDropControllerMotion func() uintptr
49
50// Creates a new event controller that will handle pointer motion
51// events during drag and drop.
52func NewDropControllerMotion() *DropControllerMotion {
53 var cls *DropControllerMotion
54
55 cret := xNewDropControllerMotion()
56
57 if cret == 0 {
58 return nil
59 }
60 cls = &DropControllerMotion{}
61 cls.Ptr = cret
62 return cls
63}
64
65var xDropControllerMotionContainsPointer func(uintptr) bool
66
67// Returns if a Drag-and-Drop operation is within the widget
68// @self or one of its children.
69func (x *DropControllerMotion) ContainsPointer() bool {
70
71 cret := xDropControllerMotionContainsPointer(x.GoPointer())
72 return cret
73}
74
75var xDropControllerMotionGetDrop func(uintptr) uintptr
76
77// Returns the `GdkDrop` of a current Drag-and-Drop operation
78// over the widget of @self.
79func (x *DropControllerMotion) GetDrop() *gdk.Drop {
80 var cls *gdk.Drop
81
82 cret := xDropControllerMotionGetDrop(x.GoPointer())
83
84 if cret == 0 {
85 return nil
86 }
87 gobject.IncreaseRef(cret)
88 cls = &gdk.Drop{}
89 cls.Ptr = cret
90 return cls
91}
92
93var xDropControllerMotionIsPointer func(uintptr) bool
94
95// Returns if a Drag-and-Drop operation is within the widget
96// @self, not one of its children.
97func (x *DropControllerMotion) IsPointer() bool {
98
99 cret := xDropControllerMotionIsPointer(x.GoPointer())
100 return cret
101}
102
103func (c *DropControllerMotion) GoPointer() uintptr {
104 if c == nil {
105 return 0
106 }
107 return c.Ptr
108}
109
110func (c *DropControllerMotion) SetGoPointer(ptr uintptr) {
111 c.Ptr = ptr
112}
113
114// GetPropertyContainsPointer gets the "contains-pointer" property.
115// Whether the pointer of a Drag-and-Drop operation is in
116// the controller's widget or a descendant.
117//
118// See also [property@Gtk.DropControllerMotion:is-pointer].
119//
120// When handling crossing events, this property is updated
121// before [signal@Gtk.DropControllerMotion::enter], but after
122// [signal@Gtk.DropControllerMotion::leave] is emitted.
123func (x *DropControllerMotion) GetPropertyContainsPointer() bool {
124 var v gobject.Value
125 x.GetProperty("contains-pointer", &v)
126 return v.GetBoolean()
127}
128
129// GetPropertyIsPointer gets the "is-pointer" property.
130// Whether the pointer is in the controllers widget itself,
131// as opposed to in a descendent widget.
132//
133// See also [property@Gtk.DropControllerMotion:contains-pointer].
134//
135// When handling crossing events, this property is updated
136// before [signal@Gtk.DropControllerMotion::enter], but after
137// [signal@Gtk.DropControllerMotion::leave] is emitted.
138func (x *DropControllerMotion) GetPropertyIsPointer() bool {
139 var v gobject.Value
140 x.GetProperty("is-pointer", &v)
141 return v.GetBoolean()
142}
143
144// Signals that the pointer has entered the widget.
145func (x *DropControllerMotion) ConnectEnter(cb *func(DropControllerMotion, float64, float64)) uint {
146 cbPtr := uintptr(unsafe.Pointer(cb))
147 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
148 handlerID := gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr)
149 glib.SaveHandlerMapping(handlerID, cbPtr)
150 return handlerID
151 }
152
153 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
154 fa := DropControllerMotion{}
155 fa.Ptr = clsPtr
156 cbFn := *cb
157
158 cbFn(fa, XVarp, YVarp)
159
160 }
161 cbRefPtr := purego.NewCallback(fcb)
162 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
163 handlerID := gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr)
164 glib.SaveHandlerMapping(handlerID, cbPtr)
165 return handlerID
166}
167
168// Signals that the pointer has left the widget.
169func (x *DropControllerMotion) ConnectLeave(cb *func(DropControllerMotion)) uint {
170 cbPtr := uintptr(unsafe.Pointer(cb))
171 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
172 handlerID := gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr)
173 glib.SaveHandlerMapping(handlerID, cbPtr)
174 return handlerID
175 }
176
177 fcb := func(clsPtr uintptr) {
178 fa := DropControllerMotion{}
179 fa.Ptr = clsPtr
180 cbFn := *cb
181
182 cbFn(fa)
183
184 }
185 cbRefPtr := purego.NewCallback(fcb)
186 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
187 handlerID := gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr)
188 glib.SaveHandlerMapping(handlerID, cbPtr)
189 return handlerID
190}
191
192// Emitted when the pointer moves inside the widget.
193func (x *DropControllerMotion) ConnectMotion(cb *func(DropControllerMotion, float64, float64)) uint {
194 cbPtr := uintptr(unsafe.Pointer(cb))
195 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
196 handlerID := gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr)
197 glib.SaveHandlerMapping(handlerID, cbPtr)
198 return handlerID
199 }
200
201 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
202 fa := DropControllerMotion{}
203 fa.Ptr = clsPtr
204 cbFn := *cb
205
206 cbFn(fa, XVarp, YVarp)
207
208 }
209 cbRefPtr := purego.NewCallback(fcb)
210 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
211 handlerID := gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr)
212 glib.SaveHandlerMapping(handlerID, cbPtr)
213 return handlerID
214}
215
216func init() {
217 core.SetPackageName("GTK", "gtk4")
218 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
219 var libs []uintptr
220 for _, libPath := range core.GetPaths("GTK") {
221 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
222 if err != nil {
223 panic(err)
224 }
225 libs = append(libs, lib)
226 }
227
228 core.PuregoSafeRegister(&xDropControllerMotionGLibType, libs, "gtk_drop_controller_motion_get_type")
229
230 core.PuregoSafeRegister(&xNewDropControllerMotion, libs, "gtk_drop_controller_motion_new")
231
232 core.PuregoSafeRegister(&xDropControllerMotionContainsPointer, libs, "gtk_drop_controller_motion_contains_pointer")
233 core.PuregoSafeRegister(&xDropControllerMotionGetDrop, libs, "gtk_drop_controller_motion_get_drop")
234 core.PuregoSafeRegister(&xDropControllerMotionIsPointer, libs, "gtk_drop_controller_motion_is_pointer")
235
236}