#[repr(transparent)]
pub struct Snapshot { /* private fields */ }
Expand description

Snapshot assists in creating gsk::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 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::Context 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 color to draw

bounds

the bounds for the new node

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

the color stops defining the gradient

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

the color stops defining the gradient

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

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

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

the color stops 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

the color stops 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

the color stops defining the gradient

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

texture

the texture to render

bounds

the bounds for the new node

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. Must be positive

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

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

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

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

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

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

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

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.

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

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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

Returns the type of the object.

Returns the ObjectClass of the object. Read more

Returns the class of the object.

Returns the class of the object in the given type T. Read more

Returns the interface T of the object. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_property but fails instead of panicking.

Sets the property property_name of the object to value value. Read more

Similar to Self::set_properties but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::set_properties_from_value but fails instead of panicking.

Sets multiple properties of the object at once. Read more

Similar to Self::property but fails instead of panicking.

Gets the property property_name of the object and cast it to the type V. Read more

Similar to Self::property_value but fails instead of panicking.

Gets the property property_name of the object. Read more

Check if the object has a property property_name of the given type_. Read more

Get the type of the property property_name of this object. Read more

Get the ParamSpec of the property property_name of this object.

Return all ParamSpec of the properties of this object.

Freeze all property notifications until the return guard object is dropped. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Set arbitrary data on this object with the given key. Read more

Return previously set arbitrary data of this object with the given key. Read more

Retrieve previously set arbitrary data of this object with the given key. Read more

Block a given signal handler. Read more

Unblock a given signal handler.

Stop emission of the currently emitted signal.

Stop emission of the currently emitted signal by the (possibly detailed) signal name.

Similar to Self::connect but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_local but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_local_id but fails instead of panicking.

Connect to the signal signal_id on this object. Read more

Similar to Self::connect_unsafe but fails instead of panicking.

Connect to the signal signal_name on this object. Read more

Similar to Self::connect_unsafe_id but fails instead of panicking.

Similar to Self::connect_closure but fails instead of panicking.

Connect a closure to the signal signal_name on this object. Read more

Similar to Self::connect_closure_id but fails instead of panicking.

Connect a closure to the signal signal_id on this object. Read more

Limits the lifetime of closure to the lifetime of the object. When the object’s reference count drops to zero, the closure will be invalidated. An invalidated closure will ignore any calls to invoke_with_values, or invoke when using Rust closures. Read more

Connect to the signal signal_id on this object. Read more

Similar to Self::emit but fails instead of panicking.

Emit signal by signal id. Read more

Similar to Self::emit_with_values but fails instead of panicking.

Same as Self::emit but takes Value for the arguments.

Similar to Self::emit_by_name but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_values but fails instead of panicking.

Emit signal by its name. Read more

Similar to Self::emit_by_name_with_details but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_by_name_with_details_and_values but fails instead of panicking.

Emit signal by its name with details. Read more

Similar to Self::emit_with_details but fails instead of panicking.

Emit signal by signal id with details. Read more

Similar to Self::emit_with_details_and_values but fails instead of panicking.

Emit signal by signal id with details. Read more

Disconnect a previously connected signal handler.

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Connect to the notify signal of the object. Read more

Notify that the given property has changed its value. Read more

Notify that the given property has changed its value. Read more

Downgrade this object to a weak reference.

Add a callback to be notified when the Object is disposed.

Add a callback to be notified when the Object is disposed. Read more

Bind property source_property on this object to the target_property on the target object. Read more

Returns the strong reference count of this object.

Ensures that the type has been registered with the type system.

The resulting type after obtaining ownership.

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

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

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.