Mercurial > malikania
comparison client/main.cpp @ 130:f58075b58fa1
Client: create dispatcher class, closes #698
The dispatcher class is the main class that contains several functions to be
called to dispatch UI events.
It is defined as a class because it has to be passed into C++ source files
which can be complicated with templates and our client backend code.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 27 Sep 2017 06:37:18 +0200 |
parents | 4031eda60e11 |
children | 37df5aa9ba82 |
comparison
equal
deleted
inserted
replaced
129:24ec19139f08 | 130:f58075b58fa1 |
---|---|
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 <malikania/client/connection.hpp> | 19 #include <iostream> |
20 #include <malikania/client/client.hpp> | 20 |
21 #include <malikania/client/button.hpp> | |
22 #include <malikania/client/color.hpp> | |
23 #include <malikania/client/frame.hpp> | |
24 #include <malikania/client/unique_layout.hpp> | |
25 #include <malikania/client/window.hpp> | |
21 | 26 |
22 int main() | 27 int main() |
23 { | 28 { |
24 boost::asio::io_service service; | 29 mlk::client::window w; |
25 | 30 |
26 mlk::client::connection cn(service); | 31 auto b = std::make_unique<mlk::client::button>("Click me!"); |
27 mlk::client::client client(service, cn); | |
28 | 32 |
29 client.connect("localhost", 3320); | 33 b->on_clicked.connect([] () { |
34 std::cout << "clicked successfully!" << std::endl; | |
35 }); | |
30 | 36 |
31 for (;;) { | 37 auto l = std::make_unique<mlk::client::unique_layout>(std::move(b)); |
32 service.run(); | 38 auto f = std::make_unique<mlk::client::frame>(std::move(l)); |
39 | |
40 w.add_frame(std::move(f)); | |
41 | |
42 while (w.is_open()) { | |
43 w.poll(); | |
44 w.set_drawing_color(0xffffffff); | |
45 w.clear(); | |
46 w.draw_frames(); | |
47 w.present(); | |
33 } | 48 } |
34 } | 49 } |