gsk4/auto/
stroke.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, LineCap, LineJoin};
6use glib::translate::*;
7
8glib::wrapper! {
9    #[derive(Debug, PartialOrd, Ord, Hash)]
10    pub struct Stroke(Boxed<ffi::GskStroke>);
11
12    match fn {
13        copy => |ptr| ffi::gsk_stroke_copy(ptr),
14        free => |ptr| ffi::gsk_stroke_free(ptr),
15        type_ => || ffi::gsk_stroke_get_type(),
16    }
17}
18
19impl Stroke {
20    #[doc(alias = "gsk_stroke_new")]
21    pub fn new(line_width: f32) -> Stroke {
22        assert_initialized_main_thread!();
23        unsafe { from_glib_full(ffi::gsk_stroke_new(line_width)) }
24    }
25
26    #[doc(alias = "gsk_stroke_get_dash")]
27    #[doc(alias = "get_dash")]
28    pub fn dash(&self) -> Vec<f32> {
29        unsafe {
30            let mut n_dash = std::mem::MaybeUninit::uninit();
31            let ret = FromGlibContainer::from_glib_none_num(
32                ffi::gsk_stroke_get_dash(self.to_glib_none().0, n_dash.as_mut_ptr()),
33                n_dash.assume_init() as _,
34            );
35            ret
36        }
37    }
38
39    #[doc(alias = "gsk_stroke_get_dash_offset")]
40    #[doc(alias = "get_dash_offset")]
41    pub fn dash_offset(&self) -> f32 {
42        unsafe { ffi::gsk_stroke_get_dash_offset(self.to_glib_none().0) }
43    }
44
45    #[doc(alias = "gsk_stroke_get_line_cap")]
46    #[doc(alias = "get_line_cap")]
47    pub fn line_cap(&self) -> LineCap {
48        unsafe { from_glib(ffi::gsk_stroke_get_line_cap(self.to_glib_none().0)) }
49    }
50
51    #[doc(alias = "gsk_stroke_get_line_join")]
52    #[doc(alias = "get_line_join")]
53    pub fn line_join(&self) -> LineJoin {
54        unsafe { from_glib(ffi::gsk_stroke_get_line_join(self.to_glib_none().0)) }
55    }
56
57    #[doc(alias = "gsk_stroke_get_line_width")]
58    #[doc(alias = "get_line_width")]
59    pub fn line_width(&self) -> f32 {
60        unsafe { ffi::gsk_stroke_get_line_width(self.to_glib_none().0) }
61    }
62
63    #[doc(alias = "gsk_stroke_get_miter_limit")]
64    #[doc(alias = "get_miter_limit")]
65    pub fn miter_limit(&self) -> f32 {
66        unsafe { ffi::gsk_stroke_get_miter_limit(self.to_glib_none().0) }
67    }
68
69    #[doc(alias = "gsk_stroke_set_dash")]
70    pub fn set_dash(&self, dash: &[f32]) {
71        let n_dash = dash.len() as _;
72        unsafe {
73            ffi::gsk_stroke_set_dash(
74                mut_override(self.to_glib_none().0),
75                dash.to_glib_none().0,
76                n_dash,
77            );
78        }
79    }
80
81    #[doc(alias = "gsk_stroke_set_dash_offset")]
82    pub fn set_dash_offset(&self, offset: f32) {
83        unsafe {
84            ffi::gsk_stroke_set_dash_offset(mut_override(self.to_glib_none().0), offset);
85        }
86    }
87
88    #[doc(alias = "gsk_stroke_set_line_cap")]
89    pub fn set_line_cap(&self, line_cap: LineCap) {
90        unsafe {
91            ffi::gsk_stroke_set_line_cap(mut_override(self.to_glib_none().0), line_cap.into_glib());
92        }
93    }
94
95    #[doc(alias = "gsk_stroke_set_line_join")]
96    pub fn set_line_join(&self, line_join: LineJoin) {
97        unsafe {
98            ffi::gsk_stroke_set_line_join(
99                mut_override(self.to_glib_none().0),
100                line_join.into_glib(),
101            );
102        }
103    }
104
105    #[doc(alias = "gsk_stroke_set_line_width")]
106    pub fn set_line_width(&self, line_width: f32) {
107        unsafe {
108            ffi::gsk_stroke_set_line_width(mut_override(self.to_glib_none().0), line_width);
109        }
110    }
111
112    #[doc(alias = "gsk_stroke_set_miter_limit")]
113    pub fn set_miter_limit(&self, limit: f32) {
114        unsafe {
115            ffi::gsk_stroke_set_miter_limit(mut_override(self.to_glib_none().0), limit);
116        }
117    }
118
119    #[doc(alias = "gsk_stroke_to_cairo")]
120    pub fn to_cairo(&self, cr: &cairo::Context) {
121        unsafe {
122            ffi::gsk_stroke_to_cairo(self.to_glib_none().0, mut_override(cr.to_glib_none().0));
123        }
124    }
125
126    #[doc(alias = "gsk_stroke_equal")]
127    fn equal(&self, stroke2: &Stroke) -> bool {
128        assert_initialized_main_thread!();
129        unsafe {
130            from_glib(ffi::gsk_stroke_equal(
131                ToGlibPtr::<*const ffi::GskStroke>::to_glib_none(self).0
132                    as glib::ffi::gconstpointer,
133                ToGlibPtr::<*const ffi::GskStroke>::to_glib_none(stroke2).0
134                    as glib::ffi::gconstpointer,
135            ))
136        }
137    }
138}
139
140impl PartialEq for Stroke {
141    #[inline]
142    fn eq(&self, other: &Self) -> bool {
143        self.equal(other)
144    }
145}
146
147impl Eq for Stroke {}