    {-# LANGUAGE TypeApplications #-}

    -- | Copyright  : Will Thompson and Iñaki García Etxebarria
    -- License    : LGPL-2.1
    -- Maintainer : Iñaki García Etxebarria
    --
    -- A color stop in a gradient node.

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

    module GI.Gsk.Structs.ColorStop
        (

    -- * Exported types
        ColorStop(..)                           ,
        newZeroColorStop                        ,

     -- * Methods

    #if defined(ENABLE_OVERLOADING)
        ResolveColorStopMethod                  ,
    #endif

     -- * Properties

    -- ** color #attr:color#
    -- | the color at the given offset

    #if defined(ENABLE_OVERLOADING)
        colorStop_color                         ,
    #endif
        getColorStopColor                       ,

    -- ** offset #attr:offset#
    -- | the offset of the color stop

    #if defined(ENABLE_OVERLOADING)
        colorStop_offset                        ,
    #endif
        getColorStopOffset                      ,
        setColorStopOffset                      ,

        ) 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
    import qualified Data.Word as DW
    import qualified Data.Int as DI
    import qualified System.Posix.Types as SPT
    import qualified Foreign.C.Types as FCT

    -- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
    #if MIN_VERSION_base(4,18,0)
    import qualified GI.Gdk.Structs.RGBA as Gdk.RGBA

    #else
    import qualified GI.Gdk.Structs.RGBA as Gdk.RGBA

    #endif

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

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

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

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

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

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

    -- | Set the value of the “@offset@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.set' colorStop [ #offset 'Data.GI.Base.Attributes.:=' value ]
    -- @
    setColorStopOffset :: MonadIO m => ColorStop -> Float -> m ()
    setColorStopOffset :: forall (m :: * -> *). MonadIO m => ColorStop -> Float -> m ()
    setColorStopOffset ColorStop
    s Float
    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
    $ ColorStop -> (Ptr ColorStop -> IO ()) -> IO ()
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr ColorStop
    s ((Ptr ColorStop -> IO ()) -> IO ())
    -> (Ptr ColorStop -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr ColorStop
    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 ColorStop
    ptr Ptr ColorStop -> Int -> Ptr CFloat
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    0) (CFloat
    val' :: CFloat)

    #if defined(ENABLE_OVERLOADING)
    data ColorStopOffsetFieldInfo
    instance AttrInfo ColorStopOffsetFieldInfo where
        type AttrBaseTypeConstraint ColorStopOffsetFieldInfo = (~) ColorStop
        type AttrAllowedOps ColorStopOffsetFieldInfo = '[ 'AttrSet, 'AttrGet]
        type AttrSetTypeConstraint ColorStopOffsetFieldInfo = (~) Float
        type AttrTransferTypeConstraint ColorStopOffsetFieldInfo = (~)Float
        type AttrTransferType ColorStopOffsetFieldInfo = Float
        type AttrGetType ColorStopOffsetFieldInfo = Float
        type AttrLabel ColorStopOffsetFieldInfo = "offset"
        type AttrOrigin ColorStopOffsetFieldInfo = ColorStop
        attrGet = getColorStopOffset
        attrSet = setColorStopOffset
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer _ v = do
            return v
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gsk.Structs.ColorStop.offset"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.9/docs/GI-Gsk-Structs-ColorStop.html#g:attr:offset"
            })

    colorStop_offset :: AttrLabelProxy "offset"
    colorStop_offset = AttrLabelProxy

    #endif

    -- | Get the value of the “@color@” field.
    -- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
    --
    -- @
    -- 'Data.GI.Base.Attributes.get' colorStop #color
    -- @
    getColorStopColor :: MonadIO m => ColorStop -> m Gdk.RGBA.RGBA
    getColorStopColor :: forall (m :: * -> *). MonadIO m => ColorStop -> m RGBA
    getColorStopColor ColorStop
    s = IO RGBA -> m RGBA
    forall a. IO a -> m a
    forall (m :: * -> *) a. MonadIO m => IO a -> m a
    liftIO (IO RGBA -> m RGBA) -> IO RGBA -> m RGBA
    forall a b. (a -> b) -> a -> b
    $ ColorStop -> (Ptr ColorStop -> IO RGBA) -> IO RGBA
    forall a c.
    (HasCallStack, ManagedPtrNewtype a) =>
    a -> (Ptr a -> IO c) -> IO c
    withManagedPtr ColorStop
    s ((Ptr ColorStop -> IO RGBA) -> IO RGBA)
    -> (Ptr ColorStop -> IO RGBA) -> IO RGBA
    forall a b. (a -> b) -> a -> b
    $ \Ptr ColorStop
    ptr -> do
        let val :: Ptr RGBA
    val = Ptr ColorStop
    ptr Ptr ColorStop -> Int -> Ptr RGBA
    forall a b. Ptr a -> Int -> Ptr b
    `plusPtr` Int
    4 :: (Ptr Gdk.RGBA.RGBA)
        val' <- ((ManagedPtr RGBA -> RGBA) -> Ptr RGBA -> IO RGBA
    forall a.
    (HasCallStack, GBoxed a) =>
    (ManagedPtr a -> a) -> Ptr a -> IO a
    newBoxed ManagedPtr RGBA -> RGBA
    Gdk.RGBA.RGBA) Ptr RGBA
    val
        return val'

    #if defined(ENABLE_OVERLOADING)
    data ColorStopColorFieldInfo
    instance AttrInfo ColorStopColorFieldInfo where
        type AttrBaseTypeConstraint ColorStopColorFieldInfo = (~) ColorStop
        type AttrAllowedOps ColorStopColorFieldInfo = '[ 'AttrGet]
        type AttrSetTypeConstraint ColorStopColorFieldInfo = (~) (Ptr Gdk.RGBA.RGBA)
        type AttrTransferTypeConstraint ColorStopColorFieldInfo = (~)(Ptr Gdk.RGBA.RGBA)
        type AttrTransferType ColorStopColorFieldInfo = (Ptr Gdk.RGBA.RGBA)
        type AttrGetType ColorStopColorFieldInfo = Gdk.RGBA.RGBA
        type AttrLabel ColorStopColorFieldInfo = "color"
        type AttrOrigin ColorStopColorFieldInfo = ColorStop
        attrGet = getColorStopColor
        attrSet = undefined
        attrConstruct = undefined
        attrClear = undefined
        attrTransfer = undefined
        dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
            O.resolvedSymbolName = "GI.Gsk.Structs.ColorStop.color"
            , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.9/docs/GI-Gsk-Structs-ColorStop.html#g:attr:color"
            })

    colorStop_color :: AttrLabelProxy "color"
    colorStop_color = AttrLabelProxy

    #endif

    #if defined(ENABLE_OVERLOADING)
    instance O.HasAttributeList ColorStop
    type instance O.AttributeList ColorStop = ColorStopAttributeList
    type ColorStopAttributeList = ('[ '("offset", ColorStopOffsetFieldInfo), '("color", ColorStopColorFieldInfo)] :: [(Symbol, DK.Type)])
    #endif

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

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

    #endif

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

    #endif