styled.rs

 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        todo!()
11        // let x: StyleRefinement = self.style_cascade().merged();
12
13        // x.into();
14    }
15
16    fn hover(self) -> Hoverable<Self>
17    where
18        Self: 'static + Sized + Send + Sync,
19        Self::Style: 'static + Refineable + Default + Send + Sync,
20        <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
21    {
22        Hoverable::new(self, None)
23    }
24
25    fn group_hover(self, group_name: impl Into<SharedString>) -> Hoverable<Self>
26    where
27        Self: 'static + Sized + Send + Sync,
28        Self::Style: 'static + Refineable + Default + Send + Sync,
29        <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
30    {
31        Hoverable::new(self, Some(group_name.into()))
32    }
33
34    fn active(self) -> Pressable<Self>
35    where
36        Self: 'static + Sized + Send + Sync,
37        Self::Style: 'static + Refineable + Default + Send + Sync,
38        <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
39    {
40        Pressable::new(self, None)
41    }
42
43    fn group_active(self, group_name: impl Into<SharedString>) -> Pressable<Self>
44    where
45        Self: 'static + Sized + Send + Sync,
46        Self::Style: 'static + Refineable + Default + Send + Sync,
47        <Self::Style as Refineable>::Refinement: 'static + Default + Send + Sync,
48    {
49        Pressable::new(self, Some(group_name.into()))
50    }
51}