From 27255cdb64b87c048fad70ca893f684cf61819a4 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 1 Aug 2024 20:46:13 +0200 Subject: Change global widget container to page --- include/gui/Page.hpp | 27 +++++++++++++++++++++++++++ include/gui/Widget.hpp | 1 - include/gui/WidgetContainer.hpp | 30 ------------------------------ 3 files changed, 27 insertions(+), 31 deletions(-) create mode 100644 include/gui/Page.hpp delete mode 100644 include/gui/WidgetContainer.hpp (limited to 'include/gui') diff --git a/include/gui/Page.hpp b/include/gui/Page.hpp new file mode 100644 index 0000000..1435e68 --- /dev/null +++ b/include/gui/Page.hpp @@ -0,0 +1,27 @@ +#pragma once + +#include +#include + +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); + + void on_event(mgl::Event &event, mgl::Window &window); + void draw(mgl::Window &window); + private: + std::vector> widgets; + }; +} \ No newline at end of file diff --git a/include/gui/Widget.hpp b/include/gui/Widget.hpp index 81f47b5..63cb64a 100644 --- a/include/gui/Widget.hpp +++ b/include/gui/Widget.hpp @@ -24,6 +24,5 @@ namespace gsr { virtual mgl::vec2f get_position() const; protected: mgl::vec2f position; - bool move_to_top = false; }; } \ No newline at end of file diff --git a/include/gui/WidgetContainer.hpp b/include/gui/WidgetContainer.hpp deleted file mode 100644 index e40ffb9..0000000 --- a/include/gui/WidgetContainer.hpp +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once - -#include -#include - -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 widgets; - }; -} \ No newline at end of file -- cgit v1.2.3