gtk4/auto/
snapshot.rs

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