raven/src/main.cpp

57 lines
1.7 KiB
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 "RGB.hpp"
#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>
int main() {
Raven::Window window {};
window.spawn_window();
2022-04-01 07:13:36 +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);
auto second_widget = main_widget->add<Raven::Widget>();
second_widget->set_layout<Raven::DocumentLayout>(20.0);
second_widget->resize(800, 800);
auto inner_widget = second_widget->add<Raven::Widget>();
inner_widget->set_layout<Raven::DocumentLayout>(8.0);
inner_widget->resize(600, 600);
int number = 0;
2022-03-20 03:05:21 +02: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
window.run(true);
return 0;
}