audio_processor_iced_design_system/
knob.rs1pub use iced_audio::Knob;
24
25pub mod style {
26 use iced_audio::graphics::knob::{Appearance, NotchShape, StyleLength};
27 use iced_audio::knob::ValueArcAppearance;
28 use iced_style::Theme;
29
30 use crate::colors::Colors;
31
32 pub struct Knob;
33
34 impl iced_audio::knob::StyleSheet for Knob {
35 type Style = Theme;
36
37 fn active(&self, _style: &Self::Style) -> Appearance {
38 Appearance::Arc(iced_audio::style::knob::ArcAppearance {
39 width: StyleLength::Fixed(3.),
40 empty_color: Colors::background_level0(),
41 filled_color: Colors::active_border_color(),
42 notch: Knob::notch(),
43 cap: Default::default(),
44 })
45 }
46
47 fn hovered(&self, _style: &Self::Style) -> Appearance {
48 Appearance::Arc(iced_audio::style::knob::ArcAppearance {
49 width: StyleLength::Fixed(3.),
50 empty_color: Colors::background_level0(),
51 filled_color: Colors::active_border_color(),
52 notch: Knob::notch(),
53 cap: Default::default(),
54 })
55 }
56
57 fn dragging(&self, _style: &Self::Style) -> Appearance {
58 Appearance::Arc(iced_audio::style::knob::ArcAppearance {
59 width: StyleLength::Fixed(3.),
60 empty_color: Colors::background_level0(),
61 filled_color: Colors::active_border_color(),
62 notch: Knob::notch(),
63 cap: Default::default(),
64 })
65 }
66
67 fn value_arc_appearance(&self, _style: &Self::Style) -> Option<ValueArcAppearance> {
68 Some(ValueArcAppearance {
69 width: 1.0,
70 offset: 0.0,
71 empty_color: Some(Colors::background_level0()),
72 left_filled_color: Default::default(),
73 right_filled_color: None,
74 cap: Default::default(),
75 })
76 }
77 }
78
79 impl Knob {
80 fn notch() -> NotchShape {
81 NotchShape::Line(iced_audio::style::knob::LineNotch {
82 color: Colors::background_level0(),
83 width: StyleLength::Scaled(0.1),
84 length: StyleLength::Scaled(0.4),
85 cap: Default::default(),
86 offset: StyleLength::Fixed(0.),
87 })
88 }
89 }
90}