SnapshotProtocol
public protocol SnapshotProtocol : SnapshotProtocol
GtkSnapshot
assists in creating GskRenderNodes
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 the one that gtk_snapshot_append_…
functions operate on. Use the gtk_snapshot_push_… functions and
gtk_snapshot_pop()
to change the current node.
The typical way to obtain a GtkSnapshot
object is as an argument to
the [vfuncGtk.Widget.snapshot
] vfunc. If you need to create your own
GtkSnapshot
, use [ctorGtk.Snapshot.new
].
The SnapshotProtocol
protocol exposes the methods and properties of an underlying GtkSnapshot
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Snapshot
.
Alternatively, use SnapshotRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkSnapshot
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
snapshot_ptr
Default implementationTyped pointer to the underlying
GtkSnapshot
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkSnapshot
instance.Declaration
Swift
var snapshot_ptr: UnsafeMutablePointer<GtkSnapshot>! { get }
-
Required Initialiser for types conforming to
SnapshotProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
appendBorder(outline:
Extension methodborderWidth: borderColor: ) Appends a stroked border rectangle inside the given
outline
.The four sides of the border can have different widths and colors.
Declaration
Swift
@inlinable func appendBorder(outline: UnsafePointer<GskRoundedRect>!, borderWidth: UnsafePointer<CFloat>!, borderColor: UnsafePointer<GdkRGBA>!)
-
appendCairo(bounds:
Extension method) Creates a new
GskCairoNode
and appends it to the current render node ofsnapshot
, without changing the current node.Declaration
Swift
@inlinable func appendCairo(bounds: UnsafePointer<graphene_rect_t>!) -> Cairo.ContextRef!
-
append(color:
Extension methodbounds: ) Creates a new render node drawing the
color
into the givenbounds
and appends it to the current render node ofsnapshot
.You should try to avoid calling this function if
color
is transparent.Declaration
Swift
@inlinable func append<RGBAT>(color: RGBAT, bounds: UnsafePointer<graphene_rect_t>!) where RGBAT : RGBAProtocol
-
appendConicGradient(bounds:
Extension methodcenter: rotation: stops: nStops: ) Appends a conic gradient node with the given stops to
snapshot
.Declaration
Swift
@inlinable func appendConicGradient(bounds: UnsafePointer<graphene_rect_t>!, center: UnsafePointer<graphene_point_t>!, rotation: CFloat, stops: UnsafePointer<GskColorStop>!, nStops: Int)
-
appendInsetShadow(outline:
Extension methodcolor: dx: dy: spread: blurRadius: ) Appends an inset shadow into the box given by
outline
.Declaration
Swift
@inlinable func appendInsetShadow<RGBAT>(outline: UnsafePointer<GskRoundedRect>!, color: RGBAT, dx: CFloat, dy: CFloat, spread: CFloat, blurRadius: CFloat) where RGBAT : RGBAProtocol
-
append(layout:
Extension methodcolor: ) Undocumented
Declaration
Swift
@inlinable func append<LayoutT, RGBAT>(layout: LayoutT, color: RGBAT) where LayoutT : LayoutProtocol, RGBAT : RGBAProtocol
-
appendLinearGradient(bounds:
Extension methodstartPoint: endPoint: stops: nStops: ) Appends a linear gradient node with the given stops to
snapshot
.Declaration
Swift
@inlinable func appendLinearGradient(bounds: UnsafePointer<graphene_rect_t>!, startPoint: UnsafePointer<graphene_point_t>!, endPoint: UnsafePointer<graphene_point_t>!, stops: UnsafePointer<GskColorStop>!, nStops: Int)
-
append(node:
Extension method) Appends
node
to the current render node ofsnapshot
, without changing the current node.If
snapshot
does not have a current node yet,node
will become the initial node.Declaration
Swift
@inlinable func append(node: UnsafeMutablePointer<GskRenderNode>!)
-
appendOutsetShadow(outline:
Extension methodcolor: dx: dy: spread: blurRadius: ) Appends an outset shadow node around the box given by
outline
.Declaration
Swift
@inlinable func appendOutsetShadow<RGBAT>(outline: UnsafePointer<GskRoundedRect>!, color: RGBAT, dx: CFloat, dy: CFloat, spread: CFloat, blurRadius: CFloat) where RGBAT : RGBAProtocol
-
Appends a radial gradient node with the given stops to
snapshot
.Declaration
Swift
@inlinable func appendRadialGradient(bounds: UnsafePointer<graphene_rect_t>!, center: UnsafePointer<graphene_point_t>!, hradius: CFloat, vradius: CFloat, start: CFloat, end: CFloat, stops: UnsafePointer<GskColorStop>!, nStops: Int)
-
Appends a repeating linear gradient node with the given stops to
snapshot
.Declaration
Swift
@inlinable func appendRepeatingLinearGradient(bounds: UnsafePointer<graphene_rect_t>!, startPoint: UnsafePointer<graphene_point_t>!, endPoint: UnsafePointer<graphene_point_t>!, stops: UnsafePointer<GskColorStop>!, nStops: Int)
-
appendRepeatingRadialGradient(bounds:
Extension methodcenter: hradius: vradius: start: end: stops: nStops: ) Appends a repeating radial gradient node with the given stops to
snapshot
.Declaration
Swift
@inlinable func appendRepeatingRadialGradient(bounds: UnsafePointer<graphene_rect_t>!, center: UnsafePointer<graphene_point_t>!, hradius: CFloat, vradius: CFloat, start: CFloat, end: CFloat, stops: UnsafePointer<GskColorStop>!, nStops: Int)
-
append(texture:
Extension methodbounds: ) Creates a new render node drawing the
texture
into the givenbounds
and appends it to the current render node ofsnapshot
.Declaration
Swift
@inlinable func append<TextureT>(texture: TextureT, bounds: UnsafePointer<graphene_rect_t>!) where TextureT : TextureProtocol
-
freeToNode()
Extension methodReturns the node that was constructed by
snapshot
and freessnapshot
.Declaration
Swift
@inlinable func freeToNode() -> UnsafeMutablePointer<GskRenderNode>!
-
freeToPaintable(size:
Extension method) Returns a paintable for the node that was constructed by
snapshot
and freessnapshot
.Declaration
Swift
@inlinable func freeToPaintable(size: UnsafePointer<graphene_size_t>? = nil) -> Gdk.PaintableRef!
-
glShaderPopTexture()
Extension methodRemoves the top element from the stack of render nodes and adds it to the nearest
GskGLShaderNode
below it.This must be called the same number of times as the number of textures is needed for the shader in [method
Gtk.Snapshot.push_gl_shader
].Declaration
Swift
@inlinable func glShaderPopTexture()
-
perspective(depth:
Extension method) Applies a perspective projection transform.
See [method
Gsk.Transform.perspective
] for a discussion on the details.Declaration
Swift
@inlinable func perspective(depth: CFloat)
-
pop()
Extension methodRemoves the top element from the stack of render nodes, and appends it to the node underneath it.
Declaration
Swift
@inlinable func pop()
-
pushBlend(blendMode:
Extension method) Blends together two images with the given blend mode.
Until the first call to [method
Gtk.Snapshot.pop
], 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 [methodGtk.Snapshot.pop
].Calling this function requires two subsequent calls to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func pushBlend(blendMode: GskBlendMode)
-
pushBlur(radius:
Extension method) Blurs an image.
The image is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func pushBlur(radius: CDouble)
-
pushClip(bounds:
Extension method) Clips an image to a rectangle.
The image is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func pushClip(bounds: UnsafePointer<graphene_rect_t>!)
-
push(colorMatrix:
Extension methodcolorOffset: ) Modifies the colors of an image by applying an affine transformation in RGB space.
The image is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func push(colorMatrix: UnsafePointer<graphene_matrix_t>!, colorOffset: UnsafePointer<graphene_vec4_t>!)
-
pushCrossFade(progress:
Extension method) Snapshots a cross-fade operation between two images with the given
progress
.Until the first call to [method
Gtk.Snapshot.pop
], the start image will be snapshot. After that call, the end image will be recorded until the second call to [methodGtk.Snapshot.pop
].Calling this function requires two subsequent calls to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func pushCrossFade(progress: CDouble)
-
pushGl(shader:
Extension methodbounds: takeArgs: ) Push a
GskGLShaderNode
.The node uses the given [class
Gsk.GLShader
] and uniform values Additionally this takes a list ofn_children
other nodes which will be passed to theGskGLShaderNode
.The
take_args
argument is a block of data to use for uniform arguments, as per types and offsets defined by theshader
. Normally this is generated by [methodGsk.GLShader.format_args
] or [structGsk.ShaderArgsBuilder
].The snapshotter takes ownership of
take_args
, 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 [method
Gsk.GLShader.compile
] to ensure theshader
will work for the renderer before using it.If the shader requires textures (see [method
Gsk.GLShader.get_n_textures
]), then it is expected that you call [methodGtk.Snapshot.gl_shader_pop_texture
] the number of times that are required. Each of these calls will generate a node that is added as a child to theGskGLShaderNode
, 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 [method
Gtk.Snapshot.pop
].If you want to use pre-existing textures as input to the shader rather than rendering new ones, use [method
Gtk.Snapshot.append_texture
] to push a texture node. These will be used directly rather than being re-rendered.For details on how to write shaders, see [class
Gsk.GLShader
].Declaration
Swift
@inlinable func pushGl<BytesT>(shader: UnsafeMutablePointer<GskGLShader>!, bounds: UnsafePointer<graphene_rect_t>!, takeArgs: BytesT) where BytesT : BytesProtocol
-
push(opacity:
Extension method) Modifies the opacity of an image.
The image is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func push(opacity: CDouble)
-
pushRepeat(bounds:
Extension methodchildBounds: ) Creates a node that repeats the child node.
The child is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func pushRepeat(bounds: UnsafePointer<graphene_rect_t>!, childBounds: UnsafePointer<graphene_rect_t>? = nil)
-
pushRoundedClip(bounds:
Extension method) Clips an image to a rounded rectangle.
The image is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func pushRoundedClip(bounds: UnsafePointer<GskRoundedRect>!)
-
push(shadow:
Extension methodnShadows: ) Applies a shadow to an image.
The image is recorded until the next call to [method
Gtk.Snapshot.pop
].Declaration
Swift
@inlinable func push(shadow: UnsafePointer<GskShadow>!, nShadows: Int)
-
renderBackground(context:
Extension methodx: y: width: height: ) Creates a render node for the CSS background according to
context
, and appends it to the current node ofsnapshot
, without changing the current node.Declaration
Swift
@inlinable func renderBackground<StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, width: CDouble, height: CDouble) where StyleContextT : StyleContextProtocol
-
renderFocus(context:
Extension methodx: y: width: height: ) Creates a render node for the focus outline according to
context
, and appends it to the current node ofsnapshot
, without changing the current node.Declaration
Swift
@inlinable func renderFocus<StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, width: CDouble, height: CDouble) where StyleContextT : StyleContextProtocol
-
renderFrame(context:
Extension methodx: y: width: height: ) Creates a render node for the CSS border according to
context
, and appends it to the current node ofsnapshot
, without changing the current node.Declaration
Swift
@inlinable func renderFrame<StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, width: CDouble, height: CDouble) where StyleContextT : StyleContextProtocol
-
renderInsertionCursor(context:
Extension methodx: y: layout: index: direction: ) Draws a text caret using
snapshot
at the specified index oflayout
.Declaration
Swift
@inlinable func renderInsertionCursor<LayoutT, StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, layout: LayoutT, index: Int, direction: PangoDirection) where LayoutT : LayoutProtocol, StyleContextT : StyleContextProtocol
-
renderLayout(context:
Extension methodx: y: layout: ) Creates a render node for rendering
layout
according to the style information incontext
, and appends it to the current node ofsnapshot
, without changing the current node.Declaration
Swift
@inlinable func renderLayout<LayoutT, StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, layout: LayoutT) where LayoutT : LayoutProtocol, StyleContextT : StyleContextProtocol
-
restore()
Extension methodRestores
snapshot
to the state saved by a preceding call togtk_snapshot_save()
and removes that state from the stack of saved states.Declaration
Swift
@inlinable func restore()
-
rotate(angle:
Extension method) Rotates @
snapshot
‘s coordinate system byangle
degrees in 2D space - or in 3D speak, rotates around the Z axis.To rotate around other axes, use [method
Gsk.Transform.rotate_3d
].Declaration
Swift
@inlinable func rotate(angle: CFloat)
-
rotate3d(angle:
Extension methodaxis: ) Rotates
snapshot
‘s coordinate system byangle
degrees aroundaxis
.For a rotation in 2D space, use [method
Gsk.Transform.rotate
].Declaration
Swift
@inlinable func rotate3d(angle: CFloat, axis: UnsafePointer<graphene_vec3_t>!)
-
save()
Extension methodMakes a copy of the current state of
snapshot
and saves it on an internal stack.When [method
Gtk.Snapshot.restore
] is called,snapshot
will be restored to the saved state. Multiple calls togtk_snapshot_save()
andgtk_snapshot_restore()
can be nested; each call togtk_snapshot_restore()
restores the state from the matching pairedgtk_snapshot_save()
.It is necessary to clear all saved states with corresponding calls to
gtk_snapshot_restore()
.Declaration
Swift
@inlinable func save()
-
scale(factorX:
Extension methodfactorY: ) Scales
snapshot
‘s coordinate system in 2-dimensional space by the given factors.Use [method
Gtk.Snapshot.scale_3d
] to scale in all 3 dimensions.Declaration
Swift
@inlinable func scale(factorX: CFloat, factorY: CFloat)
-
scale3d(factorX:
Extension methodfactorY: factorZ: ) Scales
snapshot
‘s coordinate system by the given factors.Declaration
Swift
@inlinable func scale3d(factorX: CFloat, factorY: CFloat, factorZ: CFloat)
-
toNode()
Extension methodReturns 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 isg_object_unref()
.Declaration
Swift
@inlinable func toNode() -> UnsafeMutablePointer<GskRenderNode>!
-
toPaintable(size:
Extension method) 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 isg_object_unref()
.Declaration
Swift
@inlinable func toPaintable(size: UnsafePointer<graphene_size_t>? = nil) -> Gdk.PaintableRef!
-
transform(transform:
Extension method) Transforms
snapshot
‘s coordinate system with the giventransform
.Declaration
Swift
@inlinable func transform(transform: UnsafeMutablePointer<GskTransform>? = nil)
-
transform(matrix:
Extension method) Transforms
snapshot
‘s coordinate system with the givenmatrix
.Declaration
Swift
@inlinable func transform(matrix: UnsafePointer<graphene_matrix_t>!)
-
translate(point:
Extension method) Translates
snapshot
‘s coordinate system bypoint
in 2-dimensional space.Declaration
Swift
@inlinable func translate(point: UnsafePointer<graphene_point_t>!)
-
translate3d(point:
Extension method) Translates
snapshot
‘s coordinate system bypoint
.Declaration
Swift
@inlinable func translate3d(point: UnsafePointer<graphene_point3d_t>!)