-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

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

module GI.Adw.Functions
    ( 

 -- * Methods


-- ** getEnableAnimations #method:getEnableAnimations#

    getEnableAnimations                     ,


-- ** getMajorVersion #method:getMajorVersion#

    getMajorVersion                         ,


-- ** getMicroVersion #method:getMicroVersion#

    getMicroVersion                         ,


-- ** getMinorVersion #method:getMinorVersion#

    getMinorVersion                         ,


-- ** init #method:init#

    init                                    ,


-- ** isInitialized #method:isInitialized#

    isInitialized                           ,


-- ** lerp #method:lerp#

    lerp                                    ,




    ) 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.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 GI.Gtk.Objects.Widget as Gtk.Widget

-- function lerp
-- Args: [ Arg
--           { argCName = "a"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the start" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "b"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the end" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "t"
--           , argType = TBasicType TDouble
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the interpolation rate"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "adw_lerp" adw_lerp :: 
    CDouble ->                              -- a : TBasicType TDouble
    CDouble ->                              -- b : TBasicType TDouble
    CDouble ->                              -- t : TBasicType TDouble
    IO CDouble

-- | Computes the linear interpolation between /@a@/ and /@b@/ for /@t@/.
-- 
-- /Since: 1.0/
lerp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Double
    -- ^ /@a@/: the start
    -> Double
    -- ^ /@b@/: the end
    -> Double
    -- ^ /@t@/: the interpolation rate
    -> m Double
    -- ^ __Returns:__ the computed value
lerp :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Double -> Double -> Double -> m Double
lerp Double
a Double
b Double
t = IO Double -> m Double
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Double -> m Double) -> IO Double -> m Double
forall a b. (a -> b) -> a -> b
$ do
    let a' :: CDouble
a' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a
    let b' :: CDouble
b' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
b
    let t' :: CDouble
t' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
t
    CDouble
result <- CDouble -> CDouble -> CDouble -> IO CDouble
adw_lerp CDouble
a' CDouble
b' CDouble
t'
    let result' :: Double
result' = CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
result
    Double -> IO Double
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Double
result'


-- function is_initialized
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "adw_is_initialized" adw_is_initialized :: 
    IO CInt

-- | Use this function to check if libadwaita has been initialized with
-- [func/@init@/].
isInitialized ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Bool
    -- ^ __Returns:__ the initialization status
isInitialized :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Bool
isInitialized  = 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
    CInt
result <- IO CInt
adw_is_initialized
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function init
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "adw_init" adw_init :: 
    IO ()

-- | Initializes Libadwaita.
-- 
-- This function can be used instead of 'GI.Gtk.Functions.init' as it initializes GTK
-- implicitly.
-- 
-- There\'s no need to call this function if you\'re using [class/@application@/].
-- 
-- If Libadwaita has already been initialized, the function will simply return.
-- 
-- This makes sure translations, types, themes, and icons for the Adwaita
-- library are set up properly.
-- 
-- /Since: 1.0/
init ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
init :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m ()
init  = 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
    IO ()
adw_init
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function get_minor_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "adw_get_minor_version" adw_get_minor_version :: 
    IO Word32

-- | Returns the minor version number of the Adwaita library.
-- 
-- For example, in libadwaita version 1.2.3 this is 2.
-- 
-- This function is in the library, so it represents the libadwaita library your
-- code is running against. Contrast with the [const/@mAJORVERSION@/] constant,
-- which represents the minor version of the libadwaita headers you have
-- included when compiling your code.
getMinorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the minor version number of the Adwaita library
getMinorVersion :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Word32
getMinorVersion  = IO Word32 -> m Word32
forall a. IO a -> m a
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
$ do
    Word32
result <- IO Word32
adw_get_minor_version
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function get_micro_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "adw_get_micro_version" adw_get_micro_version :: 
    IO Word32

-- | Returns the micro version number of the Adwaita library.
-- 
-- For example, in libadwaita version 1.2.3 this is 3.
-- 
-- This function is in the library, so it represents the libadwaita library your
-- code is running against. Contrast with the [const/@mAJORVERSION@/] constant,
-- which represents the micro version of the libadwaita headers you have
-- included when compiling your code.
getMicroVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the micro version number of the Adwaita library
getMicroVersion :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Word32
getMicroVersion  = IO Word32 -> m Word32
forall a. IO a -> m a
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
$ do
    Word32
result <- IO Word32
adw_get_micro_version
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function get_major_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "adw_get_major_version" adw_get_major_version :: 
    IO Word32

-- | Returns the major version number of the Adwaita library.
-- 
-- For example, in libadwaita version 1.2.3 this is 1.
-- 
-- This function is in the library, so it represents the libadwaita library your
-- code is running against. Contrast with the [const/@mAJORVERSION@/] constant,
-- which represents the major version of the libadwaita headers you have
-- included when compiling your code.
getMajorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the major version number of the Adwaita library
getMajorVersion :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Word32
getMajorVersion  = IO Word32 -> m Word32
forall a. IO a -> m a
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
$ do
    Word32
result <- IO Word32
adw_get_major_version
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function get_enable_animations
-- Args: [ Arg
--           { argCName = "widget"
--           , argType = TInterface Name { namespace = "Gtk" , name = "Widget" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a `GtkWidget`" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "adw_get_enable_animations" adw_get_enable_animations :: 
    Ptr Gtk.Widget.Widget ->                -- widget : TInterface (Name {namespace = "Gtk", name = "Widget"})
    IO CInt

-- | Checks whether animations are enabled for /@widget@/.
-- 
-- This should be used when implementing an animated widget to know whether to
-- animate it or not.
-- 
-- /Since: 1.0/
getEnableAnimations ::
    (B.CallStack.HasCallStack, MonadIO m, Gtk.Widget.IsWidget a) =>
    a
    -- ^ /@widget@/: a @GtkWidget@
    -> m Bool
    -- ^ __Returns:__ whether animations are enabled for /@widget@/
getEnableAnimations :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsWidget a) =>
a -> m Bool
getEnableAnimations a
widget = 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
    Ptr Widget
widget' <- a -> IO (Ptr Widget)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
widget
    CInt
result <- Ptr Widget -> IO CInt
adw_get_enable_animations Ptr Widget
widget'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
widget
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'