diff --git a/src/main.rs b/src/main.rs index 35c86b4..74c0d2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -164,7 +164,9 @@ fn main() { let ui = UI::init().unwrap(); // Initialize the state of the application. - let state = Rc::new(RefCell::new(State { slider_val: 0, spinner_val: 0, entry_val: "".into(), multi_val: "".into() })); + let state = Rc::new(RefCell::new( + State { slider_val: 0, spinner_val: 0, entry_val: "".into(), multi_val: "".into() } + )); // Set up the inputs for the application. // While it's not necessary to create a block for this, it makes the code a lot easier @@ -173,14 +175,17 @@ fn main() { let (input_group, mut slider, mut spinner, mut entry, mut multi) = { // The group will hold all the inputs let mut input_group = Group::new(&ui, "Inputs"); + // The vertical box arranges the inputs within the groups let mut input_vbox = VerticalBox::new(&ui); input_vbox.set_padded(&ui, true); + // Numerical inputs let slider = Slider::new(&ui, 1, 100); let spinner = Spinbox::new(&ui, 1, 100); let entry = Entry::new(&ui); let multi = MultilineEntry::new(&ui); + // Add everything in hierarchy // Note the reverse order here. Again, it's not necessary, but it improves // readability. @@ -192,6 +197,7 @@ fn main() { input_vbox.append(&ui, entry.clone(), LayoutStrategy::Compact); input_vbox.append(&ui, multi.clone(), LayoutStrategy::Stretchy); input_group.set_child(&ui, input_vbox); + (input_group, slider, spinner, entry, multi) }; @@ -209,6 +215,7 @@ fn main() { output_vbox.append(&ui, text_label.clone(), LayoutStrategy::Compact); output_vbox.append(&ui, bigtext_label.clone(), LayoutStrategy::Stretchy); output_group.set_child(&ui, output_vbox); + (output_group, add_label, sub_label, text_label, bigtext_label) };