From 441d4091cb3d2610651b621e9fa5c53259970979 Mon Sep 17 00:00:00 2001 From: hippoz <10706925-hippoz@users.noreply.gitlab.com> Date: Fri, 1 Apr 2022 07:13:36 +0300 Subject: [PATCH] make test program more interesting --- src/main.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0a0cfd9..f1cf0ef 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,17 +10,19 @@ int main() { Raven::Layout main_layout {}; Raven::Widget new_row { Raven::ControlWidgetType::NewRow }; Raven::Window window {}; - Raven::Widget main_widget {}; - Raven::Button button {"click meeeeeeeeeeee"}; - Raven::Button impostor_button {"other button"}; - Raven::Label label {"click it!"}; - int times_clicked = 0; + Raven::Widget main_widget {}; + Raven::Button add_button {"add"}; + Raven::Button subtract_button {"subtract"}; + Raven::Label label {"0"}; + + int number = 0; + window.spawn_window(); - button.set_current_geometry(Raven::Box(0, 0, 100, 30)); - impostor_button.set_current_geometry(Raven::Box(0, 0, 100, 30)); + add_button.set_current_geometry(Raven::Box(0, 0, 100, 30)); + subtract_button.set_current_geometry(Raven::Box(0, 0, 100, 30)); label.set_current_geometry(Raven::Box(0, 0, 100, 20)); main_layout.set_margin(6.0); @@ -28,15 +30,20 @@ int main() { main_widget.set_layout(&main_layout); window.set_main_widget(&main_widget); - button.on_click = [&]() { - times_clicked++; - label.set_text(std::to_string(times_clicked)); + add_button.on_click = [&]() { + number++; + label.set_text(std::to_string(number)); }; - main_widget.add_child(&button); - main_widget.add_child(&label); + subtract_button.on_click = [&]() { + number--; + label.set_text(std::to_string(number)); + }; + + main_widget.add_child(&add_button); + main_widget.add_child(&subtract_button); main_widget.add_child(&new_row); - main_widget.add_child(&impostor_button); + main_widget.add_child(&label); window.run(true);