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

The 'GI.Pango.Structs.GlyphGeometry.GlyphGeometry' structure contains width and positioning
information for a single glyph.
-}

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

module GI.Pango.Structs.GlyphGeometry
    (

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


 -- * Properties
-- ** width #attr:width#
{- | the logical width to use for the the character.
-}
    getGlyphGeometryWidth                   ,
#if ENABLE_OVERLOADING
    glyphGeometry_width                     ,
#endif
    setGlyphGeometryWidth                   ,


-- ** xOffset #attr:xOffset#
{- | horizontal offset from nominal character position.
-}
    getGlyphGeometryXOffset                 ,
#if ENABLE_OVERLOADING
    glyphGeometry_xOffset                   ,
#endif
    setGlyphGeometryXOffset                 ,


-- ** yOffset #attr:yOffset#
{- | vertical offset from nominal character position.
-}
    getGlyphGeometryYOffset                 ,
#if 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.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.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 (ManagedPtr GlyphGeometry)
instance WrappedPtr GlyphGeometry where
    wrappedPtrCalloc = callocBytes 12
    wrappedPtrCopy = \p -> withManagedPtr p (copyBytes 12 >=> wrapPtr GlyphGeometry)
    wrappedPtrFree = Just ptr_to_g_free

-- | Construct a `GlyphGeometry` struct initialized to zero.
newZeroGlyphGeometry :: MonadIO m => m GlyphGeometry
newZeroGlyphGeometry = liftIO $ wrappedPtrCalloc >>= wrapPtr GlyphGeometry

instance tag ~ 'AttrSet => Constructible GlyphGeometry tag where
    new _ attrs = do
        o <- newZeroGlyphGeometry
        GI.Attributes.set o attrs
        return o


-- | A convenience alias for `Nothing` :: `Maybe` `GlyphGeometry`.
noGlyphGeometry :: Maybe GlyphGeometry
noGlyphGeometry = Nothing

{- |
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 s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Int32
    return 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 s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 0) (val :: Int32)

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

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 s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 4) :: IO Int32
    return 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 s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 4) (val :: Int32)

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

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 s = liftIO $ withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Int32
    return 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 s val = liftIO $ withManagedPtr s $ \ptr -> do
    poke (ptr `plusPtr` 8) (val :: Int32)

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

glyphGeometry_yOffset :: AttrLabelProxy "yOffset"
glyphGeometry_yOffset = AttrLabelProxy

#endif



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

#if 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 (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif