// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type GestureSwipeClass struct { _ structs.HostLayout } func (x *GestureSwipeClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // Recognizes swipe gestures. // // After a press/move/.../move/release sequence happens, the // [signal@Gtk.GestureSwipe::swipe] signal will be emitted, // providing the velocity and directionality of the sequence // at the time it was lifted. // // If the velocity is desired in intermediate points, // [method@Gtk.GestureSwipe.get_velocity] can be called in a // [signal@Gtk.Gesture::update] handler. // // All velocities are reported in pixels/sec units. type GestureSwipe struct { GestureSingle } var xGestureSwipeGLibType func() types.GType func GestureSwipeGLibType() types.GType { return xGestureSwipeGLibType() } func GestureSwipeNewFromInternalPtr(ptr uintptr) *GestureSwipe { cls := &GestureSwipe{} cls.Ptr = ptr return cls } var xNewGestureSwipe func() uintptr // Returns a newly created `GtkGesture` that recognizes swipes. func NewGestureSwipe() *GestureSwipe { var cls *GestureSwipe cret := xNewGestureSwipe() if cret == 0 { return nil } cls = &GestureSwipe{} cls.Ptr = cret return cls } var xGestureSwipeGetVelocity func(uintptr, *float64, *float64) bool // Gets the current velocity. // // If the gesture is recognized, this function returns %TRUE and fills // in @velocity_x and @velocity_y with the recorded velocity, as per the // last events processed. func (x *GestureSwipe) GetVelocity(VelocityXVar *float64, VelocityYVar *float64) bool { cret := xGestureSwipeGetVelocity(x.GoPointer(), VelocityXVar, VelocityYVar) return cret } func (c *GestureSwipe) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *GestureSwipe) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // Emitted when the recognized gesture is finished. // // Velocity and direction are a product of previously recorded events. func (x *GestureSwipe) ConnectSwipe(cb *func(GestureSwipe, float64, float64)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "swipe", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr, VelocityXVarp float64, VelocityYVarp float64) { fa := GestureSwipe{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa, VelocityXVarp, VelocityYVarp) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "swipe", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xGestureSwipeGLibType, libs, "gtk_gesture_swipe_get_type") core.PuregoSafeRegister(&xNewGestureSwipe, libs, "gtk_gesture_swipe_new") core.PuregoSafeRegister(&xGestureSwipeGetVelocity, libs, "gtk_gesture_swipe_get_velocity") }