annotate client/main.cpp @ 63:96ba0c5cf893

Misc: update duktape.hpp to new style
author David Demelier <markand@malikania.fr>
date Fri, 16 Dec 2016 16:11:24 +0100
parents 9ccc36ba4725
children 58444cf5f227
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
27 #include "malikania/point.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
28 #include "malikania/unique_layout.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
29 #include "malikania/window.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
30
42
a47a4477f347 Misc: new style, closes #578
David Demelier <markand@malikania.fr>
parents: 36
diff changeset
31 int main()
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
32 {
52
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
33 mlk::window win;
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
34
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
35 auto f = std::make_shared<mlk::frame>();
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
36 auto b = std::make_shared<mlk::button>("click me!");
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
37 auto l = std::make_shared<mlk::unique_layout>(b);
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
38
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
39 b->on_clicked.connect([] {
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
40 puts("clicked!!!!");
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
41 });
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
42 f->move({50, 50});
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
43 f->set_layout(l);
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
44 win.add_frame(f);
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
45
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
46 while (win.is_open()) {
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
47 win.poll();
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
48 win.set_drawing_color({255, 255, 255, 255});
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
49 win.clear();
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
50 win.draw_frames();
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
51 win.present();
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
52 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
53 }
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
54 }