{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

'GI.Gtk.Objects.GestureLongPress.GestureLongPress' is a 'GI.Gtk.Objects.Gesture.Gesture' implementation able to recognize
long presses, triggering the 'GI.Gtk.Objects.GestureLongPress.GestureLongPress'::@/pressed/@ after the
timeout is exceeded.

If the touchpoint is lifted before the timeout passes, or if it drifts
too far of the initial press point, the 'GI.Gtk.Objects.GestureLongPress.GestureLongPress'::@/cancelled/@
signal will be emitted.
-}

module GI.Gtk.Objects.GestureLongPress
    ( 

-- * Exported types
    GestureLongPress(..)                    ,
    IsGestureLongPress                      ,
    toGestureLongPress                      ,
    noGestureLongPress                      ,


 -- * Methods
-- ** new #method:new#
    gestureLongPressNew                     ,




 -- * Properties
-- ** delayFactor #attr:delayFactor#
    GestureLongPressDelayFactorPropertyInfo ,
    constructGestureLongPressDelayFactor    ,
    gestureLongPressDelayFactor             ,
    getGestureLongPressDelayFactor          ,
    setGestureLongPressDelayFactor          ,




 -- * Signals
-- ** cancelled #signal:cancelled#
    C_GestureLongPressCancelledCallback     ,
    GestureLongPressCancelledCallback       ,
    GestureLongPressCancelledSignalInfo     ,
    afterGestureLongPressCancelled          ,
    genClosure_GestureLongPressCancelled    ,
    mk_GestureLongPressCancelledCallback    ,
    noGestureLongPressCancelledCallback     ,
    onGestureLongPressCancelled             ,
    wrap_GestureLongPressCancelledCallback  ,


-- ** pressed #signal:pressed#
    C_GestureLongPressPressedCallback       ,
    GestureLongPressPressedCallback         ,
    GestureLongPressPressedSignalInfo       ,
    afterGestureLongPressPressed            ,
    genClosure_GestureLongPressPressed      ,
    mk_GestureLongPressPressedCallback      ,
    noGestureLongPressPressedCallback       ,
    onGestureLongPressPressed               ,
    wrap_GestureLongPressPressedCallback    ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gtk.Objects.EventController as Gtk.EventController
import {-# SOURCE #-} qualified GI.Gtk.Objects.Gesture as Gtk.Gesture
import {-# SOURCE #-} qualified GI.Gtk.Objects.GestureSingle as Gtk.GestureSingle
import {-# SOURCE #-} qualified GI.Gtk.Objects.Widget as Gtk.Widget

newtype GestureLongPress = GestureLongPress (ManagedPtr GestureLongPress)
foreign import ccall "gtk_gesture_long_press_get_type"
    c_gtk_gesture_long_press_get_type :: IO GType

instance GObject GestureLongPress where
    gobjectType _ = c_gtk_gesture_long_press_get_type
    

class GObject o => IsGestureLongPress o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError GestureLongPress a) =>
    IsGestureLongPress a
#endif
instance IsGestureLongPress GestureLongPress
instance Gtk.GestureSingle.IsGestureSingle GestureLongPress
instance Gtk.Gesture.IsGesture GestureLongPress
instance Gtk.EventController.IsEventController GestureLongPress
instance GObject.Object.IsObject GestureLongPress

toGestureLongPress :: IsGestureLongPress o => o -> IO GestureLongPress
toGestureLongPress = unsafeCastTo GestureLongPress

noGestureLongPress :: Maybe GestureLongPress
noGestureLongPress = Nothing

type family ResolveGestureLongPressMethod (t :: Symbol) (o :: *) :: * where
    ResolveGestureLongPressMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveGestureLongPressMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveGestureLongPressMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveGestureLongPressMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveGestureLongPressMethod "group" o = Gtk.Gesture.GestureGroupMethodInfo
    ResolveGestureLongPressMethod "handleEvent" o = Gtk.EventController.EventControllerHandleEventMethodInfo
    ResolveGestureLongPressMethod "handlesSequence" o = Gtk.Gesture.GestureHandlesSequenceMethodInfo
    ResolveGestureLongPressMethod "isActive" o = Gtk.Gesture.GestureIsActiveMethodInfo
    ResolveGestureLongPressMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveGestureLongPressMethod "isGroupedWith" o = Gtk.Gesture.GestureIsGroupedWithMethodInfo
    ResolveGestureLongPressMethod "isRecognized" o = Gtk.Gesture.GestureIsRecognizedMethodInfo
    ResolveGestureLongPressMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveGestureLongPressMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveGestureLongPressMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveGestureLongPressMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveGestureLongPressMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveGestureLongPressMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveGestureLongPressMethod "reset" o = Gtk.EventController.EventControllerResetMethodInfo
    ResolveGestureLongPressMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveGestureLongPressMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveGestureLongPressMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveGestureLongPressMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveGestureLongPressMethod "ungroup" o = Gtk.Gesture.GestureUngroupMethodInfo
    ResolveGestureLongPressMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveGestureLongPressMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveGestureLongPressMethod "getBoundingBox" o = Gtk.Gesture.GestureGetBoundingBoxMethodInfo
    ResolveGestureLongPressMethod "getBoundingBoxCenter" o = Gtk.Gesture.GestureGetBoundingBoxCenterMethodInfo
    ResolveGestureLongPressMethod "getButton" o = Gtk.GestureSingle.GestureSingleGetButtonMethodInfo
    ResolveGestureLongPressMethod "getCurrentButton" o = Gtk.GestureSingle.GestureSingleGetCurrentButtonMethodInfo
    ResolveGestureLongPressMethod "getCurrentSequence" o = Gtk.GestureSingle.GestureSingleGetCurrentSequenceMethodInfo
    ResolveGestureLongPressMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveGestureLongPressMethod "getDevice" o = Gtk.Gesture.GestureGetDeviceMethodInfo
    ResolveGestureLongPressMethod "getExclusive" o = Gtk.GestureSingle.GestureSingleGetExclusiveMethodInfo
    ResolveGestureLongPressMethod "getGroup" o = Gtk.Gesture.GestureGetGroupMethodInfo
    ResolveGestureLongPressMethod "getLastEvent" o = Gtk.Gesture.GestureGetLastEventMethodInfo
    ResolveGestureLongPressMethod "getLastUpdatedSequence" o = Gtk.Gesture.GestureGetLastUpdatedSequenceMethodInfo
    ResolveGestureLongPressMethod "getPoint" o = Gtk.Gesture.GestureGetPointMethodInfo
    ResolveGestureLongPressMethod "getPropagationPhase" o = Gtk.EventController.EventControllerGetPropagationPhaseMethodInfo
    ResolveGestureLongPressMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveGestureLongPressMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveGestureLongPressMethod "getSequenceState" o = Gtk.Gesture.GestureGetSequenceStateMethodInfo
    ResolveGestureLongPressMethod "getSequences" o = Gtk.Gesture.GestureGetSequencesMethodInfo
    ResolveGestureLongPressMethod "getTouchOnly" o = Gtk.GestureSingle.GestureSingleGetTouchOnlyMethodInfo
    ResolveGestureLongPressMethod "getWidget" o = Gtk.EventController.EventControllerGetWidgetMethodInfo
    ResolveGestureLongPressMethod "getWindow" o = Gtk.Gesture.GestureGetWindowMethodInfo
    ResolveGestureLongPressMethod "setButton" o = Gtk.GestureSingle.GestureSingleSetButtonMethodInfo
    ResolveGestureLongPressMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveGestureLongPressMethod "setExclusive" o = Gtk.GestureSingle.GestureSingleSetExclusiveMethodInfo
    ResolveGestureLongPressMethod "setPropagationPhase" o = Gtk.EventController.EventControllerSetPropagationPhaseMethodInfo
    ResolveGestureLongPressMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveGestureLongPressMethod "setSequenceState" o = Gtk.Gesture.GestureSetSequenceStateMethodInfo
    ResolveGestureLongPressMethod "setState" o = Gtk.Gesture.GestureSetStateMethodInfo
    ResolveGestureLongPressMethod "setTouchOnly" o = Gtk.GestureSingle.GestureSingleSetTouchOnlyMethodInfo
    ResolveGestureLongPressMethod "setWindow" o = Gtk.Gesture.GestureSetWindowMethodInfo
    ResolveGestureLongPressMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveGestureLongPressMethod t GestureLongPress, O.MethodInfo info GestureLongPress p) => O.IsLabelProxy t (GestureLongPress -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveGestureLongPressMethod t GestureLongPress, O.MethodInfo info GestureLongPress p) => O.IsLabel t (GestureLongPress -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal GestureLongPress::cancelled
type GestureLongPressCancelledCallback =
    IO ()

noGestureLongPressCancelledCallback :: Maybe GestureLongPressCancelledCallback
noGestureLongPressCancelledCallback = Nothing

type C_GestureLongPressCancelledCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureLongPressCancelledCallback :: C_GestureLongPressCancelledCallback -> IO (FunPtr C_GestureLongPressCancelledCallback)

genClosure_GestureLongPressCancelled :: GestureLongPressCancelledCallback -> IO Closure
genClosure_GestureLongPressCancelled cb = do
    let cb' = wrap_GestureLongPressCancelledCallback cb
    mk_GestureLongPressCancelledCallback cb' >>= newCClosure


wrap_GestureLongPressCancelledCallback ::
    GestureLongPressCancelledCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_GestureLongPressCancelledCallback _cb _ _ = do
    _cb 


onGestureLongPressCancelled :: (GObject a, MonadIO m) => a -> GestureLongPressCancelledCallback -> m SignalHandlerId
onGestureLongPressCancelled obj cb = liftIO $ connectGestureLongPressCancelled obj cb SignalConnectBefore
afterGestureLongPressCancelled :: (GObject a, MonadIO m) => a -> GestureLongPressCancelledCallback -> m SignalHandlerId
afterGestureLongPressCancelled obj cb = connectGestureLongPressCancelled obj cb SignalConnectAfter

connectGestureLongPressCancelled :: (GObject a, MonadIO m) =>
                                    a -> GestureLongPressCancelledCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureLongPressCancelled obj cb after = liftIO $ do
    let cb' = wrap_GestureLongPressCancelledCallback cb
    cb'' <- mk_GestureLongPressCancelledCallback cb'
    connectSignalFunPtr obj "cancelled" cb'' after

-- signal GestureLongPress::pressed
type GestureLongPressPressedCallback =
    Double ->
    Double ->
    IO ()

noGestureLongPressPressedCallback :: Maybe GestureLongPressPressedCallback
noGestureLongPressPressedCallback = Nothing

type C_GestureLongPressPressedCallback =
    Ptr () ->                               -- object
    CDouble ->
    CDouble ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_GestureLongPressPressedCallback :: C_GestureLongPressPressedCallback -> IO (FunPtr C_GestureLongPressPressedCallback)

genClosure_GestureLongPressPressed :: GestureLongPressPressedCallback -> IO Closure
genClosure_GestureLongPressPressed cb = do
    let cb' = wrap_GestureLongPressPressedCallback cb
    mk_GestureLongPressPressedCallback cb' >>= newCClosure


wrap_GestureLongPressPressedCallback ::
    GestureLongPressPressedCallback ->
    Ptr () ->
    CDouble ->
    CDouble ->
    Ptr () ->
    IO ()
wrap_GestureLongPressPressedCallback _cb _ x y _ = do
    let x' = realToFrac x
    let y' = realToFrac y
    _cb  x' y'


onGestureLongPressPressed :: (GObject a, MonadIO m) => a -> GestureLongPressPressedCallback -> m SignalHandlerId
onGestureLongPressPressed obj cb = liftIO $ connectGestureLongPressPressed obj cb SignalConnectBefore
afterGestureLongPressPressed :: (GObject a, MonadIO m) => a -> GestureLongPressPressedCallback -> m SignalHandlerId
afterGestureLongPressPressed obj cb = connectGestureLongPressPressed obj cb SignalConnectAfter

connectGestureLongPressPressed :: (GObject a, MonadIO m) =>
                                  a -> GestureLongPressPressedCallback -> SignalConnectMode -> m SignalHandlerId
connectGestureLongPressPressed obj cb after = liftIO $ do
    let cb' = wrap_GestureLongPressPressedCallback cb
    cb'' <- mk_GestureLongPressPressedCallback cb'
    connectSignalFunPtr obj "pressed" cb'' after

-- VVV Prop "delay-factor"
   -- Type: TBasicType TDouble
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

getGestureLongPressDelayFactor :: (MonadIO m, IsGestureLongPress o) => o -> m Double
getGestureLongPressDelayFactor obj = liftIO $ getObjectPropertyDouble obj "delay-factor"

setGestureLongPressDelayFactor :: (MonadIO m, IsGestureLongPress o) => o -> Double -> m ()
setGestureLongPressDelayFactor obj val = liftIO $ setObjectPropertyDouble obj "delay-factor" val

constructGestureLongPressDelayFactor :: (IsGestureLongPress o) => Double -> IO (GValueConstruct o)
constructGestureLongPressDelayFactor val = constructObjectPropertyDouble "delay-factor" val

data GestureLongPressDelayFactorPropertyInfo
instance AttrInfo GestureLongPressDelayFactorPropertyInfo where
    type AttrAllowedOps GestureLongPressDelayFactorPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint GestureLongPressDelayFactorPropertyInfo = (~) Double
    type AttrBaseTypeConstraint GestureLongPressDelayFactorPropertyInfo = IsGestureLongPress
    type AttrGetType GestureLongPressDelayFactorPropertyInfo = Double
    type AttrLabel GestureLongPressDelayFactorPropertyInfo = "delay-factor"
    type AttrOrigin GestureLongPressDelayFactorPropertyInfo = GestureLongPress
    attrGet _ = getGestureLongPressDelayFactor
    attrSet _ = setGestureLongPressDelayFactor
    attrConstruct _ = constructGestureLongPressDelayFactor
    attrClear _ = undefined

instance O.HasAttributeList GestureLongPress
type instance O.AttributeList GestureLongPress = GestureLongPressAttributeList
type GestureLongPressAttributeList = ('[ '("button", Gtk.GestureSingle.GestureSingleButtonPropertyInfo), '("delayFactor", GestureLongPressDelayFactorPropertyInfo), '("exclusive", Gtk.GestureSingle.GestureSingleExclusivePropertyInfo), '("nPoints", Gtk.Gesture.GestureNPointsPropertyInfo), '("propagationPhase", Gtk.EventController.EventControllerPropagationPhasePropertyInfo), '("touchOnly", Gtk.GestureSingle.GestureSingleTouchOnlyPropertyInfo), '("widget", Gtk.EventController.EventControllerWidgetPropertyInfo), '("window", Gtk.Gesture.GestureWindowPropertyInfo)] :: [(Symbol, *)])

gestureLongPressDelayFactor :: AttrLabelProxy "delayFactor"
gestureLongPressDelayFactor = AttrLabelProxy

data GestureLongPressCancelledSignalInfo
instance SignalInfo GestureLongPressCancelledSignalInfo where
    type HaskellCallbackType GestureLongPressCancelledSignalInfo = GestureLongPressCancelledCallback
    connectSignal _ = connectGestureLongPressCancelled

data GestureLongPressPressedSignalInfo
instance SignalInfo GestureLongPressPressedSignalInfo where
    type HaskellCallbackType GestureLongPressPressedSignalInfo = GestureLongPressPressedCallback
    connectSignal _ = connectGestureLongPressPressed

type instance O.SignalList GestureLongPress = GestureLongPressSignalList
type GestureLongPressSignalList = ('[ '("begin", Gtk.Gesture.GestureBeginSignalInfo), '("cancel", Gtk.Gesture.GestureCancelSignalInfo), '("cancelled", GestureLongPressCancelledSignalInfo), '("end", Gtk.Gesture.GestureEndSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo), '("pressed", GestureLongPressPressedSignalInfo), '("sequenceStateChanged", Gtk.Gesture.GestureSequenceStateChangedSignalInfo), '("update", Gtk.Gesture.GestureUpdateSignalInfo)] :: [(Symbol, *)])

-- method GestureLongPress::new
-- method type : Constructor
-- Args : [Arg {argCName = "widget", argType = TInterface (Name {namespace = "Gtk", name = "Widget"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GtkWidget", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gtk", name = "GestureLongPress"}))
-- throws : False
-- Skip return : False

foreign import ccall "gtk_gesture_long_press_new" gtk_gesture_long_press_new :: 
    Ptr Gtk.Widget.Widget ->                -- widget : TInterface (Name {namespace = "Gtk", name = "Widget"})
    IO (Ptr GestureLongPress)

{- |
Returns a newly created 'GI.Gtk.Objects.Gesture.Gesture' that recognizes long presses.

@since 3.14
-}
gestureLongPressNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gtk.Widget.IsWidget a) =>
    a
    {- ^ /@widget@/: a 'GI.Gtk.Objects.Widget.Widget' -}
    -> m GestureLongPress
    {- ^ __Returns:__ a newly created 'GI.Gtk.Objects.GestureLongPress.GestureLongPress' -}
gestureLongPressNew widget = liftIO $ do
    widget' <- unsafeManagedPtrCastPtr widget
    result <- gtk_gesture_long_press_new widget'
    checkUnexpectedReturnNULL "gestureLongPressNew" result
    result' <- (wrapObject GestureLongPress) result
    touchManagedPtr widget
    return result'