make test program more interesting

This commit is contained in:
hippoz 2022-04-01 07:13:36 +03:00
parent eec776ba46
commit 441d4091cb
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -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);