1use crate::{Cascade, Hoverable, Pressable, Refineable, SharedString};
2
3pub trait Styled {
4 type Style: 'static + Refineable + Send + Sync + Default;
5
6 fn style_cascade(&mut self) -> &mut Cascade<Self::Style>;
7 fn declared_style(&mut self) -> &mut <Self::Style as Refineable>::Refinement;
8
9 fn computed_style(&mut self) -> Self::Style {
10 Self::Style::default().refined(self.style_cascade().merged())
11 }
12
13 fn hover(self) -> Hoverable<Self>
14 where
15 Self: 'static + Sized + Send + Sync,
16 Self::Style: 'static + Refineable + Default + Send + Sync,
17 <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
18 {
19 Hoverable::new(self, None)
20 }
21
22 fn group_hover(self, group_name: impl Into<SharedString>) -> Hoverable<Self>
23 where
24 Self: 'static + Sized + Send + Sync,
25 Self::Style: 'static + Refineable + Default + Send + Sync,
26 <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
27 {
28 Hoverable::new(self, Some(group_name.into()))
29 }
30
31 fn active(self) -> Pressable<Self>
32 where
33 Self: 'static + Sized + Send + Sync,
34 Self::Style: 'static + Refineable + Default + Send + Sync,
35 <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
36 {
37 Pressable::new(self, None)
38 }
39
40 fn group_active(self, group_name: impl Into<SharedString>) -> Pressable<Self>
41 where
42 Self: 'static + Sized + Send + Sync,
43 Self::Style: 'static + Refineable + Default + Send + Sync,
44 <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
45 {
46 Pressable::new(self, Some(group_name.into()))
47 }
48}