libshumate/auto/vector_sprite.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from
3// from gir-files (https://github.com/gtk-rs/gir-files.git)
4// DO NOT EDIT
5
6use crate::ffi;
7use glib::{prelude::*, translate::*};
8
9#[cfg(feature = "gtk_v4_6")]
10#[cfg_attr(docsrs, doc(cfg(feature = "gtk_v4_6")))]
11glib::wrapper! {
12 /// A sprite used to draw textures or icons.
13 ///
14 /// ## Symbolic icons
15 ///
16 /// If a sprite is created from a [`gtk::SymbolicPaintable`][crate::gtk::SymbolicPaintable] source, such
17 /// as a symbolic icon, then when the sprite is part of a symbol layer it
18 /// will be drawn using the icon-color property (or the text color, if the
19 /// sprite is part of a formatted string).
20 ///
21 /// ## Properties
22 ///
23 ///
24 /// #### `height`
25 /// The height at which the sprite should be drawn, in pixels.
26 ///
27 /// Readable | Writeable | Construct Only
28 ///
29 ///
30 /// #### `scale-factor`
31 /// The intended scale factor of the sprite.
32 ///
33 /// Readable | Writeable | Construct Only
34 ///
35 ///
36 /// #### `source-paintable`
37 /// The [`gdk::Paintable`][crate::gdk::Paintable] used to draw the sprite.
38 ///
39 /// Readable | Writeable | Construct Only
40 ///
41 ///
42 /// #### `source-rect`
43 /// The area of the source rectangle to draw, or [`None`] to use the entire paintable.
44 ///
45 /// Readable | Writeable | Construct Only
46 ///
47 ///
48 /// #### `width`
49 /// The width at which the sprite should be drawn, in pixels.
50 ///
51 /// Readable | Writeable | Construct Only
52 ///
53 /// # Implements
54 ///
55 /// [`trait@glib::ObjectExt`], [`trait@gdk::prelude::PaintableExt`], [`trait@gtk::prelude::SymbolicPaintableExt`]
56 #[doc(alias = "ShumateVectorSprite")]
57 pub struct VectorSprite(Object<ffi::ShumateVectorSprite, ffi::ShumateVectorSpriteClass>) @implements gdk::Paintable, gtk::SymbolicPaintable;
58
59 match fn {
60 type_ => || ffi::shumate_vector_sprite_get_type(),
61 }
62}
63
64#[cfg(not(any(feature = "gtk_v4_6")))]
65glib::wrapper! {
66 #[doc(alias = "ShumateVectorSprite")]
67 pub struct VectorSprite(Object<ffi::ShumateVectorSprite, ffi::ShumateVectorSpriteClass>) @implements gdk::Paintable;
68
69 match fn {
70 type_ => || ffi::shumate_vector_sprite_get_type(),
71 }
72}
73
74impl VectorSprite {
75 /// Creates a new [`VectorSprite`][crate::VectorSprite] using the paintable's intrinsic size.
76 /// ## `source_paintable`
77 /// a [`gdk::Paintable`][crate::gdk::Paintable]
78 #[doc(alias = "shumate_vector_sprite_new")]
79 pub fn new(source_paintable: &impl IsA<gdk::Paintable>) -> VectorSprite {
80 assert_initialized_main_thread!();
81 unsafe {
82 from_glib_full(ffi::shumate_vector_sprite_new(
83 source_paintable.as_ref().to_glib_none().0,
84 ))
85 }
86 }
87
88 /// Creates a new [`VectorSprite`][crate::VectorSprite] with the given size, scale factor,
89 /// and area of the source paintable.
90 /// ## `source_paintable`
91 /// a [`gdk::Paintable`][crate::gdk::Paintable]
92 /// ## `width`
93 /// the width of the sprite in pixels
94 /// ## `height`
95 /// the height of the sprite in pixels
96 /// ## `scale_factor`
97 /// the intended scale factor of the sprite
98 /// ## `source_rect`
99 /// the source rectangle of the sprite, or [`None`] to use the entire paintable
100 #[doc(alias = "shumate_vector_sprite_new_full")]
101 pub fn new_full(
102 source_paintable: &impl IsA<gdk::Paintable>,
103 width: i32,
104 height: i32,
105 scale_factor: f64,
106 source_rect: Option<&gdk::Rectangle>,
107 ) -> VectorSprite {
108 assert_initialized_main_thread!();
109 unsafe {
110 from_glib_full(ffi::shumate_vector_sprite_new_full(
111 source_paintable.as_ref().to_glib_none().0,
112 width,
113 height,
114 scale_factor,
115 mut_override(source_rect.to_glib_none().0),
116 ))
117 }
118 }
119
120 // rustdoc-stripper-ignore-next
121 /// Creates a new builder-pattern struct instance to construct [`VectorSprite`] objects.
122 ///
123 /// This method returns an instance of [`VectorSpriteBuilder`](crate::builders::VectorSpriteBuilder) which can be used to create [`VectorSprite`] objects.
124 pub fn builder() -> VectorSpriteBuilder {
125 VectorSpriteBuilder::new()
126 }
127
128 /// Gets the height at which the sprite should be drawn.
129 ///
130 /// # Returns
131 ///
132 /// the sprite's height in pixels
133 #[doc(alias = "shumate_vector_sprite_get_height")]
134 #[doc(alias = "get_height")]
135 pub fn height(&self) -> i32 {
136 unsafe { ffi::shumate_vector_sprite_get_height(self.to_glib_none().0) }
137 }
138
139 /// Gets the intended scale factor of the sprite.
140 ///
141 /// # Returns
142 ///
143 /// the sprite's scale factor
144 #[doc(alias = "shumate_vector_sprite_get_scale_factor")]
145 #[doc(alias = "get_scale_factor")]
146 #[doc(alias = "scale-factor")]
147 pub fn scale_factor(&self) -> f64 {
148 unsafe { ffi::shumate_vector_sprite_get_scale_factor(self.to_glib_none().0) }
149 }
150
151 /// Gets the source [`gdk::Paintable`][crate::gdk::Paintable] used to draw the sprite.
152 ///
153 /// Note that [`VectorSprite`][crate::VectorSprite] also implements [`gdk::Paintable`][crate::gdk::Paintable].
154 /// In most cases, you should draw the sprite rather than the original paintable.
155 ///
156 /// # Returns
157 ///
158 /// the source paintable
159 #[doc(alias = "shumate_vector_sprite_get_source_paintable")]
160 #[doc(alias = "get_source_paintable")]
161 #[doc(alias = "source-paintable")]
162 pub fn source_paintable(&self) -> Option<gdk::Paintable> {
163 unsafe {
164 from_glib_none(ffi::shumate_vector_sprite_get_source_paintable(
165 self.to_glib_none().0,
166 ))
167 }
168 }
169
170 /// Gets the source rectangle of the sprite.
171 ///
172 /// # Returns
173 ///
174 /// the sprite's source rectangle, or [`None`] if the entire paintable is used
175 #[doc(alias = "shumate_vector_sprite_get_source_rect")]
176 #[doc(alias = "get_source_rect")]
177 #[doc(alias = "source-rect")]
178 pub fn source_rect(&self) -> Option<gdk::Rectangle> {
179 unsafe {
180 from_glib_none(ffi::shumate_vector_sprite_get_source_rect(
181 self.to_glib_none().0,
182 ))
183 }
184 }
185
186 /// Gets the width at which the sprite should be drawn.
187 ///
188 /// # Returns
189 ///
190 /// the sprite's width in pixels
191 #[doc(alias = "shumate_vector_sprite_get_width")]
192 #[doc(alias = "get_width")]
193 pub fn width(&self) -> i32 {
194 unsafe { ffi::shumate_vector_sprite_get_width(self.to_glib_none().0) }
195 }
196}
197
198#[cfg(feature = "v1_1")]
199#[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
200impl Default for VectorSprite {
201 fn default() -> Self {
202 glib::object::Object::new::<Self>()
203 }
204}
205
206// rustdoc-stripper-ignore-next
207/// A [builder-pattern] type to construct [`VectorSprite`] objects.
208///
209/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
210#[must_use = "The builder must be built to be used"]
211pub struct VectorSpriteBuilder {
212 builder: glib::object::ObjectBuilder<'static, VectorSprite>,
213}
214
215impl VectorSpriteBuilder {
216 fn new() -> Self {
217 Self {
218 builder: glib::object::Object::builder(),
219 }
220 }
221
222 /// The height at which the sprite should be drawn, in pixels.
223 #[cfg(feature = "v1_1")]
224 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
225 pub fn height(self, height: i32) -> Self {
226 Self {
227 builder: self.builder.property("height", height),
228 }
229 }
230
231 /// The intended scale factor of the sprite.
232 #[cfg(feature = "v1_1")]
233 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
234 pub fn scale_factor(self, scale_factor: f64) -> Self {
235 Self {
236 builder: self.builder.property("scale-factor", scale_factor),
237 }
238 }
239
240 /// The [`gdk::Paintable`][crate::gdk::Paintable] used to draw the sprite.
241 #[cfg(feature = "v1_1")]
242 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
243 pub fn source_paintable(self, source_paintable: &impl IsA<gdk::Paintable>) -> Self {
244 Self {
245 builder: self
246 .builder
247 .property("source-paintable", source_paintable.clone().upcast()),
248 }
249 }
250
251 /// The area of the source rectangle to draw, or [`None`] to use the entire paintable.
252 #[cfg(feature = "v1_1")]
253 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
254 pub fn source_rect(self, source_rect: &gdk::Rectangle) -> Self {
255 Self {
256 builder: self.builder.property("source-rect", source_rect),
257 }
258 }
259
260 /// The width at which the sprite should be drawn, in pixels.
261 #[cfg(feature = "v1_1")]
262 #[cfg_attr(docsrs, doc(cfg(feature = "v1_1")))]
263 pub fn width(self, width: i32) -> Self {
264 Self {
265 builder: self.builder.property("width", width),
266 }
267 }
268
269 // rustdoc-stripper-ignore-next
270 /// Build the [`VectorSprite`].
271 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
272 pub fn build(self) -> VectorSprite {
273 assert_initialized_main_thread!();
274 self.builder.build()
275 }
276}