aboutsummaryrefslogtreecommitdiff
path: root/include/gui/CustomRendererWidget.hpp
blob: e16e5326a2d9c7eeed17d02b47b2d645370b893b (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
#pragma once

#include "Widget.hpp"

#include <functional>

namespace gsr {
    class CustomRendererWidget : public Widget {
    public:
        CustomRendererWidget(mgl::vec2f size);
        CustomRendererWidget(const CustomRendererWidget&) = delete;
        CustomRendererWidget& operator=(const CustomRendererWidget&) = 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;

        std::function<void(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size)> draw_handler;
        // Return true to allow other widgets to handle events
        std::function<bool(mgl::Event &event, mgl::Window &window, mgl::vec2f pos, mgl::vec2f size)> event_handler;
    private:
        mgl::vec2f size;
    };
}