    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- Defines the x and y coordinates of a point.

    #if !defined(__HADDOCK_VERSION__)
    #define ENABLE_OVERLOADING
    #endif

    module GI.Gdk.Structs.Point
        (

    -- * Exported types
        Point(..)                               ,
        newZeroPoint                            ,

     -- * Methods

    #if defined(ENABLE_OVERLOADING)
        ResolvePointMethod                      ,
    #endif

     -- * Properties

    -- ** x #attr:x#
    -- | the x coordinate of the point.

        getPointX                               ,
    #if defined(ENABLE_OVERLOADING)
        point_x                                 ,
    #endif
        setPointX                               ,

    -- ** y #attr:y#
    -- | the y coordinate of the point.

        getPointY                               ,
    #if defined(ENABLE_OVERLOADING)
        point_y                                 ,
    #endif
        setPointY                               ,

        ) 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.GArray as B.GArray
    import qualified Data.GI.Base.GClosure as B.GClosure
    import qualified Data.GI.Base.GError as B.GError
    import qualified Data.GI.Base.GHashTable as B.GHT
    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.Coerce as Coerce
    import qualified Data.Text as T
    import qualified Data.Kind as DK
    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
    import qualified GHC.Records as R

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

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

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

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

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

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

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

    #if defined(ENABLE_OVERLOADING)
    data PointXFieldInfo
    instance AttrInfo PointXFieldInfo where
        type AttrBaseTypeConstraint PointXFieldInfo = (~) Point
        type AttrAllowedOps PointXFieldInfo = '[ 'AttrSet, 'AttrGet]
        type AttrSetTypeConstraint PointXFieldInfo = (~) Int32
        type AttrTransferTypeConstraint PointXFieldInfo = (~)Int32
        type AttrTransferType PointXFieldInfo = Int32
        type AttrGetType PointXFieldInfo = Int32
        type AttrLabel PointXFieldInfo = "x"
        type AttrOrigin PointXFieldInfo = Point
        attrGet = getPointX
        attrSet = setPointX
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer _ v = do
            return v
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gdk.Structs.Point.x"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gdk-3.0.28/docs/GI-Gdk-Structs-Point.html#g:attr:x"
            })

    point_x :: AttrLabelProxy "x"
    point_x = AttrLabelProxy

    #endif

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

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

    #if defined(ENABLE_OVERLOADING)
    data PointYFieldInfo
    instance AttrInfo PointYFieldInfo where
        type AttrBaseTypeConstraint PointYFieldInfo = (~) Point
        type AttrAllowedOps PointYFieldInfo = '[ 'AttrSet, 'AttrGet]
        type AttrSetTypeConstraint PointYFieldInfo = (~) Int32
        type AttrTransferTypeConstraint PointYFieldInfo = (~)Int32
        type AttrTransferType PointYFieldInfo = Int32
        type AttrGetType PointYFieldInfo = Int32
        type AttrLabel PointYFieldInfo = "y"
        type AttrOrigin PointYFieldInfo = Point
        attrGet = getPointY
        attrSet = setPointY
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer _ v = do
            return v
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gdk.Structs.Point.y"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gdk-3.0.28/docs/GI-Gdk-Structs-Point.html#g:attr:y"
            })

    point_y :: AttrLabelProxy "y"
    point_y = AttrLabelProxy

    #endif

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList Point
    type instance O.AttributeList Point = PointAttributeList
    type PointAttributeList = ('[ '("x", PointXFieldInfo), '("y", PointYFieldInfo)] :: [(Symbol, DK.Type)])
    #endif

    #if defined(ENABLE_OVERLOADING)
    type family ResolvePointMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
        ResolvePointMethod l o = O.MethodResolutionFailed l o

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

    #if MIN_VERSION_base(4,13,0)
    instance (info ~ ResolvePointMethod t Point, O.OverloadedMethod info Point p, R.HasField t Point p) => R.HasField t Point p where
        getField = O.overloadedMethod @info

    #endif

    instance (info ~ ResolvePointMethod t Point, O.OverloadedMethodInfo info Point) => OL.IsLabel t (O.MethodProxy info Point) where
    #if MIN_VERSION_base(4,10,0)
        fromLabel = O.MethodProxy
    #else
        fromLabel _ = O.MethodProxy
    #endif

    #endif