raven/src/main.cpp

38 lines
962 B
C++
Raw Normal View History

#include "Label.hpp"
2022-03-08 02:25:22 +02:00
#include "Window.hpp"
#include "Widget.hpp"
2022-03-09 20:16:05 +02:00
#include "Button.hpp"
#include "Box.hpp"
#include "Label.hpp"
2022-03-30 14:49:31 +03:00
#include "Layout.hpp"
#include "src/DocumentLayout.hpp"
2022-05-10 16:17:12 +03:00
#include <iostream>
#include <memory>
#include <string>
int main() {
Raven::Window window {};
2022-04-01 07:13:36 +03:00
auto main_widget = window.set_main_widget<Raven::Widget>();
main_widget->set_layout<Raven::DocumentLayout>(6.0);
2022-04-01 07:13:36 +03:00
int number = 0;
2022-05-10 16:17:12 +03:00
for (int i = 0; i < 100; i++) {
auto button = main_widget->add<Raven::Button>("0");
button->on_click = [&]() {
number++;
2022-03-20 03:05:21 +02:00
2022-05-10 16:17:12 +03:00
for (auto& c : main_widget->children()) {
if (c->type() == Raven::WidgetType::Button) {
auto button_child = std::static_pointer_cast<Raven::Button>(c);
button_child->set_text(std::to_string(number));
}
}
};
}
2022-04-01 07:13:36 +03:00
window.spawn_window();
window.run(true);
return 0;
2022-03-08 02:25:22 +02:00
}