flow_rs_core/selection/
visual_feedback.rs1#[derive(Debug, Clone, PartialEq, Default)]
5pub struct VisualFeedback {
6 selected: bool,
8 hovered: bool,
10 highlighted: bool,
12 animation_progress: f64,
14}
15
16impl VisualFeedback {
17 pub fn new() -> Self {
19 Self::default()
20 }
21
22 pub fn selected() -> Self {
24 Self {
25 selected: true,
26 ..Default::default()
27 }
28 }
29
30 pub fn is_selected(&self) -> bool {
32 self.selected
33 }
34
35 pub fn is_hovered(&self) -> bool {
37 self.hovered
38 }
39
40 pub fn is_highlighted(&self) -> bool {
42 self.highlighted
43 }
44
45 pub fn animation_progress(&self) -> f64 {
47 self.animation_progress
48 }
49
50 pub fn set_selected(&mut self, selected: bool) {
52 self.selected = selected;
53 }
54
55 pub fn set_hovered(&mut self, hovered: bool) {
57 self.hovered = hovered;
58 }
59
60 pub fn set_highlighted(&mut self, highlighted: bool) {
62 self.highlighted = highlighted;
63 }
64
65 pub fn set_animation_progress(&mut self, progress: f64) {
67 self.animation_progress = progress.clamp(0.0, 1.0);
68 }
69
70 pub fn has_any_state(&self) -> bool {
72 self.selected || self.hovered || self.highlighted
73 }
74}