Refactor, GUI::storage (map for direct access to panels)

This commit is contained in:
MihailRis
2023-11-17 14:26:54 +03:00
parent 4e1f19c911
commit 6392f63604
10 changed files with 75 additions and 54 deletions
+18 -1
View File
@@ -12,6 +12,7 @@
#include "../../window/input.h"
#include "../../window/Camera.h"
using std::string;
using std::shared_ptr;
using namespace gui;
@@ -101,6 +102,22 @@ void GUI::add(shared_ptr<UINode> panel) {
container->add(panel);
}
void GUI::remove(std::shared_ptr<UINode> panel) {
void GUI::remove(shared_ptr<UINode> panel) {
container->remove(panel);
}
void GUI::store(string name, shared_ptr<UINode> node) {
storage[name] = node;
}
shared_ptr<UINode> GUI::get(string name) {
auto found = storage.find(name);
if (found == storage.end()) {
return nullptr;
}
return found->second;
}
void GUI::remove(string name) {
storage.erase(name);
}