From b68613f24ff4bb80c0571335d9274392ab3deaea Mon Sep 17 00:00:00 2001 From: Maxim Nikolenko Date: Wed, 5 Aug 2026 12:46:07 +0300 Subject: #5869 Add LEAP API to get a full tree from root (getInfo and getPaths combined) --- indra/newview/llwindowlistener.cpp | 41 ++++++++++++++++++++++++++++++++++++++ indra/newview/llwindowlistener.h | 1 + 2 files changed, 42 insertions(+) diff --git a/indra/newview/llwindowlistener.cpp b/indra/newview/llwindowlistener.cpp index 38e49d0750..54eb61a6bf 100644 --- a/indra/newview/llwindowlistener.cpp +++ b/indra/newview/llwindowlistener.cpp @@ -90,6 +90,12 @@ LLWindowListener::LLWindowListener(LLViewerWindow *window, const KeyboardGetter& "to list; all nodes from root if no [\"under\"].", &LLWindowListener::getPaths, LLSDMap("reply", LLSD())); + add("getSubtree", + "Send on [\"reply\"] a nested tree of info maps for all descendants of\n" + "optional [\"under\"] path (default: root). Each node contains the same\n" + "fields as getInfo plus a [\"children\"] array of child nodes.", + &LLWindowListener::getSubtree, + LLSDMap("reply", LLSD())); add("keyDown", keySomething + "keypress event.\n" + keyExplain + "The [\"char\"] parameter detects and handles non-ASCII characters seperately\n" + mask, @@ -265,6 +271,41 @@ void LLWindowListener::getPaths(LLSD const & request) } } +static LLSD buildSubtree(LLView* view) +{ + LLSD children; + LLSD node = view->getInfo(); + for (LLView::child_list_const_iter_t it = view->beginChild(); it != view->endChild(); ++it) + { + children.append(buildSubtree(*it)); + } + node["children"] = children; + return node; +} + +void LLWindowListener::getSubtree(LLSD const & request) +{ + Response response(LLSD(), request); + LLView* root = LLUI::getInstance()->getRootView(); + LLView* base = nullptr; + std::string under(request["under"]); + + if (under.empty()) + { + base = root; + } + else + { + base = LLUI::getInstance()->resolvePath(root, under); + if (!base) + { + return response.error(STRINGIZE(request["op"].asString() << " request specified invalid \"under\" path: '" << under << "'")); + } + } + + response.setResponse(buildSubtree(base)); +} + void LLWindowListener::keyDown(LLSD const & evt) { Response response(LLSD(), evt); diff --git a/indra/newview/llwindowlistener.h b/indra/newview/llwindowlistener.h index d3a16cfde9..537322b19b 100644 --- a/indra/newview/llwindowlistener.h +++ b/indra/newview/llwindowlistener.h @@ -41,6 +41,7 @@ public: void getInfo(LLSD const & evt); void getPaths(LLSD const & evt); + void getSubtree(LLSD const & evt); void keyDown(LLSD const & evt); void keyUp(LLSD const & evt); void mouseDown(LLSD const & evt); -- cgit v1.3