diff --git a/src/exercises/day-3/simple-gui.md b/src/exercises/day-3/simple-gui.md index 2d35ef15..ecaf0120 100644 --- a/src/exercises/day-3/simple-gui.md +++ b/src/exercises/day-3/simple-gui.md @@ -1,13 +1,14 @@ -# A Simple GUI Library +# Drawing A Simple GUI Let us design a classical GUI library using our new knowledge of traits and -trait objects. +trait objects. We'll only implement the drawing of it (as text) for simplicity. We will have a number of widgets in our library: * `Window`: has a `title` and contains other widgets. -* `Button`: has a `label` and a callback function which is invoked when the - button is pressed. +* `Button`: has a `label`. In reality, it would also take a callback + function to allow the program to do something when the button is clicked + but we won't include that since we're only drawing the GUI. * `Label`: has a `label`. The widgets will implement a `Widget` trait, see below. diff --git a/src/exercises/day-3/simple-gui.rs b/src/exercises/day-3/simple-gui.rs index ee467362..dd2058cb 100644 --- a/src/exercises/day-3/simple-gui.rs +++ b/src/exercises/day-3/simple-gui.rs @@ -43,14 +43,12 @@ impl Label { pub struct Button { label: Label, - callback: Box<dyn FnMut()>, } impl Button { - fn new(label: &str, callback: Box<dyn FnMut()>) -> Button { + fn new(label: &str) -> Button { Button { label: Label::new(label), - callback, } } } @@ -158,8 +156,7 @@ fn main() { let mut window = Window::new("Rust GUI Demo 1.23"); window.add_widget(Box::new(Label::new("This is a small text GUI demo."))); window.add_widget(Box::new(Button::new( - "Click me!", - Box::new(|| println!("You clicked the button!")), + "Click me!" ))); window.draw(); } diff --git a/src/exercises/day-3/solutions-morning.md b/src/exercises/day-3/solutions-morning.md index a226109e..f233c4fe 100644 --- a/src/exercises/day-3/solutions-morning.md +++ b/src/exercises/day-3/solutions-morning.md @@ -1,6 +1,6 @@ # Day 3 Morning Exercise -## A Simple GUI Library +## Drawing A Simple GUI ([back to exercise](simple-gui.md))