generated ui nodes indexing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "UINode.h"
|
||||
|
||||
#include "containers.h"
|
||||
#include "../../core/Batch2D.h"
|
||||
|
||||
using gui::UINode;
|
||||
@@ -256,3 +257,19 @@ void UINode::setGravity(Gravity gravity) {
|
||||
reposition();
|
||||
}
|
||||
}
|
||||
|
||||
void UINode::getIndices(
|
||||
std::shared_ptr<UINode> node,
|
||||
std::unordered_map<std::string, std::shared_ptr<UINode>>& map
|
||||
) {
|
||||
const std::string& id = node->getId();
|
||||
if (!id.empty()) {
|
||||
map[id] = node;
|
||||
}
|
||||
auto container = std::dynamic_pointer_cast<gui::Container>(node);
|
||||
if (container) {
|
||||
for (auto subnode : container->getNodes()) {
|
||||
getIndices(subnode, map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
#include "../../../delegates.h"
|
||||
#include "../../../window/input.h"
|
||||
|
||||
@@ -193,6 +194,12 @@ namespace gui {
|
||||
void reposition();
|
||||
|
||||
virtual void setGravity(Gravity gravity);
|
||||
|
||||
// @brief collect all nodes having id
|
||||
static void getIndices(
|
||||
std::shared_ptr<UINode> node,
|
||||
std::unordered_map<std::string, std::shared_ptr<UINode>>& map
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user