From c2936bb2cd280e67abff5e12a386d11825326e11 Mon Sep 17 00:00:00 2001
From: Per Lindgren <per.lindgren@ltu.se>
Date: Sun, 26 Jan 2020 03:38:31 +0100
Subject: [PATCH] dail3 wip

---
 examples/dial_test3.rs | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/examples/dial_test3.rs b/examples/dial_test3.rs
index a96a6b3..84844fb 100644
--- a/examples/dial_test3.rs
+++ b/examples/dial_test3.rs
@@ -34,11 +34,11 @@ struct DialLabel {
 }
 
 impl DialLabel {
-    fn new(text: String) -> impl Widget<DialLabel> {
-        let solid = Color::rgb8(0x3a, 0x3a, 0x3a);
-
+    fn new(text: &str) -> impl Widget<DialLabel> {
+        let text = text.to_string();
         let label =
             Label::new(move |data: &DialLabel, _env: &_| format!("{} {:.3}", text, data.value));
+        let solid = Color::rgb8(0x3a, 0x3a, 0x3a);
         let mut col = Flex::column();
         col.add_child(
             Dial::new(Size::new(100.0, 100.0))
@@ -51,9 +51,38 @@ impl DialLabel {
         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> {
-    AppLauncher::with_window(WindowDesc::new(|| DialLabel::new("Value".to_string())))
+    AppLauncher::with_window(WindowDesc::new(|| DialLabel::new("Value")))
         .use_simple_logger()
         .launch(DialLabel { value: 0.0 })?;
 
-- 
GitLab