Mercurial > malikania
annotate client/main.cpp @ 70:58444cf5f227
Client: add minimalist label
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 19 Dec 2016 13:12:32 +0100 |
parents | 96ba0c5cf893 |
children | 858621081b95 |
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 * |
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
4 * Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> |
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 |
63
96ba0c5cf893
Misc: update duktape.hpp to new style
David Demelier <markand@malikania.fr>
parents:
57
diff
changeset
|
19 #include <malikania/duktape.hpp> |
96ba0c5cf893
Misc: update duktape.hpp to new style
David Demelier <markand@malikania.fr>
parents:
57
diff
changeset
|
20 |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
21 #include <chrono> |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
22 #include <thread> |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
23 |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
24 #include "malikania/button.hpp" |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
25 #include "malikania/color.hpp" |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
26 #include "malikania/frame.hpp" |
70
58444cf5f227
Client: add minimalist label
David Demelier <markand@malikania.fr>
parents:
63
diff
changeset
|
27 #include "malikania/label.hpp" |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
28 #include "malikania/point.hpp" |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
29 #include "malikania/unique_layout.hpp" |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
30 #include "malikania/window.hpp" |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
31 |
42
a47a4477f347
Misc: new style, closes #578
David Demelier <markand@malikania.fr>
parents:
36
diff
changeset
|
32 int main() |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
33 { |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
34 mlk::window win; |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
35 |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
36 auto f = std::make_shared<mlk::frame>(); |
70
58444cf5f227
Client: add minimalist label
David Demelier <markand@malikania.fr>
parents:
63
diff
changeset
|
37 auto w = std::make_shared<mlk::label>("Malikania"); |
58444cf5f227
Client: add minimalist label
David Demelier <markand@malikania.fr>
parents:
63
diff
changeset
|
38 auto l = std::make_shared<mlk::unique_layout>(w); |
52
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
39 |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
40 f->move({50, 50}); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
41 f->set_layout(l); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
42 win.add_frame(f); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
43 |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
44 while (win.is_open()) { |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
45 win.poll(); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
46 win.set_drawing_color({255, 255, 255, 255}); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
47 win.clear(); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
48 win.draw_frames(); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
49 win.present(); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
50 std::this_thread::sleep_for(std::chrono::milliseconds(50)); |
4bc4732fa1dd
Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents:
42
diff
changeset
|
51 } |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
52 } |