{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- /No description available in the introspection data./

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

module GI.Gsk.Objects.TextureNode
    ( 

-- * Exported types
    TextureNode(..)                         ,
    IsTextureNode                           ,
    toTextureNode                           ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveTextureNodeMethod                ,
#endif


-- ** getTexture #method:getTexture#

#if defined(ENABLE_OVERLOADING)
    TextureNodeGetTextureMethodInfo         ,
#endif
    textureNodeGetTexture                   ,


-- ** new #method:new#

    textureNodeNew                          ,




    ) 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.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.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 GI.Gdk.Objects.Texture as Gdk.Texture
import qualified GI.Graphene.Structs.Rect as Graphene.Rect
import {-# SOURCE #-} qualified GI.Gsk.Objects.RenderNode as Gsk.RenderNode

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

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

foreign import ccall "gsk_texture_node_get_type"
    c_gsk_texture_node_get_type :: IO B.Types.GType

instance B.Types.TypedObject TextureNode where
    glibType :: IO GType
glibType = IO GType
c_gsk_texture_node_get_type

-- | Type class for types which can be safely cast to `TextureNode`, for instance with `toTextureNode`.
class (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf TextureNode o) => IsTextureNode o
instance (SP.BoxedPtr o, SP.TypedObject o, O.IsDescendantOf TextureNode o) => IsTextureNode o

instance O.HasParentTypes TextureNode
type instance O.ParentTypes TextureNode = '[Gsk.RenderNode.RenderNode]

-- | Cast to `TextureNode`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toTextureNode :: (MonadIO m, IsTextureNode o) => o -> m TextureNode
toTextureNode :: o -> m TextureNode
toTextureNode = IO TextureNode -> m TextureNode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TextureNode -> m TextureNode)
-> (o -> IO TextureNode) -> o -> m TextureNode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr TextureNode -> TextureNode) -> o -> IO TextureNode
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
 ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr TextureNode -> TextureNode
TextureNode

#if defined(ENABLE_OVERLOADING)
type family ResolveTextureNodeMethod (t :: Symbol) (o :: *) :: * where
    ResolveTextureNodeMethod "draw" o = Gsk.RenderNode.RenderNodeDrawMethodInfo
    ResolveTextureNodeMethod "ref" o = Gsk.RenderNode.RenderNodeRefMethodInfo
    ResolveTextureNodeMethod "serialize" o = Gsk.RenderNode.RenderNodeSerializeMethodInfo
    ResolveTextureNodeMethod "unref" o = Gsk.RenderNode.RenderNodeUnrefMethodInfo
    ResolveTextureNodeMethod "writeToFile" o = Gsk.RenderNode.RenderNodeWriteToFileMethodInfo
    ResolveTextureNodeMethod "getBounds" o = Gsk.RenderNode.RenderNodeGetBoundsMethodInfo
    ResolveTextureNodeMethod "getNodeType" o = Gsk.RenderNode.RenderNodeGetNodeTypeMethodInfo
    ResolveTextureNodeMethod "getTexture" o = TextureNodeGetTextureMethodInfo
    ResolveTextureNodeMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveTextureNodeMethod t TextureNode, O.MethodInfo info TextureNode p) => OL.IsLabel t (TextureNode -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

-- XXX Wrapping a foreign struct/union with no known destructor or size, leak?
instance BoxedPtr TextureNode where
    boxedPtrCopy :: TextureNode -> IO TextureNode
boxedPtrCopy = TextureNode -> IO TextureNode
forall (m :: * -> *) a. Monad m => a -> m a
return
    boxedPtrFree :: TextureNode -> IO ()
boxedPtrFree = \TextureNode
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- method TextureNode::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "texture"
--           , argType =
--               TInterface Name { namespace = "Gdk" , name = "Texture" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #GdkTexture" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "bounds"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Rect" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the rectangle to render the texture into"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gsk" , name = "TextureNode" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_texture_node_new" gsk_texture_node_new :: 
    Ptr Gdk.Texture.Texture ->              -- texture : TInterface (Name {namespace = "Gdk", name = "Texture"})
    Ptr Graphene.Rect.Rect ->               -- bounds : TInterface (Name {namespace = "Graphene", name = "Rect"})
    IO (Ptr TextureNode)

-- | Creates a t'GI.Gsk.Objects.RenderNode.RenderNode' that will render the given
-- /@texture@/ into the area given by /@bounds@/.
textureNodeNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gdk.Texture.IsTexture a) =>
    a
    -- ^ /@texture@/: the t'GI.Gdk.Objects.Texture.Texture'
    -> Graphene.Rect.Rect
    -- ^ /@bounds@/: the rectangle to render the texture into
    -> m TextureNode
    -- ^ __Returns:__ A new t'GI.Gsk.Objects.RenderNode.RenderNode'
textureNodeNew :: a -> Rect -> m TextureNode
textureNodeNew a
texture Rect
bounds = IO TextureNode -> m TextureNode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TextureNode -> m TextureNode)
-> IO TextureNode -> m TextureNode
forall a b. (a -> b) -> a -> b
$ do
    Ptr Texture
texture' <- a -> IO (Ptr Texture)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
texture
    Ptr Rect
bounds' <- Rect -> IO (Ptr Rect)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rect
bounds
    Ptr TextureNode
result <- Ptr Texture -> Ptr Rect -> IO (Ptr TextureNode)
gsk_texture_node_new Ptr Texture
texture' Ptr Rect
bounds'
    Text -> Ptr TextureNode -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"textureNodeNew" Ptr TextureNode
result
    TextureNode
result' <- ((ManagedPtr TextureNode -> TextureNode)
-> Ptr TextureNode -> IO TextureNode
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr TextureNode -> TextureNode
TextureNode) Ptr TextureNode
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
texture
    Rect -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rect
bounds
    TextureNode -> IO TextureNode
forall (m :: * -> *) a. Monad m => a -> m a
return TextureNode
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method TextureNode::get_texture
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "node"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "TextureNode" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GskRenderNode of type %GSK_TEXTURE_NODE"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gdk" , name = "Texture" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_texture_node_get_texture" gsk_texture_node_get_texture :: 
    Ptr TextureNode ->                      -- node : TInterface (Name {namespace = "Gsk", name = "TextureNode"})
    IO (Ptr Gdk.Texture.Texture)

-- | Retrieves the t'GI.Gdk.Objects.Texture.Texture' used when creating this t'GI.Gsk.Objects.RenderNode.RenderNode'.
textureNodeGetTexture ::
    (B.CallStack.HasCallStack, MonadIO m, IsTextureNode a) =>
    a
    -- ^ /@node@/: a t'GI.Gsk.Objects.RenderNode.RenderNode' of type 'GI.Gsk.Enums.RenderNodeTypeTextureNode'
    -> m Gdk.Texture.Texture
    -- ^ __Returns:__ the t'GI.Gdk.Objects.Texture.Texture'
textureNodeGetTexture :: a -> m Texture
textureNodeGetTexture a
node = IO Texture -> m Texture
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Texture -> m Texture) -> IO Texture -> m Texture
forall a b. (a -> b) -> a -> b
$ do
    Ptr TextureNode
node' <- a -> IO (Ptr TextureNode)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
node
    Ptr Texture
result <- Ptr TextureNode -> IO (Ptr Texture)
gsk_texture_node_get_texture Ptr TextureNode
node'
    Text -> Ptr Texture -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"textureNodeGetTexture" Ptr Texture
result
    Texture
result' <- ((ManagedPtr Texture -> Texture) -> Ptr Texture -> IO Texture
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr Texture -> Texture
Gdk.Texture.Texture) Ptr Texture
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
node
    Texture -> IO Texture
forall (m :: * -> *) a. Monad m => a -> m a
return Texture
result'

#if defined(ENABLE_OVERLOADING)
data TextureNodeGetTextureMethodInfo
instance (signature ~ (m Gdk.Texture.Texture), MonadIO m, IsTextureNode a) => O.MethodInfo TextureNodeGetTextureMethodInfo a signature where
    overloadedMethod = textureNodeGetTexture

#endif