gsk4/auto/
linear_gradient_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, ColorStop};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    #[doc(alias = "GskLinearGradientNode")]
10    pub struct LinearGradientNode(Shared<ffi::GskLinearGradientNode>);
11
12    match fn {
13        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
14        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
15    }
16}
17
18impl StaticType for LinearGradientNode {
19    fn static_type() -> glib::Type {
20        unsafe { from_glib(ffi::gsk_linear_gradient_node_get_type()) }
21    }
22}
23
24impl LinearGradientNode {
25    #[doc(alias = "gsk_linear_gradient_node_new")]
26    pub fn new(
27        bounds: &graphene::Rect,
28        start: &graphene::Point,
29        end: &graphene::Point,
30        color_stops: &[ColorStop],
31    ) -> LinearGradientNode {
32        assert_initialized_main_thread!();
33        let n_color_stops = color_stops.len() as _;
34        unsafe {
35            from_glib_full(ffi::gsk_linear_gradient_node_new(
36                bounds.to_glib_none().0,
37                start.to_glib_none().0,
38                end.to_glib_none().0,
39                color_stops.to_glib_none().0,
40                n_color_stops,
41            ))
42        }
43    }
44
45    #[doc(alias = "gsk_linear_gradient_node_get_color_stops")]
46    #[doc(alias = "get_color_stops")]
47    pub fn color_stops(&self) -> Vec<ColorStop> {
48        unsafe {
49            let mut n_stops = std::mem::MaybeUninit::uninit();
50            let ret = FromGlibContainer::from_glib_none_num(
51                ffi::gsk_linear_gradient_node_get_color_stops(
52                    self.to_glib_none().0,
53                    n_stops.as_mut_ptr(),
54                ),
55                n_stops.assume_init() as _,
56            );
57            ret
58        }
59    }
60
61    #[doc(alias = "gsk_linear_gradient_node_get_end")]
62    #[doc(alias = "get_end")]
63    pub fn end(&self) -> graphene::Point {
64        unsafe { from_glib_none(ffi::gsk_linear_gradient_node_get_end(self.to_glib_none().0)) }
65    }
66
67    #[doc(alias = "gsk_linear_gradient_node_get_n_color_stops")]
68    #[doc(alias = "get_n_color_stops")]
69    pub fn n_color_stops(&self) -> usize {
70        unsafe { ffi::gsk_linear_gradient_node_get_n_color_stops(self.to_glib_none().0) }
71    }
72
73    #[doc(alias = "gsk_linear_gradient_node_get_start")]
74    #[doc(alias = "get_start")]
75    pub fn start(&self) -> graphene::Point {
76        unsafe {
77            from_glib_none(ffi::gsk_linear_gradient_node_get_start(
78                self.to_glib_none().0,
79            ))
80        }
81    }
82}