{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A t'GI.Gdk.Structs.TimeCoord.TimeCoord' stores a single event in a motion history.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Gdk.Structs.TimeCoord
    ( 

-- * Exported types
    TimeCoord(..)                           ,
    newZeroTimeCoord                        ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveTimeCoordMethod                  ,
#endif




 -- * Properties
-- ** time #attr:time#
-- | The timestamp for this event.

    getTimeCoordTime                        ,
    setTimeCoordTime                        ,
#if defined(ENABLE_OVERLOADING)
    timeCoord_time                          ,
#endif




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 GHC.OverloadedLabels as OL


-- | Memory-managed wrapper type.
newtype TimeCoord = TimeCoord (SP.ManagedPtr TimeCoord)
    deriving (TimeCoord -> TimeCoord -> Bool
(TimeCoord -> TimeCoord -> Bool)
-> (TimeCoord -> TimeCoord -> Bool) -> Eq TimeCoord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TimeCoord -> TimeCoord -> Bool
$c/= :: TimeCoord -> TimeCoord -> Bool
== :: TimeCoord -> TimeCoord -> Bool
$c== :: TimeCoord -> TimeCoord -> Bool
Eq)

instance SP.ManagedPtrNewtype TimeCoord where
    toManagedPtr :: TimeCoord -> ManagedPtr TimeCoord
toManagedPtr (TimeCoord ManagedPtr TimeCoord
p) = ManagedPtr TimeCoord
p

instance BoxedPtr TimeCoord where
    boxedPtrCopy :: TimeCoord -> IO TimeCoord
boxedPtrCopy = \TimeCoord
p -> TimeCoord -> (Ptr TimeCoord -> IO TimeCoord) -> IO TimeCoord
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr TimeCoord
p (Int -> Ptr TimeCoord -> IO (Ptr TimeCoord)
forall a. (HasCallStack, CallocPtr a) => Int -> Ptr a -> IO (Ptr a)
copyBytes Int
1032 (Ptr TimeCoord -> IO (Ptr TimeCoord))
-> (Ptr TimeCoord -> IO TimeCoord) -> Ptr TimeCoord -> IO TimeCoord
forall (m :: * -> *) a b c.
Monad m =>
(a -> m b) -> (b -> m c) -> a -> m c
>=> (ManagedPtr TimeCoord -> TimeCoord)
-> Ptr TimeCoord -> IO TimeCoord
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.wrapPtr ManagedPtr TimeCoord -> TimeCoord
TimeCoord)
    boxedPtrFree :: TimeCoord -> IO ()
boxedPtrFree = \TimeCoord
x -> TimeCoord -> (Ptr TimeCoord -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
SP.withManagedPtr TimeCoord
x Ptr TimeCoord -> IO ()
forall a. Ptr a -> IO ()
SP.freeMem
instance CallocPtr TimeCoord where
    boxedPtrCalloc :: IO (Ptr TimeCoord)
boxedPtrCalloc = Int -> IO (Ptr TimeCoord)
forall a. Int -> IO (Ptr a)
callocBytes Int
1032


-- | Construct a `TimeCoord` struct initialized to zero.
newZeroTimeCoord :: MonadIO m => m TimeCoord
newZeroTimeCoord :: m TimeCoord
newZeroTimeCoord = IO TimeCoord -> m TimeCoord
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TimeCoord -> m TimeCoord) -> IO TimeCoord -> m TimeCoord
forall a b. (a -> b) -> a -> b
$ IO (Ptr TimeCoord)
forall a. CallocPtr a => IO (Ptr a)
boxedPtrCalloc IO (Ptr TimeCoord)
-> (Ptr TimeCoord -> IO TimeCoord) -> IO TimeCoord
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr TimeCoord -> TimeCoord)
-> Ptr TimeCoord -> IO TimeCoord
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TimeCoord -> TimeCoord
TimeCoord

instance tag ~ 'AttrSet => Constructible TimeCoord tag where
    new :: (ManagedPtr TimeCoord -> TimeCoord)
-> [AttrOp TimeCoord tag] -> m TimeCoord
new ManagedPtr TimeCoord -> TimeCoord
_ [AttrOp TimeCoord tag]
attrs = do
        TimeCoord
o <- m TimeCoord
forall (m :: * -> *). MonadIO m => m TimeCoord
newZeroTimeCoord
        TimeCoord -> [AttrOp TimeCoord 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set TimeCoord
o [AttrOp TimeCoord tag]
[AttrOp TimeCoord 'AttrSet]
attrs
        TimeCoord -> m TimeCoord
forall (m :: * -> *) a. Monad m => a -> m a
return TimeCoord
o


-- | Get the value of the “@time@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' timeCoord #time
-- @
getTimeCoordTime :: MonadIO m => TimeCoord -> m Word32
getTimeCoordTime :: TimeCoord -> m Word32
getTimeCoordTime TimeCoord
s = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ TimeCoord -> (Ptr TimeCoord -> IO Word32) -> IO Word32
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TimeCoord
s ((Ptr TimeCoord -> IO Word32) -> IO Word32)
-> (Ptr TimeCoord -> IO Word32) -> IO Word32
forall a b. (a -> b) -> a -> b
$ \Ptr TimeCoord
ptr -> do
    Word32
val <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek (Ptr TimeCoord
ptr Ptr TimeCoord -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) :: IO Word32
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
val

-- | Set the value of the “@time@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.set' timeCoord [ #time 'Data.GI.Base.Attributes.:=' value ]
-- @
setTimeCoordTime :: MonadIO m => TimeCoord -> Word32 -> m ()
setTimeCoordTime :: TimeCoord -> Word32 -> m ()
setTimeCoordTime TimeCoord
s Word32
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ TimeCoord -> (Ptr TimeCoord -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr TimeCoord
s ((Ptr TimeCoord -> IO ()) -> IO ())
-> (Ptr TimeCoord -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr TimeCoord
ptr -> do
    Ptr Word32 -> Word32 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr TimeCoord
ptr Ptr TimeCoord -> Int -> Ptr Word32
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
0) (Word32
val :: Word32)

#if defined(ENABLE_OVERLOADING)
data TimeCoordTimeFieldInfo
instance AttrInfo TimeCoordTimeFieldInfo where
    type AttrBaseTypeConstraint TimeCoordTimeFieldInfo = (~) TimeCoord
    type AttrAllowedOps TimeCoordTimeFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint TimeCoordTimeFieldInfo = (~) Word32
    type AttrTransferTypeConstraint TimeCoordTimeFieldInfo = (~)Word32
    type AttrTransferType TimeCoordTimeFieldInfo = Word32
    type AttrGetType TimeCoordTimeFieldInfo = Word32
    type AttrLabel TimeCoordTimeFieldInfo = "time"
    type AttrOrigin TimeCoordTimeFieldInfo = TimeCoord
    attrGet = getTimeCoordTime
    attrSet = setTimeCoordTime
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

timeCoord_time :: AttrLabelProxy "time"
timeCoord_time = AttrLabelProxy

#endif


-- XXX Skipped attribute for "TimeCoord:axes"
-- Not implemented: Don't know how to unpack C array of type TCArray False 128 (-1) (TBasicType TDouble)

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList TimeCoord
type instance O.AttributeList TimeCoord = TimeCoordAttributeList
type TimeCoordAttributeList = ('[ '("time", TimeCoordTimeFieldInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveTimeCoordMethod (t :: Symbol) (o :: *) :: * where
    ResolveTimeCoordMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTimeCoordMethod t TimeCoord, O.MethodInfo info TimeCoord p) => OL.IsLabel t (TimeCoord -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif