2022-03-26 02:57:41 +02:00
|
|
|
#include "Label.hpp"
|
2022-03-08 02:25:22 +02:00
|
|
|
#include "Window.hpp"
|
2022-03-09 20:02:18 +02:00
|
|
|
#include "Widget.hpp"
|
2022-03-09 20:16:05 +02:00
|
|
|
#include "Button.hpp"
|
2022-03-09 20:02:18 +02:00
|
|
|
#include "Box.hpp"
|
2022-03-26 02:57:41 +02:00
|
|
|
#include "Label.hpp"
|
2022-03-30 14:49:31 +03:00
|
|
|
#include "Layout.hpp"
|
2022-06-10 19:42:03 +03:00
|
|
|
#include "RGB.hpp"
|
2022-06-11 15:56:26 +03:00
|
|
|
#include "DocumentLayout.hpp"
|
|
|
|
#include "Events.hpp"
|
2022-06-12 22:16:26 +03:00
|
|
|
#include "src/Styles.hpp"
|
2022-05-10 16:17:12 +03:00
|
|
|
#include <iostream>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2022-01-22 17:51:54 +02:00
|
|
|
|
|
|
|
int main() {
|
2022-03-09 03:46:27 +02:00
|
|
|
Raven::Window window {};
|
2022-05-13 17:33:53 +03:00
|
|
|
window.spawn_window();
|
2022-04-01 07:13:36 +03:00
|
|
|
|
2022-04-24 02:59:47 +03:00
|
|
|
auto main_widget = window.set_main_widget<Raven::Widget>();
|
2022-06-10 20:28:03 +03:00
|
|
|
main_widget->set_layout<Raven::DocumentLayout>(10.0);
|
2022-04-24 02:59:47 +03:00
|
|
|
|
2022-06-14 01:46:58 +03:00
|
|
|
auto second_widget = main_widget->add<Raven::Widget>();
|
|
|
|
second_widget->set_layout<Raven::DocumentLayout>(20.0);
|
|
|
|
second_widget->resize(800, 800);
|
2022-06-10 19:42:03 +03:00
|
|
|
|
2022-06-14 01:46:58 +03:00
|
|
|
auto inner_widget = second_widget->add<Raven::Widget>();
|
|
|
|
inner_widget->set_layout<Raven::DocumentLayout>(8.0);
|
|
|
|
inner_widget->resize(600, 600);
|
2022-01-22 17:51:54 +02:00
|
|
|
|
2022-06-14 01:46:58 +03:00
|
|
|
int number = 0;
|
2022-03-20 03:05:21 +02:00
|
|
|
|
2022-06-14 01:46:58 +03:00
|
|
|
for (int i = 0; i < 250; i++) {
|
|
|
|
auto button = inner_widget->add<Raven::Button>("click me");
|
|
|
|
button->set_style(&Raven::accent_button_style);
|
|
|
|
auto label = inner_widget->add<Raven::Label>("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<Raven::Button>(child)->set_text(std::to_string(number));
|
|
|
|
}
|
|
|
|
if (child->type() == Raven::WidgetType::Label) {
|
|
|
|
std::static_pointer_cast<Raven::Label>(child)->set_text(std::to_string(number));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
window.end_batch();
|
|
|
|
};
|
|
|
|
}
|
2022-04-01 07:13:36 +03:00
|
|
|
|
2022-03-09 20:02:18 +02:00
|
|
|
window.run(true);
|
2022-01-22 17:51:54 +02:00
|
|
|
return 0;
|
2022-05-13 17:33:53 +03:00
|
|
|
}
|