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

#include "Widget.hpp"
#include "Page.hpp"
#include "../SafeVector.hpp"
#include <memory>

namespace gsr {
    class PageStack : public Widget {
    public:
        PageStack();
        PageStack(const PageStack&) = delete;
        PageStack& operator=(const PageStack&) = 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 push(std::unique_ptr<Page> page);
        // This can be used even if the stack is empty
        void pop();
        // This can be used even if the stack is empty
        Page* top();
        bool empty() const;
    private:
        SafeVector<std::unique_ptr<Page>> widget_stack;
    };
}