// Package adw was automatically generated by github.com/bnema/puregotk DO NOT EDIT package adw import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gdk" "github.com/bnema/puregotk/v4/gobject/types" ) // An interface for swipeable widgets. type SwipeableInterface struct { _ structs.HostLayout Parent uintptr xGetDistance uintptr xGetSnapPoints uintptr xGetProgress uintptr xGetCancelProgress uintptr xGetSwipeArea uintptr Padding [4]uintptr } func (x *SwipeableInterface) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // OverrideGetDistance sets the "get_distance" callback function. // Gets the swipe distance. func (x *SwipeableInterface) OverrideGetDistance(cb func(Swipeable) float64) { if cb == nil { x.xGetDistance = 0 } else { x.xGetDistance = purego.NewCallback(func(SelfVarp uintptr) float64 { return cb(&SwipeableBase{Ptr: SelfVarp}) }) } } // GetGetDistance gets the "get_distance" callback function. // Gets the swipe distance. func (x *SwipeableInterface) GetGetDistance() func(Swipeable) float64 { if x.xGetDistance == 0 { return nil } var rawCallback func(SelfVarp uintptr) float64 purego.RegisterFunc(&rawCallback, x.xGetDistance) return func(SelfVar Swipeable) float64 { return rawCallback(SelfVar.GoPointer()) } } // OverrideGetSnapPoints sets the "get_snap_points" callback function. // Gets the snap points. func (x *SwipeableInterface) OverrideGetSnapPoints(cb func(Swipeable, *int) uintptr) { if cb == nil { x.xGetSnapPoints = 0 } else { x.xGetSnapPoints = purego.NewCallback(func(SelfVarp uintptr, NSnapPointsVarp *int) uintptr { return cb(&SwipeableBase{Ptr: SelfVarp}, NSnapPointsVarp) }) } } // GetGetSnapPoints gets the "get_snap_points" callback function. // Gets the snap points. func (x *SwipeableInterface) GetGetSnapPoints() func(Swipeable, *int) uintptr { if x.xGetSnapPoints == 0 { return nil } var rawCallback func(SelfVarp uintptr, NSnapPointsVarp *int) uintptr purego.RegisterFunc(&rawCallback, x.xGetSnapPoints) return func(SelfVar Swipeable, NSnapPointsVar *int) uintptr { return rawCallback(SelfVar.GoPointer(), NSnapPointsVar) } } // OverrideGetProgress sets the "get_progress" callback function. // Gets the current progress. func (x *SwipeableInterface) OverrideGetProgress(cb func(Swipeable) float64) { if cb == nil { x.xGetProgress = 0 } else { x.xGetProgress = purego.NewCallback(func(SelfVarp uintptr) float64 { return cb(&SwipeableBase{Ptr: SelfVarp}) }) } } // GetGetProgress gets the "get_progress" callback function. // Gets the current progress. func (x *SwipeableInterface) GetGetProgress() func(Swipeable) float64 { if x.xGetProgress == 0 { return nil } var rawCallback func(SelfVarp uintptr) float64 purego.RegisterFunc(&rawCallback, x.xGetProgress) return func(SelfVar Swipeable) float64 { return rawCallback(SelfVar.GoPointer()) } } // OverrideGetCancelProgress sets the "get_cancel_progress" callback function. // Gets the cancel progress. func (x *SwipeableInterface) OverrideGetCancelProgress(cb func(Swipeable) float64) { if cb == nil { x.xGetCancelProgress = 0 } else { x.xGetCancelProgress = purego.NewCallback(func(SelfVarp uintptr) float64 { return cb(&SwipeableBase{Ptr: SelfVarp}) }) } } // GetGetCancelProgress gets the "get_cancel_progress" callback function. // Gets the cancel progress. func (x *SwipeableInterface) GetGetCancelProgress() func(Swipeable) float64 { if x.xGetCancelProgress == 0 { return nil } var rawCallback func(SelfVarp uintptr) float64 purego.RegisterFunc(&rawCallback, x.xGetCancelProgress) return func(SelfVar Swipeable) float64 { return rawCallback(SelfVar.GoPointer()) } } // OverrideGetSwipeArea sets the "get_swipe_area" callback function. // Gets the swipeable rectangle. func (x *SwipeableInterface) OverrideGetSwipeArea(cb func(Swipeable, NavigationDirection, bool, *gdk.Rectangle)) { if cb == nil { x.xGetSwipeArea = 0 } else { x.xGetSwipeArea = purego.NewCallback(func(SelfVarp uintptr, NavigationDirectionVarp NavigationDirection, IsDragVarp bool, RectVarp *gdk.Rectangle) { cb(&SwipeableBase{Ptr: SelfVarp}, NavigationDirectionVarp, IsDragVarp, RectVarp) }) } } // GetGetSwipeArea gets the "get_swipe_area" callback function. // Gets the swipeable rectangle. func (x *SwipeableInterface) GetGetSwipeArea() func(Swipeable, NavigationDirection, bool, *gdk.Rectangle) { if x.xGetSwipeArea == 0 { return nil } var rawCallback func(SelfVarp uintptr, NavigationDirectionVarp NavigationDirection, IsDragVarp bool, RectVarp *gdk.Rectangle) purego.RegisterFunc(&rawCallback, x.xGetSwipeArea) return func(SelfVar Swipeable, NavigationDirectionVar NavigationDirection, IsDragVar bool, RectVar *gdk.Rectangle) { rawCallback(SelfVar.GoPointer(), NavigationDirectionVar, IsDragVar, RectVar) } } // An interface for swipeable widgets. // // The `AdwSwipeable` interface is implemented by all swipeable widgets. // // See [class@SwipeTracker] for details about implementing it. type Swipeable interface { GoPointer() uintptr SetGoPointer(uintptr) GetCancelProgress() float64 GetDistance() float64 GetProgress() float64 GetSnapPoints(NSnapPointsVar *int) uintptr GetSwipeArea(NavigationDirectionVar NavigationDirection, IsDragVar bool, RectVar *gdk.Rectangle) } var xSwipeableGLibType func() types.GType func SwipeableGLibType() types.GType { return xSwipeableGLibType() } type SwipeableBase struct { Ptr uintptr } func (x *SwipeableBase) GoPointer() uintptr { if x == nil { return 0 } return x.Ptr } func (x *SwipeableBase) SetGoPointer(ptr uintptr) { x.Ptr = ptr } // Gets the progress @self will snap back to after the gesture is canceled. func (x *SwipeableBase) GetCancelProgress() float64 { cret := XAdwSwipeableGetCancelProgress(x.GoPointer()) return cret } // Gets the swipe distance of @self. // // This corresponds to how many pixels 1 unit represents. func (x *SwipeableBase) GetDistance() float64 { cret := XAdwSwipeableGetDistance(x.GoPointer()) return cret } // Gets the current progress of @self. func (x *SwipeableBase) GetProgress() float64 { cret := XAdwSwipeableGetProgress(x.GoPointer()) return cret } // Gets the snap points of @self. // // Each snap point represents a progress value that is considered acceptable to // end the swipe on. func (x *SwipeableBase) GetSnapPoints(NSnapPointsVar *int) uintptr { cret := XAdwSwipeableGetSnapPoints(x.GoPointer(), NSnapPointsVar) return cret } // Gets the area @self can start a swipe from for the given direction and // gesture type. // // This can be used to restrict swipes to only be possible from a certain area, // for example, to only allow edge swipes, or to have a draggable element and // ignore swipes elsewhere. // // If not implemented, the default implementation returns the allocation of // @self, allowing swipes from anywhere. func (x *SwipeableBase) GetSwipeArea(NavigationDirectionVar NavigationDirection, IsDragVar bool, RectVar *gdk.Rectangle) { XAdwSwipeableGetSwipeArea(x.GoPointer(), NavigationDirectionVar, IsDragVar, RectVar) } var XAdwSwipeableGetCancelProgress func(uintptr) float64 var XAdwSwipeableGetDistance func(uintptr) float64 var XAdwSwipeableGetProgress func(uintptr) float64 var XAdwSwipeableGetSnapPoints func(uintptr, *int) uintptr var XAdwSwipeableGetSwipeArea func(uintptr, NavigationDirection, bool, *gdk.Rectangle) func init() { core.SetPackageName("ADW", "libadwaita-1") core.SetSharedLibraries("ADW", []string{"libadwaita-1.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("ADW") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xSwipeableGLibType, libs, "adw_swipeable_get_type") core.PuregoSafeRegister(&XAdwSwipeableGetCancelProgress, libs, "adw_swipeable_get_cancel_progress") core.PuregoSafeRegister(&XAdwSwipeableGetDistance, libs, "adw_swipeable_get_distance") core.PuregoSafeRegister(&XAdwSwipeableGetProgress, libs, "adw_swipeable_get_progress") core.PuregoSafeRegister(&XAdwSwipeableGetSnapPoints, libs, "adw_swipeable_get_snap_points") core.PuregoSafeRegister(&XAdwSwipeableGetSwipeArea, libs, "adw_swipeable_get_swipe_area") }