feat: key pressed event interception & 'owner' input.add_callback third argument

This commit is contained in:
MihailRis
2025-01-02 20:51:43 +03:00
parent 7fce735ca1
commit b9ff1db086
17 changed files with 192 additions and 63 deletions
+2 -1
View File
@@ -2,11 +2,12 @@
#include "UINode.hpp"
#include "commons.hpp"
#include "util/ObjectsKeeper.hpp"
#include <vector>
namespace gui {
class Container : public UINode {
class Container : public UINode, public util::ObjectsKeeper {
int prevScrollY = -1;
protected:
std::vector<std::shared_ptr<UINode>> nodes;
+8 -4
View File
@@ -13,11 +13,15 @@ bool Menu::has(const std::string& name) {
pageSuppliers.find(name) != pageSuppliers.end();
}
void Menu::addPage(const std::string& name, const std::shared_ptr<UINode> &panel) {
pages[name] = Page{name, panel};
void Menu::addPage(const std::string& name, const std::shared_ptr<UINode>& panel) {
pages[name] = Page {name, panel};
}
void Menu::addSupplier(const std::string &name, const supplier<std::shared_ptr<UINode>> &pageSupplier) {
void Menu::removePage(const std::string& name) {
pages.erase(name);
}
void Menu::addSupplier(const std::string& name, const supplier<std::shared_ptr<UINode>>& pageSupplier) {
pageSuppliers[name] = pageSupplier;
}
@@ -89,6 +93,6 @@ void Menu::reset() {
clearHistory();
if (current.panel) {
Container::remove(current.panel);
current = Page{"", nullptr};
current = Page {"", nullptr};
}
}
+1
View File
@@ -32,6 +32,7 @@ namespace gui {
void setPage(const std::string &name, bool history=true);
void setPage(Page page, bool history=true);
void addPage(const std::string& name, const std::shared_ptr<UINode>& panel);
void removePage(const std::string& name);
std::shared_ptr<UINode> fetchPage(const std::string& name);
/// @brief Add page supplier used if page is not found