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.

  • ptr

    Untyped pointer to the underlying GtkSnapshot instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • snapshot_ptr Default implementation

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

Snapshot Class: SnapshotProtocol extension (methods and fields)

  • 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 of snapshot, without changing the current node.

    Declaration

    Swift

    @inlinable
    func appendCairo(bounds: UnsafePointer<graphene_rect_t>!) -> Cairo.ContextRef!
  • append(color:bounds:) Extension method

    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.

    Declaration

    Swift

    @inlinable
    func append<RGBAT>(color: RGBAT, bounds: UnsafePointer<graphene_rect_t>!) where RGBAT : RGBAProtocol
  • 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)
  • 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:color:) Extension method

    Undocumented

    Declaration

    Swift

    @inlinable
    func append<LayoutT, RGBAT>(layout: LayoutT, color: RGBAT) where LayoutT : LayoutProtocol, RGBAT : RGBAProtocol
  • 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 of snapshot, 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>!)
  • 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)
  • 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:bounds:) Extension method

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

    Declaration

    Swift

    @inlinable
    func append<TextureT>(texture: TextureT, bounds: UnsafePointer<graphene_rect_t>!) where TextureT : TextureProtocol
  • freeToNode() Extension method

    Returns the node that was constructed by snapshot and frees snapshot.

    Declaration

    Swift

    @inlinable
    func freeToNode() -> UnsafeMutablePointer<GskRenderNode>!
  • freeToPaintable(size:) Extension method

    Returns a paintable for the node that was constructed by snapshot and frees snapshot.

    Declaration

    Swift

    @inlinable
    func freeToPaintable(size: UnsafePointer<graphene_size_t>? = nil) -> Gdk.PaintableRef!
  • glShaderPopTexture() Extension method

    Removes 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 [methodGtk.Snapshot.push_gl_shader].

    Declaration

    Swift

    @inlinable
    func glShaderPopTexture()
  • perspective(depth:) Extension method

    Applies a perspective projection transform.

    See [methodGsk.Transform.perspective] for a discussion on the details.

    Declaration

    Swift

    @inlinable
    func perspective(depth: CFloat)
  • pop() Extension method

    Removes 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 [methodGtk.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 [methodGtk.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 [methodGtk.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 [methodGtk.Snapshot.pop].

    Declaration

    Swift

    @inlinable
    func pushClip(bounds: UnsafePointer<graphene_rect_t>!)
  • Modifies the colors of an image by applying an affine transformation in RGB space.

    The image is recorded until the next call to [methodGtk.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 [methodGtk.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 [methodGtk.Snapshot.pop].

    Declaration

    Swift

    @inlinable
    func pushCrossFade(progress: CDouble)
  • Push a GskGLShaderNode.

    The node uses the given [classGsk.GLShader] and uniform values Additionally this takes a list of n_children other nodes which will be passed to the GskGLShaderNode.

    The take_args 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 [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 [methodGsk.GLShader.compile] to ensure the shader will work for the renderer before using it.

    If the shader requires textures (see [methodGsk.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 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 [methodGtk.Snapshot.pop].

    If you want to use pre-existing textures as input to the shader rather than rendering new ones, use [methodGtk.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 [classGsk.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 [methodGtk.Snapshot.pop].

    Declaration

    Swift

    @inlinable
    func push(opacity: CDouble)
  • Creates a node that repeats the child node.

    The child is recorded until the next call to [methodGtk.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 [methodGtk.Snapshot.pop].

    Declaration

    Swift

    @inlinable
    func pushRoundedClip(bounds: UnsafePointer<GskRoundedRect>!)
  • push(shadow:nShadows:) Extension method

    Applies a shadow to an image.

    The image is recorded until the next call to [methodGtk.Snapshot.pop].

    Declaration

    Swift

    @inlinable
    func push(shadow: UnsafePointer<GskShadow>!, nShadows: Int)
  • 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.

    Declaration

    Swift

    @inlinable
    func renderBackground<StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, width: CDouble, height: CDouble) where StyleContextT : StyleContextProtocol
  • 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.

    Declaration

    Swift

    @inlinable
    func renderFocus<StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, width: CDouble, height: CDouble) where StyleContextT : StyleContextProtocol
  • 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.

    Declaration

    Swift

    @inlinable
    func renderFrame<StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, width: CDouble, height: CDouble) where StyleContextT : StyleContextProtocol
  • Draws a text caret using snapshot at the specified index of layout.

    Declaration

    Swift

    @inlinable
    func renderInsertionCursor<LayoutT, StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, layout: LayoutT, index: Int, direction: PangoDirection) where LayoutT : LayoutProtocol, StyleContextT : StyleContextProtocol
  • 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.

    Declaration

    Swift

    @inlinable
    func renderLayout<LayoutT, StyleContextT>(context: StyleContextT, x: CDouble, y: CDouble, layout: LayoutT) where LayoutT : LayoutProtocol, StyleContextT : StyleContextProtocol
  • restore() Extension method

    Restores snapshot to the state saved by a preceding call to gtk_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 by angle degrees in 2D space - or in 3D speak, rotates around the Z axis.

    To rotate around other axes, use [methodGsk.Transform.rotate_3d].

    Declaration

    Swift

    @inlinable
    func rotate(angle: CFloat)
  • rotate3d(angle:axis:) Extension method

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

    For a rotation in 2D space, use [methodGsk.Transform.rotate].

    Declaration

    Swift

    @inlinable
    func rotate3d(angle: CFloat, axis: UnsafePointer<graphene_vec3_t>!)
  • save() Extension method

    Makes a copy of the current state of snapshot and saves it on an internal stack.

    When [methodGtk.Snapshot.restore] is called, snapshot will be restored to the saved state. Multiple calls to gtk_snapshot_save() and gtk_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().

    Declaration

    Swift

    @inlinable
    func save()
  • scale(factorX:factorY:) Extension method

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

    Use [methodGtk.Snapshot.scale_3d] to scale in all 3 dimensions.

    Declaration

    Swift

    @inlinable
    func scale(factorX: CFloat, factorY: CFloat)
  • Scales snapshot‘s coordinate system by the given factors.

    Declaration

    Swift

    @inlinable
    func scale3d(factorX: CFloat, factorY: CFloat, factorZ: CFloat)
  • toNode() Extension method

    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 g_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 is g_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 given transform.

    Declaration

    Swift

    @inlinable
    func transform(transform: UnsafeMutablePointer<GskTransform>? = nil)
  • transform(matrix:) Extension method

    Transforms snapshot‘s coordinate system with the given matrix.

    Declaration

    Swift

    @inlinable
    func transform(matrix: UnsafePointer<graphene_matrix_t>!)
  • translate(point:) Extension method

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

    Declaration

    Swift

    @inlinable
    func translate(point: UnsafePointer<graphene_point_t>!)
  • translate3d(point:) Extension method

    Translates snapshot‘s coordinate system by point.

    Declaration

    Swift

    @inlinable
    func translate3d(point: UnsafePointer<graphene_point3d_t>!)