-
Notifications
You must be signed in to change notification settings - Fork 6
/
adw-swipe-tracker.go
476 lines (386 loc) · 12.8 KB
/
adw-swipe-tracker.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
// Code generated by girgen. DO NOT EDIT.
package adw
import (
"runtime"
"unsafe"
"github.com/diamondburned/gotk4/pkg/core/gextras"
coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
"github.com/diamondburned/gotk4/pkg/gtk/v4"
)
// #include <stdlib.h>
// #include <adwaita.h>
// #include <glib-object.h>
// extern void _gotk4_adw1_SwipeTracker_ConnectUpdateSwipe(gpointer, gdouble, guintptr);
// extern void _gotk4_adw1_SwipeTracker_ConnectPrepare(gpointer, AdwNavigationDirection, guintptr);
// extern void _gotk4_adw1_SwipeTracker_ConnectEndSwipe(gpointer, gdouble, gdouble, guintptr);
// extern void _gotk4_adw1_SwipeTracker_ConnectBeginSwipe(gpointer, guintptr);
import "C"
// GType values.
var (
GTypeSwipeTracker = coreglib.Type(C.adw_swipe_tracker_get_type())
)
func init() {
coreglib.RegisterGValueMarshalers([]coreglib.TypeMarshaler{
coreglib.TypeMarshaler{T: GTypeSwipeTracker, F: marshalSwipeTracker},
})
}
// SwipeTrackerOverrides contains methods that are overridable.
type SwipeTrackerOverrides struct {
}
func defaultSwipeTrackerOverrides(v *SwipeTracker) SwipeTrackerOverrides {
return SwipeTrackerOverrides{}
}
// SwipeTracker: swipe tracker used in carousel, navigationview and
// overlaysplitview.
//
// The AdwSwipeTracker object can be used for implementing widgets with swipe
// gestures. It supports touch-based swipes, pointer dragging, and touchpad
// scrolling.
//
// The widgets will probably want to expose the swipetracker:enabled property.
// If they expect to use horizontal orientation, swipetracker:reversed can be
// used for supporting RTL text direction.
type SwipeTracker struct {
_ [0]func() // equal guard
*coreglib.Object
gtk.Orientable
}
var (
_ coreglib.Objector = (*SwipeTracker)(nil)
)
func init() {
coreglib.RegisterClassInfo[*SwipeTracker, *SwipeTrackerClass, SwipeTrackerOverrides](
GTypeSwipeTracker,
initSwipeTrackerClass,
wrapSwipeTracker,
defaultSwipeTrackerOverrides,
)
}
func initSwipeTrackerClass(gclass unsafe.Pointer, overrides SwipeTrackerOverrides, classInitFunc func(*SwipeTrackerClass)) {
if classInitFunc != nil {
class := (*SwipeTrackerClass)(gextras.NewStructNative(gclass))
classInitFunc(class)
}
}
func wrapSwipeTracker(obj *coreglib.Object) *SwipeTracker {
return &SwipeTracker{
Object: obj,
Orientable: gtk.Orientable{
Object: obj,
},
}
}
func marshalSwipeTracker(p uintptr) (interface{}, error) {
return wrapSwipeTracker(coreglib.ValueFromNative(unsafe.Pointer(p)).Object()), nil
}
// ConnectBeginSwipe: this signal is emitted right before a swipe will be
// started, after the drag threshold has been passed.
func (self *SwipeTracker) ConnectBeginSwipe(f func()) coreglib.SignalHandle {
return coreglib.ConnectGeneratedClosure(self, "begin-swipe", false, unsafe.Pointer(C._gotk4_adw1_SwipeTracker_ConnectBeginSwipe), f)
}
// ConnectEndSwipe: this signal is emitted as soon as the gesture has stopped.
//
// The user is expected to animate the deceleration from the current progress
// value to to with an animation using velocity as the initial velocity,
// provided in pixels per second. springanimation is usually a good fit for
// this.
func (self *SwipeTracker) ConnectEndSwipe(f func(velocity, to float64)) coreglib.SignalHandle {
return coreglib.ConnectGeneratedClosure(self, "end-swipe", false, unsafe.Pointer(C._gotk4_adw1_SwipeTracker_ConnectEndSwipe), f)
}
// ConnectPrepare: this signal is emitted when a possible swipe is detected.
//
// The direction value can be used to restrict the swipe to a certain direction.
func (self *SwipeTracker) ConnectPrepare(f func(direction NavigationDirection)) coreglib.SignalHandle {
return coreglib.ConnectGeneratedClosure(self, "prepare", false, unsafe.Pointer(C._gotk4_adw1_SwipeTracker_ConnectPrepare), f)
}
// ConnectUpdateSwipe: this signal is emitted every time the progress value
// changes.
func (self *SwipeTracker) ConnectUpdateSwipe(f func(progress float64)) coreglib.SignalHandle {
return coreglib.ConnectGeneratedClosure(self, "update-swipe", false, unsafe.Pointer(C._gotk4_adw1_SwipeTracker_ConnectUpdateSwipe), f)
}
// NewSwipeTracker creates a new AdwSwipeTracker for widget.
//
// The function takes the following parameters:
//
// - swipeable: widget to add the tracker on.
//
// The function returns the following values:
//
// - swipeTracker: newly created AdwSwipeTracker.
//
func NewSwipeTracker(swipeable Swipeabler) *SwipeTracker {
var _arg1 *C.AdwSwipeable // out
var _cret *C.AdwSwipeTracker // in
_arg1 = (*C.AdwSwipeable)(unsafe.Pointer(coreglib.InternObject(swipeable).Native()))
_cret = C.adw_swipe_tracker_new(_arg1)
runtime.KeepAlive(swipeable)
var _swipeTracker *SwipeTracker // out
_swipeTracker = wrapSwipeTracker(coreglib.AssumeOwnership(unsafe.Pointer(_cret)))
return _swipeTracker
}
// AllowLongSwipes gets whether to allow swiping for more than one snap point at
// a time.
//
// The function returns the following values:
//
// - ok: whether long swipes are allowed.
//
func (self *SwipeTracker) AllowLongSwipes() bool {
var _arg0 *C.AdwSwipeTracker // out
var _cret C.gboolean // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_allow_long_swipes(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// AllowMouseDrag gets whether self can be dragged with mouse pointer.
//
// The function returns the following values:
//
// - ok: whether mouse dragging is allowed.
//
func (self *SwipeTracker) AllowMouseDrag() bool {
var _arg0 *C.AdwSwipeTracker // out
var _cret C.gboolean // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_allow_mouse_drag(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// Enabled gets whether self is enabled.
//
// The function returns the following values:
//
// - ok: whether self is enabled.
//
func (self *SwipeTracker) Enabled() bool {
var _arg0 *C.AdwSwipeTracker // out
var _cret C.gboolean // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_enabled(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// LowerOvershoot gets whether to allow swiping past the first available snap
// point.
//
// The function returns the following values:
//
// - ok: whether to allow swiping past the first available snap point.
//
func (self *SwipeTracker) LowerOvershoot() bool {
var _arg0 *C.AdwSwipeTracker // out
var _cret C.gboolean // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_lower_overshoot(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// Reversed gets whether self is reversing the swipe direction.
//
// The function returns the following values:
//
// - ok: whether the direction is reversed.
//
func (self *SwipeTracker) Reversed() bool {
var _arg0 *C.AdwSwipeTracker // out
var _cret C.gboolean // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_reversed(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// Swipeable: get the widget self is attached to.
//
// The function returns the following values:
//
// - swipeable widget.
//
func (self *SwipeTracker) Swipeable() *Swipeable {
var _arg0 *C.AdwSwipeTracker // out
var _cret *C.AdwSwipeable // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_swipeable(_arg0)
runtime.KeepAlive(self)
var _swipeable *Swipeable // out
_swipeable = wrapSwipeable(coreglib.Take(unsafe.Pointer(_cret)))
return _swipeable
}
// UpperOvershoot gets whether to allow swiping past the last available snap
// point.
//
// The function returns the following values:
//
// - ok: whether to allow swiping past the last available snap point.
//
func (self *SwipeTracker) UpperOvershoot() bool {
var _arg0 *C.AdwSwipeTracker // out
var _cret C.gboolean // in
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_cret = C.adw_swipe_tracker_get_upper_overshoot(_arg0)
runtime.KeepAlive(self)
var _ok bool // out
if _cret != 0 {
_ok = true
}
return _ok
}
// SetAllowLongSwipes sets whether to allow swiping for more than one snap point
// at a time.
//
// If the value is FALSE, each swipe can only move to the adjacent snap points.
//
// The function takes the following parameters:
//
// - allowLongSwipes: whether to allow long swipes.
//
func (self *SwipeTracker) SetAllowLongSwipes(allowLongSwipes bool) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if allowLongSwipes {
_arg1 = C.TRUE
}
C.adw_swipe_tracker_set_allow_long_swipes(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(allowLongSwipes)
}
// SetAllowMouseDrag sets whether self can be dragged with mouse pointer.
//
// The function takes the following parameters:
//
// - allowMouseDrag: whether to allow mouse dragging.
//
func (self *SwipeTracker) SetAllowMouseDrag(allowMouseDrag bool) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if allowMouseDrag {
_arg1 = C.TRUE
}
C.adw_swipe_tracker_set_allow_mouse_drag(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(allowMouseDrag)
}
// SetEnabled sets whether self is enabled.
//
// When it's not enabled, no events will be processed. Usually widgets will want
// to expose this via a property.
//
// The function takes the following parameters:
//
// - enabled: whether self is enabled.
//
func (self *SwipeTracker) SetEnabled(enabled bool) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if enabled {
_arg1 = C.TRUE
}
C.adw_swipe_tracker_set_enabled(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(enabled)
}
// SetLowerOvershoot sets whether to allow swiping past the first available snap
// point.
//
// The function takes the following parameters:
//
// - overshoot: whether to allow swiping past the first available snap point.
//
func (self *SwipeTracker) SetLowerOvershoot(overshoot bool) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if overshoot {
_arg1 = C.TRUE
}
C.adw_swipe_tracker_set_lower_overshoot(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(overshoot)
}
// SetReversed sets whether to reverse the swipe direction.
//
// If the swipe tracker is horizontal, it can be used for supporting RTL text
// direction.
//
// The function takes the following parameters:
//
// - reversed: whether to reverse the swipe direction.
//
func (self *SwipeTracker) SetReversed(reversed bool) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if reversed {
_arg1 = C.TRUE
}
C.adw_swipe_tracker_set_reversed(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(reversed)
}
// SetUpperOvershoot sets whether to allow swiping past the last available snap
// point.
//
// The function takes the following parameters:
//
// - overshoot: whether to allow swiping past the last available snap point.
//
func (self *SwipeTracker) SetUpperOvershoot(overshoot bool) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.gboolean // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
if overshoot {
_arg1 = C.TRUE
}
C.adw_swipe_tracker_set_upper_overshoot(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(overshoot)
}
// ShiftPosition moves the current progress value by delta.
//
// This can be used to adjust the current position if snap points move during
// the gesture.
//
// The function takes the following parameters:
//
// - delta: position delta.
//
func (self *SwipeTracker) ShiftPosition(delta float64) {
var _arg0 *C.AdwSwipeTracker // out
var _arg1 C.double // out
_arg0 = (*C.AdwSwipeTracker)(unsafe.Pointer(coreglib.InternObject(self).Native()))
_arg1 = C.double(delta)
C.adw_swipe_tracker_shift_position(_arg0, _arg1)
runtime.KeepAlive(self)
runtime.KeepAlive(delta)
}
// SwipeTrackerClass: instance of this type is always passed by reference.
type SwipeTrackerClass struct {
*swipeTrackerClass
}
// swipeTrackerClass is the struct that's finalized.
type swipeTrackerClass struct {
native *C.AdwSwipeTrackerClass
}