diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-08-01 20:46:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-08-01 20:46:13 +0200 |
commit | 27255cdb64b87c048fad70ca893f684cf61819a4 (patch) | |
tree | d89ea70475d1e8e9508d652eef836c49c0d162a8 /src/gui/Page.cpp | |
parent | 6624db873c91087bc1805b9d018c92c455b85190 (diff) |
Change global widget container to page
Diffstat (limited to 'src/gui/Page.cpp')
-rw-r--r-- | src/gui/Page.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/gui/Page.cpp b/src/gui/Page.cpp new file mode 100644 index 0000000..817c7fd --- /dev/null +++ b/src/gui/Page.cpp @@ -0,0 +1,22 @@ +#include "../../include/gui/Page.hpp" +#include "../../include/gui/Widget.hpp" + +namespace gsr { + void Page::add_widget(std::unique_ptr<Widget> widget) { + widgets.push_back(std::move(widget)); + } + + void Page::on_event(mgl::Event &event, mgl::Window &window) { + // Process widgets by visibility (backwards) + for(auto it = widgets.rbegin(), end = widgets.rend(); it != end; ++it) { + if(!(*it)->on_event(event, window)) + return; + } + } + + void Page::draw(mgl::Window &window) { + for(auto &widget : widgets) { + widget->draw(window); + } + } +}
\ No newline at end of file |