diff --git a/src/main.cpp b/src/main.cpp index 030a606..f495601 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,40 +11,45 @@ #include "src/Styles.hpp" #include #include -#include #include -void update_count_label_text(std::shared_ptr label, int number) { - std::stringstream text; - text << "you have clicked the button " << std::to_string(number) << " times"; - label->set_text(text.str()); -} - int main() { Raven::Window window {}; - int number = 0; - window.spawn_window(); auto main_widget = window.set_main_widget(); main_widget->set_layout(10.0); - auto count_label = main_widget->add("you have clicked the button 0 times"); + auto second_widget = main_widget->add(); + second_widget->set_layout(20.0); + second_widget->resize(800, 800); - main_widget->add(Raven::ControlWidgetType::NewRow); + auto inner_widget = second_widget->add(); + inner_widget->set_layout(8.0); + inner_widget->resize(600, 600); - auto increment_button = main_widget->add("click me"); - increment_button->set_style(&Raven::accent_button_style); - increment_button->on_click = [&]() { - number++; - update_count_label_text(count_label, number); - }; + int number = 0; - auto reset_button = main_widget->add("reset"); - reset_button->on_click = [&]() { - number = 0; - update_count_label_text(count_label, number); - }; + for (int i = 0; i < 250; i++) { + auto button = inner_widget->add("click me"); + button->set_style(&Raven::accent_button_style); + auto label = inner_widget->add("click one of the buttons!"); + button->on_click = [&]() { + number += 10; + + window.start_batch(); + auto& children = inner_widget->children(); + for (auto& child : children) { + if (child->type() == Raven::WidgetType::Button) { + std::static_pointer_cast(child)->set_text(std::to_string(number)); + } + if (child->type() == Raven::WidgetType::Label) { + std::static_pointer_cast(child)->set_text(std::to_string(number)); + } + } + window.end_batch(); + }; + } window.run(true); return 0;