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 EventControllerMotionClass struct {
17 _ structs.HostLayout
18}
19
20func (x *EventControllerMotionClass) GoPointer() uintptr {
21 return uintptr(unsafe.Pointer(x))
22}
23
24// Tracks the pointer position.
25//
26// The event controller offers [signal@Gtk.EventControllerMotion::enter]
27// and [signal@Gtk.EventControllerMotion::leave] signals, as well as
28// [property@Gtk.EventControllerMotion:is-pointer] and
29// [property@Gtk.EventControllerMotion:contains-pointer] properties
30// which are updated to reflect changes in the pointer position as it
31// moves over the widget.
32type EventControllerMotion struct {
33 EventController
34}
35
36var xEventControllerMotionGLibType func() types.GType
37
38func EventControllerMotionGLibType() types.GType {
39 return xEventControllerMotionGLibType()
40}
41
42func EventControllerMotionNewFromInternalPtr(ptr uintptr) *EventControllerMotion {
43 cls := &EventControllerMotion{}
44 cls.Ptr = ptr
45 return cls
46}
47
48var xNewEventControllerMotion func() uintptr
49
50// Creates a new event controller that will handle motion events.
51func NewEventControllerMotion() *EventControllerMotion {
52 var cls *EventControllerMotion
53
54 cret := xNewEventControllerMotion()
55
56 if cret == 0 {
57 return nil
58 }
59 cls = &EventControllerMotion{}
60 cls.Ptr = cret
61 return cls
62}
63
64var xEventControllerMotionContainsPointer func(uintptr) bool
65
66// Returns if a pointer is within @self or one of its children.
67func (x *EventControllerMotion) ContainsPointer() bool {
68
69 cret := xEventControllerMotionContainsPointer(x.GoPointer())
70 return cret
71}
72
73var xEventControllerMotionIsPointer func(uintptr) bool
74
75// Returns if a pointer is within @self, but not one of its children.
76func (x *EventControllerMotion) IsPointer() bool {
77
78 cret := xEventControllerMotionIsPointer(x.GoPointer())
79 return cret
80}
81
82func (c *EventControllerMotion) GoPointer() uintptr {
83 if c == nil {
84 return 0
85 }
86 return c.Ptr
87}
88
89func (c *EventControllerMotion) SetGoPointer(ptr uintptr) {
90 c.Ptr = ptr
91}
92
93// GetPropertyContainsPointer gets the "contains-pointer" property.
94// Whether the pointer is in the controllers widget or a descendant.
95//
96// See also [property@Gtk.EventControllerMotion:is-pointer].
97//
98// When handling crossing events, this property is updated
99// before [signal@Gtk.EventControllerMotion::enter], but after
100// [signal@Gtk.EventControllerMotion::leave] is emitted.
101func (x *EventControllerMotion) GetPropertyContainsPointer() bool {
102 var v gobject.Value
103 x.GetProperty("contains-pointer", &v)
104 return v.GetBoolean()
105}
106
107// GetPropertyIsPointer gets the "is-pointer" property.
108// Whether the pointer is in the controllers widget itself,
109// as opposed to in a descendent widget.
110//
111// See also [property@Gtk.EventControllerMotion:contains-pointer].
112//
113// When handling crossing events, this property is updated
114// before [signal@Gtk.EventControllerMotion::enter], but after
115// [signal@Gtk.EventControllerMotion::leave] is emitted.
116func (x *EventControllerMotion) GetPropertyIsPointer() bool {
117 var v gobject.Value
118 x.GetProperty("is-pointer", &v)
119 return v.GetBoolean()
120}
121
122// Signals that the pointer has entered the widget.
123func (x *EventControllerMotion) ConnectEnter(cb *func(EventControllerMotion, float64, float64)) uint {
124 cbPtr := uintptr(unsafe.Pointer(cb))
125 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
126 handlerID := gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr)
127 glib.SaveHandlerMapping(handlerID, cbPtr)
128 return handlerID
129 }
130
131 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
132 fa := EventControllerMotion{}
133 fa.Ptr = clsPtr
134 cbFn := *cb
135
136 cbFn(fa, XVarp, YVarp)
137
138 }
139 cbRefPtr := purego.NewCallback(fcb)
140 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
141 handlerID := gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr)
142 glib.SaveHandlerMapping(handlerID, cbPtr)
143 return handlerID
144}
145
146// Signals that the pointer has left the widget.
147func (x *EventControllerMotion) ConnectLeave(cb *func(EventControllerMotion)) uint {
148 cbPtr := uintptr(unsafe.Pointer(cb))
149 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
150 handlerID := gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr)
151 glib.SaveHandlerMapping(handlerID, cbPtr)
152 return handlerID
153 }
154
155 fcb := func(clsPtr uintptr) {
156 fa := EventControllerMotion{}
157 fa.Ptr = clsPtr
158 cbFn := *cb
159
160 cbFn(fa)
161
162 }
163 cbRefPtr := purego.NewCallback(fcb)
164 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
165 handlerID := gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr)
166 glib.SaveHandlerMapping(handlerID, cbPtr)
167 return handlerID
168}
169
170// Emitted when the pointer moves inside the widget.
171func (x *EventControllerMotion) ConnectMotion(cb *func(EventControllerMotion, float64, float64)) uint {
172 cbPtr := uintptr(unsafe.Pointer(cb))
173 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
174 handlerID := gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr)
175 glib.SaveHandlerMapping(handlerID, cbPtr)
176 return handlerID
177 }
178
179 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
180 fa := EventControllerMotion{}
181 fa.Ptr = clsPtr
182 cbFn := *cb
183
184 cbFn(fa, XVarp, YVarp)
185
186 }
187 cbRefPtr := purego.NewCallback(fcb)
188 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
189 handlerID := gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr)
190 glib.SaveHandlerMapping(handlerID, cbPtr)
191 return handlerID
192}
193
194func init() {
195 core.SetPackageName("GTK", "gtk4")
196 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
197 var libs []uintptr
198 for _, libPath := range core.GetPaths("GTK") {
199 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
200 if err != nil {
201 panic(err)
202 }
203 libs = append(libs, lib)
204 }
205
206 core.PuregoSafeRegister(&xEventControllerMotionGLibType, libs, "gtk_event_controller_motion_get_type")
207
208 core.PuregoSafeRegister(&xNewEventControllerMotion, libs, "gtk_event_controller_motion_new")
209
210 core.PuregoSafeRegister(&xEventControllerMotionContainsPointer, libs, "gtk_event_controller_motion_contains_pointer")
211 core.PuregoSafeRegister(&xEventControllerMotionIsPointer, libs, "gtk_event_controller_motion_is_pointer")
212
213}