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 GestureStylusClass struct {
18 _ structs.HostLayout
19}
20
21func (x *GestureStylusClass) GoPointer() uintptr {
22 return uintptr(unsafe.Pointer(x))
23}
24
25// Recognizes tablet stylus input.
26//
27// The provided signals just relay the basic information of the
28// stylus events.
29type GestureStylus struct {
30 GestureSingle
31}
32
33var xGestureStylusGLibType func() types.GType
34
35func GestureStylusGLibType() types.GType {
36 return xGestureStylusGLibType()
37}
38
39func GestureStylusNewFromInternalPtr(ptr uintptr) *GestureStylus {
40 cls := &GestureStylus{}
41 cls.Ptr = ptr
42 return cls
43}
44
45var xNewGestureStylus func() uintptr
46
47// Creates a new `GtkGestureStylus`.
48func NewGestureStylus() *GestureStylus {
49 var cls *GestureStylus
50
51 cret := xNewGestureStylus()
52
53 if cret == 0 {
54 return nil
55 }
56 cls = &GestureStylus{}
57 cls.Ptr = cret
58 return cls
59}
60
61var xGestureStylusGetAxes func(uintptr, []gdk.AxisUse, *[]float64) bool
62
63// Returns the current values for the requested @axes.
64//
65// This function must be called from the handler of one of the
66// [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion],
67// [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity]
68// signals.
69func (x *GestureStylus) GetAxes(AxesVar []gdk.AxisUse, ValuesVar *[]float64) bool {
70
71 cret := xGestureStylusGetAxes(x.GoPointer(), AxesVar, ValuesVar)
72 return cret
73}
74
75var xGestureStylusGetAxis func(uintptr, gdk.AxisUse, *float64) bool
76
77// Returns the current value for the requested @axis.
78//
79// This function must be called from the handler of one of the
80// [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion],
81// [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity]
82// signals.
83func (x *GestureStylus) GetAxis(AxisVar gdk.AxisUse, ValueVar *float64) bool {
84
85 cret := xGestureStylusGetAxis(x.GoPointer(), AxisVar, ValueVar)
86 return cret
87}
88
89var xGestureStylusGetBacklog func(uintptr, *uintptr, *uint) bool
90
91// Returns the accumulated backlog of tracking information.
92//
93// By default, GTK will limit rate of input events. On stylus input
94// where accuracy of strokes is paramount, this function returns the
95// accumulated coordinate/timing state before the emission of the
96// current [Gtk.GestureStylus::motion] signal.
97//
98// This function may only be called within a [signal@Gtk.GestureStylus::motion]
99// signal handler, the state given in this signal and obtainable through
100// [method@Gtk.GestureStylus.get_axis] express the latest (most up-to-date)
101// state in motion history.
102//
103// The @backlog is provided in chronological order.
104func (x *GestureStylus) GetBacklog(BacklogVar *uintptr, NElemsVar *uint) bool {
105
106 cret := xGestureStylusGetBacklog(x.GoPointer(), BacklogVar, NElemsVar)
107 return cret
108}
109
110var xGestureStylusGetDeviceTool func(uintptr) uintptr
111
112// Returns the `GdkDeviceTool` currently driving input through this gesture.
113//
114// This function must be called from the handler of one of the
115// [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion],
116// [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity]
117// signals.
118func (x *GestureStylus) GetDeviceTool() *gdk.DeviceTool {
119 var cls *gdk.DeviceTool
120
121 cret := xGestureStylusGetDeviceTool(x.GoPointer())
122
123 if cret == 0 {
124 return nil
125 }
126 gobject.IncreaseRef(cret)
127 cls = &gdk.DeviceTool{}
128 cls.Ptr = cret
129 return cls
130}
131
132var xGestureStylusGetStylusOnly func(uintptr) bool
133
134// Checks whether the gesture is for styluses only.
135//
136// Stylus-only gestures will signal events exclusively from stylus
137// input devices.
138func (x *GestureStylus) GetStylusOnly() bool {
139
140 cret := xGestureStylusGetStylusOnly(x.GoPointer())
141 return cret
142}
143
144var xGestureStylusSetStylusOnly func(uintptr, bool)
145
146// Sets the state of stylus-only
147//
148// If true, the gesture will exclusively handle events from stylus input devices,
149// otherwise it'll handle events from any pointing device.
150func (x *GestureStylus) SetStylusOnly(StylusOnlyVar bool) {
151
152 xGestureStylusSetStylusOnly(x.GoPointer(), StylusOnlyVar)
153
154}
155
156func (c *GestureStylus) GoPointer() uintptr {
157 if c == nil {
158 return 0
159 }
160 return c.Ptr
161}
162
163func (c *GestureStylus) SetGoPointer(ptr uintptr) {
164 c.Ptr = ptr
165}
166
167// SetPropertyStylusOnly sets the "stylus-only" property.
168// If this gesture should exclusively react to stylus input devices.
169func (x *GestureStylus) SetPropertyStylusOnly(value bool) {
170 var v gobject.Value
171 v.Init(gobject.TypeBooleanVal)
172 v.SetBoolean(value)
173 x.SetProperty("stylus-only", &v)
174}
175
176// GetPropertyStylusOnly gets the "stylus-only" property.
177// If this gesture should exclusively react to stylus input devices.
178func (x *GestureStylus) GetPropertyStylusOnly() bool {
179 var v gobject.Value
180 x.GetProperty("stylus-only", &v)
181 return v.GetBoolean()
182}
183
184// Emitted when the stylus touches the device.
185func (x *GestureStylus) ConnectDown(cb *func(GestureStylus, float64, float64)) uint {
186 cbPtr := uintptr(unsafe.Pointer(cb))
187 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
188 handlerID := gobject.SignalConnect(x.GoPointer(), "down", cbRefPtr)
189 glib.SaveHandlerMapping(handlerID, cbPtr)
190 return handlerID
191 }
192
193 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
194 fa := GestureStylus{}
195 fa.Ptr = clsPtr
196 cbFn := *cb
197
198 cbFn(fa, XVarp, YVarp)
199
200 }
201 cbRefPtr := purego.NewCallback(fcb)
202 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
203 handlerID := gobject.SignalConnect(x.GoPointer(), "down", cbRefPtr)
204 glib.SaveHandlerMapping(handlerID, cbPtr)
205 return handlerID
206}
207
208// Emitted when the stylus moves while touching the device.
209func (x *GestureStylus) ConnectMotion(cb *func(GestureStylus, float64, float64)) uint {
210 cbPtr := uintptr(unsafe.Pointer(cb))
211 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
212 handlerID := gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr)
213 glib.SaveHandlerMapping(handlerID, cbPtr)
214 return handlerID
215 }
216
217 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
218 fa := GestureStylus{}
219 fa.Ptr = clsPtr
220 cbFn := *cb
221
222 cbFn(fa, XVarp, YVarp)
223
224 }
225 cbRefPtr := purego.NewCallback(fcb)
226 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
227 handlerID := gobject.SignalConnect(x.GoPointer(), "motion", cbRefPtr)
228 glib.SaveHandlerMapping(handlerID, cbPtr)
229 return handlerID
230}
231
232// Emitted when the stylus is in proximity of the device.
233func (x *GestureStylus) ConnectProximity(cb *func(GestureStylus, float64, float64)) uint {
234 cbPtr := uintptr(unsafe.Pointer(cb))
235 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
236 handlerID := gobject.SignalConnect(x.GoPointer(), "proximity", cbRefPtr)
237 glib.SaveHandlerMapping(handlerID, cbPtr)
238 return handlerID
239 }
240
241 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
242 fa := GestureStylus{}
243 fa.Ptr = clsPtr
244 cbFn := *cb
245
246 cbFn(fa, XVarp, YVarp)
247
248 }
249 cbRefPtr := purego.NewCallback(fcb)
250 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
251 handlerID := gobject.SignalConnect(x.GoPointer(), "proximity", cbRefPtr)
252 glib.SaveHandlerMapping(handlerID, cbPtr)
253 return handlerID
254}
255
256// Emitted when the stylus no longer touches the device.
257func (x *GestureStylus) ConnectUp(cb *func(GestureStylus, float64, float64)) uint {
258 cbPtr := uintptr(unsafe.Pointer(cb))
259 if cbRefPtr, ok := glib.GetCallback(cbPtr); ok {
260 handlerID := gobject.SignalConnect(x.GoPointer(), "up", cbRefPtr)
261 glib.SaveHandlerMapping(handlerID, cbPtr)
262 return handlerID
263 }
264
265 fcb := func(clsPtr uintptr, XVarp float64, YVarp float64) {
266 fa := GestureStylus{}
267 fa.Ptr = clsPtr
268 cbFn := *cb
269
270 cbFn(fa, XVarp, YVarp)
271
272 }
273 cbRefPtr := purego.NewCallback(fcb)
274 glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb)
275 handlerID := gobject.SignalConnect(x.GoPointer(), "up", cbRefPtr)
276 glib.SaveHandlerMapping(handlerID, cbPtr)
277 return handlerID
278}
279
280func init() {
281 core.SetPackageName("GTK", "gtk4")
282 core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"})
283 var libs []uintptr
284 for _, libPath := range core.GetPaths("GTK") {
285 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
286 if err != nil {
287 panic(err)
288 }
289 libs = append(libs, lib)
290 }
291
292 core.PuregoSafeRegister(&xGestureStylusGLibType, libs, "gtk_gesture_stylus_get_type")
293
294 core.PuregoSafeRegister(&xNewGestureStylus, libs, "gtk_gesture_stylus_new")
295
296 core.PuregoSafeRegister(&xGestureStylusGetAxes, libs, "gtk_gesture_stylus_get_axes")
297 core.PuregoSafeRegister(&xGestureStylusGetAxis, libs, "gtk_gesture_stylus_get_axis")
298 core.PuregoSafeRegister(&xGestureStylusGetBacklog, libs, "gtk_gesture_stylus_get_backlog")
299 core.PuregoSafeRegister(&xGestureStylusGetDeviceTool, libs, "gtk_gesture_stylus_get_device_tool")
300 core.PuregoSafeRegister(&xGestureStylusGetStylusOnly, libs, "gtk_gesture_stylus_get_stylus_only")
301 core.PuregoSafeRegister(&xGestureStylusSetStylusOnly, libs, "gtk_gesture_stylus_set_stylus_only")
302
303}