diff 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
line wrap: on
line diff
--- a/client/main.cpp	Fri Sep 22 13:12:50 2017 +0200
+++ b/client/main.cpp	Wed Sep 27 06:37:18 2017 +0200
@@ -16,19 +16,34 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <malikania/client/connection.hpp>
-#include <malikania/client/client.hpp>
+#include <iostream>
+
+#include <malikania/client/button.hpp>
+#include <malikania/client/color.hpp>
+#include <malikania/client/frame.hpp>
+#include <malikania/client/unique_layout.hpp>
+#include <malikania/client/window.hpp>
 
 int main()
 {
-    boost::asio::io_service service;
+    mlk::client::window w;
+
+    auto b = std::make_unique<mlk::client::button>("Click me!");
 
-    mlk::client::connection cn(service);
-    mlk::client::client client(service, cn);
+    b->on_clicked.connect([] () {
+        std::cout << "clicked successfully!" << std::endl;
+    });
 
-    client.connect("localhost", 3320);
+    auto l = std::make_unique<mlk::client::unique_layout>(std::move(b));
+    auto f = std::make_unique<mlk::client::frame>(std::move(l));
+
+    w.add_frame(std::move(f));
 
-    for (;;) {
-        service.run();
+    while (w.is_open()) {
+        w.poll();
+        w.set_drawing_color(0xffffffff);
+        w.clear();
+        w.draw_frames();
+        w.present();
     }
 }