gi-gsk-4.0.9: Gsk bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.Gsk.Objects.RenderNode

Contents

- Exported types
- Methods
  - deserialize
  - draw
  - getBounds
  - getNodeType
  - getOpaqueRect
  - ref
  - serialize
  - unref
  - writeToFile

Description

The basic block in a scene graph to be rendered using `Renderer`.

Each node has a parent, except the top-level node; each node may have children nodes.

Each node has an associated drawing surface, which has the size of the rectangle set when creating it.

Render nodes are meant to be transient; once they have been associated to a `Renderer` it's safe to release any reference you have on them. All `RenderNode`s are immutable, you can only specify their properties during construction.

Synopsis

- newtype RenderNode = RenderNode (ManagedPtr RenderNode)
- class (BoxedPtr o, TypedObject o, IsDescendantOf RenderNode o) => IsRenderNode o
- toRenderNode :: (MonadIO m, IsRenderNode o) => o -> m RenderNode
- renderNodeDeserialize :: (HasCallStack, MonadIO m) => Bytes -> Maybe ParseErrorFunc -> m (Maybe RenderNode)
- renderNodeDraw :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> Context -> m ()
- renderNodeGetBounds :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> m Rect
- renderNodeGetNodeType :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> m RenderNodeType
- renderNodeGetOpaqueRect :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> m (Bool, Rect)
- renderNodeRef :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> m RenderNode
- renderNodeSerialize :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> m Bytes
- renderNodeUnref :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> m ()
- renderNodeWriteToFile :: (HasCallStack, MonadIO m, IsRenderNode a) => a -> [Char] -> m ()

# Exported types

newtype RenderNode Source #

Memory-managed wrapper type.

Constructors

RenderNode (ManagedPtr RenderNode) |

#### Instances

Instances details

Eq RenderNode Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode Methods (==) :: RenderNode -> RenderNode -> Bool Source # (/=) :: RenderNode -> RenderNode -> Bool Source #
BoxedPtr RenderNode Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode Methods boxedPtrCopy :: RenderNode -> IO RenderNode Source # boxedPtrFree :: RenderNode -> IO () Source #
ManagedPtrNewtype RenderNode Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode Methods toManagedPtr :: RenderNode -> ManagedPtr RenderNode Source #
TypedObject RenderNode Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode Methods glibType :: IO GType Source #
HasParentTypes RenderNode Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode
IsGValue (Maybe RenderNode) Source # | Convert `RenderNode` to and from `GValue`. See `toGValue` and `fromGValue`.
Instance details Defined in GI.Gsk.Objects.RenderNode Methods gvalueGType_ :: IO GType Source # gvalueSet_ :: Ptr GValue -> Maybe RenderNode -> IO () Source # gvalueGet_ :: Ptr GValue -> IO (Maybe RenderNode) Source #
type ParentTypes RenderNode Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode type ParentTypes RenderNode = '[] :: [Type]

class (BoxedPtr o, TypedObject o, IsDescendantOf RenderNode o) => IsRenderNode o Source #

Type class for types which can be safely cast to `RenderNode`, for instance with `toRenderNode`.

#### Instances

Instances details

(BoxedPtr o, TypedObject o, IsDescendantOf RenderNode o) => IsRenderNode o Source # |
Instance details Defined in GI.Gsk.Objects.RenderNode

toRenderNode :: (MonadIO m, IsRenderNode o) => o -> m RenderNode Source #

Cast to `RenderNode`, for types for which this is known to be safe. For general casts, use `castTo`.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

draw, ref, serialize, unref, writeToFile.

#### Getters

getBounds, getNodeType, getOpaqueRect.

#### Setters

None.

## deserialize

renderNodeDeserialize Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Bytes | `bytes`: the bytes containing the data
-> Maybe ParseErrorFunc | `errorFunc`: callback on parsing errors
-> m (Maybe RenderNode) | Returns: a new render node

Loads data previously created via `renderNodeSerialize`.

For a discussion of the supported format, see that function.

## draw

renderNodeDraw Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a render node
-> Context | `cr`: cairo context to draw to
-> m () |

Draws the contents of a render node on a cairo context.

Typically, you'll use this function to implement fallback rendering of render nodes on an intermediate Cairo context, instead of using the drawing context associated to a `Surface`'s rendering buffer.

For advanced nodes that cannot be supported using Cairo, in particular for nodes doing 3D operations, this function may fail.

## getBounds

renderNodeGetBounds Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a render node
-> m Rect |

Retrieves the boundaries of the `node`.

The node will not draw outside of its boundaries.

## getNodeType

renderNodeGetNodeType Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a render node
-> m RenderNodeType | Returns: the type of `node`

Returns the type of the render node.

## getOpaqueRect

renderNodeGetOpaqueRect Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `self`: a render node
-> m (Bool, Rect) | Returns: true if part or all of the rendernode is opaque, false if no opaque region could be found.

Gets an opaque rectangle inside the node that GTK can determine to be fully opaque.

There is no guarantee that this is indeed the largest opaque rectangle or that regions outside the rectangle are not opaque. This function is a best effort with that goal.

The rectangle will be fully contained in the bounds of the node.

Since: 4.16

## ref

renderNodeRef Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a render node
-> m RenderNode | Returns: the render node with an additional reference

Acquires a reference on the given `GskRenderNode`.

## serialize

renderNodeSerialize Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a `GskRenderNode`
-> m Bytes | Returns: a `GBytes` representing the node.

Serializes the `node` for later deserialization via `renderNodeDeserialize`. No guarantees are made about the format used other than that the same version of GTK will be able to deserialize the result of a call to `renderNodeSerialize` and `renderNodeDeserialize` will correctly reject files it cannot open that were created with previous versions of GTK.

The intended use of this functions is testing, benchmarking and debugging. The format is not meant as a permanent storage format.

## unref

renderNodeUnref Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a render node
-> m () |

Releases a reference on the given `GskRenderNode`.

If the reference was the last, the resources associated to the `node` are freed.

## writeToFile

renderNodeWriteToFile Source #

Arguments

:: (HasCallStack, MonadIO m, IsRenderNode a) |
=> a | `node`: a render node
-> [Char] | `filename`: the file to save it to
-> m () | (Can throw `GError`)

This function is equivalent to calling `renderNodeSerialize` followed by `fileSetContents`.

See those two functions for details on the arguments.

It is mostly intended for use inside a debugger to quickly dump a render node to a file for later inspection.