Skip to content
Snippets Groups Projects
Commit c2936bb2 authored by Per Lindgren's avatar Per Lindgren
Browse files

dail3 wip

parent e5eeb053
No related branches found
No related tags found
No related merge requests found
...@@ -34,11 +34,11 @@ struct DialLabel { ...@@ -34,11 +34,11 @@ struct DialLabel {
} }
impl DialLabel { impl DialLabel {
fn new(text: String) -> impl Widget<DialLabel> { fn new(text: &str) -> impl Widget<DialLabel> {
let solid = Color::rgb8(0x3a, 0x3a, 0x3a); let text = text.to_string();
let label = let label =
Label::new(move |data: &DialLabel, _env: &_| format!("{} {:.3}", text, data.value)); Label::new(move |data: &DialLabel, _env: &_| format!("{} {:.3}", text, data.value));
let solid = Color::rgb8(0x3a, 0x3a, 0x3a);
let mut col = Flex::column(); let mut col = Flex::column();
col.add_child( col.add_child(
Dial::new(Size::new(100.0, 100.0)) Dial::new(Size::new(100.0, 100.0))
...@@ -51,9 +51,38 @@ impl DialLabel { ...@@ -51,9 +51,38 @@ impl DialLabel {
col col
} }
} }
#[derive(Clone, Data, Lens)]
struct Envelope {
attack: DialLabel,
decay: DialLabel,
sustain: DialLabel,
release: DialLabel,
}
impl Envelope {
fn new() -> impl Widget<Envelope> {
let solid = Color::rgb8(0x3a, 0x3a, 0x3a);
let mut col = Flex::column();
col.add_child(
DialLabel::new("Attack")
.lens(Envelope::attack)
.background(solid.clone())
.padding(5.0),
0.0,
);
col.add_child(
DialLabel::new("Decay")
.lens(Envelope::decay)
.background(solid.clone())
.padding(5.0),
0.0,
);
col
}
}
fn main() -> Result<(), PlatformError> { fn main() -> Result<(), PlatformError> {
AppLauncher::with_window(WindowDesc::new(|| DialLabel::new("Value".to_string()))) AppLauncher::with_window(WindowDesc::new(|| DialLabel::new("Value")))
.use_simple_logger() .use_simple_logger()
.launch(DialLabel { value: 0.0 })?; .launch(DialLabel { value: 0.0 })?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment