annotate client/main.cpp @ 52:4bc4732fa1dd

Client: add basic button, closes #601
author David Demelier <markand@malikania.fr>
date Thu, 15 Dec 2016 13:46:46 +0100
parents a47a4477f347
children 9ccc36ba4725
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
52
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
19 #include <chrono>
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
20 #include <thread>
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
21
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
22 #include "malikania/button.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
23 #include "malikania/color.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
24 #include "malikania/frame.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
25 #include "malikania/point.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
26 #include "malikania/unique_layout.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
27 #include "malikania/window.hpp"
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
28
42
a47a4477f347 Misc: new style, closes #578
David Demelier <markand@malikania.fr>
parents: 36
diff changeset
29 int main()
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
30 {
52
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
31 mlk::window win;
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
32
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
33 auto f = std::make_shared<mlk::frame>();
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
34 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
35 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
36
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
37 b->on_clicked.connect([] {
4bc4732fa1dd Client: add basic button, closes #601
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
38 puts("clicked!!!!");
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 }
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
53