GtkSnapshot

GtkSnapshot — Auxiliary object for snapshots

Types and Values

typedef GtkSnapshot

Object Hierarchy

    GObject
    ╰── GdkSnapshot
        ╰── GtkSnapshot

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_… functions operate on. Use the gtk_snapshot_push_… functions and gtk_snapshot_pop() to change the current node.

The typical way to obtain a GtkSnapshot object is as an argument to the “snapshot” vfunc. If you need to create your own GtkSnapshot, use gtk_snapshot_new().

Functions

gtk_snapshot_new ()

GtkSnapshot *
gtk_snapshot_new (void);

Creates a new GtkSnapshot.

Returns

a newly-allocated GtkSnapshot


gtk_snapshot_to_node ()

GskRenderNode *
gtk_snapshot_to_node (GtkSnapshot *snapshot);

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

Parameters

snapshot

a GtkSnapshot

 

Returns

the constructed GskRenderNode


gtk_snapshot_to_paintable ()

GdkPaintable *
gtk_snapshot_to_paintable (GtkSnapshot *snapshot,
                           const graphene_size_t *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 gtk_snapshot_unref().

Parameters

snapshot

a GtkSnapshot

 

size

The size of the resulting paintable or NULL to use the bounds of the snapshot.

[allow-none]

Returns

a new GdkPaintable.

[transfer full]


gtk_snapshot_free_to_node ()

GskRenderNode *
gtk_snapshot_free_to_node (GtkSnapshot *snapshot);

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

[skip]

Parameters

snapshot

a GtkSnapshot.

[transfer full]

Returns

a newly-created GskRenderNode.

[transfer full]


gtk_snapshot_free_to_paintable ()

GdkPaintable *
gtk_snapshot_free_to_paintable (GtkSnapshot *snapshot,
                                const graphene_size_t *size);

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

[skip]

Parameters

snapshot

a GtkSnapshot.

[transfer full]

size

The size of the resulting paintable or NULL to use the bounds of the snapshot.

[allow-none]

Returns

a newly-created GdkPaintable.

[transfer full]


gtk_snapshot_push_transform ()

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

gtk_snapshot_push_opacity ()

void
gtk_snapshot_push_opacity (GtkSnapshot *snapshot,
                           double opacity);

gtk_snapshot_push_color_matrix ()

void
gtk_snapshot_push_color_matrix (GtkSnapshot *snapshot,
                                const graphene_matrix_t *color_matrix,
                                const graphene_vec4_t *color_offset);

gtk_snapshot_push_repeat ()

void
gtk_snapshot_push_repeat (GtkSnapshot *snapshot,
                          const graphene_rect_t *bounds,
                          const graphene_rect_t *child_bounds);

gtk_snapshot_push_clip ()

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

gtk_snapshot_push_rounded_clip ()

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

gtk_snapshot_push_cross_fade ()

void
gtk_snapshot_push_cross_fade (GtkSnapshot *snapshot,
                              double progress);

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

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

Calling this function requires 2 calls to gtk_snapshot_pop().

Parameters

snapshot

a GtkSnapshot

 

progress

progress between 0.0 and 1.0

 

gtk_snapshot_push_blend ()

void
gtk_snapshot_push_blend (GtkSnapshot *snapshot,
                         GskBlendMode blend_mode);

Blends together 2 images with the given blend mode.

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

Calling this function requires 2 subsequent calls to gtk_snapshot_pop().

Parameters

snapshot

a GtkSnapshot

 

blend_mode

blend mode to use

 

gtk_snapshot_pop ()

void
gtk_snapshot_pop (GtkSnapshot *snapshot);

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

Parameters

snapshot

a GtkSnapshot

 

gtk_snapshot_offset ()

void
gtk_snapshot_offset (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

 

gtk_snapshot_get_offset ()

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

Queries the offset managed by snapshot . This offset is the accumulated sum of calls to gtk_snapshot_offset().

Use this offset to determine how to offset nodes that you manually add to the snapshot using gtk_snapshot_append().

Note that other functions that add nodes for you, such as gtk_snapshot_append_cairo() will add this offset for you.

Parameters

snapshot

a GtkSnapshot

 

x

return location for x offset.

[out][optional]

y

return location for y offset.

[out][optional]

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

cairo_t *
gtk_snapshot_append_cairo (GtkSnapshot *snapshot,
                           const graphene_rect_t *bounds);

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

 

Returns

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


gtk_snapshot_append_texture ()

void
gtk_snapshot_append_texture (GtkSnapshot *snapshot,
                             GdkTexture *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 .

Parameters

snapshot

a GtkSnapshot

 

texture

the GdkTexture to render

 

bounds

the bounds for the new node

 

gtk_snapshot_append_color ()

void
gtk_snapshot_append_color (GtkSnapshot *snapshot,
                           const GdkRGBA *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.

Parameters

snapshot

a GtkSnapshot

 

color

the GdkRGBA to draw

 

bounds

the bounds for the new node

 

gtk_snapshot_append_layout ()

void
gtk_snapshot_append_layout (GtkSnapshot *snapshot,
                            PangoLayout *layout,
                            const GdkRGBA *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.

Parameters

snapshot

a GtkSnapshot

 

layout

the PangoLayout to render

 

color

the foreground color to render the layout in

 

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

 

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

 

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

 

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

 

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

 

Types and Values

GtkSnapshot

typedef GdkSnapshot                    GtkSnapshot;