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    /// 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    /// Modifies the colors of an image by applying a transfer
640    /// function for each component.
641    ///
642    /// The transfer functions operate on unpremultiplied colors.
643    ///
644    /// The image is recorded until the next call to [`pop()`][Self::pop()].
645    /// ## `red`
646    /// the transfer for the red component
647    /// ## `green`
648    /// the transfer for the green component
649    /// ## `blue`
650    /// the transfer for the blue component
651    /// ## `alpha`
652    /// the transfer for the alpha component
653    #[cfg(feature = "v4_20")]
654    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
655    #[doc(alias = "gtk_snapshot_push_component_transfer")]
656    fn push_component_transfer(
657        &self,
658        red: &gsk::ComponentTransfer,
659        green: &gsk::ComponentTransfer,
660        blue: &gsk::ComponentTransfer,
661        alpha: &gsk::ComponentTransfer,
662    ) {
663        unsafe {
664            ffi::gtk_snapshot_push_component_transfer(
665                self.as_ref().to_glib_none().0,
666                red.to_glib_none().0,
667                green.to_glib_none().0,
668                blue.to_glib_none().0,
669                alpha.to_glib_none().0,
670            );
671        }
672    }
673
674    /// Snapshots a cross-fade operation between two images with the
675    /// given @progress.
676    ///
677    /// Until the first call to [`pop()`][Self::pop()], the start image
678    /// will be snapshot. After that call, the end image will be recorded
679    /// until the second call to [`pop()`][Self::pop()].
680    ///
681    /// Calling this function requires two subsequent calls
682    /// to [`pop()`][Self::pop()].
683    /// ## `progress`
684    /// progress between 0.0 and 1.0
685    #[doc(alias = "gtk_snapshot_push_cross_fade")]
686    fn push_cross_fade(&self, progress: f64) {
687        unsafe {
688            ffi::gtk_snapshot_push_cross_fade(self.as_ref().to_glib_none().0, progress);
689        }
690    }
691
692    /// Fills the area given by @path and @fill_rule with an image and discards everything
693    /// outside of it.
694    ///
695    /// The image is recorded until the next call to [`pop()`][Self::pop()].
696    ///
697    /// If you want to fill the path with a color, [`append_fill()`][Self::append_fill()]
698    /// than rendering new ones, use [`append_fill()`][Self::append_fill()]
699    /// may be more convenient.
700    /// ## `path`
701    /// The path describing the area to fill
702    /// ## `fill_rule`
703    /// The fill rule to use
704    #[cfg(feature = "v4_14")]
705    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
706    #[doc(alias = "gtk_snapshot_push_fill")]
707    fn push_fill(&self, path: &gsk::Path, fill_rule: gsk::FillRule) {
708        unsafe {
709            ffi::gtk_snapshot_push_fill(
710                self.as_ref().to_glib_none().0,
711                path.to_glib_none().0,
712                fill_rule.into_glib(),
713            );
714        }
715    }
716
717    /// Push a [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
718    ///
719    /// The node uses the given [`gsk::GLShader`][crate::gsk::GLShader] and uniform values
720    /// Additionally this takes a list of @n_children other nodes
721    /// which will be passed to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
722    ///
723    /// The @take_args argument is a block of data to use for uniform
724    /// arguments, as per types and offsets defined by the @shader.
725    /// Normally this is generated by `Gsk::GLShader::format_args()`
726    /// or `Gsk::ShaderArgsBuilder`.
727    ///
728    /// The snapshotter takes ownership of @take_args, so the caller should
729    /// not free it after this.
730    ///
731    /// If the renderer doesn't support GL shaders, or if there is any
732    /// problem when compiling the shader, then the node will draw pink.
733    /// You should use [`GLShader::compile()`][crate::gsk::GLShader::compile()] to ensure the @shader
734    /// will work for the renderer before using it.
735    ///
736    /// If the shader requires textures (see [`GLShader::n_textures()`][crate::gsk::GLShader::n_textures()]),
737    /// then it is expected that you call [`gl_shader_pop_texture()`][Self::gl_shader_pop_texture()]
738    /// the number of times that are required. Each of these calls will generate
739    /// a node that is added as a child to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode], which in turn
740    /// will render these offscreen and pass as a texture to the shader.
741    ///
742    /// Once all textures (if any) are pop:ed, you must call the regular
743    /// [`pop()`][Self::pop()].
744    ///
745    /// If you want to use pre-existing textures as input to the shader rather
746    /// than rendering new ones, use [`append_texture()`][Self::append_texture()] to
747    /// push a texture node. These will be used directly rather than being
748    /// re-rendered.
749    ///
750    /// For details on how to write shaders, see [`gsk::GLShader`][crate::gsk::GLShader].
751    ///
752    /// # Deprecated since 4.16
753    ///
754    /// GTK's new Vulkan-focused rendering
755    ///   does not support this feature. Use [`GLArea`][crate::GLArea] for
756    ///   OpenGL rendering.
757    /// ## `shader`
758    /// The code to run
759    /// ## `bounds`
760    /// the rectangle to render into
761    /// ## `take_args`
762    /// Data block with arguments for the shader.
763    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
764    #[allow(deprecated)]
765    #[doc(alias = "gtk_snapshot_push_gl_shader")]
766    fn push_gl_shader(
767        &self,
768        shader: &gsk::GLShader,
769        bounds: &graphene::Rect,
770        take_args: glib::Bytes,
771    ) {
772        unsafe {
773            ffi::gtk_snapshot_push_gl_shader(
774                self.as_ref().to_glib_none().0,
775                shader.to_glib_none().0,
776                bounds.to_glib_none().0,
777                take_args.into_glib_ptr(),
778            );
779        }
780    }
781
782    /// Until the first call to [`pop()`][Self::pop()], the
783    /// mask image for the mask operation will be recorded.
784    ///
785    /// After that call, the source image will be recorded until
786    /// the second call to [`pop()`][Self::pop()].
787    ///
788    /// Calling this function requires 2 subsequent calls to gtk_snapshot_pop().
789    /// ## `mask_mode`
790    /// mask mode to use
791    #[cfg(feature = "v4_10")]
792    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
793    #[doc(alias = "gtk_snapshot_push_mask")]
794    fn push_mask(&self, mask_mode: gsk::MaskMode) {
795        unsafe {
796            ffi::gtk_snapshot_push_mask(self.as_ref().to_glib_none().0, mask_mode.into_glib());
797        }
798    }
799
800    /// Modifies the opacity of an image.
801    ///
802    /// The image is recorded until the next call to [`pop()`][Self::pop()].
803    /// ## `opacity`
804    /// the opacity to use
805    #[doc(alias = "gtk_snapshot_push_opacity")]
806    fn push_opacity(&self, opacity: f64) {
807        unsafe {
808            ffi::gtk_snapshot_push_opacity(self.as_ref().to_glib_none().0, opacity);
809        }
810    }
811
812    /// Creates a node that repeats the child node.
813    ///
814    /// The child is recorded until the next call to [`pop()`][Self::pop()].
815    /// ## `bounds`
816    /// the bounds within which to repeat
817    /// ## `child_bounds`
818    /// the bounds of the child or [`None`]
819    ///   to use the full size of the collected child node
820    #[doc(alias = "gtk_snapshot_push_repeat")]
821    fn push_repeat(&self, bounds: &graphene::Rect, child_bounds: Option<&graphene::Rect>) {
822        unsafe {
823            ffi::gtk_snapshot_push_repeat(
824                self.as_ref().to_glib_none().0,
825                bounds.to_glib_none().0,
826                child_bounds.to_glib_none().0,
827            );
828        }
829    }
830
831    /// Clips an image to a rounded rectangle.
832    ///
833    /// The image is recorded until the next call to [`pop()`][Self::pop()].
834    /// ## `bounds`
835    /// the rounded rectangle to clip to
836    #[doc(alias = "gtk_snapshot_push_rounded_clip")]
837    fn push_rounded_clip(&self, bounds: &gsk::RoundedRect) {
838        unsafe {
839            ffi::gtk_snapshot_push_rounded_clip(
840                self.as_ref().to_glib_none().0,
841                bounds.to_glib_none().0,
842            );
843        }
844    }
845
846    /// Applies a shadow to an image.
847    ///
848    /// The image is recorded until the next call to [`pop()`][Self::pop()].
849    /// ## `shadow`
850    /// the first shadow specification
851    #[doc(alias = "gtk_snapshot_push_shadow")]
852    fn push_shadow(&self, shadow: &[gsk::Shadow]) {
853        let n_shadows = shadow.len() as _;
854        unsafe {
855            ffi::gtk_snapshot_push_shadow(
856                self.as_ref().to_glib_none().0,
857                shadow.to_glib_none().0,
858                n_shadows,
859            );
860        }
861    }
862
863    /// Strokes the given @path with the attributes given by @stroke and
864    /// an image.
865    ///
866    /// The image is recorded until the next call to [`pop()`][Self::pop()].
867    ///
868    /// Note that the strokes are subject to the same transformation as
869    /// everything else, so uneven scaling will cause horizontal and vertical
870    /// strokes to have different widths.
871    ///
872    /// If you want to stroke the path with a color, [`append_stroke()`][Self::append_stroke()]
873    /// may be more convenient.
874    /// ## `path`
875    /// The path to stroke
876    /// ## `stroke`
877    /// The stroke attributes
878    #[cfg(feature = "v4_14")]
879    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
880    #[doc(alias = "gtk_snapshot_push_stroke")]
881    fn push_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke) {
882        unsafe {
883            ffi::gtk_snapshot_push_stroke(
884                self.as_ref().to_glib_none().0,
885                path.to_glib_none().0,
886                stroke.to_glib_none().0,
887            );
888        }
889    }
890
891    /// Creates a render node for the CSS background according to @context,
892    /// and appends it to the current node of @self, without changing
893    /// the current node.
894    ///
895    /// # Deprecated since 4.10
896    ///
897    /// ## `context`
898    /// the style context that defines the background
899    /// ## `x`
900    /// X origin of the rectangle
901    /// ## `y`
902    /// Y origin of the rectangle
903    /// ## `width`
904    /// rectangle width
905    /// ## `height`
906    /// rectangle height
907    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
908    #[allow(deprecated)]
909    #[doc(alias = "gtk_snapshot_render_background")]
910    fn render_background(
911        &self,
912        context: &impl IsA<StyleContext>,
913        x: f64,
914        y: f64,
915        width: f64,
916        height: f64,
917    ) {
918        unsafe {
919            ffi::gtk_snapshot_render_background(
920                self.as_ref().to_glib_none().0,
921                context.as_ref().to_glib_none().0,
922                x,
923                y,
924                width,
925                height,
926            );
927        }
928    }
929
930    /// Creates a render node for the focus outline according to @context,
931    /// and appends it to the current node of @self, without changing
932    /// the current node.
933    ///
934    /// # Deprecated since 4.10
935    ///
936    /// ## `context`
937    /// the style context that defines the focus ring
938    /// ## `x`
939    /// X origin of the rectangle
940    /// ## `y`
941    /// Y origin of the rectangle
942    /// ## `width`
943    /// rectangle width
944    /// ## `height`
945    /// rectangle height
946    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
947    #[allow(deprecated)]
948    #[doc(alias = "gtk_snapshot_render_focus")]
949    fn render_focus(
950        &self,
951        context: &impl IsA<StyleContext>,
952        x: f64,
953        y: f64,
954        width: f64,
955        height: f64,
956    ) {
957        unsafe {
958            ffi::gtk_snapshot_render_focus(
959                self.as_ref().to_glib_none().0,
960                context.as_ref().to_glib_none().0,
961                x,
962                y,
963                width,
964                height,
965            );
966        }
967    }
968
969    /// Creates a render node for the CSS border according to @context,
970    /// and appends it to the current node of @self, without changing
971    /// the current node.
972    ///
973    /// # Deprecated since 4.10
974    ///
975    /// ## `context`
976    /// the style context that defines the frame
977    /// ## `x`
978    /// X origin of the rectangle
979    /// ## `y`
980    /// Y origin of the rectangle
981    /// ## `width`
982    /// rectangle width
983    /// ## `height`
984    /// rectangle height
985    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
986    #[allow(deprecated)]
987    #[doc(alias = "gtk_snapshot_render_frame")]
988    fn render_frame(
989        &self,
990        context: &impl IsA<StyleContext>,
991        x: f64,
992        y: f64,
993        width: f64,
994        height: f64,
995    ) {
996        unsafe {
997            ffi::gtk_snapshot_render_frame(
998                self.as_ref().to_glib_none().0,
999                context.as_ref().to_glib_none().0,
1000                x,
1001                y,
1002                width,
1003                height,
1004            );
1005        }
1006    }
1007
1008    /// Draws a text caret using @self at the specified index of @layout.
1009    ///
1010    /// # Deprecated since 4.10
1011    ///
1012    /// ## `context`
1013    /// a [`StyleContext`][crate::StyleContext]
1014    /// ## `x`
1015    /// X origin
1016    /// ## `y`
1017    /// Y origin
1018    /// ## `layout`
1019    /// the [`pango::Layout`][crate::pango::Layout] of the text
1020    /// ## `index`
1021    /// the index in the [`pango::Layout`][crate::pango::Layout]
1022    /// ## `direction`
1023    /// the [`pango::Direction`][crate::pango::Direction] of the text
1024    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1025    #[allow(deprecated)]
1026    #[doc(alias = "gtk_snapshot_render_insertion_cursor")]
1027    fn render_insertion_cursor(
1028        &self,
1029        context: &impl IsA<StyleContext>,
1030        x: f64,
1031        y: f64,
1032        layout: &pango::Layout,
1033        index: i32,
1034        direction: pango::Direction,
1035    ) {
1036        unsafe {
1037            ffi::gtk_snapshot_render_insertion_cursor(
1038                self.as_ref().to_glib_none().0,
1039                context.as_ref().to_glib_none().0,
1040                x,
1041                y,
1042                layout.to_glib_none().0,
1043                index,
1044                direction.into_glib(),
1045            );
1046        }
1047    }
1048
1049    /// Creates a render node for rendering @layout according to the style
1050    /// information in @context, and appends it to the current node of @self,
1051    /// without changing the current node.
1052    ///
1053    /// # Deprecated since 4.10
1054    ///
1055    /// ## `context`
1056    /// the style context that defines the text
1057    /// ## `x`
1058    /// X origin of the rectangle
1059    /// ## `y`
1060    /// Y origin of the rectangle
1061    /// ## `layout`
1062    /// the [`pango::Layout`][crate::pango::Layout] to render
1063    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1064    #[allow(deprecated)]
1065    #[doc(alias = "gtk_snapshot_render_layout")]
1066    fn render_layout(
1067        &self,
1068        context: &impl IsA<StyleContext>,
1069        x: f64,
1070        y: f64,
1071        layout: &pango::Layout,
1072    ) {
1073        unsafe {
1074            ffi::gtk_snapshot_render_layout(
1075                self.as_ref().to_glib_none().0,
1076                context.as_ref().to_glib_none().0,
1077                x,
1078                y,
1079                layout.to_glib_none().0,
1080            );
1081        }
1082    }
1083
1084    /// Restores @self to the state saved by a preceding call to
1085    /// [`save()`][Self::save()] and removes that state from the stack of
1086    /// saved states.
1087    #[doc(alias = "gtk_snapshot_restore")]
1088    fn restore(&self) {
1089        unsafe {
1090            ffi::gtk_snapshot_restore(self.as_ref().to_glib_none().0);
1091        }
1092    }
1093
1094    /// Rotates @@self's coordinate system by @angle degrees in 2D space -
1095    /// or in 3D speak, rotates around the Z axis. The rotation happens around
1096    /// the origin point of (0, 0) in the @self's current coordinate system.
1097    ///
1098    /// To rotate around axes other than the Z axis, use [`gsk::Transform::rotate_3d()`][crate::gsk::Transform::rotate_3d()].
1099    /// ## `angle`
1100    /// the rotation angle, in degrees (clockwise)
1101    #[doc(alias = "gtk_snapshot_rotate")]
1102    fn rotate(&self, angle: f32) {
1103        unsafe {
1104            ffi::gtk_snapshot_rotate(self.as_ref().to_glib_none().0, angle);
1105        }
1106    }
1107
1108    /// Rotates @self's coordinate system by @angle degrees around @axis.
1109    ///
1110    /// For a rotation in 2D space, use [`gsk::Transform::rotate()`][crate::gsk::Transform::rotate()].
1111    /// ## `angle`
1112    /// the rotation angle, in degrees (clockwise)
1113    /// ## `axis`
1114    /// The rotation axis
1115    #[doc(alias = "gtk_snapshot_rotate_3d")]
1116    fn rotate_3d(&self, angle: f32, axis: &graphene::Vec3) {
1117        unsafe {
1118            ffi::gtk_snapshot_rotate_3d(
1119                self.as_ref().to_glib_none().0,
1120                angle,
1121                axis.to_glib_none().0,
1122            );
1123        }
1124    }
1125
1126    /// Makes a copy of the current state of @self and saves it
1127    /// on an internal stack.
1128    ///
1129    /// When [`restore()`][Self::restore()] is called, @self will
1130    /// be restored to the saved state.
1131    ///
1132    /// Multiple calls to [`save()`][Self::save()] and [`restore()`][Self::restore()]
1133    /// can be nested; each call to `gtk_snapshot_restore()` restores the state from
1134    /// the matching paired `gtk_snapshot_save()`.
1135    ///
1136    /// It is necessary to clear all saved states with corresponding
1137    /// calls to `gtk_snapshot_restore()`.
1138    #[doc(alias = "gtk_snapshot_save")]
1139    fn save(&self) {
1140        unsafe {
1141            ffi::gtk_snapshot_save(self.as_ref().to_glib_none().0);
1142        }
1143    }
1144
1145    /// Scales @self's coordinate system in 2-dimensional space by
1146    /// the given factors.
1147    ///
1148    /// Use [`scale_3d()`][Self::scale_3d()] to scale in all 3 dimensions.
1149    /// ## `factor_x`
1150    /// scaling factor on the X axis
1151    /// ## `factor_y`
1152    /// scaling factor on the Y axis
1153    #[doc(alias = "gtk_snapshot_scale")]
1154    fn scale(&self, factor_x: f32, factor_y: f32) {
1155        unsafe {
1156            ffi::gtk_snapshot_scale(self.as_ref().to_glib_none().0, factor_x, factor_y);
1157        }
1158    }
1159
1160    /// Scales @self's coordinate system by the given factors.
1161    /// ## `factor_x`
1162    /// scaling factor on the X axis
1163    /// ## `factor_y`
1164    /// scaling factor on the Y axis
1165    /// ## `factor_z`
1166    /// scaling factor on the Z axis
1167    #[doc(alias = "gtk_snapshot_scale_3d")]
1168    fn scale_3d(&self, factor_x: f32, factor_y: f32, factor_z: f32) {
1169        unsafe {
1170            ffi::gtk_snapshot_scale_3d(
1171                self.as_ref().to_glib_none().0,
1172                factor_x,
1173                factor_y,
1174                factor_z,
1175            );
1176        }
1177    }
1178
1179    /// Transforms @self's coordinate system with the given @transform.
1180    /// ## `transform`
1181    /// the transform to apply
1182    #[doc(alias = "gtk_snapshot_transform")]
1183    fn transform(&self, transform: Option<&gsk::Transform>) {
1184        unsafe {
1185            ffi::gtk_snapshot_transform(self.as_ref().to_glib_none().0, transform.to_glib_none().0);
1186        }
1187    }
1188
1189    /// Transforms @self's coordinate system with the given @matrix.
1190    /// ## `matrix`
1191    /// the matrix to multiply the transform with
1192    #[doc(alias = "gtk_snapshot_transform_matrix")]
1193    fn transform_matrix(&self, matrix: &graphene::Matrix) {
1194        unsafe {
1195            ffi::gtk_snapshot_transform_matrix(
1196                self.as_ref().to_glib_none().0,
1197                matrix.to_glib_none().0,
1198            );
1199        }
1200    }
1201
1202    /// Translates @self's coordinate system by @point in 2-dimensional space.
1203    /// ## `point`
1204    /// the point to translate the snapshot by
1205    #[doc(alias = "gtk_snapshot_translate")]
1206    fn translate(&self, point: &graphene::Point) {
1207        unsafe {
1208            ffi::gtk_snapshot_translate(self.as_ref().to_glib_none().0, point.to_glib_none().0);
1209        }
1210    }
1211
1212    /// Translates @self's coordinate system by @point.
1213    /// ## `point`
1214    /// the point to translate the snapshot by
1215    #[doc(alias = "gtk_snapshot_translate_3d")]
1216    fn translate_3d(&self, point: &graphene::Point3D) {
1217        unsafe {
1218            ffi::gtk_snapshot_translate_3d(self.as_ref().to_glib_none().0, point.to_glib_none().0);
1219        }
1220    }
1221}
1222
1223impl<O: IsA<Snapshot>> SnapshotExt for O {}