Package ch.bailu.gtk.gtk
Klasse Snapshot
- Alle implementierten Schnittstellen:
PointerInterface
Assists in creating [class@Gsk.RenderNode]s 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
[method@Snapshot.pop] to change the current node.
The typical way to obtain a `GtkSnapshot` object is as an argument to
the [vfunc@Gtk.Widget.snapshot] vfunc. If you need to create your own
`GtkSnapshot`, use [ctor@Gtk.Snapshot.new].
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
[method@Snapshot.pop] to change the current node.
The typical way to obtain a `GtkSnapshot` object is as an argument to
the [vfunc@Gtk.Widget.snapshot] vfunc. If you need to create your own
`GtkSnapshot`, use [ctor@Gtk.Snapshot.new].
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDestroyNotify, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify -
Feldübersicht
Von Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungappendCairo(Rect bounds) Creates a new [class@Gsk.CairoNode] and appends it to the current
render node of @snapshot, without changing the current node.voidappendColor(RGBA color, Rect bounds) Creates a new render node drawing the @color into the
given @bounds and appends it to the current render node
of @snapshot.voidappendFill(Path path, int fill_rule, RGBA color) A convenience method to fill a path with a color.voidappendInsetShadow(RoundedRect outline, RGBA color, float dx, float dy, float spread, float blur_radius) Appends an inset shadow into the box given by @outline.voidappendLayout(Layout layout, 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.voidappendNode(RenderNode node) Appends @node to the current render node of @snapshot,
without changing the current node.voidappendOutsetShadow(RoundedRect outline, RGBA color, float dx, float dy, float spread, float blur_radius) Appends an outset shadow node around the box given by @outline.voidappendScaledTexture(Texture texture, int filter, Rect bounds) Creates a new render node drawing the @texture
into the given @bounds and appends it to the
current render node of @snapshot.voidappendStroke(Path path, Stroke stroke, RGBA color) A convenience method to stroke a path with a color.voidappendTexture(Texture texture, Rect bounds) Creates a new render node drawing the @texture
into the given @bounds and appends it to the
current render node of @snapshot.Returns the node that was constructed by @snapshot
and frees @snapshot.freeToPaintable(Size size) Returns a paintable for the node that was
constructed by @snapshot and frees @snapshot.static ClassHandlerstatic intstatic longstatic TypeSystem.TypeSizestatic longstatic TypeSystem.TypeSizevoidVeraltet.voidperspective(float depth) Applies a perspective projection transform.voidpop()Removes the top element from the stack of render nodes,
and appends it to the node underneath it.voidpushBlend(int blend_mode) Blends together two images with the given blend mode.voidpushBlur(double radius) Blurs an image.voidClips an image to a rectangle.voidpushColorMatrix(Matrix color_matrix, Vec4 color_offset) Modifies the colors of an image by applying an affine transformation
in RGB space.voidpushCrossFade(double progress) Snapshots a cross-fade operation between two images with the
given @progress.voidInserts a debug node with a message.voidInserts a debug node with a message.voidFills the area given by @path and @fill_rule with an image and discards everything
outside of it.voidpushGlShader(GLShader shader, Rect bounds, Bytes take_args) Veraltet.voidpushMask(int mask_mode) Until the first call to [method@Gtk.Snapshot.pop], the
mask image for the mask operation will be recorded.voidpushOpacity(double opacity) Modifies the opacity of an image.voidpushRepeat(Rect bounds, Rect child_bounds) Creates a node that repeats the child node.voidpushRoundedClip(RoundedRect bounds) Clips an image to a rounded rectangle.voidpushStroke(Path path, Stroke stroke) Strokes the given @path with the attributes given by @stroke and
an image.voidrenderBackground(StyleContext context, double x, double y, double width, double height) Veraltet.voidrenderFocus(StyleContext context, double x, double y, double width, double height) Veraltet.voidrenderFrame(StyleContext context, double x, double y, double width, double height) Veraltet.voidrenderInsertionCursor(StyleContext context, double x, double y, Layout layout, int index, int direction) Veraltet.voidrenderLayout(StyleContext context, double x, double y, Layout layout) Veraltet.voidrestore()Restores @snapshot to the state saved by a preceding call to
[method@Snapshot.save] and removes that state from the stack of
saved states.voidrotate(float angle) Rotates @@snapshot's coordinate system by @angle degrees in 2D space -
or in 3D speak, rotates around the Z axis.voidRotates @snapshot's coordinate system by @angle degrees around @axis.voidsave()Makes a copy of the current state of @snapshot and saves it
on an internal stack.voidscale(float factor_x, float factor_y) Scales @snapshot's coordinate system in 2-dimensional space by
the given factors.voidscale3d(float factor_x, float factor_y, float factor_z) Scales @snapshot's coordinate system by the given factors.toNode()Returns the render node that was constructed
by @snapshot.toPaintable(Size size) Returns a paintable encapsulating the render node
that was constructed by @snapshot.voidTransforms @snapshot's coordinate system with the given @transform.voidtransformMatrix(Matrix matrix) Transforms @snapshot's coordinate system with the given @matrix.voidTranslates @snapshot's coordinate system by @point in 2-dimensional space.voidtranslate3d(Point3D point) Translates @snapshot's coordinate system by @point.Von Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrPropertyVon Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnrefVon Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacksVon Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNullVon Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitVon Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Konstruktordetails
-
Snapshot
-
Snapshot
public Snapshot()Creates a new `GtkSnapshot`.
-
-
Methodendetails
-
getClassHandler
-
appendCairo
Creates a new [class@Gsk.CairoNode] and appends it to the current
render node of @snapshot, without changing the current node.- Parameter:
bounds- the bounds for the new node- Gibt zurück:
- a `cairo_t` suitable for drawing the contents of the newly created render node
-
appendColor
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.- Parameter:
color- the color to drawbounds- the bounds for the new node
-
appendFill
A convenience method to fill a path with a color.
See [method@Gtk.Snapshot.push_fill] if you need
to fill a path with more complex content than
a color.- Parameter:
path- The path describing the area to fillfill_rule- The fill rule to usecolor- the color to fill the path with
-
appendInsetShadow
public void appendInsetShadow(@Nonnull RoundedRect outline, @Nonnull RGBA color, float dx, float dy, float spread, float blur_radius) Appends an inset shadow into the box given by @outline.- Parameter:
outline- outline of the region surrounded by shadowcolor- color of the shadowdx- horizontal offset of shadowdy- vertical offset of shadowspread- how far the shadow spreads towards the insideblur_radius- how much blur to apply to the shadow
-
appendLayout
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 [method@Gtk.Widget.get_color].
Note that if the layout does not produce any visible output, then nodes
may not be added to the @snapshot.- Parameter:
layout- the `PangoLayout` to rendercolor- the foreground color to render the layout in
-
appendNode
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.- Parameter:
node- a `GskRenderNode`
-
appendOutsetShadow
public void appendOutsetShadow(@Nonnull RoundedRect outline, @Nonnull RGBA color, float dx, float dy, float spread, float blur_radius) Appends an outset shadow node around the box given by @outline.- Parameter:
outline- outline of the region surrounded by shadowcolor- color of the shadowdx- horizontal offset of shadowdy- vertical offset of shadowspread- how far the shadow spreads towards the outsideblur_radius- how much blur to apply to the shadow
-
appendScaledTexture
Creates a new render node drawing the @texture
into the given @bounds and appends it to the
current render node of @snapshot.
In contrast to [method@Gtk.Snapshot.append_texture],
this function provides control about how the filter
that is used when scaling.- Parameter:
texture- the texture to renderfilter- the filter to usebounds- the bounds for the new node
-
appendStroke
A convenience method to stroke a path with a color.
See [method@Gtk.Snapshot.push_stroke] if you need
to stroke a path with more complex content than
a color.- Parameter:
path- The path describing the area to fillstroke- The stroke attributescolor- the color to fill the path with
-
appendTexture
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 [method@Gtk.Snapshot.append_scaled_texture]
if you need other filtering, such as nearest-neighbour.- Parameter:
texture- the texture to renderbounds- the bounds for the new node
-
freeToNode
Returns the node that was constructed by @snapshot
and frees @snapshot.
See also [method@Gtk.Snapshot.to_node].- Gibt zurück:
- a newly-created [class@Gsk.RenderNode]
-
freeToPaintable
Returns a paintable for the node that was
constructed by @snapshot and frees @snapshot.- Parameter:
size- The size of the resulting paintable or %NULL to use the bounds of the snapshot- Gibt zurück:
- a newly-created [iface@Gdk.Paintable]
-
glShaderPopTexture
Veraltet.Removes the top element from the stack of render nodes and
adds it to the nearest [class@Gsk.GLShaderNode] below it.
This must be called the same number of times as the number
of textures is needed for the shader in
[method@Gtk.Snapshot.push_gl_shader]. -
perspective
public void perspective(float depth) Applies a perspective projection transform.
See [method@Gsk.Transform.perspective] for a discussion on the details.- Parameter:
depth- distance of the z=0 plane
-
pop
public void pop()Removes the top element from the stack of render nodes,
and appends it to the node underneath it. -
pushBlend
public void pushBlend(int blend_mode) Blends together two images with the given blend mode.
Until the first call to [method@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 [method@Gtk.Snapshot.pop].
Calling this function requires two subsequent calls
to [method@Gtk.Snapshot.pop].- Parameter:
blend_mode- blend mode to use
-
pushBlur
public void pushBlur(double radius) Blurs an image.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].- Parameter:
radius- the blur radius to use. Must be positive
-
pushClip
Clips an image to a rectangle.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].- Parameter:
bounds- the rectangle to clip to
-
pushColorMatrix
Modifies the colors of an image by applying an affine transformation
in RGB space.
In particular, the colors will be transformed by applying
pixel = transpose(color_matrix) * pixel + color_offset
for every pixel. The transformation operates on unpremultiplied
colors, with color components ordered R, G, B, A.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].- Parameter:
color_matrix- the color matrix to usecolor_offset- the color offset to use
-
pushCrossFade
public void pushCrossFade(double progress) Snapshots a cross-fade operation between two images with the
given @progress.
Until the first call to [method@Gtk.Snapshot.pop], the start image
will be snapshot. After that call, the end image will be recorded
until the second call to [method@Gtk.Snapshot.pop].
Calling this function requires two subsequent calls
to [method@Gtk.Snapshot.pop].- Parameter:
progress- progress between 0.0 and 1.0
-
pushDebug
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.- Parameter:
message- a printf-style format string_ellipsis- arguments for @message
-
pushDebug
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.- Parameter:
message- a printf-style format string_ellipsis- arguments for @message
-
pushFill
Fills the area given by @path and @fill_rule with an image and discards everything
outside of it.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].
If you want to fill the path with a color, [method@Gtk.Snapshot.append_fill]
may be more convenient.- Parameter:
path- The path describing the area to fillfill_rule- The fill rule to use
-
pushGlShader
@Deprecated public void pushGlShader(@Nonnull GLShader shader, @Nonnull Rect bounds, @Nonnull Bytes take_args) Veraltet.Push a [class@Gsk.GLShaderNode].
The node uses the given [class@Gsk.GLShader] and uniform values
Additionally this takes a list of @n_children other nodes
which will be passed to the [class@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 [method@Gsk.GLShader.format_args]
or [struct@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 [method@Gsk.GLShader.compile] to ensure the @shader
will work for the renderer before using it.
If the shader requires textures (see [method@Gsk.GLShader.get_n_textures]),
then it is expected that you call [method@Gtk.Snapshot.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 `GskGLShaderNode`, 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
[method@Gtk.Snapshot.pop].
If you want to use pre-existing textures as input to the shader rather
than rendering new ones, use [method@Gtk.Snapshot.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 [class@Gsk.GLShader].- Parameter:
shader- The code to runbounds- the rectangle to render intotake_args- Data block with arguments for the shader.
-
pushMask
public void pushMask(int mask_mode) Until the first call to [method@Gtk.Snapshot.pop], the
mask image for the mask operation will be recorded.
After that call, the source image will be recorded until
the second call to [method@Gtk.Snapshot.pop].
Calling this function requires 2 subsequent calls to gtk_snapshot_pop().- Parameter:
mask_mode- mask mode to use
-
pushOpacity
public void pushOpacity(double opacity) Modifies the opacity of an image.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].- Parameter:
opacity- the opacity to use
-
pushRepeat
Creates a node that repeats the child node.
The child is recorded until the next call to [method@Gtk.Snapshot.pop].- Parameter:
bounds- the bounds within which to repeatchild_bounds- the bounds of the child or %NULL to use the full size of the collected child node
-
pushRoundedClip
Clips an image to a rounded rectangle.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].- Parameter:
bounds- the rounded rectangle to clip to
-
pushStroke
Strokes the given @path with the attributes given by @stroke and
an image.
The image is recorded until the next call to [method@Gtk.Snapshot.pop].
Note that the strokes are subject to the same transformation as
everything else, so uneven scaling will cause horizontal and vertical
strokes to have different widths.
If you want to stroke the path with a color, [method@Gtk.Snapshot.append_stroke]
may be more convenient.- Parameter:
path- The path to strokestroke- The stroke attributes
-
renderBackground
@Deprecated public void renderBackground(@Nonnull StyleContext context, double x, double y, double width, double height) Veraltet.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.- Parameter:
context- the style context that defines the backgroundx- X origin of the rectangley- Y origin of the rectanglewidth- rectangle widthheight- rectangle height
-
renderFocus
@Deprecated public void renderFocus(@Nonnull StyleContext context, double x, double y, double width, double height) Veraltet.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.- Parameter:
context- the style context that defines the focus ringx- X origin of the rectangley- Y origin of the rectanglewidth- rectangle widthheight- rectangle height
-
renderFrame
@Deprecated public void renderFrame(@Nonnull StyleContext context, double x, double y, double width, double height) Veraltet.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.- Parameter:
context- the style context that defines the framex- X origin of the rectangley- Y origin of the rectanglewidth- rectangle widthheight- rectangle height
-
renderInsertionCursor
@Deprecated public void renderInsertionCursor(@Nonnull StyleContext context, double x, double y, @Nonnull Layout layout, int index, int direction) Veraltet.Draws a text caret using @snapshot at the specified index of @layout.- Parameter:
context- a `GtkStyleContext`x- X originy- Y originlayout- the `PangoLayout` of the textindex- the index in the `PangoLayout`direction- the `PangoDirection` of the text
-
renderLayout
@Deprecated public void renderLayout(@Nonnull StyleContext context, double x, double y, @Nonnull Layout layout) Veraltet.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.- Parameter:
context- the style context that defines the textx- X origin of the rectangley- Y origin of the rectanglelayout- the `PangoLayout` to render
-
restore
public void restore()Restores @snapshot to the state saved by a preceding call to
[method@Snapshot.save] and removes that state from the stack of
saved states. -
rotate
public void 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 [method@Gsk.Transform.rotate_3d].- Parameter:
angle- the rotation angle, in degrees (clockwise)
-
rotate3d
Rotates @snapshot's coordinate system by @angle degrees around @axis.
For a rotation in 2D space, use [method@Gsk.Transform.rotate].- Parameter:
angle- the rotation angle, in degrees (clockwise)axis- The rotation axis
-
save
public void save()Makes a copy of the current state of @snapshot and saves it
on an internal stack.
When [method@Gtk.Snapshot.restore] is called, @snapshot will
be restored to the saved state.
Multiple calls to [method@Gtk.Snapshot.save] and [method@Gtk.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()`. -
scale
public void scale(float factor_x, float factor_y) Scales @snapshot's coordinate system in 2-dimensional space by
the given factors.
Use [method@Gtk.Snapshot.scale_3d] to scale in all 3 dimensions.- Parameter:
factor_x- scaling factor on the X axisfactor_y- scaling factor on the Y axis
-
scale3d
public void scale3d(float factor_x, float factor_y, float factor_z) Scales @snapshot's coordinate system by the given factors.- Parameter:
factor_x- scaling factor on the X axisfactor_y- scaling factor on the Y axisfactor_z- scaling factor on the Z axis
-
toNode
Returns the render node that was constructed
by @snapshot.
Note that this function may return %NULL if nothing has been
added to the snapshot or if its content does not produce pixels
to be rendered.
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 [method@GObject.Object.unref].- Gibt zurück:
- the constructed `GskRenderNode` or %NULL if there are no nodes to render.
-
toPaintable
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 [method@GObject.Object.unref].- Parameter:
size- The size of the resulting paintable or %NULL to use the bounds of the snapshot- Gibt zurück:
- a new `GdkPaintable`
-
transform
Transforms @snapshot's coordinate system with the given @transform.- Parameter:
transform- the transform to apply
-
transformMatrix
Transforms @snapshot's coordinate system with the given @matrix.- Parameter:
matrix- the matrix to multiply the transform with
-
translate
Translates @snapshot's coordinate system by @point in 2-dimensional space.- Parameter:
point- the point to translate the snapshot by
-
translate3d
Translates @snapshot's coordinate system by @point.- Parameter:
point- the point to translate the snapshot by
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-