view 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 source

/*
 * main.cpp -- main client file
 *
 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr>
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#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()
{
    mlk::client::window w;

    auto b = std::make_unique<mlk::client::button>("Click me!");

    b->on_clicked.connect([] () {
        std::cout << "clicked successfully!" << std::endl;
    });

    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));

    while (w.is_open()) {
        w.poll();
        w.set_drawing_color(0xffffffff);
        w.clear();
        w.draw_frames();
        w.present();
    }
}