diff options
author | Joshua Bell <josh@lindenlab.com> | 2011-02-18 13:04:41 -0800 |
---|---|---|
committer | Joshua Bell <josh@lindenlab.com> | 2011-02-18 13:04:41 -0800 |
commit | f6970e6ad1f0576ec194fdc8d369030f1e31aeab (patch) | |
tree | 498802d2ab1e214f64a43317fa461384df99d1fa /indra | |
parent | 0e39a7881e29fe58761403424941b78f82042ac1 (diff) |
Implemented path resolution. Should be able to test this now.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/lluilistener.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp index dafca0abf2..22d3b8b219 100644 --- a/indra/newview/lluilistener.cpp +++ b/indra/newview/lluilistener.cpp @@ -34,9 +34,11 @@ // std headers // external library headers // other Linden headers +#include "llviewerwindow.h" // to get root view #include "lluictrl.h" #include "llerror.h" + LLUIListener::LLUIListener(): LLEventAPI("UI", "LLUICtrl::CommitCallbackRegistry listener.\n" @@ -78,9 +80,38 @@ void LLUIListener::call(const LLSD& event) const } } -const LLUICtrl* resolve_path(const LLUICtrl* base, const std::string path) +const LLView* resolve_path(const LLView* context, const std::string path) { - // *TODO: walk the path + std::vector<std::string> parts; + const std::string delims("/"); + LLStringUtilBase<char>::getTokens(path, parts, delims); + + bool recurse = false; + for (std::vector<std::string>::iterator it = parts.begin(); + it != parts.end() && context; it++) + { + std::string part = *it; + + if (part.length() == 0) + { + // Allow "foo//bar" meaning "descendant named bar" + recurse = true; + } + else + { + const LLView* found = context->findChildView(part, recurse); + if (!found) + { + return NULL; + } + else + { + context = found; + } + recurse = false; + } + } + return NULL; } @@ -88,9 +119,10 @@ void LLUIListener::getValue(const LLSD&event) const { LLSD reply; - const LLUICtrl* root = NULL; // *TODO: look this up - const LLUICtrl* ctrl = resolve_path(root, event["path"].asString()); - + const LLView* root = (LLView*)(gViewerWindow->getRootView()); + const LLView* view = resolve_path(root, event["path"].asString()); + const LLUICtrl* ctrl(dynamic_cast<const LLUICtrl*>(view)); + if (ctrl) { reply["value"] = ctrl->getValue(); |