gi-gtk-4.0.1: Gtk bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gtk.Objects.Snapshot

Description

GtkSnapshot is an auxiliary object that assists in creating GskRenderNodes in the Widget::snapshot vfunc. It functions in a similar way to a cairo context, and maintains a stack of render nodes and their associated transformations.

The node at the top of the stack is the the one that gtk_snapshot_append_… functions operate on. Use the gtk_snapshot_push_… functions and snapshotPop to change the current node.

The typical way to obtain a GtkSnapshot object is as an argument to the Widget::snapshot vfunc. If you need to create your own GtkSnapshot, use snapshotNew.

Synopsis

Exported types

newtype Snapshot Source #

Memory-managed wrapper type.

Constructors

Snapshot (ManagedPtr Snapshot) 

Instances

Instances details
Eq Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

IsGValue Snapshot Source #

Convert Snapshot to and from GValue with toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.Snapshot

GObject Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

Methods

gobjectType :: IO GType #

HasParentTypes Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

type ParentTypes Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

class (GObject o, IsDescendantOf Snapshot o) => IsSnapshot o Source #

Type class for types which can be safely cast to Snapshot, for instance with toSnapshot.

Instances

Instances details
(GObject o, IsDescendantOf Snapshot o) => IsSnapshot o Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

toSnapshot :: (MonadIO m, IsSnapshot o) => o -> m Snapshot Source #

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

noSnapshot :: Maybe Snapshot Source #

A convenience alias for Nothing :: Maybe Snapshot.

Methods

Overloaded methods

appendBorder

snapshotAppendBorder Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> RoundedRect

outline: a RoundedRect describing the outline of the border

-> [Float]

borderWidth: the stroke width of the border on the top, right, bottom and left side respectively.

-> [RGBA]

borderColor: the color used on the top, right, bottom and left side.

-> m () 

Appends a stroked border rectangle inside the given outline. The 4 sides of the border can have different widths and colors.

appendCairo

snapshotAppendCairo Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Rect

bounds: the bounds for the new node

-> m Context

Returns: a cairo_t suitable for drawing the contents of the newly created render node

Creates a new render node and appends it to the current render node of snapshot, without changing the current node.

appendColor

snapshotAppendColor Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> RGBA

color: the RGBA to draw

-> Rect

bounds: the bounds for the new node

-> m () 

Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot.

You should try to avoid calling this function if color is transparent.

appendInsetShadow

snapshotAppendInsetShadow Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> RoundedRect

outline: outline of the region surrounded by shadow

-> RGBA

color: color of the shadow

-> Float

dx: horizontal offset of shadow

-> Float

dy: vertical offset of shadow

-> Float

spread: how far the shadow spreads towards the inside

-> Float

blurRadius: how much blur to apply to the shadow

-> m () 

Appends an inset shadow into the box given by outline.

appendLayout

snapshotAppendLayout :: (HasCallStack, MonadIO m, IsSnapshot a, IsLayout b) => a -> b -> RGBA -> m () Source #

No description available in the introspection data.

appendLinearGradient

snapshotAppendLinearGradient Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Rect

bounds: the rectangle to render the linear gradient into

-> Point

startPoint: the point at which the linear gradient will begin

-> Point

endPoint: the point at which the linear gradient will finish

-> [ColorStop]

stops: a pointer to an array of ColorStop defining the gradient

-> m () 

Appends a linear gradient node with the given stops to snapshot.

appendNode

snapshotAppendNode Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> RenderNode

node: a RenderNode

-> m () 

Appends node to the current render node of snapshot, without changing the current node. If snapshot does not have a current node yet, node will become the initial node.

appendOutsetShadow

snapshotAppendOutsetShadow Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> RoundedRect

outline: outline of the region surrounded by shadow

-> RGBA

color: color of the shadow

-> Float

dx: horizontal offset of shadow

-> Float

dy: vertical offset of shadow

-> Float

spread: how far the shadow spreads towards the outside

-> Float

blurRadius: how much blur to apply to the shadow

-> m () 

Appends an outset shadow node around the box given by outline.

appendRepeatingLinearGradient

snapshotAppendRepeatingLinearGradient Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Rect

bounds: the rectangle to render the linear gradient into

-> Point

startPoint: the point at which the linear gradient will begin

-> Point

endPoint: the point at which the linear gradient will finish

-> [ColorStop]

stops: a pointer to an array of ColorStop defining the gradient

-> m () 

Appends a repeating linear gradient node with the given stops to snapshot.

appendTexture

snapshotAppendTexture Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a, IsTexture b) 
=> a

snapshot: a GtkSnapshot

-> b

texture: the Texture to render

-> Rect

bounds: the bounds for the new node

-> m () 

Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot.

new

snapshotNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Snapshot

Returns: a newly-allocated GtkSnapshot

Creates a new GtkSnapshot.

perspective

snapshotPerspective Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Float

depth: distance of the z=0 plane

-> m () 

Applies a perspective projection transform.

See transformPerspective for a discussion on the details.

pop

snapshotPop Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> m () 

Removes the top element from the stack of render nodes, and appends it to the node underneath it.

pushBlend

snapshotPushBlend Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> BlendMode

blendMode: blend mode to use

-> m () 

Blends together 2 images with the given blend mode.

Until the first call to snapshotPop, the bottom image for the blend operation will be recorded. After that call, the top image to be blended will be recorded until the second call to snapshotPop.

Calling this function requires 2 subsequent calls to snapshotPop.

pushBlur

snapshotPushBlur Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Double

radius: the blur radius to use

-> m () 

Blurs an image.

The image is recorded until the next call to snapshotPop.

pushClip

snapshotPushClip Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Rect

bounds: the rectangle to clip to

-> m () 

Clips an image to a rectangle.

The image is recorded until the next call to snapshotPop.

pushColorMatrix

snapshotPushColorMatrix Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Matrix

colorMatrix: the color matrix to use

-> Vec4

colorOffset: the color offset to use

-> m () 

Modifies the colors of an image by applying an affine transformation in RGB space.

The image is recorded until the next call to snapshotPop.

pushCrossFade

snapshotPushCrossFade Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Double

progress: progress between 0.0 and 1.0

-> m () 

Snapshots a cross-fade operation between two images with the given progress.

Until the first call to snapshotPop, the start image will be snapshot. After that call, the end image will be recorded until the second call to snapshotPop.

Calling this function requires 2 calls to snapshotPop.

pushOpacity

snapshotPushOpacity Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Double

opacity: the opacity to use

-> m () 

Modifies the opacity of an image.

The image is recorded until the next call to snapshotPop.

pushRepeat

snapshotPushRepeat Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Rect

bounds: the bounds within which to repeat

-> Rect

childBounds: the bounds of the child

-> m () 

Creates a node that repeats the child node.

The child is recorded until the next call to snapshotPop.

pushRoundedClip

snapshotPushRoundedClip Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> RoundedRect

bounds: the rounded rectangle to clip to

-> m () 

Clips an image to a rounded rectangle.

The image is recorded until the next call to snapshotPop.

pushShadow

snapshotPushShadow Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Shadow

shadow: the first shadow specification

-> Word64

nShadows: number of shadow specifications

-> m () 

Applies a shadow to an image.

The image is recorded until the next call to snapshotPop.

renderBackground

snapshotRenderBackground Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) 
=> a

snapshot: a GtkSnapshot

-> b

context: the StyleContext to use

-> Double

x: X origin of the rectangle

-> Double

y: Y origin of the rectangle

-> Double

width: rectangle width

-> Double

height: rectangle height

-> m () 

Creates a render node for the CSS background according to context, and appends it to the current node of snapshot, without changing the current node.

renderFocus

snapshotRenderFocus Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) 
=> a

snapshot: a GtkSnapshot

-> b

context: the StyleContext to use

-> Double

x: X origin of the rectangle

-> Double

y: Y origin of the rectangle

-> Double

width: rectangle width

-> Double

height: rectangle height

-> m () 

Creates a render node for the focus outline according to context, and appends it to the current node of snapshot, without changing the current node.

renderFrame

snapshotRenderFrame Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b) 
=> a

snapshot: a GtkSnapshot

-> b

context: the StyleContext to use

-> Double

x: X origin of the rectangle

-> Double

y: Y origin of the rectangle

-> Double

width: rectangle width

-> Double

height: rectangle height

-> m () 

Creates a render node for the CSS border according to context, and appends it to the current node of snapshot, without changing the current node.

renderInsertionCursor

snapshotRenderInsertionCursor Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b, IsLayout c) 
=> a

snapshot: snapshot to render to

-> b

context: a StyleContext

-> Double

x: X origin

-> Double

y: Y origin

-> c

layout: the Layout of the text

-> Int32

index: the index in the Layout

-> Direction

direction: the Direction of the text

-> m () 

Draws a text caret using snapshot at the specified index of layout.

renderLayout

snapshotRenderLayout Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a, IsStyleContext b, IsLayout c) 
=> a

snapshot: a GtkSnapshot

-> b

context: the StyleContext to use

-> Double

x: X origin of the rectangle

-> Double

y: Y origin of the rectangle

-> c

layout: the Layout to render

-> m () 

Creates a render node for rendering layout according to the style information in context, and appends it to the current node of snapshot, without changing the current node.

restore

snapshotRestore Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> m () 

Restores snapshot to the state saved by a preceding call to snapshotSave and removes that state from the stack of saved states.

rotate

snapshotRotate Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Float

angle: the rotation angle, in degrees (clockwise)

-> m () 

Rotates @snapshot's coordinate system by angle degrees in 2D space - or in 3D speak, rotates around the z axis.

rotate3d

snapshotRotate3d Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Float

angle: the rotation angle, in degrees (clockwise)

-> Vec3

axis: The rotation axis

-> m () 

Rotates snapshot's coordinate system by angle degrees around axis.

For a rotation in 2D space, use transformRotate.

save

snapshotSave Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> m () 

Makes a copy of the current state of snapshot and saves it on an internal stack of saved states for snapshot. When snapshotRestore is called, snapshot will be restored to the saved state. Multiple calls to snapshotSave and snapshotRestore can be nested; each call to snapshotRestore restores the state from the matching paired snapshotSave.

It is necessary to clear all saved states with corresponding calls to snapshotRestore.

scale

snapshotScale Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Float

factorX: scaling factor on the X axis

-> Float

factorY: scaling factor on the Y axis

-> m () 

Scales snapshot's coordinate system in 2-dimensional space by the given factors.

Use snapshotScale3d to scale in all 3 dimensions.

scale3d

snapshotScale3d Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Float

factorX: scaling factor on the X axis

-> Float

factorY: scaling factor on the Y axis

-> Float

factorZ: scaling factor on the Z axis

-> m () 

Scales snapshot's coordinate system by the given factors.

toNode

snapshotToNode Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> m RenderNode

Returns: the constructed RenderNode

Returns the render node that was constructed by snapshot. After calling this function, it is no longer possible to add more nodes to snapshot. The only function that should be called after this is gtk_snapshot_unref().

toPaintable

snapshotToPaintable Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Maybe Size

size: The size of the resulting paintable or Nothing to use the bounds of the snapshot

-> m Paintable

Returns: a new Paintable

Returns a paintable encapsulating the render node that was constructed by snapshot. After calling this function, it is no longer possible to add more nodes to snapshot. The only function that should be called after this is gtk_snapshot_unref().

transform

snapshotTransform Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Maybe Transform

transform: the transform to apply

-> m () 

Transforms snapshot's coordinate system with the given transform.

transformMatrix

snapshotTransformMatrix Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Matrix

matrix: the matrix to multiply the transform with

-> m () 

Transforms snapshot's coordinate system with the given matrix.

translate

snapshotTranslate Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Point

point: the point to translate the snapshot by

-> m () 

Translates snapshot's coordinate system by point in 2-dimensional space.

translate3d

snapshotTranslate3d Source #

Arguments

:: (HasCallStack, MonadIO m, IsSnapshot a) 
=> a

snapshot: a GtkSnapshot

-> Point3D

point: the point to translate the snapshot by

-> m () 

Translates snapshot's coordinate system by point.