gsk4/auto/
color_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;
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node for a solid color.
10    #[doc(alias = "GskColorNode")]
11    pub struct ColorNode(Shared<ffi::GskColorNode>);
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 ColorNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_color_node_get_type()) }
22    }
23}
24
25impl ColorNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will render the color specified by @rgba into
27    /// the area given by @bounds.
28    /// ## `rgba`
29    /// a [`gdk::RGBA`][crate::gdk::RGBA] specifying a color
30    /// ## `bounds`
31    /// the rectangle to render the color into
32    ///
33    /// # Returns
34    ///
35    /// A new [`RenderNode`][crate::RenderNode]
36    #[doc(alias = "gsk_color_node_new")]
37    pub fn new(rgba: &gdk::RGBA, bounds: &graphene::Rect) -> ColorNode {
38        assert_initialized_main_thread!();
39        unsafe {
40            from_glib_full(ffi::gsk_color_node_new(
41                rgba.to_glib_none().0,
42                bounds.to_glib_none().0,
43            ))
44        }
45    }
46
47    /// Retrieves the color of the given @self.
48    ///
49    /// The value returned by this function will not be correct
50    /// if the render node was created for a non-sRGB color.
51    ///
52    /// # Returns
53    ///
54    /// the color of the node
55    #[doc(alias = "gsk_color_node_get_color")]
56    #[doc(alias = "get_color")]
57    pub fn color(&self) -> gdk::RGBA {
58        unsafe { from_glib_none(ffi::gsk_color_node_get_color(self.to_glib_none().0)) }
59    }
60}