framework_tool_tui/tui/
control.rs1pub enum AdjustableControl {
2 Percentage(bool, u8),
3 Range(bool, f32, f32),
4}
5
6impl AdjustableControl {
7 pub fn toggle_focus(&self) -> Self {
8 match self {
9 AdjustableControl::Percentage(focused, value) => {
10 AdjustableControl::Percentage(!focused, *value)
11 }
12 AdjustableControl::Range(focused, from, to) => {
13 AdjustableControl::Range(!focused, *from, *to)
14 }
15 }
16 }
17
18 pub fn is_focused(&self) -> bool {
19 match self {
20 AdjustableControl::Percentage(focused, _) => *focused,
21 AdjustableControl::Range(focused, _, _) => *focused,
22 }
23 }
24
25 pub fn get_percentage_value(&self) -> Option<u8> {
26 match self {
27 AdjustableControl::Percentage(_, value) => Some(*value),
28 _ => None,
29 }
30 }
31}
32
33pub fn percentage_control(value: u8) -> AdjustableControl {
34 AdjustableControl::Percentage(false, value)
35}
36
37pub fn range_control(from: f32, to: f32) -> AdjustableControl {
38 AdjustableControl::Range(false, from, to)
39}