ferroui_base/media/
immutable_experimental_acrylic_material.rs1use crate::media::{AcrylicBackgroundSource, Color, IExperimentalAcrylicMaterial};
2use std::any::Any;
3use std::hash::{Hash, Hasher};
4
5#[derive(Clone, Copy, Debug, Default)]
7pub struct ImmutableExperimentalAcrylicMaterial {
8 background_source: AcrylicBackgroundSource,
9 tint_color: Color,
10 material_color: Color,
11 tint_opacity: f64,
12 fallback_color: Color,
13}
14
15impl ImmutableExperimentalAcrylicMaterial {
16 pub fn new(brush: &dyn IExperimentalAcrylicMaterial) -> Self {
18 Self {
19 background_source: brush.background_source(),
20 tint_color: brush.tint_color(),
21 tint_opacity: brush.tint_opacity(),
22 fallback_color: brush.fallback_color(),
23 material_color: brush.material_color(),
24 }
25 }
26
27 #[inline]
29 pub fn background_source(&self) -> AcrylicBackgroundSource {
30 self.background_source
31 }
32
33 #[inline]
35 pub fn tint_color(&self) -> Color {
36 self.tint_color
37 }
38
39 #[inline]
41 pub fn material_color(&self) -> Color {
42 self.material_color
43 }
44
45 #[inline]
47 pub fn tint_opacity(&self) -> f64 {
48 self.tint_opacity
49 }
50
51 #[inline]
53 pub fn fallback_color(&self) -> Color {
54 self.fallback_color
55 }
56
57 pub fn equals(&self, other: &ImmutableExperimentalAcrylicMaterial) -> bool {
59 self.tint_color == other.tint_color
60 && self.tint_opacity == other.tint_opacity
61 && self.background_source == other.background_source
62 && self.fallback_color == other.fallback_color
63 && self.material_color == other.material_color
64 }
65
66 pub fn get_effective_tint_color(&self) -> Color {
68 self.tint_color
69 }
70}
71
72impl PartialEq for ImmutableExperimentalAcrylicMaterial {
73 #[inline]
74 fn eq(&self, other: &Self) -> bool {
75 self.equals(other)
76 }
77}
78
79impl Hash for ImmutableExperimentalAcrylicMaterial {
80 fn hash<H: Hasher>(&self, state: &mut H) {
81 self.tint_color.hash(state);
82 self.tint_opacity.to_bits().hash(state);
83 self.background_source.hash(state);
84 self.fallback_color.hash(state);
85 self.material_color.hash(state);
86 }
87}
88
89impl IExperimentalAcrylicMaterial for ImmutableExperimentalAcrylicMaterial {
90 #[inline]
91 fn background_source(&self) -> AcrylicBackgroundSource {
92 self.background_source
93 }
94
95 #[inline]
96 fn tint_color(&self) -> Color {
97 self.tint_color
98 }
99
100 #[inline]
101 fn tint_opacity(&self) -> f64 {
102 self.tint_opacity
103 }
104
105 #[inline]
106 fn material_color(&self) -> Color {
107 self.material_color
108 }
109
110 #[inline]
111 fn fallback_color(&self) -> Color {
112 self.fallback_color
113 }
114
115 fn as_any(&self) -> &dyn Any {
116 self
117 }
118}