gi-gtk-4.0.6: Gtk bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Gtk.Objects.Snapshot

Description

GtkSnapshot assists in creating RenderNodes for widgets.

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 one that gtk_snapshot_append_…() functions operate on. Use the gtk_snapshot_push_…() functions and [methodsnapshot.pop] 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

GObject Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

ManagedPtrNewtype Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

Methods

toManagedPtr :: Snapshot -> ManagedPtr Snapshot

TypedObject Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

Methods

glibType :: IO GType

HasParentTypes Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

IsGValue (Maybe Snapshot) Source #

Convert Snapshot to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gtk.Objects.Snapshot

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Snapshot -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Snapshot)

type ParentTypes Snapshot Source # 
Instance details

Defined in GI.Gtk.Objects.Snapshot

type ParentTypes Snapshot = '[Snapshot, Object]

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.

Methods

appendBorder

snapshotAppendBorder Source #

Arguments

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

snapshot: a GtkSnapshot

-> RoundedRect

outline: 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 four 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 CairoNode 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 color 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.

appendConicGradient

snapshotAppendConicGradient Source #

Arguments

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

snapshot: a GtkSnapshot

-> Rect

bounds: the rectangle to render the gradient into

-> Point

center: the center point of the conic gradient

-> Float

rotation: the clockwise rotation in degrees of the starting angle. 0 means the starting angle is the top.

-> [ColorStop]

stops: the color stops defining the gradient

-> m () 

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

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: the color stops defining the gradient

-> m () 

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

appendNode

snapshotAppendNode Source #

Arguments

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

snapshot: a GtkSnapshot

-> b

node: a GskRenderNode

-> 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.

appendRadialGradient

snapshotAppendRadialGradient Source #

Arguments

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

snapshot: a GtkSnapshot

-> Rect

bounds: the rectangle to render the readial gradient into

-> Point

center: the center point for the radial gradient

-> Float

hradius: the horizontal radius

-> Float

vradius: the vertical radius

-> Float

start: the start position (on the horizontal axis)

-> Float

end: the end position (on the horizontal axis)

-> [ColorStop]

stops: the color stops defining the gradient

-> m () 

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

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: the color stops defining the gradient

-> m () 

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

appendRepeatingRadialGradient

snapshotAppendRepeatingRadialGradient Source #

Arguments

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

snapshot: a GtkSnapshot

-> Rect

bounds: the rectangle to render the readial gradient into

-> Point

center: the center point for the radial gradient

-> Float

hradius: the horizontal radius

-> Float

vradius: the vertical radius

-> Float

start: the start position (on the horizontal axis)

-> Float

end: the end position (on the horizontal axis)

-> [ColorStop]

stops: the color stops defining the gradient

-> m () 

Appends a repeating radial 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.

glShaderPopTexture

snapshotGlShaderPopTexture Source #

Arguments

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

snapshot: a GtkSnapshot

-> m () 

Removes the top element from the stack of render nodes and adds it to the nearest GLShaderNode below it.

This must be called the same number of times as the number of textures is needed for the shader in snapshotPushGlShader.

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 two 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 two subsequent calls to snapshotPop.

pushBlur

snapshotPushBlur Source #

Arguments

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

snapshot: a GtkSnapshot

-> Double

radius: the blur radius to use. Must be positive

-> 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 two subsequent calls to snapshotPop.

pushGlShader

snapshotPushGlShader Source #

Arguments

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

snapshot: a GtkSnapshot

-> b

shader: The code to run

-> Rect

bounds: the rectangle to render into

-> Bytes

takeArgs: Data block with arguments for the shader.

-> m () 

Push a GLShaderNode.

The node uses the given GLShader and uniform values Additionally this takes a list of nChildren other nodes which will be passed to the GLShaderNode.

The takeArgs argument is a block of data to use for uniform arguments, as per types and offsets defined by the shader. Normally this is generated by GLShader.format_args() or [structgsk.ShaderArgsBuilder].

The snapshotter takes ownership of takeArgs, so the caller should not free it after this.

If the renderer doesn't support GL shaders, or if there is any problem when compiling the shader, then the node will draw pink. You should use gLShaderCompile to ensure the shader will work for the renderer before using it.

If the shader requires textures (see gLShaderGetNTextures), then it is expected that you call snapshotGlShaderPopTexture the number of times that are required. Each of these calls will generate a node that is added as a child to the GskGLShaderNode, which in turn will render these offscreen and pass as a texture to the shader.

Once all textures (if any) are pop:ed, you must call the regular snapshotPop.

If you want to use pre-existing textures as input to the shader rather than rendering new ones, use snapshotAppendTexture to push a texture node. These will be used directly rather than being re-rendered.

For details on how to write shaders, see GLShader.

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

-> Maybe Rect

childBounds: the bounds of the child or Nothing to use the full size of the collected child node

-> 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

-> 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 style context that defines the background

-> 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 style context that defines the focus ring

-> 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 style context that defines the frame

-> 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 GtkStyleContext

-> Double

x: X origin

-> Double

y: Y origin

-> c

layout: the PangoLayout of the text

-> Int32

index: the index in the PangoLayout

-> Direction

direction: the PangoDirection 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 style context that defines the text

-> Double

x: X origin of the rectangle

-> Double

y: Y origin of the rectangle

-> c

layout: the PangoLayout 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 [methodsnapshot.save] 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.

To rotate around other axes, use transformRotate3d.

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.

When snapshotRestore is called, snapshot will be restored to the saved state. Multiple calls to [methodsnapshot.save] and Snapshot.restore can be nested; each call to gtk_snapshot_restore() restores the state from the matching paired gtk_snapshot_save().

It is necessary to clear all saved states with corresponding calls to gtk_snapshot_restore().

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 (Maybe RenderNode)

Returns: the constructed GskRenderNode

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 objectUnref.

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 (Maybe Paintable)

Returns: a new GdkPaintable

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 objectUnref.

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.