ferroui_base/media/
gradient_stop.rs1use crate::media::Color;
2use crate::{
3 ferro_class, ferro_impl_classes, ferro_property, instantiate, FerroObject, FerroObjectImpl, FerroProperty, Ref,
4 StyledProperty,
5};
6
7#[repr(C)]
9pub struct GradientStop {
10 base: FerroObject,
11}
12
13ferro_class!(GradientStop: FerroObject);
14crate::ferro_class_info!(GradientStop { new: GradientStop::new });
15ferro_impl_classes!(GradientStop: FerroObjectImpl);
16
17crate::ferro_properties! { impl GradientStop {
18 ferro_property!(pub fn offset_property() -> StyledProperty<f64> {
19 FerroProperty::register::<GradientStop, _>("Offset", 0.0)
20 });
21
22 ferro_property!(pub fn color_property() -> StyledProperty<Color> {
23 FerroProperty::register::<GradientStop, _>("Color", Color::default())
24 });
25} }
26
27impl GradientStop {
28 pub fn construct() -> Self {
30 Self { base: FerroObject::construct() }
31 }
32
33 pub fn new() -> Ref<Self> {
34 instantiate(Self::construct())
35 }
36
37 pub fn with_color_and_offset(color: Color, offset: f64) -> Ref<Self> {
39 let result = Self::new();
40 result.set_color(color);
41 result.set_offset(offset);
42 result
43 }
44
45 pub fn offset(&self) -> f64 {
47 self.get_value(Self::offset_property())
48 }
49
50 pub fn set_offset(&self, value: f64) {
51 self.set_value(Self::offset_property(), value)
52 }
53
54 pub fn color(&self) -> Color {
56 self.get_value(Self::color_property())
57 }
58
59 pub fn set_color(&self, value: Color) {
60 self.set_value(Self::color_property(), value)
61 }
62}