gtkmm 4.14.0
Public Member Functions | Static Public Member Functions | Related Functions | List of all members
Gtk::Snapshot Class Reference

Auxiliary object for snapshots. More...

#include <gtkmm/snapshot.h>

Inheritance diagram for Gtk::Snapshot:
Inheritance graph
[legend]

Public Member Functions

 Snapshot (Snapshot && src) noexcept
 
Snapshotoperator= (Snapshot && src) noexcept
 
 ~Snapshot () noexcept override
 
GtkSnapshot * gobj ()
 Provides access to the underlying C GObject. More...
 
const GtkSnapshot * gobj () const
 Provides access to the underlying C GObject. More...
 
GtkSnapshot * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 
Glib::RefPtr< Gdk::Paintableto_paintable (const Gdk::Graphene::Size &size)
 Returns a paintable encapsulating the render node that was constructed by snapshot. More...
 
Glib::RefPtr< Gdk::Paintableto_paintable ()
 A to_paintable() convenience overload. More...
 
void push_debug (const Glib::ustring & name)
 Creates a new debug node. More...
 
void push_opacity (double opacity)
 Modifies the opacity of an image. More...
 
void push_blur (double radius)
 Blurs an image. More...
 
void push_repeat (const graphene_rect_t * bounds, const graphene_rect_t * child_bounds)
 Creates a node that repeats the child node. More...
 
void push_repeat (const Gdk::Rectangle & bounds, const Gdk::Rectangle & child_bounds)
 Creates a node that repeats the child node. More...
 
void push_repeat (const Gdk::Rectangle & bounds)
 A push_repeat() convenience overload. More...
 
void push_repeat (const Gdk::Graphene::Rect & bounds, const Gdk::Graphene::Rect & child_bounds)
 Creates a node that repeats the child node. More...
 
void push_repeat (const Gdk::Graphene::Rect & bounds)
 A push_repeat() convenience overload. More...
 
void push_clip (const graphene_rect_t * bounds)
 Clips an image to a rectangle. More...
 
void push_clip (const Gdk::Rectangle & bounds)
 Clips an image to a rectangle. More...
 
void push_clip (const Gdk::Graphene::Rect & bounds)
 Clips an image to a rectangle. More...
 
void push_cross_fade (double progress)
 Snapshots a cross-fade operation between two images with the given progress. More...
 
void gl_shader_pop_texture ()
 Removes the top element from the stack of render nodes and adds it to the nearest Gsk::GLShaderNode below it. More...
 
void pop ()
 Removes the top element from the stack of render nodes, and appends it to the node underneath it. More...
 
void save ()
 Makes a copy of the current state of snapshot and saves it on an internal stack. More...
 
void restore ()
 Restores snapshot to the state saved by a preceding call to save() and removes that state from the stack of saved states. More...
 
void translate (const Gdk::Graphene::Point & point)
 Translates snapshot's coordinate system by point in 2-dimensional space. More...
 
void rotate (float angle)
 Rotates @ snapshot's coordinate system by angle degrees in 2D space - or in 3D speak, rotates around the Z axis. More...
 
void scale (float factor_x, float factor_y)
 Scales snapshot's coordinate system in 2-dimensional space by the given factors. More...
 
void scale (float factor_x, float factor_y, float factor_z)
 Scales snapshot's coordinate system by the given factors. More...
 
void perspective (float depth)
 Applies a perspective projection transform. More...
 
Cairo::RefPtr< Cairo::Context > append_cairo (const graphene_rect_t * bounds)
 Creates a new Gsk::CairoNode and appends it to the current render node of snapshot, without changing the current node. More...
 
Cairo::RefPtr< Cairo::Context > append_cairo (const Gdk::Rectangle & bounds)
 Creates a new Gsk::CairoNode and appends it to the current render node of snapshot, without changing the current node. More...
 
Cairo::RefPtr< Cairo::Context > append_cairo (const Gdk::Graphene::Rect & bounds)
 Creates a new Gsk::CairoNode and appends it to the current render node of snapshot, without changing the current node. More...
 
void append_texture (const Glib::RefPtr< Gdk::Texture > & texture, const graphene_rect_t * bounds)
 Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot. More...
 
void append_texture (const Glib::RefPtr< Gdk::Texture > & texture, const Gdk::Rectangle & bounds)
 Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot. More...
 
void append_texture (const Glib::RefPtr< Gdk::Texture > & texture, const Gdk::Graphene::Rect & bounds)
 Creates a new render node drawing the texture into the given bounds and appends it to the current render node of snapshot. More...
 
void append_color (const Gdk::RGBA & color, const graphene_rect_t * bounds)
 Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot. More...
 
void append_color (const Gdk::RGBA & color, const Gdk::Rectangle & bounds)
 Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot. More...
 
void append_color (const Gdk::RGBA & color, const Gdk::Graphene::Rect & bounds)
 Creates a new render node drawing the color into the given bounds and appends it to the current render node of snapshot. More...
 
void append_layout (const Glib::RefPtr< Pango::Layout > & layout, const Gdk::RGBA & color)
 Creates render nodes for rendering layout in the given foregound color and appends them to the current node of snapshot without changing the current node. More...
 
void render_backgrount (const Glib::RefPtr< StyleContext > & context, double x, double y, double width, double height)
 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. More...
 
void render_frame (const Glib::RefPtr< StyleContext > & context, double x, double y, double width, double height)
 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. More...
 
void render_focus (const Glib::RefPtr< StyleContext > & context, double x, double y, double width, double height)
 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. More...
 
void render_layout (const Glib::RefPtr< StyleContext > & context, double x, double y, const Glib::RefPtr< Pango::Layout > & layout)
 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. More...
 
void render_insertion_cursor (const Glib::RefPtr< StyleContext > & context, double x, double y, const Glib::RefPtr< Pango::Layout > & layout, int index, Pango::Direction direction)
 Draws a text caret using snapshot at the specified index of layout. More...
 
- Public Member Functions inherited from Gdk::Snapshot
 Snapshot (Snapshot && src) noexcept
 
Snapshotoperator= (Snapshot && src) noexcept
 
 ~Snapshot () noexcept override
 
GdkSnapshot * gobj ()
 Provides access to the underlying C GObject. More...
 
const GdkSnapshot * gobj () const
 Provides access to the underlying C GObject. More...
 
GdkSnapshot * gobj_copy ()
 Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 
static Glib::RefPtr< Snapshotcreate ()
 Creates a new Gtk::Snapshot. More...
 
- Static Public Member Functions inherited from Gdk::Snapshot
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gtk::Snapshotwrap_gtk_snapshot (GtkSnapshot * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Auxiliary object for snapshots.

Snapshot is an auxiliary object that assists in creating GskRenderNodes in Gtk::Widget::snapshot_vfunc(). 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 append_node() operates on. Use the push() and pop() functions to change the current node.

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

Since gtkmm 3.90:

Constructor & Destructor Documentation

◆ Snapshot()

Gtk::Snapshot::Snapshot ( Snapshot &&  src)
noexcept

◆ ~Snapshot()

Gtk::Snapshot::~Snapshot ( )
overridenoexcept

Member Function Documentation

◆ append_cairo() [1/3]

Cairo::RefPtr< Cairo::Context > Gtk::Snapshot::append_cairo ( const Gdk::Graphene::Rect bounds)

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

Since gtkmm 4.12:
Parameters
boundsThe bounds for the new node.
Returns
A cairo_t suitable for drawing the contents of the newly created render node.

◆ append_cairo() [2/3]

Cairo::RefPtr< Cairo::Context > Gtk::Snapshot::append_cairo ( const Gdk::Rectangle bounds)

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

Deprecated:
Use append_cairo() with Gdk::Graphene::Rect instead.
Parameters
boundsThe bounds for the new node.
Returns
A cairo_t suitable for drawing the contents of the newly created render node.

◆ append_cairo() [3/3]

Cairo::RefPtr< Cairo::Context > Gtk::Snapshot::append_cairo ( const graphene_rect_t *  bounds)

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

Deprecated:
Use append_cairo() with Gdk::Graphene::Rect instead.
Parameters
boundsThe bounds for the new node.
Returns
A cairo_t suitable for drawing the contents of the newly created render node.

◆ append_color() [1/3]

void Gtk::Snapshot::append_color ( const Gdk::RGBA color,
const Gdk::Graphene::Rect bounds 
)

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.

Since gtkmm 4.12:
Parameters
colorThe color to draw.
boundsThe bounds for the new node.

◆ append_color() [2/3]

void Gtk::Snapshot::append_color ( const Gdk::RGBA color,
const Gdk::Rectangle bounds 
)

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.

Deprecated:
Use append_color() with Gdk::Graphene::Rect instead.
Parameters
colorThe color to draw.
boundsThe bounds for the new node.

◆ append_color() [3/3]

void Gtk::Snapshot::append_color ( const Gdk::RGBA color,
const graphene_rect_t *  bounds 
)

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.

Deprecated:
Use append_color() with Gdk::Graphene::Rect instead.
Parameters
colorThe color to draw.
boundsThe bounds for the new node.

◆ append_layout()

void Gtk::Snapshot::append_layout ( const Glib::RefPtr< Pango::Layout > &  layout,
const Gdk::RGBA color 
)

Creates render nodes for rendering layout in the given foregound color and appends them to the current node of snapshot without changing the current node.

The current theme's foreground color for a widget can be obtained with Gtk::Widget::get_color().

Note that if the layout does not produce any visible output, then nodes may not be added to the snapshot.

Parameters
layoutThe Pango::Layout to render.
colorThe foreground color to render the layout in.

◆ append_texture() [1/3]

void Gtk::Snapshot::append_texture ( const Glib::RefPtr< Gdk::Texture > &  texture,
const Gdk::Graphene::Rect bounds 
)

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

If the texture needs to be scaled to fill bounds, linear filtering is used. See append_scaled_texture() if you need other filtering, such as nearest-neighbour.

Since gtkmm 4.12:
Parameters
textureThe texture to render.
boundsThe bounds for the new node.

◆ append_texture() [2/3]

void Gtk::Snapshot::append_texture ( const Glib::RefPtr< Gdk::Texture > &  texture,
const Gdk::Rectangle bounds 
)

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

If the texture needs to be scaled to fill bounds, linear filtering is used. See append_scaled_texture() if you need other filtering, such as nearest-neighbour.

Deprecated:
Use append_texture() with Gdk::Graphene::Rect instead.
Parameters
textureThe texture to render.
boundsThe bounds for the new node.

◆ append_texture() [3/3]

void Gtk::Snapshot::append_texture ( const Glib::RefPtr< Gdk::Texture > &  texture,
const graphene_rect_t *  bounds 
)

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

If the texture needs to be scaled to fill bounds, linear filtering is used. See append_scaled_texture() if you need other filtering, such as nearest-neighbour.

Deprecated:
Use append_texture() with Gdk::Graphene::Rect instead.
Parameters
textureThe texture to render.
boundsThe bounds for the new node.

◆ create()

static Glib::RefPtr< Snapshot > Gtk::Snapshot::create ( )
static

Creates a new Gtk::Snapshot.

Returns
A newly-allocated Gtk::Snapshot.

◆ get_type()

static GType Gtk::Snapshot::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gl_shader_pop_texture()

void Gtk::Snapshot::gl_shader_pop_texture ( )

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

◆ gobj() [1/2]

GtkSnapshot * Gtk::Snapshot::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GtkSnapshot * Gtk::Snapshot::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

GtkSnapshot * Gtk::Snapshot::gobj_copy ( )

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

◆ operator=()

Snapshot & Gtk::Snapshot::operator= ( Snapshot &&  src)
noexcept

◆ perspective()

void Gtk::Snapshot::perspective ( float  depth)

Applies a perspective projection transform.

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

Parameters
depthDistance of the z=0 plane.

◆ pop()

void Gtk::Snapshot::pop ( )

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

◆ push_blur()

void Gtk::Snapshot::push_blur ( double  radius)

Blurs an image.

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

Parameters
radiusThe blur radius to use. Must be positive.

◆ push_clip() [1/3]

void Gtk::Snapshot::push_clip ( const Gdk::Graphene::Rect bounds)

Clips an image to a rectangle.

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

Since gtkmm 4.12:
Parameters
boundsThe rectangle to clip to.

◆ push_clip() [2/3]

void Gtk::Snapshot::push_clip ( const Gdk::Rectangle bounds)

Clips an image to a rectangle.

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

Deprecated:
Use push_clip() with Gdk::Graphene::Rect instead.
Parameters
boundsThe rectangle to clip to.

◆ push_clip() [3/3]

void Gtk::Snapshot::push_clip ( const graphene_rect_t *  bounds)

Clips an image to a rectangle.

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

Deprecated:
Use push_clip() with Gdk::Graphene::Rect instead.
Parameters
boundsThe rectangle to clip to.

◆ push_cross_fade()

void Gtk::Snapshot::push_cross_fade ( double  progress)

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

Parameters
progressProgress between 0.0 and 1.0.

◆ push_debug()

void Gtk::Snapshot::push_debug ( const Glib::ustring &  name)

Creates a new debug node.

Since gtkmm 3.94:
Parameters
nameThe name for the new node, or an empty string for no name.

◆ push_opacity()

void Gtk::Snapshot::push_opacity ( double  opacity)

Modifies the opacity of an image.

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

Parameters
opacityThe opacity to use.

◆ push_repeat() [1/5]

void Gtk::Snapshot::push_repeat ( const Gdk::Graphene::Rect bounds)

A push_repeat() convenience overload.

◆ push_repeat() [2/5]

void Gtk::Snapshot::push_repeat ( const Gdk::Graphene::Rect bounds,
const Gdk::Graphene::Rect child_bounds 
)

Creates a node that repeats the child node.

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

Since gtkmm 4.12:
Parameters
boundsThe bounds within which to repeat.
child_boundsThe bounds of the child or nullptr to use the full size of the collected child node.

◆ push_repeat() [3/5]

void Gtk::Snapshot::push_repeat ( const Gdk::Rectangle bounds)

A push_repeat() convenience overload.

◆ push_repeat() [4/5]

void Gtk::Snapshot::push_repeat ( const Gdk::Rectangle bounds,
const Gdk::Rectangle child_bounds 
)

Creates a node that repeats the child node.

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

Deprecated:
Use push_repeat() with Gdk::Graphene::Rect instead.
Parameters
boundsThe bounds within which to repeat.
child_boundsThe bounds of the child or nullptr to use the full size of the collected child node.

◆ push_repeat() [5/5]

void Gtk::Snapshot::push_repeat ( const graphene_rect_t *  bounds,
const graphene_rect_t *  child_bounds 
)

Creates a node that repeats the child node.

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

Deprecated:
Use push_repeat() with Gdk::Graphene::Rect instead.
Parameters
boundsThe bounds within which to repeat.
child_boundsThe bounds of the child or nullptr to use the full size of the collected child node.

◆ render_backgrount()

void Gtk::Snapshot::render_backgrount ( const Glib::RefPtr< StyleContext > &  context,
double  x,
double  y,
double  width,
double  height 
)

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.

Deprecated: 4.10

Deprecated:
There is no replacement for querying the style machinery. Stylable UI elements should use widgets.
Parameters
contextThe style context that defines the background.
xX origin of the rectangle.
yY origin of the rectangle.
widthRectangle width.
heightRectangle height.

◆ render_focus()

void Gtk::Snapshot::render_focus ( const Glib::RefPtr< StyleContext > &  context,
double  x,
double  y,
double  width,
double  height 
)

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.

Deprecated: 4.10

Deprecated:
There is no replacement for querying the style machinery. Stylable UI elements should use widgets.
Parameters
contextThe style context that defines the focus ring.
xX origin of the rectangle.
yY origin of the rectangle.
widthRectangle width.
heightRectangle height.

◆ render_frame()

void Gtk::Snapshot::render_frame ( const Glib::RefPtr< StyleContext > &  context,
double  x,
double  y,
double  width,
double  height 
)

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.

Deprecated: 4.10

Deprecated:
There is no replacement for querying the style machinery. Stylable UI elements should use widgets.
Parameters
contextThe style context that defines the frame.
xX origin of the rectangle.
yY origin of the rectangle.
widthRectangle width.
heightRectangle height.

◆ render_insertion_cursor()

void Gtk::Snapshot::render_insertion_cursor ( const Glib::RefPtr< StyleContext > &  context,
double  x,
double  y,
const Glib::RefPtr< Pango::Layout > &  layout,
int  index,
Pango::Direction  direction 
)

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

Deprecated: 4.10

Deprecated:
There is no replacement for querying the style machinery. Stylable UI elements should use widgets.
Parameters
contextA Gtk::StyleContext.
xX origin.
yY origin.
layoutThe Pango::Layout of the text.
indexThe index in the Pango::Layout.
directionThe Pango::Direction of the text.

◆ render_layout()

void Gtk::Snapshot::render_layout ( const Glib::RefPtr< StyleContext > &  context,
double  x,
double  y,
const Glib::RefPtr< Pango::Layout > &  layout 
)

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.

Deprecated: 4.10

Deprecated:
There is no replacement for querying the style machinery. Stylable UI elements should use widgets.
Parameters
contextThe style context that defines the text.
xX origin of the rectangle.
yY origin of the rectangle.
layoutThe Pango::Layout to render.

◆ restore()

void Gtk::Snapshot::restore ( )

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

◆ rotate()

void Gtk::Snapshot::rotate ( float  angle)

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

The rotation happens around the origin point of (0, 0) in the snapshot's current coordinate system.

To rotate around axes other than the Z axis, use Gsk::Transform::rotate_3d().

Parameters
angleThe rotation angle, in degrees (clockwise).

◆ save()

void Gtk::Snapshot::save ( )

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

When restore() is called, snapshot 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().

◆ scale() [1/2]

void Gtk::Snapshot::scale ( float  factor_x,
float  factor_y 
)

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

Use scale_3d() to scale in all 3 dimensions.

Parameters
factor_xScaling factor on the X axis.
factor_yScaling factor on the Y axis.

◆ scale() [2/2]

void Gtk::Snapshot::scale ( float  factor_x,
float  factor_y,
float  factor_z 
)

Scales snapshot's coordinate system by the given factors.

Parameters
factor_xScaling factor on the X axis.
factor_yScaling factor on the Y axis.
factor_zScaling factor on the Z axis.

◆ to_paintable() [1/2]

Glib::RefPtr< Gdk::Paintable > Gtk::Snapshot::to_paintable ( )

A to_paintable() convenience overload.

◆ to_paintable() [2/2]

Glib::RefPtr< Gdk::Paintable > Gtk::Snapshot::to_paintable ( const Gdk::Graphene::Size size)

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 GObject::Object::unref().

Since gtkmm 4.12:
Parameters
sizeThe size of the resulting paintable or nullptr to use the bounds of the snapshot.
Returns
A new Gdk::Paintable.

◆ translate()

void Gtk::Snapshot::translate ( const Gdk::Graphene::Point point)

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

Since gtkmm 4.12:
Parameters
pointThe point to translate the snapshot by.

Friends And Related Function Documentation

◆ wrap_gtk_snapshot()

Glib::RefPtr< Gtk::Snapshot > wrap_gtk_snapshot ( GtkSnapshot *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

It's not called wrap() because GtkSnapshot is a typedef of GdkSnapshot.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.