module GI.Gtk.Objects.GestureSwipe
(
GestureSwipe(..) ,
GestureSwipeK ,
toGestureSwipe ,
noGestureSwipe ,
gestureSwipeGetVelocity ,
gestureSwipeNew ,
GestureSwipeSwipeCallback ,
GestureSwipeSwipeCallbackC ,
GestureSwipeSwipeSignalInfo ,
afterGestureSwipeSwipe ,
gestureSwipeSwipeCallbackWrapper ,
gestureSwipeSwipeClosure ,
mkGestureSwipeSwipeCallback ,
noGestureSwipeSwipeCallback ,
onGestureSwipeSwipe ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.Gtk.Types
import GI.Gtk.Callbacks
import qualified GI.GObject as GObject
newtype GestureSwipe = GestureSwipe (ForeignPtr GestureSwipe)
foreign import ccall "gtk_gesture_swipe_get_type"
c_gtk_gesture_swipe_get_type :: IO GType
type instance ParentTypes GestureSwipe = GestureSwipeParentTypes
type GestureSwipeParentTypes = '[GestureSingle, Gesture, EventController, GObject.Object]
instance GObject GestureSwipe where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_gtk_gesture_swipe_get_type
class GObject o => GestureSwipeK o
instance (GObject o, IsDescendantOf GestureSwipe o) => GestureSwipeK o
toGestureSwipe :: GestureSwipeK o => o -> IO GestureSwipe
toGestureSwipe = unsafeCastTo GestureSwipe
noGestureSwipe :: Maybe GestureSwipe
noGestureSwipe = Nothing
type GestureSwipeSwipeCallback =
Double ->
Double ->
IO ()
noGestureSwipeSwipeCallback :: Maybe GestureSwipeSwipeCallback
noGestureSwipeSwipeCallback = Nothing
type GestureSwipeSwipeCallbackC =
Ptr () ->
CDouble ->
CDouble ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mkGestureSwipeSwipeCallback :: GestureSwipeSwipeCallbackC -> IO (FunPtr GestureSwipeSwipeCallbackC)
gestureSwipeSwipeClosure :: GestureSwipeSwipeCallback -> IO Closure
gestureSwipeSwipeClosure cb = newCClosure =<< mkGestureSwipeSwipeCallback wrapped
where wrapped = gestureSwipeSwipeCallbackWrapper cb
gestureSwipeSwipeCallbackWrapper ::
GestureSwipeSwipeCallback ->
Ptr () ->
CDouble ->
CDouble ->
Ptr () ->
IO ()
gestureSwipeSwipeCallbackWrapper _cb _ velocity_x velocity_y _ = do
let velocity_x' = realToFrac velocity_x
let velocity_y' = realToFrac velocity_y
_cb velocity_x' velocity_y'
onGestureSwipeSwipe :: (GObject a, MonadIO m) => a -> GestureSwipeSwipeCallback -> m SignalHandlerId
onGestureSwipeSwipe obj cb = liftIO $ connectGestureSwipeSwipe obj cb SignalConnectBefore
afterGestureSwipeSwipe :: (GObject a, MonadIO m) => a -> GestureSwipeSwipeCallback -> m SignalHandlerId
afterGestureSwipeSwipe obj cb = connectGestureSwipeSwipe obj cb SignalConnectAfter
connectGestureSwipeSwipe :: (GObject a, MonadIO m) =>
a -> GestureSwipeSwipeCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureSwipeSwipe obj cb after = liftIO $ do
cb' <- mkGestureSwipeSwipeCallback (gestureSwipeSwipeCallbackWrapper cb)
connectSignalFunPtr obj "swipe" cb' after
type instance AttributeList GestureSwipe = GestureSwipeAttributeList
type GestureSwipeAttributeList = ('[ '("button", GestureSingleButtonPropertyInfo), '("exclusive", GestureSingleExclusivePropertyInfo), '("n-points", GestureNPointsPropertyInfo), '("propagation-phase", EventControllerPropagationPhasePropertyInfo), '("touch-only", GestureSingleTouchOnlyPropertyInfo), '("widget", EventControllerWidgetPropertyInfo), '("window", GestureWindowPropertyInfo)] :: [(Symbol, *)])
data GestureSwipeSwipeSignalInfo
instance SignalInfo GestureSwipeSwipeSignalInfo where
type HaskellCallbackType GestureSwipeSwipeSignalInfo = GestureSwipeSwipeCallback
connectSignal _ = connectGestureSwipeSwipe
type instance SignalList GestureSwipe = GestureSwipeSignalList
type GestureSwipeSignalList = ('[ '("begin", GestureBeginSignalInfo), '("cancel", GestureCancelSignalInfo), '("end", GestureEndSignalInfo), '("notify", GObject.ObjectNotifySignalInfo), '("sequence-state-changed", GestureSequenceStateChangedSignalInfo), '("swipe", GestureSwipeSwipeSignalInfo), '("update", GestureUpdateSignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
foreign import ccall "gtk_gesture_swipe_new" gtk_gesture_swipe_new ::
Ptr Widget ->
IO (Ptr GestureSwipe)
gestureSwipeNew ::
(MonadIO m, WidgetK a) =>
a ->
m GestureSwipe
gestureSwipeNew widget = liftIO $ do
let widget' = unsafeManagedPtrCastPtr widget
result <- gtk_gesture_swipe_new widget'
checkUnexpectedReturnNULL "gtk_gesture_swipe_new" result
result' <- (wrapObject GestureSwipe) result
touchManagedPtr widget
return result'
foreign import ccall "gtk_gesture_swipe_get_velocity" gtk_gesture_swipe_get_velocity ::
Ptr GestureSwipe ->
Ptr CDouble ->
Ptr CDouble ->
IO CInt
gestureSwipeGetVelocity ::
(MonadIO m, GestureSwipeK a) =>
a ->
m (Bool,Double,Double)
gestureSwipeGetVelocity _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
velocity_x <- allocMem :: IO (Ptr CDouble)
velocity_y <- allocMem :: IO (Ptr CDouble)
result <- gtk_gesture_swipe_get_velocity _obj' velocity_x velocity_y
let result' = (/= 0) result
velocity_x' <- peek velocity_x
let velocity_x'' = realToFrac velocity_x'
velocity_y' <- peek velocity_y
let velocity_y'' = realToFrac velocity_y'
touchManagedPtr _obj
freeMem velocity_x
freeMem velocity_y
return (result', velocity_x'', velocity_y'')