raven/src/main.cpp

52 lines
1.4 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>
2022-06-12 23:40:04 +03:00
#include <sstream>
2022-05-10 16:17:12 +03:00
#include <string>
2022-06-12 23:40:04 +03:00
void update_count_label_text(std::shared_ptr<Raven::Label> 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 {};
2022-06-12 23:40:04 +03:00
int number = 0;
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);
2022-06-12 23:40:04 +03:00
auto count_label = main_widget->add<Raven::Label>("you have clicked the button 0 times");
2022-06-12 23:40:04 +03:00
main_widget->add<Raven::Widget>(Raven::ControlWidgetType::NewRow);
2022-06-12 23:40:04 +03:00
auto increment_button = main_widget->add<Raven::Button>("click me");
increment_button->set_style(&Raven::accent_button_style);
increment_button->on_click = [&]() {
number++;
update_count_label_text(count_label, number);
};
2022-03-20 03:05:21 +02:00
2022-06-12 23:40:04 +03:00
auto reset_button = main_widget->add<Raven::Button>("reset");
reset_button->on_click = [&]() {
number = 0;
update_count_label_text(count_label, number);
};
2022-04-01 07:13:36 +03:00
window.run(true);
return 0;
}