Mercurial > malikania
comparison mlk-client/main.cpp @ 212:e50f51702df4
client: add basic button prototype, closes #908 @1h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 04 Jan 2019 18:26:04 +0100 |
parents | ac99f440ee44 |
children | 61580ff3138a |
comparison
equal
deleted
inserted
replaced
211:ac99f440ee44 | 212:e50f51702df4 |
---|---|
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 */ | 17 */ |
18 | 18 |
19 #include <chrono> | |
20 #include <iostream> | |
21 #include <thread> | |
22 | |
23 #include <malikania/client/color.hpp> | |
24 #include <malikania/client/button.hpp> | |
25 #include <malikania/client/window.hpp> | |
26 #include <malikania/client/painter.hpp> | |
27 | |
28 using namespace std::chrono_literals; | |
29 | |
30 int main(int argc, char** argv) | |
31 { | |
32 mlk::client::window win(1920/2, 1080/2); | |
33 mlk::client::painter painter(win); | |
34 mlk::client::button button("click me"); | |
35 | |
36 button.set_size({200, 64}); | |
37 button.set_position({50, 50}); | |
38 button.set_on_press([] { | |
39 std::cout << "je suis clické" << std::endl; | |
40 }); | |
41 | |
42 for (;;) { | |
43 while (auto ev = win.poll()) { | |
44 if (std::get_if<mlk::client::quit_event>(&ev)) | |
45 goto end; | |
46 else | |
47 button.handle_event(ev); | |
48 } | |
49 | |
50 painter.set_drawing_color(mlk::client::color::from_hex(0xffffffff)); | |
51 painter.clear(); | |
52 button.draw(painter); | |
53 painter.present(); | |
54 | |
55 std::this_thread::sleep_for(50ms); | |
56 } | |
57 | |
58 end: | |
59 return 0; | |
60 } | |
61 | |
62 #if 0 | |
63 | |
19 #include <cerrno> | 64 #include <cerrno> |
20 #include <cstring> | 65 #include <cstring> |
21 #include <fstream> | 66 #include <fstream> |
22 #include <iostream> | 67 #include <iostream> |
23 #include <iterator> | 68 #include <iterator> |
24 | 69 |
25 #include <malikania/client/js/context.hpp> | 70 #include <malikania/client/js/context.hpp> |
71 | |
72 // Simple javascript startup file. Don't delete. | |
26 | 73 |
27 int main(int argc, char** argv) | 74 int main(int argc, char** argv) |
28 { | 75 { |
29 -- argc; | 76 -- argc; |
30 ++ argv; | 77 ++ argv; |
55 return 1; | 102 return 1; |
56 } | 103 } |
57 | 104 |
58 return 0; | 105 return 0; |
59 } | 106 } |
107 | |
108 #endif |