{-# 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.ClipNode
    ( 

-- * Exported types
    ClipNode(..)                            ,
    IsClipNode                              ,
    toClipNode                              ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveClipNodeMethod                   ,
#endif


-- ** getChild #method:getChild#

#if defined(ENABLE_OVERLOADING)
    ClipNodeGetChildMethodInfo              ,
#endif
    clipNodeGetChild                        ,


-- ** new #method:new#

    clipNodeNew                             ,


-- ** peekClip #method:peekClip#

#if defined(ENABLE_OVERLOADING)
    ClipNodePeekClipMethodInfo              ,
#endif
    clipNodePeekClip                        ,




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

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

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

foreign import ccall "gsk_clip_node_get_type"
    c_gsk_clip_node_get_type :: IO B.Types.GType

instance B.Types.TypedObject ClipNode where
    glibType :: IO GType
glibType = IO GType
c_gsk_clip_node_get_type

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

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

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

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

instance (info ~ ResolveClipNodeMethod t ClipNode, O.MethodInfo info ClipNode p) => OL.IsLabel t (ClipNode -> 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 ClipNode where
    boxedPtrCopy :: ClipNode -> IO ClipNode
boxedPtrCopy = ClipNode -> IO ClipNode
forall (m :: * -> *) a. Monad m => a -> m a
return
    boxedPtrFree :: ClipNode -> IO ()
boxedPtrFree = \ClipNode
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- method ClipNode::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "child"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "RenderNode" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The node to draw" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "clip"
--           , argType =
--               TInterface Name { namespace = "Graphene" , name = "Rect" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "The clip to apply" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gsk" , name = "ClipNode" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_clip_node_new" gsk_clip_node_new :: 
    Ptr Gsk.RenderNode.RenderNode ->        -- child : TInterface (Name {namespace = "Gsk", name = "RenderNode"})
    Ptr Graphene.Rect.Rect ->               -- clip : TInterface (Name {namespace = "Graphene", name = "Rect"})
    IO (Ptr ClipNode)

-- | Creates a t'GI.Gsk.Objects.RenderNode.RenderNode' that will clip the /@child@/ to the area
-- given by /@clip@/.
clipNodeNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gsk.RenderNode.IsRenderNode a) =>
    a
    -- ^ /@child@/: The node to draw
    -> Graphene.Rect.Rect
    -- ^ /@clip@/: The clip to apply
    -> m ClipNode
    -- ^ __Returns:__ A new t'GI.Gsk.Objects.RenderNode.RenderNode'
clipNodeNew :: a -> Rect -> m ClipNode
clipNodeNew a
child Rect
clip = IO ClipNode -> m ClipNode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ClipNode -> m ClipNode) -> IO ClipNode -> m ClipNode
forall a b. (a -> b) -> a -> b
$ do
    Ptr RenderNode
child' <- a -> IO (Ptr RenderNode)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
child
    Ptr Rect
clip' <- Rect -> IO (Ptr Rect)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Rect
clip
    Ptr ClipNode
result <- Ptr RenderNode -> Ptr Rect -> IO (Ptr ClipNode)
gsk_clip_node_new Ptr RenderNode
child' Ptr Rect
clip'
    Text -> Ptr ClipNode -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"clipNodeNew" Ptr ClipNode
result
    ClipNode
result' <- ((ManagedPtr ClipNode -> ClipNode) -> Ptr ClipNode -> IO ClipNode
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr ClipNode -> ClipNode
ClipNode) Ptr ClipNode
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
child
    Rect -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Rect
clip
    ClipNode -> IO ClipNode
forall (m :: * -> *) a. Monad m => a -> m a
return ClipNode
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method ClipNode::get_child
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "node"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "ClipNode" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a clip @GskRenderNode"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Gsk" , name = "RenderNode" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_clip_node_get_child" gsk_clip_node_get_child :: 
    Ptr ClipNode ->                         -- node : TInterface (Name {namespace = "Gsk", name = "ClipNode"})
    IO (Ptr Gsk.RenderNode.RenderNode)

-- | Gets the child node that is getting clipped by the given /@node@/.
clipNodeGetChild ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipNode a) =>
    a
    -- ^ /@node@/: a clip /@gskRenderNode@/
    -> m Gsk.RenderNode.RenderNode
    -- ^ __Returns:__ The child that is getting clipped
clipNodeGetChild :: a -> m RenderNode
clipNodeGetChild a
node = IO RenderNode -> m RenderNode
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO RenderNode -> m RenderNode) -> IO RenderNode -> m RenderNode
forall a b. (a -> b) -> a -> b
$ do
    Ptr ClipNode
node' <- a -> IO (Ptr ClipNode)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
node
    Ptr RenderNode
result <- Ptr ClipNode -> IO (Ptr RenderNode)
gsk_clip_node_get_child Ptr ClipNode
node'
    Text -> Ptr RenderNode -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"clipNodeGetChild" Ptr RenderNode
result
    RenderNode
result' <- ((ManagedPtr RenderNode -> RenderNode)
-> Ptr RenderNode -> IO RenderNode
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newPtr ManagedPtr RenderNode -> RenderNode
Gsk.RenderNode.RenderNode) Ptr RenderNode
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
node
    RenderNode -> IO RenderNode
forall (m :: * -> *) a. Monad m => a -> m a
return RenderNode
result'

#if defined(ENABLE_OVERLOADING)
data ClipNodeGetChildMethodInfo
instance (signature ~ (m Gsk.RenderNode.RenderNode), MonadIO m, IsClipNode a) => O.MethodInfo ClipNodeGetChildMethodInfo a signature where
    overloadedMethod = clipNodeGetChild

#endif

-- method ClipNode::peek_clip
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "node"
--           , argType =
--               TInterface Name { namespace = "Gsk" , name = "ClipNode" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GskClipNode" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Graphene" , name = "Rect" })
-- throws : False
-- Skip return : False

foreign import ccall "gsk_clip_node_peek_clip" gsk_clip_node_peek_clip :: 
    Ptr ClipNode ->                         -- node : TInterface (Name {namespace = "Gsk", name = "ClipNode"})
    IO (Ptr Graphene.Rect.Rect)

-- | Retrieves the clip rectangle for /@node@/.
clipNodePeekClip ::
    (B.CallStack.HasCallStack, MonadIO m, IsClipNode a) =>
    a
    -- ^ /@node@/: a t'GI.Gsk.Objects.ClipNode.ClipNode'
    -> m Graphene.Rect.Rect
    -- ^ __Returns:__ a clip rectangle
clipNodePeekClip :: a -> m Rect
clipNodePeekClip a
node = IO Rect -> m Rect
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Rect -> m Rect) -> IO Rect -> m Rect
forall a b. (a -> b) -> a -> b
$ do
    Ptr ClipNode
node' <- a -> IO (Ptr ClipNode)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
node
    Ptr Rect
result <- Ptr ClipNode -> IO (Ptr Rect)
gsk_clip_node_peek_clip Ptr ClipNode
node'
    Text -> Ptr Rect -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"clipNodePeekClip" Ptr Rect
result
    Rect
result' <- ((ManagedPtr Rect -> Rect) -> Ptr Rect -> IO Rect
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Rect -> Rect
Graphene.Rect.Rect) Ptr Rect
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
node
    Rect -> IO Rect
forall (m :: * -> *) a. Monad m => a -> m a
return Rect
result'

#if defined(ENABLE_OVERLOADING)
data ClipNodePeekClipMethodInfo
instance (signature ~ (m Graphene.Rect.Rect), MonadIO m, IsClipNode a) => O.MethodInfo ClipNodePeekClipMethodInfo a signature where
    overloadedMethod = clipNodePeekClip

#endif