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