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 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
pub fn append_inset_shadow(
&self,
outline: &RoundedRect,
color: &RGBA,
dx: f32,
dy: f32,
spread: f32,
blur_radius: f32
)
pub fn append_inset_shadow(
&self,
outline: &RoundedRect,
color: &RGBA,
dx: f32,
dy: f32,
spread: f32,
blur_radius: f32
)
pub fn append_outset_shadow(
&self,
outline: &RoundedRect,
color: &RGBA,
dx: f32,
dy: f32,
spread: f32,
blur_radius: f32
)
pub fn append_outset_shadow(
&self,
outline: &RoundedRect,
color: &RGBA,
dx: f32,
dy: f32,
spread: f32,
blur_radius: f32
)
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
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.
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
pub fn render_background<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64
)
pub fn render_background<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64
)
pub fn render_focus<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64
)
pub fn render_focus<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64
)
pub fn render_frame<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64
)
pub fn render_frame<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
width: f64,
height: f64
)
pub fn render_insertion_cursor<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
layout: &Layout,
index: i32,
direction: Direction
)
pub fn render_insertion_cursor<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
layout: &Layout,
index: i32,
direction: Direction
)
Draws a text caret using self
at the specified index of layout
.
context
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
pub fn render_layout<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
layout: &Layout
)
pub fn render_layout<P: IsA<StyleContext>>(
&self,
context: &P,
x: f64,
y: f64,
layout: &Layout
)
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
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 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
pub fn append_border(
&self,
outline: &RoundedRect,
border_width: &[f32; 4],
border_color: &[RGBA; 4]
)
pub fn append_border(
&self,
outline: &RoundedRect,
border_width: &[f32; 4],
border_color: &[RGBA; 4]
)
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
Trait Implementations
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
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for Snapshot
impl UnwindSafe for Snapshot
Blanket Implementations
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 true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
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.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.