Mercurial > malikania
annotate client/main.cpp @ 132:37df5aa9ba82
Client: enable edition support, closes #703
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 27 Sep 2017 12:52:36 +0200 |
parents | f58075b58fa1 |
children | b80d37e71b87 |
rev | line source |
---|---|
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
1 /* |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
2 * main.cpp -- main client file |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
3 * |
76 | 4 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr> |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
5 * |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
6 * Permission to use, copy, modify, and/or distribute this software for any |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
7 * purpose with or without fee is hereby granted, provided that the above |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
8 * copyright notice and this permission notice appear in all copies. |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
9 * |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
17 */ |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
18 |
130
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
19 #include <iostream> |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
20 |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
21 #include <malikania/client/button.hpp> |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
22 #include <malikania/client/color.hpp> |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
23 #include <malikania/client/frame.hpp> |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
24 #include <malikania/client/unique_layout.hpp> |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
25 #include <malikania/client/window.hpp> |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
26 |
42
a47a4477f347
Misc: new style, closes #578
David Demelier <markand@malikania.fr>
parents:
36
diff
changeset
|
27 int main() |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
28 { |
130
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
29 mlk::client::window w; |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
30 |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
31 auto b = std::make_unique<mlk::client::button>("Click me!"); |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
32 |
130
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
33 b->on_clicked.connect([] () { |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
34 std::cout << "clicked successfully!" << std::endl; |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
35 }); |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
36 |
130
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
37 auto l = std::make_unique<mlk::client::unique_layout>(std::move(b)); |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
38 auto f = std::make_unique<mlk::client::frame>(std::move(l)); |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
39 |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
40 w.add_frame(std::move(f)); |
132
37df5aa9ba82
Client: enable edition support, closes #703
David Demelier <markand@malikania.fr>
parents:
130
diff
changeset
|
41 w.start_edit(); |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
42 |
130
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
43 while (w.is_open()) { |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
44 w.poll(); |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
45 w.set_drawing_color(0xffffffff); |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
46 w.clear(); |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
47 w.draw_frames(); |
f58075b58fa1
Client: create dispatcher class, closes #698
David Demelier <markand@malikania.fr>
parents:
92
diff
changeset
|
48 w.present(); |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
49 } |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
50 } |