Struct gtk4::Snapshot[][src]

pub struct Snapshot(_);
Expand description

Snapshot 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 pop() to change the current node.

The typical way to obtain a Snapshot object is as an argument to the vfunc::Gtk::Widget::snapshot vfunc. If you need to create your own Snapshot, use new().

Implements

[trait@gdk::prelude::SnapshotExt], glib::ObjectExt

Implementations

Creates a new Snapshot.

Returns

a newly-allocated Snapshot

Creates a new gsk::CairoNode and appends it to the current render node of self, without changing the current node.

bounds

the bounds for the new node

Returns

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

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

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

color

the gdk::RGBA to draw

bounds

the bounds for the new node

Appends an inset shadow into the box given by outline.

outline

outline of the region surrounded by shadow

color

color of the shadow

dx

horizontal offset of shadow

dy

vertical offset of shadow

spread

how far the shadow spreads towards the inside

blur_radius

how much blur to apply to the shadow

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

outline

outline of the region surrounded by shadow

color

color of the shadow

dx

horizontal offset of shadow

dy

vertical offset of shadow

spread

how far the shadow spreads towards the outside

blur_radius

how much blur to apply to the shadow

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

texture

the gdk::Texture to render

bounds

the bounds for the new node

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

Returns

a newly-created gsk::RenderNode

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

size

The size of the resulting paintable or None to use the bounds of the snapshot

Returns

a newly-created gdk::Paintable

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

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

Applies a perspective projection transform.

See gsk::Transform::perspective()`` for a discussion on the details.

depth

distance of the z=0 plane

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

Blends together two images with the given blend mode.

Until the first call to 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 pop().

Calling this function requires two subsequent calls to pop().

blend_mode

blend mode to use

Blurs an image.

The image is recorded until the next call to pop().

radius

the blur radius to use

Clips an image to a rectangle.

The image is recorded until the next call to pop().

bounds

the rectangle to clip to

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

The image is recorded until the next call to pop().

color_matrix

the color matrix to use

color_offset

the color offset to use

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

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

Calling this function requires two subsequent calls to pop().

progress

progress between 0.0 and 1.0

Push a gsk::GLShaderNode.

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

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 Gsk::GLShader::format_args()`` or Gsk::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 GLShader::compile() to ensure the shader will work for the renderer before using it.

If the shader requires textures (see GLShader::n_textures()), then it is expected that you call 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 gsk::GLShaderNode, 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 pop().

If you want to use pre-existing textures as input to the shader rather than rendering new ones, use 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 gsk::GLShader.

shader

The code to run

bounds

the rectangle to render into

take_args

Data block with arguments for the shader.

Modifies the opacity of an image.

The image is recorded until the next call to pop().

opacity

the opacity to use

Creates a node that repeats the child node.

The child is recorded until the next call to pop().

bounds

the bounds within which to repeat

child_bounds

the bounds of the child or None to use the full size of the collected child node

Clips an image to a rounded rectangle.

The image is recorded until the next call to pop().

bounds

the rounded rectangle to clip to

Applies a shadow to an image.

The image is recorded until the next call to pop().

shadow

the first shadow specification

n_shadows

number of shadow specifications

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

context

the StyleContext to use

x

X origin of the rectangle

y

Y origin of the rectangle

width

rectangle width

height

rectangle height

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

context

the StyleContext to use

x

X origin of the rectangle

y

Y origin of the rectangle

width

rectangle width

height

rectangle height

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

context

the StyleContext to use

x

X origin of the rectangle

y

Y origin of the rectangle

width

rectangle width

height

rectangle height

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

context

a StyleContext

x

X origin

y

Y origin

layout

the pango::Layout of the text

index

the index in the pango::Layout

direction

the pango::Direction of the text

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

context

the StyleContext to use

x

X origin of the rectangle

y

Y origin of the rectangle

layout

the pango::Layout to render

Restores self to the state saved by a preceding call to save() and removes that state from the stack of saved states.

Rotates @self’s coordinate system by angle degrees in 2D space - or in 3D speak, rotates around the Z axis.

To rotate around other axes, use gsk::Transform::rotate_3d()``.

angle

the rotation angle, in degrees (clockwise)

Rotates self’s coordinate system by angle degrees around axis.

For a rotation in 2D space, use gsk::Transform::rotate()``.

angle

the rotation angle, in degrees (clockwise)

axis

The rotation axis

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

When restore() is called, self will be restored to the saved state. Multiple calls to save() and restore() can be nested; each call to restore() restores the state from the matching paired save().

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

Scales self’s coordinate system in 2-dimensional space by the given factors.

Use scale_3d() to scale in all 3 dimensions.

factor_x

scaling factor on the X axis

factor_y

scaling factor on the Y axis

Scales self’s coordinate system by the given factors.

factor_x

scaling factor on the X axis

factor_y

scaling factor on the Y axis

factor_z

scaling factor on the Z axis

Returns the render node that was constructed by self.

After calling this function, it is no longer possible to add more nodes to self. The only function that should be called after this is g_object_unref().

Returns

the constructed gsk::RenderNode

Returns a paintable encapsulating the render node that was constructed by self.

After calling this function, it is no longer possible to add more nodes to self. The only function that should be called after this is g_object_unref().

size

The size of the resulting paintable or None to use the bounds of the snapshot

Returns

a new gdk::Paintable

Transforms self’s coordinate system with the given transform.

transform

the transform to apply

Transforms self’s coordinate system with the given matrix.

matrix

the matrix to multiply the transform with

Translates self’s coordinate system by point in 2-dimensional space.

point

the point to translate the snapshot by

Translates self’s coordinate system by point.

point

the point to translate the snapshot by

Appends a stroked border rectangle inside the given outline.

The four sides of the border can have different widths and colors.

outline

a gsk::RoundedRect describing the outline of the border

border_width

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

border_color

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

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

bounds

the rectangle to render the linear gradient into

start_point

the point at which the linear gradient will begin

end_point

the point at which the linear gradient will finish

stops

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

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

bounds

the rectangle to render the readial gradient into

center

the center point for the radial gradient

hradius

the horizontal radius

vradius

the vertical radius

start

the start position (on the horizontal axis)

end

the end position (on the horizontal axis)

stops

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

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

bounds

the rectangle to render the gradient into

center

the center point of the conic gradient

rotation

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

stops

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

Appends a repeating radial gradient node with the given stops to self.

bounds

the rectangle to render the readial gradient into

center

the center point for the radial gradient

hradius

the horizontal radius

vradius

the vertical radius

start

the start position (on the horizontal axis)

end

the end position (on the horizontal axis)

stops

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

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

bounds

the rectangle to render the linear gradient into

start_point

the point at which the linear gradient will begin

end_point

the point at which the linear gradient will finish

stops

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

Inserts a debug node with a message.

Debug nodes don’t affect the rendering at all, but can be helpful in identifying parts of a render node tree dump, for example in the GTK inspector.

message

a printf-style format string

Appends node to the current render node of self, without changing the current node.

If self does not have a current node yet, node will become the initial node.

node

a gsk::RenderNode

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Returns the type identifier of Self.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Upcasts an object to a superclass or interface T. Read more

Upcasts an object to a reference of its superclass or interface T. Read more

Tries to downcast to a subclass or interface implementor T. Read more

Tries to downcast to a reference of its subclass or interface implementor T. Read more

Tries to cast to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Tries to cast to reference to an object of type T. This handles upcasting, downcasting and casting between interface and interface implementors. All checks are performed at runtime, while downcast and upcast will do many checks at compile-time already. Read more

Casts to T unconditionally. Read more

Casts to &T unconditionally. Read more

Performs the conversion.

Performs the conversion.

Returns true if the object is an instance of (can be cast to) T.

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Safety Read more

Same as connect but takes a SignalId instead of a signal name.

Same as connect_local but takes a SignalId instead of a signal name.

Same as connect_unsafe but takes a SignalId instead of a signal name.

Emit signal by signal id.

Same as emit but takes Value for the arguments.

Emit signal by its name.

Same as emit_by_name but takes Value for the arguments.

Emit signal with details by signal id.

Same as emit_with_details but takes Value for the arguments.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Returns a SendValue clone of self.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.