{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- The t'GI.Pango.Structs.GlyphGeometry.GlyphGeometry' structure contains width and positioning
-- information for a single glyph.

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

module GI.Pango.Structs.GlyphGeometry
    ( 

-- * Exported types
    GlyphGeometry(..)                       ,
    newZeroGlyphGeometry                    ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveGlyphGeometryMethod              ,
#endif




 -- * Properties
-- ** width #attr:width#
-- | the logical width to use for the the character.

    getGlyphGeometryWidth                   ,
#if defined(ENABLE_OVERLOADING)
    glyphGeometry_width                     ,
#endif
    setGlyphGeometryWidth                   ,


-- ** xOffset #attr:xOffset#
-- | horizontal offset from nominal character position.

    getGlyphGeometryXOffset                 ,
#if defined(ENABLE_OVERLOADING)
    glyphGeometry_xOffset                   ,
#endif
    setGlyphGeometryXOffset                 ,


-- ** yOffset #attr:yOffset#
-- | vertical offset from nominal character position.

    getGlyphGeometryYOffset                 ,
#if defined(ENABLE_OVERLOADING)
    glyphGeometry_yOffset                   ,
#endif
    setGlyphGeometryYOffset                 ,




    ) 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 GlyphGeometry = GlyphGeometry (SP.ManagedPtr GlyphGeometry)
    deriving (GlyphGeometry -> GlyphGeometry -> Bool
(GlyphGeometry -> GlyphGeometry -> Bool)
-> (GlyphGeometry -> GlyphGeometry -> Bool) -> Eq GlyphGeometry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlyphGeometry -> GlyphGeometry -> Bool
$c/= :: GlyphGeometry -> GlyphGeometry -> Bool
== :: GlyphGeometry -> GlyphGeometry -> Bool
$c== :: GlyphGeometry -> GlyphGeometry -> Bool
Eq)

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

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


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

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


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

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

#if defined(ENABLE_OVERLOADING)
data GlyphGeometryWidthFieldInfo
instance AttrInfo GlyphGeometryWidthFieldInfo where
    type AttrBaseTypeConstraint GlyphGeometryWidthFieldInfo = (~) GlyphGeometry
    type AttrAllowedOps GlyphGeometryWidthFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint GlyphGeometryWidthFieldInfo = (~) Int32
    type AttrTransferTypeConstraint GlyphGeometryWidthFieldInfo = (~)Int32
    type AttrTransferType GlyphGeometryWidthFieldInfo = Int32
    type AttrGetType GlyphGeometryWidthFieldInfo = Int32
    type AttrLabel GlyphGeometryWidthFieldInfo = "width"
    type AttrOrigin GlyphGeometryWidthFieldInfo = GlyphGeometry
    attrGet = getGlyphGeometryWidth
    attrSet = setGlyphGeometryWidth
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

glyphGeometry_width :: AttrLabelProxy "width"
glyphGeometry_width = AttrLabelProxy

#endif


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

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

#if defined(ENABLE_OVERLOADING)
data GlyphGeometryXOffsetFieldInfo
instance AttrInfo GlyphGeometryXOffsetFieldInfo where
    type AttrBaseTypeConstraint GlyphGeometryXOffsetFieldInfo = (~) GlyphGeometry
    type AttrAllowedOps GlyphGeometryXOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint GlyphGeometryXOffsetFieldInfo = (~) Int32
    type AttrTransferTypeConstraint GlyphGeometryXOffsetFieldInfo = (~)Int32
    type AttrTransferType GlyphGeometryXOffsetFieldInfo = Int32
    type AttrGetType GlyphGeometryXOffsetFieldInfo = Int32
    type AttrLabel GlyphGeometryXOffsetFieldInfo = "x_offset"
    type AttrOrigin GlyphGeometryXOffsetFieldInfo = GlyphGeometry
    attrGet = getGlyphGeometryXOffset
    attrSet = setGlyphGeometryXOffset
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

glyphGeometry_xOffset :: AttrLabelProxy "xOffset"
glyphGeometry_xOffset = AttrLabelProxy

#endif


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

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

#if defined(ENABLE_OVERLOADING)
data GlyphGeometryYOffsetFieldInfo
instance AttrInfo GlyphGeometryYOffsetFieldInfo where
    type AttrBaseTypeConstraint GlyphGeometryYOffsetFieldInfo = (~) GlyphGeometry
    type AttrAllowedOps GlyphGeometryYOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint GlyphGeometryYOffsetFieldInfo = (~) Int32
    type AttrTransferTypeConstraint GlyphGeometryYOffsetFieldInfo = (~)Int32
    type AttrTransferType GlyphGeometryYOffsetFieldInfo = Int32
    type AttrGetType GlyphGeometryYOffsetFieldInfo = Int32
    type AttrLabel GlyphGeometryYOffsetFieldInfo = "y_offset"
    type AttrOrigin GlyphGeometryYOffsetFieldInfo = GlyphGeometry
    attrGet = getGlyphGeometryYOffset
    attrSet = setGlyphGeometryYOffset
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v

glyphGeometry_yOffset :: AttrLabelProxy "yOffset"
glyphGeometry_yOffset = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList GlyphGeometry
type instance O.AttributeList GlyphGeometry = GlyphGeometryAttributeList
type GlyphGeometryAttributeList = ('[ '("width", GlyphGeometryWidthFieldInfo), '("xOffset", GlyphGeometryXOffsetFieldInfo), '("yOffset", GlyphGeometryYOffsetFieldInfo)] :: [(Symbol, *)])
#endif

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

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

#endif