Change global widget container to page

This commit is contained in:
dec05eba
2024-08-01 20:46:13 +02:00
parent 6624db873c
commit 27255cdb64
8 changed files with 61 additions and 100 deletions

27
include/gui/Page.hpp Normal file
View File

@@ -0,0 +1,27 @@
#pragma once
#include <vector>
#include <memory>
namespace mgl {
class Event;
class Window;
}
namespace gsr {
class Widget;
class Page {
public:
Page() = default;
Page(const Page&) = delete;
Page& operator=(const Page&) = delete;
void add_widget(std::unique_ptr<Widget> widget);
void on_event(mgl::Event &event, mgl::Window &window);
void draw(mgl::Window &window);
private:
std::vector<std::unique_ptr<Widget>> widgets;
};
}

View File

@@ -24,6 +24,5 @@ namespace gsr {
virtual mgl::vec2f get_position() const;
protected:
mgl::vec2f position;
bool move_to_top = false;
};
}

View File

@@ -1,30 +0,0 @@
#pragma once
#include <vector>
#include <memory>
namespace mgl {
class Event;
class Window;
}
namespace gsr {
class Widget;
class WidgetContainer {
public:
static WidgetContainer& get_instance();
void add_widget(Widget *widget);
void remove_widget(Widget *widget);
void on_event(mgl::Event &event, mgl::Window &window);
void draw(mgl::Window &window);
private:
WidgetContainer() = default;
WidgetContainer& operator=(const WidgetContainer&) = delete;
WidgetContainer(const WidgetContainer&) = delete;
private:
std::vector<Widget*> widgets;
};
}