aboutsummaryrefslogtreecommitdiff
path: root/include/gui/Button.hpp
blob: 2a22a880142b192da0f7c1f663eede99e4eb5e5d (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
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#include "../RoundedRectangle.hpp"
#include <string>
#include <mglpp/graphics/Text.hpp>

namespace mgl {
    class Event;
    class Font;
    class Window;
    class Shader;
}

namespace QuickMedia {
    enum ButtonEvent {
        BUTTON_EVENT_NONE    = 0,
        BUTTON_EVENT_CLICKED = 1
    };

    class Button {
    public:
        Button(const std::string &label, mgl::Font *font, float width, mgl::Shader *rounded_rectangle_shader, float scale = 1.0f);

        ButtonEvent on_event(mgl::Event &event);
        void draw(mgl::Window &target);

        void set_background_color(mgl::Color color);
        void set_position(mgl::vec2f pos);

        mgl::vec2f get_position() const;
        float get_width() const;
        float get_height();
    private:
        mgl::Text label;
        RoundedRectangle background;
        mgl::Color background_color;
        float scale;
        bool clicked_inside = false;
    };
}