summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp112
1 files changed, 112 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
new file mode 100644
index 0000000..c1c14ca
--- /dev/null
+++ b/main.cpp
@@ -0,0 +1,112 @@
+#include <iostream>
+
+#include <string>
+#include <chisel/box.hpp>
+#include <chisel/sdl_window.hpp>
+#include <chisel/vertical_box.hpp>
+#include <chisel/button.hpp>
+#include <chisel/attribute.hpp>
+
+#include <socket/socket.hpp>
+
+void mouse_button_up(int x, int y, int button) {
+ std::cout << "mouse button up " << x << " " << y << " " << button << std::endl;
+}
+
+void mouse_button_down(int x, int y, int button) {
+ std::cout << "mouse button down " << x << " " << y << " " << button << std::endl;
+}
+
+void mouse_enter(int x, int y) {
+ std::cout << "mouse entered from " << x << " " << y << std::endl;
+}
+
+void mouse_exit(int x, int y) {
+ std::cout << "mouse exitted on " << x << " " << y << std::endl;
+}
+
+int main() {
+ std::cout << "chisel toolkit" << std::endl;
+ chisel::SDLWindow window("hai");
+ chisel::Kiosk *a = new chisel::Kiosk();
+ a->padding_top = 10;
+ a->padding_bottom = 10;
+ a->padding_left = 10;
+ a->padding_right = 10;
+ a->width_attr = {
+ .type = chisel::PR,
+ .pr = 1.0
+ };
+ a->height_attr = {
+ .type = chisel::PR,
+ .pr = 1.0
+ };
+ a->mouse_button_up.connect(mouse_button_up);
+ a->mouse_button_down.connect(mouse_button_down);
+ a->mouse_enter.connect(mouse_enter);
+ a->mouse_exit.connect(mouse_exit);
+ window.add_child(a);
+ chisel::VerticalBox *b = new chisel::VerticalBox();
+ b->id = "B";
+ b->margin = 8;
+ b->padding_top = 15;
+ b->padding_bottom = 15;
+ b->padding_left = 15;
+ b->padding_right = 15;
+ b->width_attr = {
+ .type = chisel::PR,
+ .pr = 1.0
+ };
+ b->height_attr = {
+ .type = chisel::PR,
+ .pr = 1.0
+ };
+ b->mouse_button_up.connect(mouse_button_up);
+ b->mouse_button_down.connect(mouse_button_down);
+ b->mouse_enter.connect(mouse_enter);
+ b->mouse_exit.connect(mouse_exit);
+ a->add_child(b);
+
+ for (int i = 0; i < 5; i++) {
+ chisel::Button *c = new chisel::Button();
+ c->width_attr = {
+ .type = chisel::PR,
+ .pr = 1.0
+ };
+ c->height_attr = {
+ .type = chisel::PR,
+ .pr = 0.08
+ };
+ c->mouse_button_up.connect(mouse_button_up);
+ c->mouse_button_down.connect(mouse_button_down);
+ c->mouse_enter.connect(mouse_enter);
+ c->mouse_exit.connect(mouse_exit);
+ b->add_child(c);
+ }
+
+/*
+ chisel::Button *c = new chisel::Button();
+ c->x = 0;
+ c->y = 0;
+ c->width_attr = {
+ .type = chisel::PX,
+ .px = 30
+ };
+ c->height_attr = {
+ .type = chisel::PX,
+ .px = 25
+ };
+ c->parent = b;
+ c->window = &window;
+ c->mouse_button_up.connect(mouse_button_up);
+ c->mouse_button_down.connect(mouse_button_down);
+ c->mouse_enter.connect(mouse_enter);
+ c->mouse_exit.connect(mouse_exit);
+ b->add_child(c);*/
+
+ window.run();
+
+ chisel::AttributeType attr = chisel::AttributeType::AUTO;
+
+ return 0;
+}