ferroui_base/media/effects/
blur_effect.rs1use crate::media::effects::{Effect, IImmutableEffect, ImmutableBlurEffect};
2use crate::{
3 ferro_class, ferro_property, instantiate, FerroObjectImpl, FerroProperty, Ref, StyledProperty,
4};
5
6#[repr(C)]
8pub struct BlurEffect {
9 base: Effect,
10}
11
12ferro_class!(BlurEffect: Effect);
13crate::ferro_class_info!(BlurEffect { new: BlurEffect::new });
14
15crate::ferro_impl_classes!(BlurEffect: FerroObjectImpl);
16
17crate::ferro_properties! { impl BlurEffect {
18 ferro_property!(pub fn radius_property() -> StyledProperty<f64> {
19 FerroProperty::register::<BlurEffect, _>("Radius", 5.0)
20 });
21} }
22
23impl BlurEffect {
24 fn static_constructor() {
25 Effect::affects_render::<BlurEffect>(&[Self::radius_property().as_property()]);
26 }
27
28 pub fn construct() -> Self {
30 Self { base: Effect::construct() }
31 }
32
33 pub fn new() -> Ref<Self> {
34 instantiate(Self::construct())
35 }
36
37 pub fn radius(&self) -> f64 {
39 self.get_value(Self::radius_property())
40 }
41
42 pub fn set_radius(&self, value: f64) {
43 self.set_value(Self::radius_property(), value)
44 }
45
46 pub fn to_immutable(&self) -> std::sync::Arc<dyn IImmutableEffect> {
48 std::sync::Arc::new(ImmutableBlurEffect::new(self.radius()))
49 }
50}