gsk4/auto/
isolation_node.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
5use crate::{ffi, Isolation, RenderNode};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node that isolates its child from surrounding rendernodes.
10    #[doc(alias = "GskIsolationNode")]
11    pub struct IsolationNode(Shared<ffi::GskIsolationNode>);
12
13    match fn {
14        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
15        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
16    }
17}
18
19impl StaticType for IsolationNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_isolation_node_get_type()) }
22    }
23}
24
25impl IsolationNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that isolates the drawing operations of
27    /// the child from surrounding ones.
28    ///
29    /// You can express "everything but these flags" in a forward compatible
30    /// way by using bit math:
31    /// `GSK_ISOLATION_ALL & ~(GSK_ISOLATION_BACKGROUND | GSK_ISOLATION_COPY_PASTE)`
32    /// will isolate everything but background and copy/paste.
33    ///
34    /// For the available isolations, see [`Isolation`][crate::Isolation].
35    /// ## `child`
36    /// The child
37    /// ## `isolations`
38    /// features to isolate
39    ///
40    /// # Returns
41    ///
42    /// A new [`RenderNode`][crate::RenderNode]
43    #[doc(alias = "gsk_isolation_node_new")]
44    pub fn new(child: impl AsRef<RenderNode>, isolations: Isolation) -> IsolationNode {
45        skip_assert_initialized!();
46        unsafe {
47            from_glib_full(ffi::gsk_isolation_node_new(
48                child.as_ref().to_glib_none().0,
49                isolations.into_glib(),
50            ))
51        }
52    }
53
54    /// Gets the child node that is getting drawn by the given @self.
55    ///
56    /// # Returns
57    ///
58    /// the child [`RenderNode`][crate::RenderNode]
59    #[doc(alias = "gsk_isolation_node_get_child")]
60    #[doc(alias = "get_child")]
61    pub fn child(&self) -> RenderNode {
62        unsafe { from_glib_none(ffi::gsk_isolation_node_get_child(self.to_glib_none().0)) }
63    }
64
65    /// Gets the isolation features that are enforced by this node.
66    ///
67    /// # Returns
68    ///
69    /// the isolation features
70    #[doc(alias = "gsk_isolation_node_get_isolations")]
71    #[doc(alias = "get_isolations")]
72    pub fn isolations(&self) -> Isolation {
73        unsafe {
74            from_glib(ffi::gsk_isolation_node_get_isolations(
75                self.to_glib_none().0,
76            ))
77        }
78    }
79}