comparison client/main.cpp @ 139:b80d37e71b87

Client: rework dispatching between client and window, closes #711 The window backend is able to produce user events but they need to be dispatched into the client, the state and the window. This change makes client owner of window and dispatches events from client to the window and the future state mechanism. Remove the client network code temporarily to rework in the dispatcher later.
author David Demelier <markand@malikania.fr>
date Wed, 27 Sep 2017 20:34:59 +0200
parents 37df5aa9ba82
children 473e1eb96363
comparison
equal deleted inserted replaced
138:532f259557dd 139:b80d37e71b87
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 <iostream> 19 #include <iostream>
20 20
21 #include <malikania/client/button.hpp> 21 #include <malikania/client/client.hpp>
22 #include <malikania/client/color.hpp> 22 #include <malikania/client/connection.hpp>
23 #include <malikania/client/frame.hpp>
24 #include <malikania/client/unique_layout.hpp>
25 #include <malikania/client/window.hpp> 23 #include <malikania/client/window.hpp>
26 24
27 int main() 25 int main()
28 { 26 {
27 boost::asio::io_service service;
28
29 mlk::client::connection conn(service);
29 mlk::client::window w; 30 mlk::client::window w;
31 mlk::client::client clt(service, conn, w);
30 32
31 auto b = std::make_unique<mlk::client::button>("Click me!"); 33 clt.run();
32
33 b->on_clicked.connect([] () {
34 std::cout << "clicked successfully!" << std::endl;
35 });
36
37 auto l = std::make_unique<mlk::client::unique_layout>(std::move(b));
38 auto f = std::make_unique<mlk::client::frame>(std::move(l));
39
40 w.add_frame(std::move(f));
41 w.start_edit();
42
43 while (w.is_open()) {
44 w.poll();
45 w.set_drawing_color(0xffffffff);
46 w.clear();
47 w.draw_frames();
48 w.present();
49 }
50 } 34 }