{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A @PangoGlyphInfo@ structure represents a single glyph with
-- positioning information and visual attributes.

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

module GI.Pango.Structs.GlyphInfo
    ( 

-- * Exported types
    GlyphInfo(..)                           ,
    newZeroGlyphInfo                        ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveGlyphInfoMethod                  ,
#endif



 -- * Properties


-- ** attr #attr:attr#
-- | the visual attributes of the glyph.

    getGlyphInfoAttr                        ,
#if defined(ENABLE_OVERLOADING)
    glyphInfo_attr                          ,
#endif


-- ** geometry #attr:geometry#
-- | the positional information about the glyph.

    getGlyphInfoGeometry                    ,
#if defined(ENABLE_OVERLOADING)
    glyphInfo_geometry                      ,
#endif


-- ** glyph #attr:glyph#
-- | the glyph itself.

    getGlyphInfoGlyph                       ,
#if defined(ENABLE_OVERLOADING)
    glyphInfo_glyph                         ,
#endif
    setGlyphInfoGlyph                       ,




    ) 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.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.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

import {-# SOURCE #-} qualified GI.Pango.Structs.GlyphGeometry as Pango.GlyphGeometry
import {-# SOURCE #-} qualified GI.Pango.Structs.GlyphVisAttr as Pango.GlyphVisAttr

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

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

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


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

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


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

#if defined(ENABLE_OVERLOADING)
data GlyphInfoGlyphFieldInfo
instance AttrInfo GlyphInfoGlyphFieldInfo where
    type AttrBaseTypeConstraint GlyphInfoGlyphFieldInfo = (~) GlyphInfo
    type AttrAllowedOps GlyphInfoGlyphFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint GlyphInfoGlyphFieldInfo = (~) Word32
    type AttrTransferTypeConstraint GlyphInfoGlyphFieldInfo = (~)Word32
    type AttrTransferType GlyphInfoGlyphFieldInfo = Word32
    type AttrGetType GlyphInfoGlyphFieldInfo = Word32
    type AttrLabel GlyphInfoGlyphFieldInfo = "glyph"
    type AttrOrigin GlyphInfoGlyphFieldInfo = GlyphInfo
    attrGet = getGlyphInfoGlyph
    attrSet = setGlyphInfoGlyph
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Pango.Structs.GlyphInfo.glyph"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-pango-1.0.25/docs/GI-Pango-Structs-GlyphInfo.html#g:attr:glyph"
        })

glyphInfo_glyph :: AttrLabelProxy "glyph"
glyphInfo_glyph = AttrLabelProxy

#endif


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

#if defined(ENABLE_OVERLOADING)
data GlyphInfoGeometryFieldInfo
instance AttrInfo GlyphInfoGeometryFieldInfo where
    type AttrBaseTypeConstraint GlyphInfoGeometryFieldInfo = (~) GlyphInfo
    type AttrAllowedOps GlyphInfoGeometryFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint GlyphInfoGeometryFieldInfo = (~) (Ptr Pango.GlyphGeometry.GlyphGeometry)
    type AttrTransferTypeConstraint GlyphInfoGeometryFieldInfo = (~)(Ptr Pango.GlyphGeometry.GlyphGeometry)
    type AttrTransferType GlyphInfoGeometryFieldInfo = (Ptr Pango.GlyphGeometry.GlyphGeometry)
    type AttrGetType GlyphInfoGeometryFieldInfo = Pango.GlyphGeometry.GlyphGeometry
    type AttrLabel GlyphInfoGeometryFieldInfo = "geometry"
    type AttrOrigin GlyphInfoGeometryFieldInfo = GlyphInfo
    attrGet = getGlyphInfoGeometry
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Pango.Structs.GlyphInfo.geometry"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-pango-1.0.25/docs/GI-Pango-Structs-GlyphInfo.html#g:attr:geometry"
        })

glyphInfo_geometry :: AttrLabelProxy "geometry"
glyphInfo_geometry = AttrLabelProxy

#endif


-- | Get the value of the “@attr@” field.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' glyphInfo #attr
-- @
getGlyphInfoAttr :: MonadIO m => GlyphInfo -> m Pango.GlyphVisAttr.GlyphVisAttr
getGlyphInfoAttr :: forall (m :: * -> *). MonadIO m => GlyphInfo -> m GlyphVisAttr
getGlyphInfoAttr GlyphInfo
s = IO GlyphVisAttr -> m GlyphVisAttr
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GlyphVisAttr -> m GlyphVisAttr)
-> IO GlyphVisAttr -> m GlyphVisAttr
forall a b. (a -> b) -> a -> b
$ GlyphInfo -> (Ptr GlyphInfo -> IO GlyphVisAttr) -> IO GlyphVisAttr
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr GlyphInfo
s ((Ptr GlyphInfo -> IO GlyphVisAttr) -> IO GlyphVisAttr)
-> (Ptr GlyphInfo -> IO GlyphVisAttr) -> IO GlyphVisAttr
forall a b. (a -> b) -> a -> b
$ \Ptr GlyphInfo
ptr -> do
    let val :: Ptr GlyphVisAttr
val = Ptr GlyphInfo
ptr Ptr GlyphInfo -> Int -> Ptr GlyphVisAttr
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` Int
16 :: (Ptr Pango.GlyphVisAttr.GlyphVisAttr)
    GlyphVisAttr
val' <- ((ManagedPtr GlyphVisAttr -> GlyphVisAttr)
-> Ptr GlyphVisAttr -> IO GlyphVisAttr
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr GlyphVisAttr -> GlyphVisAttr
Pango.GlyphVisAttr.GlyphVisAttr) Ptr GlyphVisAttr
val
    GlyphVisAttr -> IO GlyphVisAttr
forall (m :: * -> *) a. Monad m => a -> m a
return GlyphVisAttr
val'

#if defined(ENABLE_OVERLOADING)
data GlyphInfoAttrFieldInfo
instance AttrInfo GlyphInfoAttrFieldInfo where
    type AttrBaseTypeConstraint GlyphInfoAttrFieldInfo = (~) GlyphInfo
    type AttrAllowedOps GlyphInfoAttrFieldInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint GlyphInfoAttrFieldInfo = (~) (Ptr Pango.GlyphVisAttr.GlyphVisAttr)
    type AttrTransferTypeConstraint GlyphInfoAttrFieldInfo = (~)(Ptr Pango.GlyphVisAttr.GlyphVisAttr)
    type AttrTransferType GlyphInfoAttrFieldInfo = (Ptr Pango.GlyphVisAttr.GlyphVisAttr)
    type AttrGetType GlyphInfoAttrFieldInfo = Pango.GlyphVisAttr.GlyphVisAttr
    type AttrLabel GlyphInfoAttrFieldInfo = "attr"
    type AttrOrigin GlyphInfoAttrFieldInfo = GlyphInfo
    attrGet = getGlyphInfoAttr
    attrSet = undefined
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Pango.Structs.GlyphInfo.attr"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-pango-1.0.25/docs/GI-Pango-Structs-GlyphInfo.html#g:attr:attr"
        })

glyphInfo_attr :: AttrLabelProxy "attr"
glyphInfo_attr = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList GlyphInfo
type instance O.AttributeList GlyphInfo = GlyphInfoAttributeList
type GlyphInfoAttributeList = ('[ '("glyph", GlyphInfoGlyphFieldInfo), '("geometry", GlyphInfoGeometryFieldInfo), '("attr", GlyphInfoAttrFieldInfo)] :: [(Symbol, *)])
#endif

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

instance (info ~ ResolveGlyphInfoMethod t GlyphInfo, O.OverloadedMethod info GlyphInfo p) => OL.IsLabel t (GlyphInfo -> 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 ~ ResolveGlyphInfoMethod t GlyphInfo, O.OverloadedMethod info GlyphInfo p, R.HasField t GlyphInfo p) => R.HasField t GlyphInfo p where
    getField = O.overloadedMethod @info

#endif

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

#endif