aboutsummaryrefslogtreecommitdiff
path: root/include/gui/Button.hpp
blob: c9a933b362abaa1eb88de98d34b11af39a1e9dae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include "Widget.hpp"
#include <functional>

#include <mglpp/graphics/Color.hpp>
#include <mglpp/graphics/Text.hpp>

namespace gsr {
    class Button : public Widget {
    public:
        Button(mgl::Font *font, const char *text, mgl::vec2f size, mgl::Color bg_color);
        Button(const Button&) = delete;
        Button& operator=(const Button&) = delete;

        bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
        void draw(mgl::Window &window, mgl::vec2f offset) override;

        mgl::vec2f get_size() override { return size; }

        std::function<void()> on_click;
    private:
        mgl::vec2f size;
        mgl::Color bg_color;
        bool mouse_inside = false;
        mgl::Text text;
    };
}