GtkSnapshot

GtkSnapshot — Auxiliary object for snapshots

Functions

Types and Values

Includes

#include <gtk/gtk.h>

Description

GtkSnapshot is an auxiliary object that assists in creating GskRenderNodes in the “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 gtk_snapshot_append_node() operates on. Use the gtk_snapshot_push() and gtk_snapshot_pop() functions to change the current node.

The only way to obtain a GtkSnapshot object is as an argument to the “snapshot” vfunc.

Functions

gtk_snapshot_push ()

void
gtk_snapshot_push (GtkSnapshot *snapshot,
                   gboolean keep_coordinates,
                   const char *name,
                   ...);

Creates a new render node, appends it to the current render node of snapshot , and makes it the new current render node.

Parameters

snapshot

a GtkSnapshot

 

keep_coordinates

If TRUE, the current offset and clip will be kept. Otherwise, the clip will be unset and the offset will be reset to (0, 0).

 

name

a printf() style format string for the name for the new node.

[transfer none]

...

arguments to insert into the format string

 

Since: 3.90


gtk_snapshot_push_transform ()

void
gtk_snapshot_push_transform (GtkSnapshot *snapshot,
                             const graphene_matrix_t *transform,
                             const char *name,
                             ...);

gtk_snapshot_push_clip ()

void
gtk_snapshot_push_clip (GtkSnapshot *snapshot,
                        const graphene_rect_t *bounds,
                        const char *name,
                        ...);

gtk_snapshot_push_rounded_clip ()

void
gtk_snapshot_push_rounded_clip (GtkSnapshot *snapshot,
                                const GskRoundedRect *bounds,
                                const char *name,
                                ...);

gtk_snapshot_pop ()

GskRenderNode *
gtk_snapshot_pop (GtkSnapshot *snapshot);

Removes the top element from the stack of render nodes, making the node underneath the current node again.

Parameters

snapshot

a GtkSnapshot

 

Returns

A GskRenderNode for the contents that were rendered to snapshot since the corresponding gtk_snapshot_push() call.

[transfer full][nullable]

Since: 3.90


gtk_snapshot_pop_and_append ()

void
gtk_snapshot_pop_and_append (GtkSnapshot *snapshot);

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

Parameters

snapshot

a GtkSnapshot

 

Since: 3.90


gtk_snapshot_translate_2d ()

void
gtk_snapshot_translate_2d (GtkSnapshot *snapshot,
                           int x,
                           int y);

Appends a translation by (x , y ) to the current transformation.

Parameters

snapshot

a $GtkSnapshot

 

x

horizontal translation

 

y

vertical translation

 

Since: 3.90


gtk_snapshot_append_node ()

void
gtk_snapshot_append_node (GtkSnapshot *snapshot,
                          GskRenderNode *node);

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.

Parameters

snapshot

a GtkSnapshot

 

node

a GskRenderNode

 

gtk_snapshot_append_cairo_node ()

cairo_t *
gtk_snapshot_append_cairo_node (GtkSnapshot *snapshot,
                                const graphene_rect_t *bounds,
                                const char *name,
                                ...);

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

Parameters

snapshot

a GtkSnapshot

 

bounds

the bounds for the new node

 

name

a printf() style format string for the name for the new node.

[transfer none]

...

arguments to insert into the format string

 

Returns

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

Since: 3.90


gtk_snapshot_append_texture_node ()

void
gtk_snapshot_append_texture_node (GtkSnapshot *snapshot,
                                  GskTexture *texture,
                                  const graphene_rect_t *bounds,
                                  const char *name,
                                  ...);

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

Parameters

snapshot

a GtkSnapshot

 

texture

the GskTexture to render

 

bounds

the bounds for the new node

 

name

a printf() style format string for the name for the new node.

[transfer none]

...

arguments to insert into the format string

 

gtk_snapshot_append_color_node ()

void
gtk_snapshot_append_color_node (GtkSnapshot *snapshot,
                                const GdkRGBA *color,
                                const graphene_rect_t *bounds,
                                const char *name,
                                ...);

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.

Parameters

snapshot

a GtkSnapshot

 

color

the GdkRGBA to draw

 

bounds

the bounds for the new node

 

name

a printf() style format string for the name for the new node.

[transfer none]

...

arguments to insert into the format string

 

gtk_snapshot_clips_rect ()

gboolean
gtk_snapshot_clips_rect (GtkSnapshot *snapshot,
                         const graphene_rect_t *bounds);

Tests whether the rectangle is entirely outside the clip region of snapshot .

Parameters

snapshot

a GtkSnapshot

 

bounds

a rectangle

 

Returns

TRUE is bounds is entirely outside the clip region

Since: 3.90


gtk_snapshot_render_background ()

void
gtk_snapshot_render_background (GtkSnapshot *snapshot,
                                GtkStyleContext *context,
                                gdouble x,
                                gdouble y,
                                gdouble width,
                                gdouble 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.

Parameters

snapshot

a GtkSnapshot

 

context

the GtkStyleContext to use

 

x

X origin of the rectangle

 

y

Y origin of the rectangle

 

width

rectangle width

 

height

rectangle height

 

Since: 3.90


gtk_snapshot_render_frame ()

void
gtk_snapshot_render_frame (GtkSnapshot *snapshot,
                           GtkStyleContext *context,
                           gdouble x,
                           gdouble y,
                           gdouble width,
                           gdouble 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.

Parameters

snapshot

a GtkSnapshot

 

context

the GtkStyleContext to use

 

x

X origin of the rectangle

 

y

Y origin of the rectangle

 

width

rectangle width

 

height

rectangle height

 

Since: 3.90


gtk_snapshot_render_focus ()

void
gtk_snapshot_render_focus (GtkSnapshot *snapshot,
                           GtkStyleContext *context,
                           gdouble x,
                           gdouble y,
                           gdouble width,
                           gdouble 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.

Parameters

snapshot

a GtkSnapshot

 

context

the GtkStyleContext to use

 

x

X origin of the rectangle

 

y

Y origin of the rectangle

 

width

rectangle width

 

height

rectangle height

 

Since: 3.90


gtk_snapshot_render_layout ()

void
gtk_snapshot_render_layout (GtkSnapshot *snapshot,
                            GtkStyleContext *context,
                            gdouble x,
                            gdouble y,
                            PangoLayout *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.

Parameters

snapshot

a GtkSnapshot

 

context

the GtkStyleContext to use

 

x

X origin of the rectangle

 

y

Y origin of the rectangle

 

layout

the PangoLayout to render

 

Since: 3.90


gtk_snapshot_render_insertion_cursor ()

void
gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot,
                                      GtkStyleContext *context,
                                      gdouble x,
                                      gdouble y,
                                      PangoLayout *layout,
                                      int index,
                                      PangoDirection direction);

Draws a text caret on cr at the specified index of layout .

Parameters

snapshot

snapshot to render to

 

context

a GtkStyleContext

 

x

X origin

 

y

Y origin

 

layout

the PangoLayout of the text

 

index

the index in the PangoLayout

 

direction

the PangoDirection of the text

 

Since: 3.90


gtk_snapshot_render_icon ()

void
gtk_snapshot_render_icon (GtkSnapshot *snapshot,
                          GtkStyleContext *context,
                          GdkPixbuf *pixbuf,
                          gdouble x,
                          gdouble y);

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

Parameters

snapshot

a GtkSnapshot

 

context

the GtkStyleContext to use

 

pixbuf

the GdkPixbuf to render

 

x

X origin of the rectangle

 

y

Y origin of the rectangle

 

Since: 3.90

Types and Values

GtkSnapshot

typedef struct _GtkSnapshot GtkSnapshot;