gtk4/auto/
snapshot.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4#![allow(deprecated)]
5
6use crate::{ffi, StyleContext};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// [`Snapshot`][crate::Snapshot] assists in creating [`gsk::RenderNode`][crate::gsk::RenderNode]s for widgets.
11    ///
12    /// It functions in a similar way to a cairo context, and maintains a stack
13    /// of render nodes and their associated transformations.
14    ///
15    /// The node at the top of the stack is the one that `gtk_snapshot_append_…()`
16    /// functions operate on. Use the `gtk_snapshot_push_…()` functions and
17    /// [`SnapshotExt::pop()`][crate::prelude::SnapshotExt::pop()] to change the current node.
18    ///
19    /// The typical way to obtain a [`Snapshot`][crate::Snapshot] object is as an argument to
20    /// the [`WidgetImpl::snapshot()`][crate::subclass::prelude::WidgetImpl::snapshot()] vfunc. If you need to create your own
21    /// [`Snapshot`][crate::Snapshot], use [`new()`][Self::new()].
22    ///
23    /// # Implements
24    ///
25    /// [`SnapshotExt`][trait@crate::prelude::SnapshotExt], [`trait@gdk::prelude::SnapshotExt`], [`trait@glib::ObjectExt`], [`SnapshotExtManual`][trait@crate::prelude::SnapshotExtManual]
26    #[doc(alias = "GtkSnapshot")]
27    pub struct Snapshot(Object<ffi::GtkSnapshot, ffi::GtkSnapshotClass>) @extends gdk::Snapshot;
28
29    match fn {
30        type_ => || ffi::gtk_snapshot_get_type(),
31    }
32}
33
34impl Snapshot {
35    pub const NONE: Option<&'static Snapshot> = None;
36
37    /// Creates a new [`Snapshot`][crate::Snapshot].
38    ///
39    /// # Returns
40    ///
41    /// a newly-allocated [`Snapshot`][crate::Snapshot]
42    #[doc(alias = "gtk_snapshot_new")]
43    pub fn new() -> Snapshot {
44        assert_initialized_main_thread!();
45        unsafe { from_glib_full(ffi::gtk_snapshot_new()) }
46    }
47}
48
49impl Default for Snapshot {
50    fn default() -> Self {
51        Self::new()
52    }
53}
54
55/// Trait containing all [`struct@Snapshot`] methods.
56///
57/// # Implementors
58///
59/// [`Snapshot`][struct@crate::Snapshot]
60pub trait SnapshotExt: IsA<Snapshot> + 'static {
61    /// Creates a new [`gsk::CairoNode`][crate::gsk::CairoNode] and appends it to the current
62    /// render node of @self, without changing the current node.
63    /// ## `bounds`
64    /// the bounds for the new node
65    ///
66    /// # Returns
67    ///
68    /// a [`cairo::Context`][crate::cairo::Context] suitable for drawing the contents of
69    ///   the newly created render node
70    #[doc(alias = "gtk_snapshot_append_cairo")]
71    fn append_cairo(&self, bounds: &graphene::Rect) -> cairo::Context {
72        unsafe {
73            from_glib_full(ffi::gtk_snapshot_append_cairo(
74                self.as_ref().to_glib_none().0,
75                bounds.to_glib_none().0,
76            ))
77        }
78    }
79
80    /// Creates a new render node drawing the @color into the
81    /// given @bounds and appends it to the current render node
82    /// of @self.
83    ///
84    /// You should try to avoid calling this function if
85    /// @color is transparent.
86    /// ## `color`
87    /// the color to draw
88    /// ## `bounds`
89    /// the bounds for the new node
90    #[doc(alias = "gtk_snapshot_append_color")]
91    fn append_color(&self, color: &gdk::RGBA, bounds: &graphene::Rect) {
92        unsafe {
93            ffi::gtk_snapshot_append_color(
94                self.as_ref().to_glib_none().0,
95                color.to_glib_none().0,
96                bounds.to_glib_none().0,
97            );
98        }
99    }
100
101    /// Appends a conic gradient node with the given stops to @self.
102    /// ## `bounds`
103    /// the rectangle to render the gradient into
104    /// ## `center`
105    /// the center point of the conic gradient
106    /// ## `rotation`
107    /// the clockwise rotation in degrees of the starting angle.
108    ///   0 means the starting angle is the top.
109    /// ## `stops`
110    /// the color stops defining the gradient
111    #[doc(alias = "gtk_snapshot_append_conic_gradient")]
112    fn append_conic_gradient(
113        &self,
114        bounds: &graphene::Rect,
115        center: &graphene::Point,
116        rotation: f32,
117        stops: &[gsk::ColorStop],
118    ) {
119        let n_stops = stops.len() as _;
120        unsafe {
121            ffi::gtk_snapshot_append_conic_gradient(
122                self.as_ref().to_glib_none().0,
123                bounds.to_glib_none().0,
124                center.to_glib_none().0,
125                rotation,
126                stops.to_glib_none().0,
127                n_stops,
128            );
129        }
130    }
131
132    /// A convenience method to fill a path with a color.
133    ///
134    /// See [`push_fill()`][Self::push_fill()] if you need
135    /// to fill a path with more complex content than
136    /// a color.
137    /// ## `path`
138    /// The path describing the area to fill
139    /// ## `fill_rule`
140    /// The fill rule to use
141    /// ## `color`
142    /// the color to fill the path with
143    #[cfg(feature = "v4_14")]
144    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
145    #[doc(alias = "gtk_snapshot_append_fill")]
146    fn append_fill(&self, path: &gsk::Path, fill_rule: gsk::FillRule, color: &gdk::RGBA) {
147        unsafe {
148            ffi::gtk_snapshot_append_fill(
149                self.as_ref().to_glib_none().0,
150                path.to_glib_none().0,
151                fill_rule.into_glib(),
152                color.to_glib_none().0,
153            );
154        }
155    }
156
157    /// Appends an inset shadow into the box given by @outline.
158    /// ## `outline`
159    /// outline of the region surrounded by shadow
160    /// ## `color`
161    /// color of the shadow
162    /// ## `dx`
163    /// horizontal offset of shadow
164    /// ## `dy`
165    /// vertical offset of shadow
166    /// ## `spread`
167    /// how far the shadow spreads towards the inside
168    /// ## `blur_radius`
169    /// how much blur to apply to the shadow
170    #[doc(alias = "gtk_snapshot_append_inset_shadow")]
171    fn append_inset_shadow(
172        &self,
173        outline: &gsk::RoundedRect,
174        color: &gdk::RGBA,
175        dx: f32,
176        dy: f32,
177        spread: f32,
178        blur_radius: f32,
179    ) {
180        unsafe {
181            ffi::gtk_snapshot_append_inset_shadow(
182                self.as_ref().to_glib_none().0,
183                outline.to_glib_none().0,
184                color.to_glib_none().0,
185                dx,
186                dy,
187                spread,
188                blur_radius,
189            );
190        }
191    }
192
193    /// Creates render nodes for rendering @layout in the given foregound @color
194    /// and appends them to the current node of @self without changing the
195    /// current node. The current theme's foreground color for a widget can be
196    /// obtained with [`WidgetExt::color()`][crate::prelude::WidgetExt::color()].
197    ///
198    /// Note that if the layout does not produce any visible output, then nodes
199    /// may not be added to the @self.
200    /// ## `layout`
201    /// the [`pango::Layout`][crate::pango::Layout] to render
202    /// ## `color`
203    /// the foreground color to render the layout in
204    #[doc(alias = "gtk_snapshot_append_layout")]
205    fn append_layout(&self, layout: &pango::Layout, color: &gdk::RGBA) {
206        unsafe {
207            ffi::gtk_snapshot_append_layout(
208                self.as_ref().to_glib_none().0,
209                layout.to_glib_none().0,
210                color.to_glib_none().0,
211            );
212        }
213    }
214
215    /// Appends a linear gradient node with the given stops to @self.
216    /// ## `bounds`
217    /// the rectangle to render the linear gradient into
218    /// ## `start_point`
219    /// the point at which the linear gradient will begin
220    /// ## `end_point`
221    /// the point at which the linear gradient will finish
222    /// ## `stops`
223    /// the color stops defining the gradient
224    #[doc(alias = "gtk_snapshot_append_linear_gradient")]
225    fn append_linear_gradient(
226        &self,
227        bounds: &graphene::Rect,
228        start_point: &graphene::Point,
229        end_point: &graphene::Point,
230        stops: &[gsk::ColorStop],
231    ) {
232        let n_stops = stops.len() as _;
233        unsafe {
234            ffi::gtk_snapshot_append_linear_gradient(
235                self.as_ref().to_glib_none().0,
236                bounds.to_glib_none().0,
237                start_point.to_glib_none().0,
238                end_point.to_glib_none().0,
239                stops.to_glib_none().0,
240                n_stops,
241            );
242        }
243    }
244
245    /// Appends @node to the current render node of @self,
246    /// without changing the current node.
247    ///
248    /// If @self does not have a current node yet, @node
249    /// will become the initial node.
250    /// ## `node`
251    /// a [`gsk::RenderNode`][crate::gsk::RenderNode]
252    #[doc(alias = "gtk_snapshot_append_node")]
253    fn append_node(&self, node: impl AsRef<gsk::RenderNode>) {
254        unsafe {
255            ffi::gtk_snapshot_append_node(
256                self.as_ref().to_glib_none().0,
257                node.as_ref().to_glib_none().0,
258            );
259        }
260    }
261
262    /// Appends an outset shadow node around the box given by @outline.
263    /// ## `outline`
264    /// outline of the region surrounded by shadow
265    /// ## `color`
266    /// color of the shadow
267    /// ## `dx`
268    /// horizontal offset of shadow
269    /// ## `dy`
270    /// vertical offset of shadow
271    /// ## `spread`
272    /// how far the shadow spreads towards the outside
273    /// ## `blur_radius`
274    /// how much blur to apply to the shadow
275    #[doc(alias = "gtk_snapshot_append_outset_shadow")]
276    fn append_outset_shadow(
277        &self,
278        outline: &gsk::RoundedRect,
279        color: &gdk::RGBA,
280        dx: f32,
281        dy: f32,
282        spread: f32,
283        blur_radius: f32,
284    ) {
285        unsafe {
286            ffi::gtk_snapshot_append_outset_shadow(
287                self.as_ref().to_glib_none().0,
288                outline.to_glib_none().0,
289                color.to_glib_none().0,
290                dx,
291                dy,
292                spread,
293                blur_radius,
294            );
295        }
296    }
297
298    /// Appends a radial gradient node with the given stops to @self.
299    /// ## `bounds`
300    /// the rectangle to render the readial gradient into
301    /// ## `center`
302    /// the center point for the radial gradient
303    /// ## `hradius`
304    /// the horizontal radius
305    /// ## `vradius`
306    /// the vertical radius
307    /// ## `start`
308    /// the start position (on the horizontal axis)
309    /// ## `end`
310    /// the end position (on the horizontal axis)
311    /// ## `stops`
312    /// the color stops defining the gradient
313    #[doc(alias = "gtk_snapshot_append_radial_gradient")]
314    fn append_radial_gradient(
315        &self,
316        bounds: &graphene::Rect,
317        center: &graphene::Point,
318        hradius: f32,
319        vradius: f32,
320        start: f32,
321        end: f32,
322        stops: &[gsk::ColorStop],
323    ) {
324        let n_stops = stops.len() as _;
325        unsafe {
326            ffi::gtk_snapshot_append_radial_gradient(
327                self.as_ref().to_glib_none().0,
328                bounds.to_glib_none().0,
329                center.to_glib_none().0,
330                hradius,
331                vradius,
332                start,
333                end,
334                stops.to_glib_none().0,
335                n_stops,
336            );
337        }
338    }
339
340    /// Appends a repeating linear gradient node with the given stops to @self.
341    /// ## `bounds`
342    /// the rectangle to render the linear gradient into
343    /// ## `start_point`
344    /// the point at which the linear gradient will begin
345    /// ## `end_point`
346    /// the point at which the linear gradient will finish
347    /// ## `stops`
348    /// the color stops defining the gradient
349    #[doc(alias = "gtk_snapshot_append_repeating_linear_gradient")]
350    fn append_repeating_linear_gradient(
351        &self,
352        bounds: &graphene::Rect,
353        start_point: &graphene::Point,
354        end_point: &graphene::Point,
355        stops: &[gsk::ColorStop],
356    ) {
357        let n_stops = stops.len() as _;
358        unsafe {
359            ffi::gtk_snapshot_append_repeating_linear_gradient(
360                self.as_ref().to_glib_none().0,
361                bounds.to_glib_none().0,
362                start_point.to_glib_none().0,
363                end_point.to_glib_none().0,
364                stops.to_glib_none().0,
365                n_stops,
366            );
367        }
368    }
369
370    /// Appends a repeating radial gradient node with the given stops to @self.
371    /// ## `bounds`
372    /// the rectangle to render the readial gradient into
373    /// ## `center`
374    /// the center point for the radial gradient
375    /// ## `hradius`
376    /// the horizontal radius
377    /// ## `vradius`
378    /// the vertical radius
379    /// ## `start`
380    /// the start position (on the horizontal axis)
381    /// ## `end`
382    /// the end position (on the horizontal axis)
383    /// ## `stops`
384    /// the color stops defining the gradient
385    #[doc(alias = "gtk_snapshot_append_repeating_radial_gradient")]
386    fn append_repeating_radial_gradient(
387        &self,
388        bounds: &graphene::Rect,
389        center: &graphene::Point,
390        hradius: f32,
391        vradius: f32,
392        start: f32,
393        end: f32,
394        stops: &[gsk::ColorStop],
395    ) {
396        let n_stops = stops.len() as _;
397        unsafe {
398            ffi::gtk_snapshot_append_repeating_radial_gradient(
399                self.as_ref().to_glib_none().0,
400                bounds.to_glib_none().0,
401                center.to_glib_none().0,
402                hradius,
403                vradius,
404                start,
405                end,
406                stops.to_glib_none().0,
407                n_stops,
408            );
409        }
410    }
411
412    /// Creates a new render node drawing the @texture
413    /// into the given @bounds and appends it to the
414    /// current render node of @self.
415    ///
416    /// In contrast to [`append_texture()`][Self::append_texture()],
417    /// this function provides control about how the filter
418    /// that is used when scaling.
419    /// ## `texture`
420    /// the texture to render
421    /// ## `filter`
422    /// the filter to use
423    /// ## `bounds`
424    /// the bounds for the new node
425    #[cfg(feature = "v4_10")]
426    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
427    #[doc(alias = "gtk_snapshot_append_scaled_texture")]
428    fn append_scaled_texture(
429        &self,
430        texture: &impl IsA<gdk::Texture>,
431        filter: gsk::ScalingFilter,
432        bounds: &graphene::Rect,
433    ) {
434        unsafe {
435            ffi::gtk_snapshot_append_scaled_texture(
436                self.as_ref().to_glib_none().0,
437                texture.as_ref().to_glib_none().0,
438                filter.into_glib(),
439                bounds.to_glib_none().0,
440            );
441        }
442    }
443
444    /// A convenience method to stroke a path with a color.
445    ///
446    /// See [`push_stroke()`][Self::push_stroke()] if you need
447    /// to stroke a path with more complex content than
448    /// a color.
449    /// ## `path`
450    /// The path describing the area to fill
451    /// ## `stroke`
452    /// The stroke attributes
453    /// ## `color`
454    /// the color to fill the path with
455    #[cfg(feature = "v4_14")]
456    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
457    #[doc(alias = "gtk_snapshot_append_stroke")]
458    fn append_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke, color: &gdk::RGBA) {
459        unsafe {
460            ffi::gtk_snapshot_append_stroke(
461                self.as_ref().to_glib_none().0,
462                path.to_glib_none().0,
463                stroke.to_glib_none().0,
464                color.to_glib_none().0,
465            );
466        }
467    }
468
469    /// Creates a new render node drawing the @texture
470    /// into the given @bounds and appends it to the
471    /// current render node of @self.
472    ///
473    /// If the texture needs to be scaled to fill @bounds,
474    /// linear filtering is used. See [`append_scaled_texture()`][Self::append_scaled_texture()]
475    /// if you need other filtering, such as nearest-neighbour.
476    /// ## `texture`
477    /// the texture to render
478    /// ## `bounds`
479    /// the bounds for the new node
480    #[doc(alias = "gtk_snapshot_append_texture")]
481    fn append_texture(&self, texture: &impl IsA<gdk::Texture>, bounds: &graphene::Rect) {
482        unsafe {
483            ffi::gtk_snapshot_append_texture(
484                self.as_ref().to_glib_none().0,
485                texture.as_ref().to_glib_none().0,
486                bounds.to_glib_none().0,
487            );
488        }
489    }
490
491    /// Returns the node that was constructed by @self
492    /// and frees @self.
493    ///
494    /// See also `Gtk::Snapshot::to_node()`.
495    ///
496    /// # Returns
497    ///
498    /// a newly-created [`gsk::RenderNode`][crate::gsk::RenderNode]
499    #[doc(alias = "gtk_snapshot_free_to_node")]
500    #[doc(alias = "free_to_node")]
501    fn to_node(self) -> Option<gsk::RenderNode> {
502        unsafe {
503            from_glib_full(ffi::gtk_snapshot_free_to_node(
504                self.upcast().into_glib_ptr(),
505            ))
506        }
507    }
508
509    /// Returns a paintable for the node that was
510    /// constructed by @self and frees @self.
511    /// ## `size`
512    /// The size of the resulting paintable
513    ///   or [`None`] to use the bounds of the snapshot
514    ///
515    /// # Returns
516    ///
517    /// a newly-created [`gdk::Paintable`][crate::gdk::Paintable]
518    #[doc(alias = "gtk_snapshot_free_to_paintable")]
519    #[doc(alias = "free_to_paintable")]
520    fn to_paintable(self, size: Option<&graphene::Size>) -> Option<gdk::Paintable> {
521        unsafe {
522            from_glib_full(ffi::gtk_snapshot_free_to_paintable(
523                self.upcast().into_glib_ptr(),
524                size.to_glib_none().0,
525            ))
526        }
527    }
528
529    /// Removes the top element from the stack of render nodes and
530    /// adds it to the nearest [`gsk::GLShaderNode`][crate::gsk::GLShaderNode] below it.
531    ///
532    /// This must be called the same number of times as the number
533    /// of textures is needed for the shader in
534    /// [`push_gl_shader()`][Self::push_gl_shader()].
535    ///
536    /// # Deprecated since 4.16
537    ///
538    /// GTK's new Vulkan-focused rendering
539    ///   does not support this feature. Use [`GLArea`][crate::GLArea] for
540    ///   OpenGL rendering.
541    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
542    #[allow(deprecated)]
543    #[doc(alias = "gtk_snapshot_gl_shader_pop_texture")]
544    fn gl_shader_pop_texture(&self) {
545        unsafe {
546            ffi::gtk_snapshot_gl_shader_pop_texture(self.as_ref().to_glib_none().0);
547        }
548    }
549
550    /// Applies a perspective projection transform.
551    ///
552    /// See [`gsk::Transform::perspective()`][crate::gsk::Transform::perspective()] for a discussion on the details.
553    /// ## `depth`
554    /// distance of the z=0 plane
555    #[doc(alias = "gtk_snapshot_perspective")]
556    fn perspective(&self, depth: f32) {
557        unsafe {
558            ffi::gtk_snapshot_perspective(self.as_ref().to_glib_none().0, depth);
559        }
560    }
561
562    /// Removes the top element from the stack of render nodes,
563    /// and appends it to the node underneath it.
564    #[doc(alias = "gtk_snapshot_pop")]
565    fn pop(&self) {
566        unsafe {
567            ffi::gtk_snapshot_pop(self.as_ref().to_glib_none().0);
568        }
569    }
570
571    /// Blends together two images with the given blend mode.
572    ///
573    /// Until the first call to [`pop()`][Self::pop()], the
574    /// bottom image for the blend operation will be recorded.
575    /// After that call, the top image to be blended will be
576    /// recorded until the second call to [`pop()`][Self::pop()].
577    ///
578    /// Calling this function requires two subsequent calls
579    /// to [`pop()`][Self::pop()].
580    /// ## `blend_mode`
581    /// blend mode to use
582    #[doc(alias = "gtk_snapshot_push_blend")]
583    fn push_blend(&self, blend_mode: gsk::BlendMode) {
584        unsafe {
585            ffi::gtk_snapshot_push_blend(self.as_ref().to_glib_none().0, blend_mode.into_glib());
586        }
587    }
588
589    /// Blurs an image.
590    ///
591    /// The image is recorded until the next call to [`pop()`][Self::pop()].
592    /// ## `radius`
593    /// the blur radius to use. Must be positive
594    #[doc(alias = "gtk_snapshot_push_blur")]
595    fn push_blur(&self, radius: f64) {
596        unsafe {
597            ffi::gtk_snapshot_push_blur(self.as_ref().to_glib_none().0, radius);
598        }
599    }
600
601    /// Clips an image to a rectangle.
602    ///
603    /// The image is recorded until the next call to [`pop()`][Self::pop()].
604    /// ## `bounds`
605    /// the rectangle to clip to
606    #[doc(alias = "gtk_snapshot_push_clip")]
607    fn push_clip(&self, bounds: &graphene::Rect) {
608        unsafe {
609            ffi::gtk_snapshot_push_clip(self.as_ref().to_glib_none().0, bounds.to_glib_none().0);
610        }
611    }
612
613    /// Modifies the colors of an image by applying an affine transformation
614    /// in RGB space.
615    ///
616    /// In particular, the colors will be transformed by applying
617    ///
618    ///     pixel = transpose(color_matrix) * pixel + color_offset
619    ///
620    /// for every pixel. The transformation operates on unpremultiplied
621    /// colors, with color components ordered R, G, B, A.
622    ///
623    /// The image is recorded until the next call to [`pop()`][Self::pop()].
624    /// ## `color_matrix`
625    /// the color matrix to use
626    /// ## `color_offset`
627    /// the color offset to use
628    #[doc(alias = "gtk_snapshot_push_color_matrix")]
629    fn push_color_matrix(&self, color_matrix: &graphene::Matrix, color_offset: &graphene::Vec4) {
630        unsafe {
631            ffi::gtk_snapshot_push_color_matrix(
632                self.as_ref().to_glib_none().0,
633                color_matrix.to_glib_none().0,
634                color_offset.to_glib_none().0,
635            );
636        }
637    }
638
639    /// Snapshots a cross-fade operation between two images with the
640    /// given @progress.
641    ///
642    /// Until the first call to [`pop()`][Self::pop()], the start image
643    /// will be snapshot. After that call, the end image will be recorded
644    /// until the second call to [`pop()`][Self::pop()].
645    ///
646    /// Calling this function requires two subsequent calls
647    /// to [`pop()`][Self::pop()].
648    /// ## `progress`
649    /// progress between 0.0 and 1.0
650    #[doc(alias = "gtk_snapshot_push_cross_fade")]
651    fn push_cross_fade(&self, progress: f64) {
652        unsafe {
653            ffi::gtk_snapshot_push_cross_fade(self.as_ref().to_glib_none().0, progress);
654        }
655    }
656
657    /// Fills the area given by @path and @fill_rule with an image and discards everything
658    /// outside of it.
659    ///
660    /// The image is recorded until the next call to [`pop()`][Self::pop()].
661    ///
662    /// If you want to fill the path with a color, [`append_fill()`][Self::append_fill()]
663    /// may be more convenient.
664    /// ## `path`
665    /// The path describing the area to fill
666    /// ## `fill_rule`
667    /// The fill rule to use
668    #[cfg(feature = "v4_14")]
669    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
670    #[doc(alias = "gtk_snapshot_push_fill")]
671    fn push_fill(&self, path: &gsk::Path, fill_rule: gsk::FillRule) {
672        unsafe {
673            ffi::gtk_snapshot_push_fill(
674                self.as_ref().to_glib_none().0,
675                path.to_glib_none().0,
676                fill_rule.into_glib(),
677            );
678        }
679    }
680
681    /// Push a [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
682    ///
683    /// The node uses the given [`gsk::GLShader`][crate::gsk::GLShader] and uniform values
684    /// Additionally this takes a list of @n_children other nodes
685    /// which will be passed to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
686    ///
687    /// The @take_args argument is a block of data to use for uniform
688    /// arguments, as per types and offsets defined by the @shader.
689    /// Normally this is generated by `Gsk::GLShader::format_args()`
690    /// or `Gsk::ShaderArgsBuilder`.
691    ///
692    /// The snapshotter takes ownership of @take_args, so the caller should
693    /// not free it after this.
694    ///
695    /// If the renderer doesn't support GL shaders, or if there is any
696    /// problem when compiling the shader, then the node will draw pink.
697    /// You should use [`GLShader::compile()`][crate::gsk::GLShader::compile()] to ensure the @shader
698    /// will work for the renderer before using it.
699    ///
700    /// If the shader requires textures (see [`GLShader::n_textures()`][crate::gsk::GLShader::n_textures()]),
701    /// then it is expected that you call [`gl_shader_pop_texture()`][Self::gl_shader_pop_texture()]
702    /// the number of times that are required. Each of these calls will generate
703    /// a node that is added as a child to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode], which in turn
704    /// will render these offscreen and pass as a texture to the shader.
705    ///
706    /// Once all textures (if any) are pop:ed, you must call the regular
707    /// [`pop()`][Self::pop()].
708    ///
709    /// If you want to use pre-existing textures as input to the shader rather
710    /// than rendering new ones, use [`append_texture()`][Self::append_texture()] to
711    /// push a texture node. These will be used directly rather than being
712    /// re-rendered.
713    ///
714    /// For details on how to write shaders, see [`gsk::GLShader`][crate::gsk::GLShader].
715    ///
716    /// # Deprecated since 4.16
717    ///
718    /// GTK's new Vulkan-focused rendering
719    ///   does not support this feature. Use [`GLArea`][crate::GLArea] for
720    ///   OpenGL rendering.
721    /// ## `shader`
722    /// The code to run
723    /// ## `bounds`
724    /// the rectangle to render into
725    /// ## `take_args`
726    /// Data block with arguments for the shader.
727    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
728    #[allow(deprecated)]
729    #[doc(alias = "gtk_snapshot_push_gl_shader")]
730    fn push_gl_shader(
731        &self,
732        shader: &gsk::GLShader,
733        bounds: &graphene::Rect,
734        take_args: glib::Bytes,
735    ) {
736        unsafe {
737            ffi::gtk_snapshot_push_gl_shader(
738                self.as_ref().to_glib_none().0,
739                shader.to_glib_none().0,
740                bounds.to_glib_none().0,
741                take_args.into_glib_ptr(),
742            );
743        }
744    }
745
746    /// Until the first call to [`pop()`][Self::pop()], the
747    /// mask image for the mask operation will be recorded.
748    ///
749    /// After that call, the source image will be recorded until
750    /// the second call to [`pop()`][Self::pop()].
751    ///
752    /// Calling this function requires 2 subsequent calls to gtk_snapshot_pop().
753    /// ## `mask_mode`
754    /// mask mode to use
755    #[cfg(feature = "v4_10")]
756    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
757    #[doc(alias = "gtk_snapshot_push_mask")]
758    fn push_mask(&self, mask_mode: gsk::MaskMode) {
759        unsafe {
760            ffi::gtk_snapshot_push_mask(self.as_ref().to_glib_none().0, mask_mode.into_glib());
761        }
762    }
763
764    /// Modifies the opacity of an image.
765    ///
766    /// The image is recorded until the next call to [`pop()`][Self::pop()].
767    /// ## `opacity`
768    /// the opacity to use
769    #[doc(alias = "gtk_snapshot_push_opacity")]
770    fn push_opacity(&self, opacity: f64) {
771        unsafe {
772            ffi::gtk_snapshot_push_opacity(self.as_ref().to_glib_none().0, opacity);
773        }
774    }
775
776    /// Creates a node that repeats the child node.
777    ///
778    /// The child is recorded until the next call to [`pop()`][Self::pop()].
779    /// ## `bounds`
780    /// the bounds within which to repeat
781    /// ## `child_bounds`
782    /// the bounds of the child or [`None`]
783    ///   to use the full size of the collected child node
784    #[doc(alias = "gtk_snapshot_push_repeat")]
785    fn push_repeat(&self, bounds: &graphene::Rect, child_bounds: Option<&graphene::Rect>) {
786        unsafe {
787            ffi::gtk_snapshot_push_repeat(
788                self.as_ref().to_glib_none().0,
789                bounds.to_glib_none().0,
790                child_bounds.to_glib_none().0,
791            );
792        }
793    }
794
795    /// Clips an image to a rounded rectangle.
796    ///
797    /// The image is recorded until the next call to [`pop()`][Self::pop()].
798    /// ## `bounds`
799    /// the rounded rectangle to clip to
800    #[doc(alias = "gtk_snapshot_push_rounded_clip")]
801    fn push_rounded_clip(&self, bounds: &gsk::RoundedRect) {
802        unsafe {
803            ffi::gtk_snapshot_push_rounded_clip(
804                self.as_ref().to_glib_none().0,
805                bounds.to_glib_none().0,
806            );
807        }
808    }
809
810    /// Applies a shadow to an image.
811    ///
812    /// The image is recorded until the next call to [`pop()`][Self::pop()].
813    /// ## `shadow`
814    /// the first shadow specification
815    #[doc(alias = "gtk_snapshot_push_shadow")]
816    fn push_shadow(&self, shadow: &[gsk::Shadow]) {
817        let n_shadows = shadow.len() as _;
818        unsafe {
819            ffi::gtk_snapshot_push_shadow(
820                self.as_ref().to_glib_none().0,
821                shadow.to_glib_none().0,
822                n_shadows,
823            );
824        }
825    }
826
827    /// Strokes the given @path with the attributes given by @stroke and
828    /// an image.
829    ///
830    /// The image is recorded until the next call to [`pop()`][Self::pop()].
831    ///
832    /// Note that the strokes are subject to the same transformation as
833    /// everything else, so uneven scaling will cause horizontal and vertical
834    /// strokes to have different widths.
835    ///
836    /// If you want to stroke the path with a color, [`append_stroke()`][Self::append_stroke()]
837    /// may be more convenient.
838    /// ## `path`
839    /// The path to stroke
840    /// ## `stroke`
841    /// The stroke attributes
842    #[cfg(feature = "v4_14")]
843    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
844    #[doc(alias = "gtk_snapshot_push_stroke")]
845    fn push_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke) {
846        unsafe {
847            ffi::gtk_snapshot_push_stroke(
848                self.as_ref().to_glib_none().0,
849                path.to_glib_none().0,
850                stroke.to_glib_none().0,
851            );
852        }
853    }
854
855    /// Creates a render node for the CSS background according to @context,
856    /// and appends it to the current node of @self, without changing
857    /// the current node.
858    ///
859    /// # Deprecated since 4.10
860    ///
861    /// ## `context`
862    /// the style context that defines the background
863    /// ## `x`
864    /// X origin of the rectangle
865    /// ## `y`
866    /// Y origin of the rectangle
867    /// ## `width`
868    /// rectangle width
869    /// ## `height`
870    /// rectangle height
871    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
872    #[allow(deprecated)]
873    #[doc(alias = "gtk_snapshot_render_background")]
874    fn render_background(
875        &self,
876        context: &impl IsA<StyleContext>,
877        x: f64,
878        y: f64,
879        width: f64,
880        height: f64,
881    ) {
882        unsafe {
883            ffi::gtk_snapshot_render_background(
884                self.as_ref().to_glib_none().0,
885                context.as_ref().to_glib_none().0,
886                x,
887                y,
888                width,
889                height,
890            );
891        }
892    }
893
894    /// Creates a render node for the focus outline according to @context,
895    /// and appends it to the current node of @self, without changing
896    /// the current node.
897    ///
898    /// # Deprecated since 4.10
899    ///
900    /// ## `context`
901    /// the style context that defines the focus ring
902    /// ## `x`
903    /// X origin of the rectangle
904    /// ## `y`
905    /// Y origin of the rectangle
906    /// ## `width`
907    /// rectangle width
908    /// ## `height`
909    /// rectangle height
910    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
911    #[allow(deprecated)]
912    #[doc(alias = "gtk_snapshot_render_focus")]
913    fn render_focus(
914        &self,
915        context: &impl IsA<StyleContext>,
916        x: f64,
917        y: f64,
918        width: f64,
919        height: f64,
920    ) {
921        unsafe {
922            ffi::gtk_snapshot_render_focus(
923                self.as_ref().to_glib_none().0,
924                context.as_ref().to_glib_none().0,
925                x,
926                y,
927                width,
928                height,
929            );
930        }
931    }
932
933    /// Creates a render node for the CSS border according to @context,
934    /// and appends it to the current node of @self, without changing
935    /// the current node.
936    ///
937    /// # Deprecated since 4.10
938    ///
939    /// ## `context`
940    /// the style context that defines the frame
941    /// ## `x`
942    /// X origin of the rectangle
943    /// ## `y`
944    /// Y origin of the rectangle
945    /// ## `width`
946    /// rectangle width
947    /// ## `height`
948    /// rectangle height
949    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
950    #[allow(deprecated)]
951    #[doc(alias = "gtk_snapshot_render_frame")]
952    fn render_frame(
953        &self,
954        context: &impl IsA<StyleContext>,
955        x: f64,
956        y: f64,
957        width: f64,
958        height: f64,
959    ) {
960        unsafe {
961            ffi::gtk_snapshot_render_frame(
962                self.as_ref().to_glib_none().0,
963                context.as_ref().to_glib_none().0,
964                x,
965                y,
966                width,
967                height,
968            );
969        }
970    }
971
972    /// Draws a text caret using @self at the specified index of @layout.
973    ///
974    /// # Deprecated since 4.10
975    ///
976    /// ## `context`
977    /// a [`StyleContext`][crate::StyleContext]
978    /// ## `x`
979    /// X origin
980    /// ## `y`
981    /// Y origin
982    /// ## `layout`
983    /// the [`pango::Layout`][crate::pango::Layout] of the text
984    /// ## `index`
985    /// the index in the [`pango::Layout`][crate::pango::Layout]
986    /// ## `direction`
987    /// the [`pango::Direction`][crate::pango::Direction] of the text
988    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
989    #[allow(deprecated)]
990    #[doc(alias = "gtk_snapshot_render_insertion_cursor")]
991    fn render_insertion_cursor(
992        &self,
993        context: &impl IsA<StyleContext>,
994        x: f64,
995        y: f64,
996        layout: &pango::Layout,
997        index: i32,
998        direction: pango::Direction,
999    ) {
1000        unsafe {
1001            ffi::gtk_snapshot_render_insertion_cursor(
1002                self.as_ref().to_glib_none().0,
1003                context.as_ref().to_glib_none().0,
1004                x,
1005                y,
1006                layout.to_glib_none().0,
1007                index,
1008                direction.into_glib(),
1009            );
1010        }
1011    }
1012
1013    /// Creates a render node for rendering @layout according to the style
1014    /// information in @context, and appends it to the current node of @self,
1015    /// without changing the current node.
1016    ///
1017    /// # Deprecated since 4.10
1018    ///
1019    /// ## `context`
1020    /// the style context that defines the text
1021    /// ## `x`
1022    /// X origin of the rectangle
1023    /// ## `y`
1024    /// Y origin of the rectangle
1025    /// ## `layout`
1026    /// the [`pango::Layout`][crate::pango::Layout] to render
1027    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1028    #[allow(deprecated)]
1029    #[doc(alias = "gtk_snapshot_render_layout")]
1030    fn render_layout(
1031        &self,
1032        context: &impl IsA<StyleContext>,
1033        x: f64,
1034        y: f64,
1035        layout: &pango::Layout,
1036    ) {
1037        unsafe {
1038            ffi::gtk_snapshot_render_layout(
1039                self.as_ref().to_glib_none().0,
1040                context.as_ref().to_glib_none().0,
1041                x,
1042                y,
1043                layout.to_glib_none().0,
1044            );
1045        }
1046    }
1047
1048    /// Restores @self to the state saved by a preceding call to
1049    /// [`save()`][Self::save()] and removes that state from the stack of
1050    /// saved states.
1051    #[doc(alias = "gtk_snapshot_restore")]
1052    fn restore(&self) {
1053        unsafe {
1054            ffi::gtk_snapshot_restore(self.as_ref().to_glib_none().0);
1055        }
1056    }
1057
1058    /// Rotates @@self's coordinate system by @angle degrees in 2D space -
1059    /// or in 3D speak, rotates around the Z axis. The rotation happens around
1060    /// the origin point of (0, 0) in the @self's current coordinate system.
1061    ///
1062    /// To rotate around axes other than the Z axis, use [`gsk::Transform::rotate_3d()`][crate::gsk::Transform::rotate_3d()].
1063    /// ## `angle`
1064    /// the rotation angle, in degrees (clockwise)
1065    #[doc(alias = "gtk_snapshot_rotate")]
1066    fn rotate(&self, angle: f32) {
1067        unsafe {
1068            ffi::gtk_snapshot_rotate(self.as_ref().to_glib_none().0, angle);
1069        }
1070    }
1071
1072    /// Rotates @self's coordinate system by @angle degrees around @axis.
1073    ///
1074    /// For a rotation in 2D space, use [`gsk::Transform::rotate()`][crate::gsk::Transform::rotate()].
1075    /// ## `angle`
1076    /// the rotation angle, in degrees (clockwise)
1077    /// ## `axis`
1078    /// The rotation axis
1079    #[doc(alias = "gtk_snapshot_rotate_3d")]
1080    fn rotate_3d(&self, angle: f32, axis: &graphene::Vec3) {
1081        unsafe {
1082            ffi::gtk_snapshot_rotate_3d(
1083                self.as_ref().to_glib_none().0,
1084                angle,
1085                axis.to_glib_none().0,
1086            );
1087        }
1088    }
1089
1090    /// Makes a copy of the current state of @self and saves it
1091    /// on an internal stack.
1092    ///
1093    /// When [`restore()`][Self::restore()] is called, @self will
1094    /// be restored to the saved state.
1095    ///
1096    /// Multiple calls to [`save()`][Self::save()] and [`restore()`][Self::restore()]
1097    /// can be nested; each call to `gtk_snapshot_restore()` restores the state from
1098    /// the matching paired `gtk_snapshot_save()`.
1099    ///
1100    /// It is necessary to clear all saved states with corresponding
1101    /// calls to `gtk_snapshot_restore()`.
1102    #[doc(alias = "gtk_snapshot_save")]
1103    fn save(&self) {
1104        unsafe {
1105            ffi::gtk_snapshot_save(self.as_ref().to_glib_none().0);
1106        }
1107    }
1108
1109    /// Scales @self's coordinate system in 2-dimensional space by
1110    /// the given factors.
1111    ///
1112    /// Use [`scale_3d()`][Self::scale_3d()] to scale in all 3 dimensions.
1113    /// ## `factor_x`
1114    /// scaling factor on the X axis
1115    /// ## `factor_y`
1116    /// scaling factor on the Y axis
1117    #[doc(alias = "gtk_snapshot_scale")]
1118    fn scale(&self, factor_x: f32, factor_y: f32) {
1119        unsafe {
1120            ffi::gtk_snapshot_scale(self.as_ref().to_glib_none().0, factor_x, factor_y);
1121        }
1122    }
1123
1124    /// Scales @self's coordinate system by the given factors.
1125    /// ## `factor_x`
1126    /// scaling factor on the X axis
1127    /// ## `factor_y`
1128    /// scaling factor on the Y axis
1129    /// ## `factor_z`
1130    /// scaling factor on the Z axis
1131    #[doc(alias = "gtk_snapshot_scale_3d")]
1132    fn scale_3d(&self, factor_x: f32, factor_y: f32, factor_z: f32) {
1133        unsafe {
1134            ffi::gtk_snapshot_scale_3d(
1135                self.as_ref().to_glib_none().0,
1136                factor_x,
1137                factor_y,
1138                factor_z,
1139            );
1140        }
1141    }
1142
1143    /// Transforms @self's coordinate system with the given @transform.
1144    /// ## `transform`
1145    /// the transform to apply
1146    #[doc(alias = "gtk_snapshot_transform")]
1147    fn transform(&self, transform: Option<&gsk::Transform>) {
1148        unsafe {
1149            ffi::gtk_snapshot_transform(self.as_ref().to_glib_none().0, transform.to_glib_none().0);
1150        }
1151    }
1152
1153    /// Transforms @self's coordinate system with the given @matrix.
1154    /// ## `matrix`
1155    /// the matrix to multiply the transform with
1156    #[doc(alias = "gtk_snapshot_transform_matrix")]
1157    fn transform_matrix(&self, matrix: &graphene::Matrix) {
1158        unsafe {
1159            ffi::gtk_snapshot_transform_matrix(
1160                self.as_ref().to_glib_none().0,
1161                matrix.to_glib_none().0,
1162            );
1163        }
1164    }
1165
1166    /// Translates @self's coordinate system by @point in 2-dimensional space.
1167    /// ## `point`
1168    /// the point to translate the snapshot by
1169    #[doc(alias = "gtk_snapshot_translate")]
1170    fn translate(&self, point: &graphene::Point) {
1171        unsafe {
1172            ffi::gtk_snapshot_translate(self.as_ref().to_glib_none().0, point.to_glib_none().0);
1173        }
1174    }
1175
1176    /// Translates @self's coordinate system by @point.
1177    /// ## `point`
1178    /// the point to translate the snapshot by
1179    #[doc(alias = "gtk_snapshot_translate_3d")]
1180    fn translate_3d(&self, point: &graphene::Point3D) {
1181        unsafe {
1182            ffi::gtk_snapshot_translate_3d(self.as_ref().to_glib_none().0, point.to_glib_none().0);
1183        }
1184    }
1185}
1186
1187impl<O: IsA<Snapshot>> SnapshotExt for O {}