summaryrefslogtreecommitdiff
path: root/main.cpp
blob: 7e54192daceb46d82c2fd099a8bb700bef93c691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
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->on_mouse_button_up.connect(mouse_button_up);
	a->on_mouse_button_down.connect(mouse_button_down);
	a->on_mouse_enter.connect(mouse_enter);
	a->on_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->on_mouse_button_up.connect(mouse_button_up);
	b->on_mouse_button_down.connect(mouse_button_down);
	b->on_mouse_enter.connect(mouse_enter);
	b->on_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->on_mouse_button_up.connect(mouse_button_up);
		c->on_mouse_button_down.connect(mouse_button_down);
		c->on_mouse_enter.connect(mouse_enter);
		c->on_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;
}