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

envelope works

parent c2936bb2
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ use log::info; ...@@ -28,7 +28,7 @@ use log::info;
use druid_widgets::*; use druid_widgets::*;
#[derive(Clone, Data, Lens)] #[derive(Clone, Data, Lens, Default)]
struct DialLabel { struct DialLabel {
value: f64, value: f64,
} }
...@@ -51,7 +51,7 @@ impl DialLabel { ...@@ -51,7 +51,7 @@ impl DialLabel {
col col
} }
} }
#[derive(Clone, Data, Lens)] #[derive(Clone, Data, Lens, Default)]
struct Envelope { struct Envelope {
attack: DialLabel, attack: DialLabel,
decay: DialLabel, decay: DialLabel,
...@@ -62,29 +62,43 @@ struct Envelope { ...@@ -62,29 +62,43 @@ struct Envelope {
impl Envelope { impl Envelope {
fn new() -> impl Widget<Envelope> { fn new() -> impl Widget<Envelope> {
let solid = Color::rgb8(0x3a, 0x3a, 0x3a); let solid = Color::rgb8(0x3a, 0x3a, 0x3a);
let mut col = Flex::column(); let mut row = Flex::row();
col.add_child( row.add_child(
DialLabel::new("Attack") DialLabel::new("Attack")
.lens(Envelope::attack) .lens(Envelope::attack)
.background(solid.clone()) .background(solid.clone())
.padding(5.0), .padding(5.0),
0.0, 0.0,
); );
col.add_child( row.add_child(
DialLabel::new("Decay") DialLabel::new("Decay")
.lens(Envelope::decay) .lens(Envelope::decay)
.background(solid.clone()) .background(solid.clone())
.padding(5.0), .padding(5.0),
0.0, 0.0,
); );
col row.add_child(
DialLabel::new("Sustain")
.lens(Envelope::sustain)
.background(solid.clone())
.padding(5.0),
0.0,
);
row.add_child(
DialLabel::new("Release")
.lens(Envelope::release)
.background(solid.clone())
.padding(5.0),
0.0,
);
row
} }
} }
fn main() -> Result<(), PlatformError> { fn main() -> Result<(), PlatformError> {
AppLauncher::with_window(WindowDesc::new(|| DialLabel::new("Value"))) AppLauncher::with_window(WindowDesc::new(Envelope::new))
.use_simple_logger() .use_simple_logger()
.launch(DialLabel { value: 0.0 })?; .launch(Envelope::default())?;
Ok(()) Ok(())
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment