uinode:add method fix + gui.reindex(document_name)
This commit is contained in:
@@ -13,9 +13,12 @@ UiDocument::UiDocument(
|
||||
std::shared_ptr<gui::UINode> root,
|
||||
std::unique_ptr<scripting::Environment> env
|
||||
) : id(id), script(script), root(root), env(std::move(env)) {
|
||||
collect(map, root);
|
||||
buildIndices(map, root);
|
||||
}
|
||||
|
||||
void UiDocument::rebuildIndices() {
|
||||
buildIndices(map, root);
|
||||
}
|
||||
|
||||
const uinodes_map& UiDocument::getMap() const {
|
||||
return map;
|
||||
@@ -45,7 +48,7 @@ int UiDocument::getEnvironment() const {
|
||||
return env->getId();
|
||||
}
|
||||
|
||||
void UiDocument::collect(uinodes_map& map, std::shared_ptr<gui::UINode> node) {
|
||||
void UiDocument::buildIndices(uinodes_map& map, std::shared_ptr<gui::UINode> node) {
|
||||
const std::string& id = node->getId();
|
||||
if (!id.empty()) {
|
||||
map[id] = node;
|
||||
@@ -53,7 +56,7 @@ void UiDocument::collect(uinodes_map& map, std::shared_ptr<gui::UINode> node) {
|
||||
auto container = std::dynamic_pointer_cast<gui::Container>(node);
|
||||
if (container) {
|
||||
for (auto subnode : container->getNodes()) {
|
||||
collect(map, subnode);
|
||||
buildIndices(map, subnode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,16 @@ public:
|
||||
std::unique_ptr<scripting::Environment> env
|
||||
);
|
||||
|
||||
void rebuildIndices();
|
||||
|
||||
const std::string& getId() const;
|
||||
const uinodes_map& getMap() const;
|
||||
const std::shared_ptr<gui::UINode> getRoot() const;
|
||||
const std::shared_ptr<gui::UINode> get(const std::string& id) const;
|
||||
const uidocscript& getScript() const;
|
||||
int getEnvironment() const;
|
||||
/* Collect map of all uinodes having identifiers */
|
||||
static void collect(uinodes_map& map, std::shared_ptr<gui::UINode> node);
|
||||
// @brief Collect map of all uinodes having identifiers
|
||||
static void buildIndices(uinodes_map& map, std::shared_ptr<gui::UINode> node);
|
||||
|
||||
static std::unique_ptr<UiDocument> read(int env, std::string name, fs::path file);
|
||||
static std::shared_ptr<gui::UINode> readElement(fs::path file);
|
||||
|
||||
Reference in New Issue
Block a user