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>
|
2022-06-12 23:40:04 +03:00
|
|
|
#include <sstream>
|
2022-05-10 16:17:12 +03:00
|
|
|
#include <string>
|
2022-01-22 17:51:54 +02:00
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2022-01-22 17:51:54 +02:00
|
|
|
int main() {
|
2022-03-09 03:46:27 +02:00
|
|
|
Raven::Window window {};
|
2022-06-12 23:40:04 +03:00
|
|
|
int number = 0;
|
|
|
|
|
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-12 23:40:04 +03:00
|
|
|
auto count_label = main_widget->add<Raven::Label>("you have clicked the button 0 times");
|
2022-06-10 19:42:03 +03:00
|
|
|
|
2022-06-12 23:40:04 +03:00
|
|
|
main_widget->add<Raven::Widget>(Raven::ControlWidgetType::NewRow);
|
2022-01-22 17:51:54 +02:00
|
|
|
|
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
|
|
|
|
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
|
|
|
}
|