{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Fog settings used to create the depth cueing effect.
-- 
-- /Since: 0.6/

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

module GI.Clutter.Structs.Fog
    ( 

-- * Exported types
    Fog(..)                                 ,
    newZeroFog                              ,


 -- * Methods

#if defined(ENABLE_OVERLOADING)
    ResolveFogMethod                        ,
#endif



 -- * Properties


-- ** zFar #attr:zFar#
-- | final distance from the viewer to the far clipping
--   plane (always positive)

#if defined(ENABLE_OVERLOADING)
    fog_zFar                                ,
#endif
    getFogZFar                              ,
    setFogZFar                              ,


-- ** zNear #attr:zNear#
-- | starting distance from the viewer to the near clipping
--   plane (always positive)

#if defined(ENABLE_OVERLOADING)
    fog_zNear                               ,
#endif
    getFogZNear                             ,
    setFogZNear                             ,




    ) 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


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

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

foreign import ccall "clutter_fog_get_type" c_clutter_fog_get_type :: 
    IO GType

type instance O.ParentTypes Fog = '[]
instance O.HasParentTypes Fog

instance B.Types.TypedObject Fog where
    glibType :: IO GType
glibType = IO GType
c_clutter_fog_get_type

instance B.Types.GBoxed Fog

-- | Convert 'Fog' to and from 'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe Fog) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_clutter_fog_get_type
    gvalueSet_ :: Ptr GValue -> Maybe Fog -> IO ()
gvalueSet_ Ptr GValue
gv Maybe Fog
P.Nothing = Ptr GValue -> Ptr Fog -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr Fog
forall a. Ptr a
FP.nullPtr :: FP.Ptr Fog)
    gvalueSet_ Ptr GValue
gv (P.Just Fog
obj) = Fog -> (Ptr Fog -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Fog
obj (Ptr GValue -> Ptr Fog -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe Fog)
gvalueGet_ Ptr GValue
gv = do
        Ptr Fog
ptr <- Ptr GValue -> IO (Ptr Fog)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr Fog)
        if Ptr Fog
ptr Ptr Fog -> Ptr Fog -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr Fog
forall a. Ptr a
FP.nullPtr
        then Fog -> Maybe Fog
forall a. a -> Maybe a
P.Just (Fog -> Maybe Fog) -> IO Fog -> IO (Maybe Fog)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ManagedPtr Fog -> Fog) -> Ptr Fog -> IO Fog
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Fog -> Fog
Fog Ptr Fog
ptr
        else Maybe Fog -> IO (Maybe Fog)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Fog
forall a. Maybe a
P.Nothing
        
    

-- | Construct a `Fog` struct initialized to zero.
newZeroFog :: MonadIO m => m Fog
newZeroFog :: forall (m :: * -> *). MonadIO m => m Fog
newZeroFog = IO Fog -> m Fog
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Fog -> m Fog) -> IO Fog -> m Fog
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr Fog)
forall a. GBoxed a => Int -> IO (Ptr a)
callocBoxedBytes Int
8 IO (Ptr Fog) -> (Ptr Fog -> IO Fog) -> IO Fog
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr Fog -> Fog) -> Ptr Fog -> IO Fog
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Fog -> Fog
Fog

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


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

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

#if defined(ENABLE_OVERLOADING)
data FogZNearFieldInfo
instance AttrInfo FogZNearFieldInfo where
    type AttrBaseTypeConstraint FogZNearFieldInfo = (~) Fog
    type AttrAllowedOps FogZNearFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint FogZNearFieldInfo = (~) Float
    type AttrTransferTypeConstraint FogZNearFieldInfo = (~)Float
    type AttrTransferType FogZNearFieldInfo = Float
    type AttrGetType FogZNearFieldInfo = Float
    type AttrLabel FogZNearFieldInfo = "z_near"
    type AttrOrigin FogZNearFieldInfo = Fog
    attrGet = getFogZNear
    attrSet = setFogZNear
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Clutter.Structs.Fog.zNear"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Fog.html#g:attr:zNear"
        })

fog_zNear :: AttrLabelProxy "zNear"
fog_zNear = AttrLabelProxy

#endif


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

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

#if defined(ENABLE_OVERLOADING)
data FogZFarFieldInfo
instance AttrInfo FogZFarFieldInfo where
    type AttrBaseTypeConstraint FogZFarFieldInfo = (~) Fog
    type AttrAllowedOps FogZFarFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint FogZFarFieldInfo = (~) Float
    type AttrTransferTypeConstraint FogZFarFieldInfo = (~)Float
    type AttrTransferType FogZFarFieldInfo = Float
    type AttrGetType FogZFarFieldInfo = Float
    type AttrLabel FogZFarFieldInfo = "z_far"
    type AttrOrigin FogZFarFieldInfo = Fog
    attrGet = getFogZFar
    attrSet = setFogZFar
    attrConstruct = undefined
    attrClear = undefined
    attrTransfer _ v = do
        return v
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Clutter.Structs.Fog.zFar"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-clutter-1.0.2/docs/GI-Clutter-Structs-Fog.html#g:attr:zFar"
        })

fog_zFar :: AttrLabelProxy "zFar"
fog_zFar = AttrLabelProxy

#endif



#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList Fog
type instance O.AttributeList Fog = FogAttributeList
type FogAttributeList = ('[ '("zNear", FogZNearFieldInfo), '("zFar", FogZFarFieldInfo)] :: [(Symbol, *)])
#endif

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

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

#endif

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

#endif