{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Specifies a transfer function for a color component to be applied
-- while rendering.
-- 
-- The available functions include linear, piecewise-linear,
-- gamma and step functions.
-- 
-- Note that the transfer function is applied to un-premultiplied
-- values, and all results are clamped to the [0, 1] range.
-- 
-- /Since: 4.20/

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

module GI.Gsk.Structs.ComponentTransfer
    ( 

-- * Exported types
    ComponentTransfer(..)                   ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [copy]("GI.Gsk.Structs.ComponentTransfer#g:method:copy"), [free]("GI.Gsk.Structs.ComponentTransfer#g:method:free").
-- 
-- ==== Getters
-- /None/.
-- 
-- ==== Setters
-- /None/.

#if defined(ENABLE_OVERLOADING)
    ResolveComponentTransferMethod          ,
#endif

-- ** copy #method:copy#

#if defined(ENABLE_OVERLOADING)
    ComponentTransferCopyMethodInfo         ,
#endif
    componentTransferCopy                   ,


-- ** equal #method:equal#

    componentTransferEqual                  ,


-- ** free #method:free#

#if defined(ENABLE_OVERLOADING)
    ComponentTransferFreeMethodInfo         ,
#endif
    componentTransferFree                   ,


-- ** newDiscrete #method:newDiscrete#

    componentTransferNewDiscrete            ,


-- ** newGamma #method:newGamma#

    componentTransferNewGamma               ,


-- ** newIdentity #method:newIdentity#

    componentTransferNewIdentity            ,


-- ** newLevels #method:newLevels#

    componentTransferNewLevels              ,


-- ** newLinear #method:newLinear#

    componentTransferNewLinear              ,


-- ** newTable #method:newTable#

    componentTransferNewTable               ,




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

#else

#endif

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

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

foreign import ccall "gsk_component_transfer_get_type" c_gsk_component_transfer_get_type :: 
    IO GType

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

instance B.Types.TypedObject ComponentTransfer where
    glibType :: IO GType
glibType = IO GType
c_gsk_component_transfer_get_type

instance B.Types.GBoxed ComponentTransfer

-- | Convert t'ComponentTransfer' 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 ComponentTransfer) where
    gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_gsk_component_transfer_get_type
    gvalueSet_ :: Ptr GValue -> Maybe ComponentTransfer -> IO ()
gvalueSet_ Ptr GValue
gv Maybe ComponentTransfer
P.Nothing = Ptr GValue -> Ptr ComponentTransfer -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv (Ptr ComponentTransfer
forall a. Ptr a
FP.nullPtr :: FP.Ptr ComponentTransfer)
    gvalueSet_ Ptr GValue
gv (P.Just ComponentTransfer
obj) = ComponentTransfer -> (Ptr ComponentTransfer -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr ComponentTransfer
obj (Ptr GValue -> Ptr ComponentTransfer -> IO ()
forall a. Ptr GValue -> Ptr a -> IO ()
B.GValue.set_boxed Ptr GValue
gv)
    gvalueGet_ :: Ptr GValue -> IO (Maybe ComponentTransfer)
gvalueGet_ Ptr GValue
gv = do
        ptr <- Ptr GValue -> IO (Ptr ComponentTransfer)
forall b. Ptr GValue -> IO (Ptr b)
B.GValue.get_boxed Ptr GValue
gv :: IO (Ptr ComponentTransfer)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newBoxed ComponentTransfer ptr
        else return P.Nothing
        
    


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList ComponentTransfer
type instance O.AttributeList ComponentTransfer = ComponentTransferAttributeList
type ComponentTransferAttributeList = ('[ ] :: [(Symbol, DK.Type)])
#endif

-- method ComponentTransfer::new_discrete
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "n"
--           , argType = TBasicType TUInt
--           , argCType = Just "guint"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Number of values" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "values"
--           , argType = TCArray False (-1) 0 (TBasicType TFloat)
--           , argCType = Just "float*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Values" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n"
--              , argType = TBasicType TUInt
--              , argCType = Just "guint"
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "Number of values" , sinceVersion = Nothing }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_new_discrete" gsk_component_transfer_new_discrete :: 
    Word32 ->                               -- n : TBasicType TUInt
    Ptr CFloat ->                           -- values : TCArray False (-1) 0 (TBasicType TFloat)
    IO (Ptr ComponentTransfer)

-- | Creates a new component transfer that applies
-- a step function.
-- 
-- The new value is computed as
-- 
--     C\' = values[k]
-- 
-- where k is the smallest value such that
-- 
--     k \/ n \<= C \< (k + 1) \/ n
-- 
-- \<figure>
--   \<picture>
--     \<source srcset=\"discrete-dark.png\" media=\"(prefers-color-scheme: dark)\">
--       \<img alt=\"Component transfer: discrete\" src=\"discrete-light.png\">
--   \<\/picture>
-- \<\/figure>
-- 
-- /Since: 4.20/
componentTransferNewDiscrete ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Float]
    -- ^ /@values@/: Values
    -> m ComponentTransfer
    -- ^ __Returns:__ a new @GskComponentTransfer@
componentTransferNewDiscrete :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[Float] -> m ComponentTransfer
componentTransferNewDiscrete [Float]
values = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    let n :: Word32
n = Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word32) -> Int -> Word32
forall a b. (a -> b) -> a -> b
$ [Float] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Float]
values
    values' <- ((Float -> CFloat) -> [Float] -> IO (Ptr CFloat)
forall a b. Storable b => (a -> b) -> [a] -> IO (Ptr b)
packMapStorableArray Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac) [Float]
values
    result <- gsk_component_transfer_new_discrete n values'
    checkUnexpectedReturnNULL "componentTransferNewDiscrete" result
    result' <- (wrapBoxed ComponentTransfer) result
    freeMem values'
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ComponentTransfer::new_gamma
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "amp"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Amplitude" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "exp"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Exponent" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ofs"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Offset" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_new_gamma" gsk_component_transfer_new_gamma :: 
    CFloat ->                               -- amp : TBasicType TFloat
    CFloat ->                               -- exp : TBasicType TFloat
    CFloat ->                               -- ofs : TBasicType TFloat
    IO (Ptr ComponentTransfer)

-- | Creates a new component transfer that applies
-- a gamma transform.
-- 
-- The new value is computed as
-- 
--     C\' = amp * pow (C, exp) + ofs
-- 
-- \<figure>
--   \<picture>
--     \<source srcset=\"gamma-dark.png\" media=\"(prefers-color-scheme: dark)\">
--       \<img alt=\"Component transfer: gamma\" src=\"gamma-light.png\">
--   \<\/picture>
-- \<\/figure>
-- 
-- /Since: 4.20/
componentTransferNewGamma ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Float
    -- ^ /@amp@/: Amplitude
    -> Float
    -- ^ /@exp@/: Exponent
    -> Float
    -- ^ /@ofs@/: Offset
    -> m ComponentTransfer
    -- ^ __Returns:__ a new @GskComponentTransfer@
componentTransferNewGamma :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Float -> Float -> Float -> m ComponentTransfer
componentTransferNewGamma Float
amp Float
exp Float
ofs = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    let amp' :: CFloat
amp' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
amp
    let exp' :: CFloat
exp' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
exp
    let ofs' :: CFloat
ofs' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
ofs
    result <- CFloat -> CFloat -> CFloat -> IO (Ptr ComponentTransfer)
gsk_component_transfer_new_gamma CFloat
amp' CFloat
exp' CFloat
ofs'
    checkUnexpectedReturnNULL "componentTransferNewGamma" result
    result' <- (wrapBoxed ComponentTransfer) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ComponentTransfer::new_identity
-- method type : Constructor
-- Args: []
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_new_identity" gsk_component_transfer_new_identity :: 
    IO (Ptr ComponentTransfer)

-- | Creates a new component transfer that doesn\'t
-- change the component value.
-- 
-- \<figure>
--   \<picture>
--     \<source srcset=\"identity-dark.png\" media=\"(prefers-color-scheme: dark)\">
--       \<img alt=\"Component transfer: identity\" src=\"identity-light.png\">
--   \<\/picture>
-- \<\/figure>
-- 
-- /Since: 4.20/
componentTransferNewIdentity ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ComponentTransfer
    -- ^ __Returns:__ a new @GskComponentTransfer@
componentTransferNewIdentity :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
m ComponentTransfer
componentTransferNewIdentity  = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    result <- IO (Ptr ComponentTransfer)
gsk_component_transfer_new_identity
    checkUnexpectedReturnNULL "componentTransferNewIdentity" result
    result' <- (wrapBoxed ComponentTransfer) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ComponentTransfer::new_levels
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "n"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Number of levels" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_new_levels" gsk_component_transfer_new_levels :: 
    CFloat ->                               -- n : TBasicType TFloat
    IO (Ptr ComponentTransfer)

-- | Creates a new component transfer that limits
-- the values of the component to @n@ levels.
-- 
-- The new value is computed as
-- 
--     C\' = (floor (C * n) + 0.5) \/ n
-- 
-- \<figure>
--   \<picture>
--     \<source srcset=\"levels-dark.png\" media=\"(prefers-color-scheme: dark)\">
--       \<img alt=\"Component transfer: levels\" src=\"levels-light.png\">
--   \<\/picture>
-- \<\/figure>
-- 
-- /Since: 4.20/
componentTransferNewLevels ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Float
    -- ^ /@n@/: Number of levels
    -> m ComponentTransfer
    -- ^ __Returns:__ a new @GskComponentTransfer@
componentTransferNewLevels :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Float -> m ComponentTransfer
componentTransferNewLevels Float
n = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    let n' :: CFloat
n' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
n
    result <- CFloat -> IO (Ptr ComponentTransfer)
gsk_component_transfer_new_levels CFloat
n'
    checkUnexpectedReturnNULL "componentTransferNewLevels" result
    result' <- (wrapBoxed ComponentTransfer) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ComponentTransfer::new_linear
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "m"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Slope" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "b"
--           , argType = TBasicType TFloat
--           , argCType = Just "float"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Offset" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_new_linear" gsk_component_transfer_new_linear :: 
    CFloat ->                               -- m : TBasicType TFloat
    CFloat ->                               -- b : TBasicType TFloat
    IO (Ptr ComponentTransfer)

-- | Creates a new component transfer that applies
-- a linear transform.
-- 
-- The new value is computed as
-- 
--     C\' = C * m + b
-- 
-- \<figure>
--   \<picture>
--     \<source srcset=\"linear-dark.png\" media=\"(prefers-color-scheme: dark)\">
--       \<img alt=\"Component transfer: linear\" src=\"linear-light.png\">
--   \<\/picture>
-- \<\/figure>
-- 
-- /Since: 4.20/
componentTransferNewLinear ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Float
    -- ^ /@m@/: Slope
    -> Float
    -- ^ /@b@/: Offset
    -> m ComponentTransfer
    -- ^ __Returns:__ a new @GskComponentTransfer@
componentTransferNewLinear :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Float -> Float -> m ComponentTransfer
componentTransferNewLinear Float
m Float
b = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    let m' :: CFloat
m' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
m
    let b' :: CFloat
b' = Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
b
    result <- CFloat -> CFloat -> IO (Ptr ComponentTransfer)
gsk_component_transfer_new_linear CFloat
m' CFloat
b'
    checkUnexpectedReturnNULL "componentTransferNewLinear" result
    result' <- (wrapBoxed ComponentTransfer) result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ComponentTransfer::new_table
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "n"
--           , argType = TBasicType TUInt
--           , argCType = Just "guint"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Number of values" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "values"
--           , argType = TCArray False (-1) 0 (TBasicType TFloat)
--           , argCType = Just "float*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Values" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n"
--              , argType = TBasicType TUInt
--              , argCType = Just "guint"
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "Number of values" , sinceVersion = Nothing }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_new_table" gsk_component_transfer_new_table :: 
    Word32 ->                               -- n : TBasicType TUInt
    Ptr CFloat ->                           -- values : TCArray False (-1) 0 (TBasicType TFloat)
    IO (Ptr ComponentTransfer)

-- | Creates a new component transfer that applies
-- a piecewise linear function.
-- 
-- The new value is computed as
-- 
--     C\' = values[k] + (C - k \/ (n - 1)) * n * (values[k + 1] - values[k])
-- 
-- where k is the smallest value such that
-- 
--     k \/ (n - 1) \<= C \< (k + 1) \/ (n - 1)
-- 
-- \<figure>
--   \<picture>
--     \<source srcset=\"table-dark.png\" media=\"(prefers-color-scheme: dark)\">
--       \<img alt=\"Component transfer: table\" src=\"table-light.png\">
--   \<\/picture>
-- \<\/figure>
-- 
-- /Since: 4.20/
componentTransferNewTable ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Float]
    -- ^ /@values@/: Values
    -> m ComponentTransfer
    -- ^ __Returns:__ a new @GskComponentTransfer@
componentTransferNewTable :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[Float] -> m ComponentTransfer
componentTransferNewTable [Float]
values = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    let n :: Word32
n = Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word32) -> Int -> Word32
forall a b. (a -> b) -> a -> b
$ [Float] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [Float]
values
    values' <- ((Float -> CFloat) -> [Float] -> IO (Ptr CFloat)
forall a b. Storable b => (a -> b) -> [a] -> IO (Ptr b)
packMapStorableArray Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac) [Float]
values
    result <- gsk_component_transfer_new_table n values'
    checkUnexpectedReturnNULL "componentTransferNewTable" result
    result' <- (wrapBoxed ComponentTransfer) result
    freeMem values'
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ComponentTransfer::copy
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "other"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "ComponentTransfer" }
--           , argCType = Just "const GskComponentTransfer*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a component transfer"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface
--                  Name { namespace = "Gsk" , name = "ComponentTransfer" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_copy" gsk_component_transfer_copy :: 
    Ptr ComponentTransfer ->                -- other : TInterface (Name {namespace = "Gsk", name = "ComponentTransfer"})
    IO (Ptr ComponentTransfer)

-- | Creates a copy of /@other@/.
-- 
-- /Since: 4.20/
componentTransferCopy ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ComponentTransfer
    -- ^ /@other@/: a component transfer
    -> m ComponentTransfer
    -- ^ __Returns:__ a newly allocated copy of /@other@/
componentTransferCopy :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ComponentTransfer -> m ComponentTransfer
componentTransferCopy ComponentTransfer
other = IO ComponentTransfer -> m ComponentTransfer
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ComponentTransfer -> m ComponentTransfer)
-> IO ComponentTransfer -> m ComponentTransfer
forall a b. (a -> b) -> a -> b
$ do
    other' <- ComponentTransfer -> IO (Ptr ComponentTransfer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ComponentTransfer
other
    result <- gsk_component_transfer_copy other'
    checkUnexpectedReturnNULL "componentTransferCopy" result
    result' <- (wrapBoxed ComponentTransfer) result
    touchManagedPtr other
    return result'

#if defined(ENABLE_OVERLOADING)
data ComponentTransferCopyMethodInfo
instance (signature ~ (m ComponentTransfer), MonadIO m) => O.OverloadedMethod ComponentTransferCopyMethodInfo ComponentTransfer signature where
    overloadedMethod = componentTransferCopy

instance O.OverloadedMethodInfo ComponentTransferCopyMethodInfo ComponentTransfer where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.ComponentTransfer.componentTransferCopy",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.9/docs/GI-Gsk-Structs-ComponentTransfer.html#v:componentTransferCopy"
        })


#endif

-- method ComponentTransfer::free
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "self"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "ComponentTransfer" }
--           , argCType = Just "GskComponentTransfer*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a component transfer"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_free" gsk_component_transfer_free :: 
    Ptr ComponentTransfer ->                -- self : TInterface (Name {namespace = "Gsk", name = "ComponentTransfer"})
    IO ()

-- | Frees a component transfer.
-- 
-- /Since: 4.20/
componentTransferFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ComponentTransfer
    -- ^ /@self@/: a component transfer
    -> m ()
componentTransferFree :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ComponentTransfer -> m ()
componentTransferFree ComponentTransfer
self = 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
$ do
    self' <- ComponentTransfer -> IO (Ptr ComponentTransfer)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr ComponentTransfer
self
    gsk_component_transfer_free self'
    touchManagedPtr self
    return ()

#if defined(ENABLE_OVERLOADING)
data ComponentTransferFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.OverloadedMethod ComponentTransferFreeMethodInfo ComponentTransfer signature where
    overloadedMethod = componentTransferFree

instance O.OverloadedMethodInfo ComponentTransferFreeMethodInfo ComponentTransfer where
    overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Gsk.Structs.ComponentTransfer.componentTransferFree",
        O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gsk-4.0.9/docs/GI-Gsk-Structs-ComponentTransfer.html#v:componentTransferFree"
        })


#endif

-- method ComponentTransfer::equal
-- method type : MemberFunction
-- Args: [ Arg
--           { argCName = "self"
--           , argType = TBasicType TPtr
--           , argCType = Just "gconstpointer"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a component transfer"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "other"
--           , argType = TBasicType TPtr
--           , argCType = Just "gconstpointer"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "another component transfer"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "gsk_component_transfer_equal" gsk_component_transfer_equal :: 
    Ptr () ->                               -- self : TBasicType TPtr
    Ptr () ->                               -- other : TBasicType TPtr
    IO CInt

-- | Compares two component transfers for equality.
-- 
-- /Since: 4.20/
componentTransferEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@self@/: a component transfer
    -> Ptr ()
    -- ^ /@other@/: another component transfer
    -> m Bool
    -- ^ __Returns:__ true if /@self@/ and /@other@/ are equal
componentTransferEqual :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> Ptr () -> m Bool
componentTransferEqual Ptr ()
self Ptr ()
other = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    result <- Ptr () -> Ptr () -> IO CInt
gsk_component_transfer_equal Ptr ()
self Ptr ()
other
    let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    return result'

#if defined(ENABLE_OVERLOADING)
#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveComponentTransferMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveComponentTransferMethod "copy" o = ComponentTransferCopyMethodInfo
    ResolveComponentTransferMethod "free" o = ComponentTransferFreeMethodInfo
    ResolveComponentTransferMethod l o = O.MethodResolutionFailed l o

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

#endif

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

#endif