Skip to main content

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::{StyleContext, ffi};
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    /// Creates a new render node that pastes the contents
299    /// copied by a previous call to `Gtk::Snapshot::push_copy()`
300    /// ## `bounds`
301    /// the bounds for the new node
302    /// ## `nth`
303    /// the index of the copy, with 0 being the latest
304    ///  copy, 1 being the copy before that, and so on.
305    #[cfg(feature = "v4_22")]
306    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
307    #[doc(alias = "gtk_snapshot_append_paste")]
308    fn append_paste(&self, bounds: &graphene::Rect, nth: usize) {
309        unsafe {
310            ffi::gtk_snapshot_append_paste(
311                self.as_ref().to_glib_none().0,
312                bounds.to_glib_none().0,
313                nth,
314            );
315        }
316    }
317
318    /// Appends a radial gradient node with the given stops to @self.
319    /// ## `bounds`
320    /// the rectangle to render the readial gradient into
321    /// ## `center`
322    /// the center point for the radial gradient
323    /// ## `hradius`
324    /// the horizontal radius
325    /// ## `vradius`
326    /// the vertical radius
327    /// ## `start`
328    /// the start position (on the horizontal axis)
329    /// ## `end`
330    /// the end position (on the horizontal axis)
331    /// ## `stops`
332    /// the color stops defining the gradient
333    #[doc(alias = "gtk_snapshot_append_radial_gradient")]
334    fn append_radial_gradient(
335        &self,
336        bounds: &graphene::Rect,
337        center: &graphene::Point,
338        hradius: f32,
339        vradius: f32,
340        start: f32,
341        end: f32,
342        stops: &[gsk::ColorStop],
343    ) {
344        let n_stops = stops.len() as _;
345        unsafe {
346            ffi::gtk_snapshot_append_radial_gradient(
347                self.as_ref().to_glib_none().0,
348                bounds.to_glib_none().0,
349                center.to_glib_none().0,
350                hradius,
351                vradius,
352                start,
353                end,
354                stops.to_glib_none().0,
355                n_stops,
356            );
357        }
358    }
359
360    /// Appends a repeating linear gradient node with the given stops to @self.
361    /// ## `bounds`
362    /// the rectangle to render the linear gradient into
363    /// ## `start_point`
364    /// the point at which the linear gradient will begin
365    /// ## `end_point`
366    /// the point at which the linear gradient will finish
367    /// ## `stops`
368    /// the color stops defining the gradient
369    #[doc(alias = "gtk_snapshot_append_repeating_linear_gradient")]
370    fn append_repeating_linear_gradient(
371        &self,
372        bounds: &graphene::Rect,
373        start_point: &graphene::Point,
374        end_point: &graphene::Point,
375        stops: &[gsk::ColorStop],
376    ) {
377        let n_stops = stops.len() as _;
378        unsafe {
379            ffi::gtk_snapshot_append_repeating_linear_gradient(
380                self.as_ref().to_glib_none().0,
381                bounds.to_glib_none().0,
382                start_point.to_glib_none().0,
383                end_point.to_glib_none().0,
384                stops.to_glib_none().0,
385                n_stops,
386            );
387        }
388    }
389
390    /// Appends a repeating radial gradient node with the given stops to @self.
391    /// ## `bounds`
392    /// the rectangle to render the readial gradient into
393    /// ## `center`
394    /// the center point for the radial gradient
395    /// ## `hradius`
396    /// the horizontal radius
397    /// ## `vradius`
398    /// the vertical radius
399    /// ## `start`
400    /// the start position (on the horizontal axis)
401    /// ## `end`
402    /// the end position (on the horizontal axis)
403    /// ## `stops`
404    /// the color stops defining the gradient
405    #[doc(alias = "gtk_snapshot_append_repeating_radial_gradient")]
406    fn append_repeating_radial_gradient(
407        &self,
408        bounds: &graphene::Rect,
409        center: &graphene::Point,
410        hradius: f32,
411        vradius: f32,
412        start: f32,
413        end: f32,
414        stops: &[gsk::ColorStop],
415    ) {
416        let n_stops = stops.len() as _;
417        unsafe {
418            ffi::gtk_snapshot_append_repeating_radial_gradient(
419                self.as_ref().to_glib_none().0,
420                bounds.to_glib_none().0,
421                center.to_glib_none().0,
422                hradius,
423                vradius,
424                start,
425                end,
426                stops.to_glib_none().0,
427                n_stops,
428            );
429        }
430    }
431
432    /// Creates a new render node drawing the @texture
433    /// into the given @bounds and appends it to the
434    /// current render node of @self.
435    ///
436    /// In contrast to [`append_texture()`][Self::append_texture()],
437    /// this function provides control about how the filter
438    /// that is used when scaling.
439    /// ## `texture`
440    /// the texture to render
441    /// ## `filter`
442    /// the filter to use
443    /// ## `bounds`
444    /// the bounds for the new node
445    #[cfg(feature = "v4_10")]
446    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
447    #[doc(alias = "gtk_snapshot_append_scaled_texture")]
448    fn append_scaled_texture(
449        &self,
450        texture: &impl IsA<gdk::Texture>,
451        filter: gsk::ScalingFilter,
452        bounds: &graphene::Rect,
453    ) {
454        unsafe {
455            ffi::gtk_snapshot_append_scaled_texture(
456                self.as_ref().to_glib_none().0,
457                texture.as_ref().to_glib_none().0,
458                filter.into_glib(),
459                bounds.to_glib_none().0,
460            );
461        }
462    }
463
464    /// A convenience method to stroke a path with a color.
465    ///
466    /// See [`push_stroke()`][Self::push_stroke()] if you need
467    /// to stroke a path with more complex content than
468    /// a color.
469    /// ## `path`
470    /// The path describing the area to fill
471    /// ## `stroke`
472    /// The stroke attributes
473    /// ## `color`
474    /// the color to fill the path with
475    #[cfg(feature = "v4_14")]
476    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
477    #[doc(alias = "gtk_snapshot_append_stroke")]
478    fn append_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke, color: &gdk::RGBA) {
479        unsafe {
480            ffi::gtk_snapshot_append_stroke(
481                self.as_ref().to_glib_none().0,
482                path.to_glib_none().0,
483                stroke.to_glib_none().0,
484                color.to_glib_none().0,
485            );
486        }
487    }
488
489    /// Creates a new render node drawing the @texture
490    /// into the given @bounds and appends it to the
491    /// current render node of @self.
492    ///
493    /// If the texture needs to be scaled to fill @bounds,
494    /// linear filtering is used. See [`append_scaled_texture()`][Self::append_scaled_texture()]
495    /// if you need other filtering, such as nearest-neighbour.
496    /// ## `texture`
497    /// the texture to render
498    /// ## `bounds`
499    /// the bounds for the new node
500    #[doc(alias = "gtk_snapshot_append_texture")]
501    fn append_texture(&self, texture: &impl IsA<gdk::Texture>, bounds: &graphene::Rect) {
502        unsafe {
503            ffi::gtk_snapshot_append_texture(
504                self.as_ref().to_glib_none().0,
505                texture.as_ref().to_glib_none().0,
506                bounds.to_glib_none().0,
507            );
508        }
509    }
510
511    /// Returns the node that was constructed by @self
512    /// and frees @self.
513    ///
514    /// See also `Gtk::Snapshot::to_node()`.
515    ///
516    /// # Returns
517    ///
518    /// a newly-created [`gsk::RenderNode`][crate::gsk::RenderNode]
519    #[doc(alias = "gtk_snapshot_free_to_node")]
520    #[doc(alias = "free_to_node")]
521    fn to_node(self) -> Option<gsk::RenderNode> {
522        unsafe {
523            from_glib_full(ffi::gtk_snapshot_free_to_node(
524                self.upcast().into_glib_ptr(),
525            ))
526        }
527    }
528
529    /// Returns a paintable for the node that was
530    /// constructed by @self and frees @self.
531    /// ## `size`
532    /// The size of the resulting paintable
533    ///   or [`None`] to use the bounds of the snapshot
534    ///
535    /// # Returns
536    ///
537    /// a newly-created [`gdk::Paintable`][crate::gdk::Paintable]
538    #[doc(alias = "gtk_snapshot_free_to_paintable")]
539    #[doc(alias = "free_to_paintable")]
540    fn to_paintable(self, size: Option<&graphene::Size>) -> Option<gdk::Paintable> {
541        unsafe {
542            from_glib_full(ffi::gtk_snapshot_free_to_paintable(
543                self.upcast().into_glib_ptr(),
544                size.to_glib_none().0,
545            ))
546        }
547    }
548
549    /// Removes the top element from the stack of render nodes and
550    /// adds it to the nearest [`gsk::GLShaderNode`][crate::gsk::GLShaderNode] below it.
551    ///
552    /// This must be called the same number of times as the number
553    /// of textures is needed for the shader in
554    /// [`push_gl_shader()`][Self::push_gl_shader()].
555    ///
556    /// # Deprecated since 4.16
557    ///
558    /// GTK's new Vulkan-focused rendering
559    ///   does not support this feature. Use [`GLArea`][crate::GLArea] for
560    ///   OpenGL rendering.
561    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
562    #[allow(deprecated)]
563    #[doc(alias = "gtk_snapshot_gl_shader_pop_texture")]
564    fn gl_shader_pop_texture(&self) {
565        unsafe {
566            ffi::gtk_snapshot_gl_shader_pop_texture(self.as_ref().to_glib_none().0);
567        }
568    }
569
570    /// Applies a perspective projection transform.
571    ///
572    /// See [`gsk::Transform::perspective()`][crate::gsk::Transform::perspective()] for a discussion on the details.
573    /// ## `depth`
574    /// distance of the z=0 plane
575    #[doc(alias = "gtk_snapshot_perspective")]
576    fn perspective(&self, depth: f32) {
577        unsafe {
578            ffi::gtk_snapshot_perspective(self.as_ref().to_glib_none().0, depth);
579        }
580    }
581
582    /// Removes the top element from the stack of render nodes,
583    /// and appends it to the node underneath it.
584    #[doc(alias = "gtk_snapshot_pop")]
585    fn pop(&self) {
586        unsafe {
587            ffi::gtk_snapshot_pop(self.as_ref().to_glib_none().0);
588        }
589    }
590
591    /// Blends together two images with the given blend mode.
592    ///
593    /// Until the first call to [`pop()`][Self::pop()], the
594    /// bottom image for the blend operation will be recorded.
595    /// After that call, the top image to be blended will be
596    /// recorded until the second call to [`pop()`][Self::pop()].
597    ///
598    /// Calling this function requires two subsequent calls
599    /// to [`pop()`][Self::pop()].
600    /// ## `blend_mode`
601    /// blend mode to use
602    #[doc(alias = "gtk_snapshot_push_blend")]
603    fn push_blend(&self, blend_mode: gsk::BlendMode) {
604        unsafe {
605            ffi::gtk_snapshot_push_blend(self.as_ref().to_glib_none().0, blend_mode.into_glib());
606        }
607    }
608
609    /// Blurs an image.
610    ///
611    /// The image is recorded until the next call to [`pop()`][Self::pop()].
612    /// ## `radius`
613    /// the blur radius to use. Must be positive
614    #[doc(alias = "gtk_snapshot_push_blur")]
615    fn push_blur(&self, radius: f64) {
616        unsafe {
617            ffi::gtk_snapshot_push_blur(self.as_ref().to_glib_none().0, radius);
618        }
619    }
620
621    /// Clips an image to a rectangle.
622    ///
623    /// The image is recorded until the next call to [`pop()`][Self::pop()].
624    /// ## `bounds`
625    /// the rectangle to clip to
626    #[doc(alias = "gtk_snapshot_push_clip")]
627    fn push_clip(&self, bounds: &graphene::Rect) {
628        unsafe {
629            ffi::gtk_snapshot_push_clip(self.as_ref().to_glib_none().0, bounds.to_glib_none().0);
630        }
631    }
632
633    /// Modifies the colors of an image by applying an affine transformation
634    /// in RGB space.
635    ///
636    /// In particular, the colors will be transformed by applying
637    ///
638    ///     pixel = transpose(color_matrix) * pixel + color_offset
639    ///
640    /// for every pixel. The transformation operates on unpremultiplied
641    /// colors, with color components ordered R, G, B, A.
642    ///
643    /// The image is recorded until the next call to [`pop()`][Self::pop()].
644    /// ## `color_matrix`
645    /// the color matrix to use
646    /// ## `color_offset`
647    /// the color offset to use
648    #[doc(alias = "gtk_snapshot_push_color_matrix")]
649    fn push_color_matrix(&self, color_matrix: &graphene::Matrix, color_offset: &graphene::Vec4) {
650        unsafe {
651            ffi::gtk_snapshot_push_color_matrix(
652                self.as_ref().to_glib_none().0,
653                color_matrix.to_glib_none().0,
654                color_offset.to_glib_none().0,
655            );
656        }
657    }
658
659    /// Modifies the colors of an image by applying a transfer
660    /// function for each component.
661    ///
662    /// The transfer functions operate on unpremultiplied colors.
663    ///
664    /// The image is recorded until the next call to [`pop()`][Self::pop()].
665    /// ## `red`
666    /// the transfer for the red component
667    /// ## `green`
668    /// the transfer for the green component
669    /// ## `blue`
670    /// the transfer for the blue component
671    /// ## `alpha`
672    /// the transfer for the alpha component
673    #[cfg(feature = "v4_20")]
674    #[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
675    #[doc(alias = "gtk_snapshot_push_component_transfer")]
676    fn push_component_transfer(
677        &self,
678        red: &gsk::ComponentTransfer,
679        green: &gsk::ComponentTransfer,
680        blue: &gsk::ComponentTransfer,
681        alpha: &gsk::ComponentTransfer,
682    ) {
683        unsafe {
684            ffi::gtk_snapshot_push_component_transfer(
685                self.as_ref().to_glib_none().0,
686                red.to_glib_none().0,
687                green.to_glib_none().0,
688                blue.to_glib_none().0,
689                alpha.to_glib_none().0,
690            );
691        }
692    }
693
694    /// Until the first call to [`pop()`][Self::pop()], the
695    /// mask image for the mask operation will be recorded.
696    ///
697    /// After that call, the child image will be recorded until
698    /// the second call to [`pop()`][Self::pop()].
699    ///
700    /// Calling this function requires 2 subsequent calls to gtk_snapshot_pop().
701    /// ## `op`
702    /// The Porter/Duff compositing operator to use
703    #[cfg(feature = "v4_22")]
704    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
705    #[doc(alias = "gtk_snapshot_push_composite")]
706    fn push_composite(&self, op: gsk::PorterDuff) {
707        unsafe {
708            ffi::gtk_snapshot_push_composite(self.as_ref().to_glib_none().0, op.into_glib());
709        }
710    }
711
712    #[cfg(feature = "v4_22")]
713    #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
714    #[doc(alias = "gtk_snapshot_push_copy")]
715    fn push_copy(&self) {
716        unsafe {
717            ffi::gtk_snapshot_push_copy(self.as_ref().to_glib_none().0);
718        }
719    }
720
721    /// Snapshots a cross-fade operation between two images with the
722    /// given @progress.
723    ///
724    /// Until the first call to [`pop()`][Self::pop()], the start image
725    /// will be snapshot. After that call, the end image will be recorded
726    /// until the second call to [`pop()`][Self::pop()].
727    ///
728    /// Calling this function requires two subsequent calls
729    /// to [`pop()`][Self::pop()].
730    /// ## `progress`
731    /// progress between 0.0 and 1.0
732    #[doc(alias = "gtk_snapshot_push_cross_fade")]
733    fn push_cross_fade(&self, progress: f64) {
734        unsafe {
735            ffi::gtk_snapshot_push_cross_fade(self.as_ref().to_glib_none().0, progress);
736        }
737    }
738
739    /// Fills the area given by @path and @fill_rule with an image and discards everything
740    /// outside of it.
741    ///
742    /// The image is recorded until the next call to [`pop()`][Self::pop()].
743    ///
744    /// If you want to fill the path with a color, [`append_fill()`][Self::append_fill()]
745    /// than rendering new ones, use [`append_fill()`][Self::append_fill()]
746    /// may be more convenient.
747    /// ## `path`
748    /// The path describing the area to fill
749    /// ## `fill_rule`
750    /// The fill rule to use
751    #[cfg(feature = "v4_14")]
752    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
753    #[doc(alias = "gtk_snapshot_push_fill")]
754    fn push_fill(&self, path: &gsk::Path, fill_rule: gsk::FillRule) {
755        unsafe {
756            ffi::gtk_snapshot_push_fill(
757                self.as_ref().to_glib_none().0,
758                path.to_glib_none().0,
759                fill_rule.into_glib(),
760            );
761        }
762    }
763
764    /// Push a [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
765    ///
766    /// The node uses the given [`gsk::GLShader`][crate::gsk::GLShader] and uniform values
767    /// Additionally this takes a list of @n_children other nodes
768    /// which will be passed to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode].
769    ///
770    /// The @take_args argument is a block of data to use for uniform
771    /// arguments, as per types and offsets defined by the @shader.
772    /// Normally this is generated by `Gsk::GLShader::format_args()`
773    /// or `Gsk::ShaderArgsBuilder`.
774    ///
775    /// The snapshotter takes ownership of @take_args, so the caller should
776    /// not free it after this.
777    ///
778    /// If the renderer doesn't support GL shaders, or if there is any
779    /// problem when compiling the shader, then the node will draw pink.
780    /// You should use [`GLShader::compile()`][crate::gsk::GLShader::compile()] to ensure the @shader
781    /// will work for the renderer before using it.
782    ///
783    /// If the shader requires textures (see [`GLShader::n_textures()`][crate::gsk::GLShader::n_textures()]),
784    /// then it is expected that you call [`gl_shader_pop_texture()`][Self::gl_shader_pop_texture()]
785    /// the number of times that are required. Each of these calls will generate
786    /// a node that is added as a child to the [`gsk::GLShaderNode`][crate::gsk::GLShaderNode], which in turn
787    /// will render these offscreen and pass as a texture to the shader.
788    ///
789    /// Once all textures (if any) are pop:ed, you must call the regular
790    /// [`pop()`][Self::pop()].
791    ///
792    /// If you want to use pre-existing textures as input to the shader rather
793    /// than rendering new ones, use [`append_texture()`][Self::append_texture()] to
794    /// push a texture node. These will be used directly rather than being
795    /// re-rendered.
796    ///
797    /// For details on how to write shaders, see [`gsk::GLShader`][crate::gsk::GLShader].
798    ///
799    /// # Deprecated since 4.16
800    ///
801    /// GTK's new Vulkan-focused rendering
802    ///   does not support this feature. Use [`GLArea`][crate::GLArea] for
803    ///   OpenGL rendering.
804    /// ## `shader`
805    /// The code to run
806    /// ## `bounds`
807    /// the rectangle to render into
808    /// ## `take_args`
809    /// Data block with arguments for the shader.
810    #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")]
811    #[allow(deprecated)]
812    #[doc(alias = "gtk_snapshot_push_gl_shader")]
813    fn push_gl_shader(
814        &self,
815        shader: &gsk::GLShader,
816        bounds: &graphene::Rect,
817        take_args: glib::Bytes,
818    ) {
819        unsafe {
820            ffi::gtk_snapshot_push_gl_shader(
821                self.as_ref().to_glib_none().0,
822                shader.to_glib_none().0,
823                bounds.to_glib_none().0,
824                take_args.into_glib_ptr(),
825            );
826        }
827    }
828
829    //#[cfg(feature = "v4_22")]
830    //#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
831    //#[doc(alias = "gtk_snapshot_push_isolation")]
832    //fn push_isolation(&self, features: /*Ignored*/gsk::Isolation) {
833    //    unsafe { TODO: call ffi:gtk_snapshot_push_isolation() }
834    //}
835
836    /// Until the first call to [`pop()`][Self::pop()], the
837    /// mask image for the mask operation will be recorded.
838    ///
839    /// After that call, the source image will be recorded until
840    /// the second call to [`pop()`][Self::pop()].
841    ///
842    /// Calling this function requires 2 subsequent calls to gtk_snapshot_pop().
843    /// ## `mask_mode`
844    /// mask mode to use
845    #[cfg(feature = "v4_10")]
846    #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))]
847    #[doc(alias = "gtk_snapshot_push_mask")]
848    fn push_mask(&self, mask_mode: gsk::MaskMode) {
849        unsafe {
850            ffi::gtk_snapshot_push_mask(self.as_ref().to_glib_none().0, mask_mode.into_glib());
851        }
852    }
853
854    /// Modifies the opacity of an image.
855    ///
856    /// The image is recorded until the next call to [`pop()`][Self::pop()].
857    /// ## `opacity`
858    /// the opacity to use
859    #[doc(alias = "gtk_snapshot_push_opacity")]
860    fn push_opacity(&self, opacity: f64) {
861        unsafe {
862            ffi::gtk_snapshot_push_opacity(self.as_ref().to_glib_none().0, opacity);
863        }
864    }
865
866    /// Creates a node that repeats the child node.
867    ///
868    /// The child is recorded until the next call to [`pop()`][Self::pop()].
869    /// ## `bounds`
870    /// the bounds within which to repeat
871    /// ## `child_bounds`
872    /// the bounds of the child or [`None`]
873    ///   to use the full size of the collected child node
874    #[doc(alias = "gtk_snapshot_push_repeat")]
875    fn push_repeat(&self, bounds: &graphene::Rect, child_bounds: Option<&graphene::Rect>) {
876        unsafe {
877            ffi::gtk_snapshot_push_repeat(
878                self.as_ref().to_glib_none().0,
879                bounds.to_glib_none().0,
880                child_bounds.to_glib_none().0,
881            );
882        }
883    }
884
885    /// Clips an image to a rounded rectangle.
886    ///
887    /// The image is recorded until the next call to [`pop()`][Self::pop()].
888    /// ## `bounds`
889    /// the rounded rectangle to clip to
890    #[doc(alias = "gtk_snapshot_push_rounded_clip")]
891    fn push_rounded_clip(&self, bounds: &gsk::RoundedRect) {
892        unsafe {
893            ffi::gtk_snapshot_push_rounded_clip(
894                self.as_ref().to_glib_none().0,
895                bounds.to_glib_none().0,
896            );
897        }
898    }
899
900    /// Applies a shadow to an image.
901    ///
902    /// The image is recorded until the next call to [`pop()`][Self::pop()].
903    /// ## `shadow`
904    /// the first shadow specification
905    #[doc(alias = "gtk_snapshot_push_shadow")]
906    fn push_shadow(&self, shadow: &[gsk::Shadow]) {
907        let n_shadows = shadow.len() as _;
908        unsafe {
909            ffi::gtk_snapshot_push_shadow(
910                self.as_ref().to_glib_none().0,
911                shadow.to_glib_none().0,
912                n_shadows,
913            );
914        }
915    }
916
917    /// Strokes the given @path with the attributes given by @stroke and
918    /// an image.
919    ///
920    /// The image is recorded until the next call to [`pop()`][Self::pop()].
921    ///
922    /// Note that the strokes are subject to the same transformation as
923    /// everything else, so uneven scaling will cause horizontal and vertical
924    /// strokes to have different widths.
925    ///
926    /// If you want to stroke the path with a color, [`append_stroke()`][Self::append_stroke()]
927    /// may be more convenient.
928    /// ## `path`
929    /// The path to stroke
930    /// ## `stroke`
931    /// The stroke attributes
932    #[cfg(feature = "v4_14")]
933    #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
934    #[doc(alias = "gtk_snapshot_push_stroke")]
935    fn push_stroke(&self, path: &gsk::Path, stroke: &gsk::Stroke) {
936        unsafe {
937            ffi::gtk_snapshot_push_stroke(
938                self.as_ref().to_glib_none().0,
939                path.to_glib_none().0,
940                stroke.to_glib_none().0,
941            );
942        }
943    }
944
945    /// Creates a render node for the CSS background according to @context,
946    /// and appends it to the current node of @self, without changing
947    /// the current node.
948    ///
949    /// # Deprecated since 4.10
950    ///
951    /// ## `context`
952    /// the style context that defines the background
953    /// ## `x`
954    /// X origin of the rectangle
955    /// ## `y`
956    /// Y origin of the rectangle
957    /// ## `width`
958    /// rectangle width
959    /// ## `height`
960    /// rectangle height
961    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
962    #[allow(deprecated)]
963    #[doc(alias = "gtk_snapshot_render_background")]
964    fn render_background(
965        &self,
966        context: &impl IsA<StyleContext>,
967        x: f64,
968        y: f64,
969        width: f64,
970        height: f64,
971    ) {
972        unsafe {
973            ffi::gtk_snapshot_render_background(
974                self.as_ref().to_glib_none().0,
975                context.as_ref().to_glib_none().0,
976                x,
977                y,
978                width,
979                height,
980            );
981        }
982    }
983
984    /// Creates a render node for the focus outline according to @context,
985    /// and appends it to the current node of @self, without changing
986    /// the current node.
987    ///
988    /// # Deprecated since 4.10
989    ///
990    /// ## `context`
991    /// the style context that defines the focus ring
992    /// ## `x`
993    /// X origin of the rectangle
994    /// ## `y`
995    /// Y origin of the rectangle
996    /// ## `width`
997    /// rectangle width
998    /// ## `height`
999    /// rectangle height
1000    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1001    #[allow(deprecated)]
1002    #[doc(alias = "gtk_snapshot_render_focus")]
1003    fn render_focus(
1004        &self,
1005        context: &impl IsA<StyleContext>,
1006        x: f64,
1007        y: f64,
1008        width: f64,
1009        height: f64,
1010    ) {
1011        unsafe {
1012            ffi::gtk_snapshot_render_focus(
1013                self.as_ref().to_glib_none().0,
1014                context.as_ref().to_glib_none().0,
1015                x,
1016                y,
1017                width,
1018                height,
1019            );
1020        }
1021    }
1022
1023    /// Creates a render node for the CSS border according to @context,
1024    /// and appends it to the current node of @self, without changing
1025    /// the current node.
1026    ///
1027    /// # Deprecated since 4.10
1028    ///
1029    /// ## `context`
1030    /// the style context that defines the frame
1031    /// ## `x`
1032    /// X origin of the rectangle
1033    /// ## `y`
1034    /// Y origin of the rectangle
1035    /// ## `width`
1036    /// rectangle width
1037    /// ## `height`
1038    /// rectangle height
1039    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1040    #[allow(deprecated)]
1041    #[doc(alias = "gtk_snapshot_render_frame")]
1042    fn render_frame(
1043        &self,
1044        context: &impl IsA<StyleContext>,
1045        x: f64,
1046        y: f64,
1047        width: f64,
1048        height: f64,
1049    ) {
1050        unsafe {
1051            ffi::gtk_snapshot_render_frame(
1052                self.as_ref().to_glib_none().0,
1053                context.as_ref().to_glib_none().0,
1054                x,
1055                y,
1056                width,
1057                height,
1058            );
1059        }
1060    }
1061
1062    /// Draws a text caret using @self at the specified index of @layout.
1063    ///
1064    /// # Deprecated since 4.10
1065    ///
1066    /// ## `context`
1067    /// a [`StyleContext`][crate::StyleContext]
1068    /// ## `x`
1069    /// X origin
1070    /// ## `y`
1071    /// Y origin
1072    /// ## `layout`
1073    /// the [`pango::Layout`][crate::pango::Layout] of the text
1074    /// ## `index`
1075    /// the index in the [`pango::Layout`][crate::pango::Layout]
1076    /// ## `direction`
1077    /// the [`pango::Direction`][crate::pango::Direction] of the text
1078    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1079    #[allow(deprecated)]
1080    #[doc(alias = "gtk_snapshot_render_insertion_cursor")]
1081    fn render_insertion_cursor(
1082        &self,
1083        context: &impl IsA<StyleContext>,
1084        x: f64,
1085        y: f64,
1086        layout: &pango::Layout,
1087        index: i32,
1088        direction: pango::Direction,
1089    ) {
1090        unsafe {
1091            ffi::gtk_snapshot_render_insertion_cursor(
1092                self.as_ref().to_glib_none().0,
1093                context.as_ref().to_glib_none().0,
1094                x,
1095                y,
1096                layout.to_glib_none().0,
1097                index,
1098                direction.into_glib(),
1099            );
1100        }
1101    }
1102
1103    /// Creates a render node for rendering @layout according to the style
1104    /// information in @context, and appends it to the current node of @self,
1105    /// without changing the current node.
1106    ///
1107    /// # Deprecated since 4.10
1108    ///
1109    /// ## `context`
1110    /// the style context that defines the text
1111    /// ## `x`
1112    /// X origin of the rectangle
1113    /// ## `y`
1114    /// Y origin of the rectangle
1115    /// ## `layout`
1116    /// the [`pango::Layout`][crate::pango::Layout] to render
1117    #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")]
1118    #[allow(deprecated)]
1119    #[doc(alias = "gtk_snapshot_render_layout")]
1120    fn render_layout(
1121        &self,
1122        context: &impl IsA<StyleContext>,
1123        x: f64,
1124        y: f64,
1125        layout: &pango::Layout,
1126    ) {
1127        unsafe {
1128            ffi::gtk_snapshot_render_layout(
1129                self.as_ref().to_glib_none().0,
1130                context.as_ref().to_glib_none().0,
1131                x,
1132                y,
1133                layout.to_glib_none().0,
1134            );
1135        }
1136    }
1137
1138    /// Restores @self to the state saved by a preceding call to
1139    /// [`save()`][Self::save()] and removes that state from the stack of
1140    /// saved states.
1141    #[doc(alias = "gtk_snapshot_restore")]
1142    fn restore(&self) {
1143        unsafe {
1144            ffi::gtk_snapshot_restore(self.as_ref().to_glib_none().0);
1145        }
1146    }
1147
1148    /// Rotates @@self's coordinate system by @angle degrees in 2D space -
1149    /// or in 3D speak, rotates around the Z axis. The rotation happens around
1150    /// the origin point of (0, 0) in the @self's current coordinate system.
1151    ///
1152    /// To rotate around axes other than the Z axis, use [`gsk::Transform::rotate_3d()`][crate::gsk::Transform::rotate_3d()].
1153    /// ## `angle`
1154    /// the rotation angle, in degrees (clockwise)
1155    #[doc(alias = "gtk_snapshot_rotate")]
1156    fn rotate(&self, angle: f32) {
1157        unsafe {
1158            ffi::gtk_snapshot_rotate(self.as_ref().to_glib_none().0, angle);
1159        }
1160    }
1161
1162    /// Rotates @self's coordinate system by @angle degrees around @axis.
1163    ///
1164    /// For a rotation in 2D space, use [`gsk::Transform::rotate()`][crate::gsk::Transform::rotate()].
1165    /// ## `angle`
1166    /// the rotation angle, in degrees (clockwise)
1167    /// ## `axis`
1168    /// The rotation axis
1169    #[doc(alias = "gtk_snapshot_rotate_3d")]
1170    fn rotate_3d(&self, angle: f32, axis: &graphene::Vec3) {
1171        unsafe {
1172            ffi::gtk_snapshot_rotate_3d(
1173                self.as_ref().to_glib_none().0,
1174                angle,
1175                axis.to_glib_none().0,
1176            );
1177        }
1178    }
1179
1180    /// Makes a copy of the current state of @self and saves it
1181    /// on an internal stack.
1182    ///
1183    /// When [`restore()`][Self::restore()] is called, @self will
1184    /// be restored to the saved state.
1185    ///
1186    /// Multiple calls to [`save()`][Self::save()] and [`restore()`][Self::restore()]
1187    /// can be nested; each call to `gtk_snapshot_restore()` restores the state from
1188    /// the matching paired `gtk_snapshot_save()`.
1189    ///
1190    /// It is necessary to clear all saved states with corresponding
1191    /// calls to `gtk_snapshot_restore()`.
1192    #[doc(alias = "gtk_snapshot_save")]
1193    fn save(&self) {
1194        unsafe {
1195            ffi::gtk_snapshot_save(self.as_ref().to_glib_none().0);
1196        }
1197    }
1198
1199    /// Scales @self's coordinate system in 2-dimensional space by
1200    /// the given factors.
1201    ///
1202    /// Use [`scale_3d()`][Self::scale_3d()] to scale in all 3 dimensions.
1203    /// ## `factor_x`
1204    /// scaling factor on the X axis
1205    /// ## `factor_y`
1206    /// scaling factor on the Y axis
1207    #[doc(alias = "gtk_snapshot_scale")]
1208    fn scale(&self, factor_x: f32, factor_y: f32) {
1209        unsafe {
1210            ffi::gtk_snapshot_scale(self.as_ref().to_glib_none().0, factor_x, factor_y);
1211        }
1212    }
1213
1214    /// Scales @self's coordinate system by the given factors.
1215    /// ## `factor_x`
1216    /// scaling factor on the X axis
1217    /// ## `factor_y`
1218    /// scaling factor on the Y axis
1219    /// ## `factor_z`
1220    /// scaling factor on the Z axis
1221    #[doc(alias = "gtk_snapshot_scale_3d")]
1222    fn scale_3d(&self, factor_x: f32, factor_y: f32, factor_z: f32) {
1223        unsafe {
1224            ffi::gtk_snapshot_scale_3d(
1225                self.as_ref().to_glib_none().0,
1226                factor_x,
1227                factor_y,
1228                factor_z,
1229            );
1230        }
1231    }
1232
1233    /// Transforms @self's coordinate system with the given @transform.
1234    /// ## `transform`
1235    /// the transform to apply
1236    #[doc(alias = "gtk_snapshot_transform")]
1237    fn transform(&self, transform: Option<&gsk::Transform>) {
1238        unsafe {
1239            ffi::gtk_snapshot_transform(self.as_ref().to_glib_none().0, transform.to_glib_none().0);
1240        }
1241    }
1242
1243    /// Transforms @self's coordinate system with the given @matrix.
1244    /// ## `matrix`
1245    /// the matrix to multiply the transform with
1246    #[doc(alias = "gtk_snapshot_transform_matrix")]
1247    fn transform_matrix(&self, matrix: &graphene::Matrix) {
1248        unsafe {
1249            ffi::gtk_snapshot_transform_matrix(
1250                self.as_ref().to_glib_none().0,
1251                matrix.to_glib_none().0,
1252            );
1253        }
1254    }
1255
1256    /// Translates @self's coordinate system by @point in 2-dimensional space.
1257    /// ## `point`
1258    /// the point to translate the snapshot by
1259    #[doc(alias = "gtk_snapshot_translate")]
1260    fn translate(&self, point: &graphene::Point) {
1261        unsafe {
1262            ffi::gtk_snapshot_translate(self.as_ref().to_glib_none().0, point.to_glib_none().0);
1263        }
1264    }
1265
1266    /// Translates @self's coordinate system by @point.
1267    /// ## `point`
1268    /// the point to translate the snapshot by
1269    #[doc(alias = "gtk_snapshot_translate_3d")]
1270    fn translate_3d(&self, point: &graphene::Point3D) {
1271        unsafe {
1272            ffi::gtk_snapshot_translate_3d(self.as_ref().to_glib_none().0, point.to_glib_none().0);
1273        }
1274    }
1275}
1276
1277impl<O: IsA<Snapshot>> SnapshotExt for O {}