gsk4/auto/
stroke_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, Path, RenderNode, Stroke};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node that will fill the area determined by stroking the the given
10    /// [`Path`][crate::Path] using the [`Stroke`][crate::Stroke] attributes.
11    #[doc(alias = "GskStrokeNode")]
12    pub struct StrokeNode(Shared<ffi::GskStrokeNode>);
13
14    match fn {
15        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
16        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
17    }
18}
19
20impl StaticType for StrokeNode {
21    fn static_type() -> glib::Type {
22        unsafe { from_glib(ffi::gsk_stroke_node_get_type()) }
23    }
24}
25
26impl StrokeNode {
27    /// Creates a #GskRenderNode that will fill the outline generated by stroking
28    /// the given @path using the attributes defined in @stroke.
29    ///
30    /// The area is filled with @child.
31    ///
32    /// GSK aims to follow the SVG semantics for stroking paths.
33    /// E.g. zero-length contours will get round or square line
34    /// caps drawn, regardless whether they are closed or not.
35    /// ## `child`
36    /// The node to stroke the area with
37    /// ## `path`
38    /// The path describing the area to stroke
39    /// ## `stroke`
40    /// The stroke attributes to use
41    ///
42    /// # Returns
43    ///
44    /// A new #GskRenderNode
45    #[doc(alias = "gsk_stroke_node_new")]
46    pub fn new(child: impl AsRef<RenderNode>, path: &Path, stroke: &Stroke) -> StrokeNode {
47        skip_assert_initialized!();
48        unsafe {
49            from_glib_none(ffi::gsk_stroke_node_new(
50                child.as_ref().to_glib_none().0,
51                path.to_glib_none().0,
52                stroke.to_glib_none().0,
53            ))
54        }
55    }
56
57    /// Gets the child node that is getting drawn by the given @self.
58    ///
59    /// # Returns
60    ///
61    /// The child that is getting drawn
62    #[doc(alias = "gsk_stroke_node_get_child")]
63    #[doc(alias = "get_child")]
64    pub fn child(&self) -> RenderNode {
65        unsafe { from_glib_none(ffi::gsk_stroke_node_get_child(self.to_glib_none().0)) }
66    }
67
68    /// Retrieves the path that will be stroked with the contents of
69    /// the @self.
70    ///
71    /// # Returns
72    ///
73    /// a #GskPath
74    #[doc(alias = "gsk_stroke_node_get_path")]
75    #[doc(alias = "get_path")]
76    pub fn path(&self) -> Path {
77        unsafe { from_glib_none(ffi::gsk_stroke_node_get_path(self.to_glib_none().0)) }
78    }
79
80    /// Retrieves the stroke attributes used in this @self.
81    ///
82    /// # Returns
83    ///
84    /// a #GskStroke
85    #[doc(alias = "gsk_stroke_node_get_stroke")]
86    #[doc(alias = "get_stroke")]
87    pub fn stroke(&self) -> Stroke {
88        unsafe { from_glib_none(ffi::gsk_stroke_node_get_stroke(self.to_glib_none().0)) }
89    }
90}