#pragma once

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

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

namespace gsr {
    class Button : public Widget {
    public:
        // If width is 0 then the width of the text is used instead (with padding).
        // If height is 0 then the height of the text is used instead (with padding).
        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;
        void set_border_scale(float scale);

        const std::string& get_text() const;
        void set_text(std::string str);

        std::function<void()> on_click;
    private:
        mgl::vec2f size;
        mgl::Color bg_color;
        mgl::Text text;
        float border_scale = 0.0015f;
    };
}