summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgtags1
-rw-r--r--indra/llui/llui.cpp49
-rw-r--r--indra/llui/llui.h27
-rw-r--r--indra/newview/llappviewerwin32.cpp41
-rw-r--r--indra/newview/lluilistener.cpp28
-rw-r--r--indra/newview/lluilistener.h1
6 files changed, 138 insertions, 9 deletions
diff --git a/.hgtags b/.hgtags
index 2b143b0013..d78dce8f6e 100644
--- a/.hgtags
+++ b/.hgtags
@@ -71,3 +71,4 @@ b723921b5c711bd24dbe77dc76ef488b544dac78 DRTVWR-34_2.5.0-beta3
b723921b5c711bd24dbe77dc76ef488b544dac78 2.5.0-release
b723921b5c711bd24dbe77dc76ef488b544dac78 DRTVWR-31_2.5.0-release
92e58e51776a4f8c29069b1a62ff21454d2085f0 2.6.0-start
+3178e311da3a8739a85363665006ea3c4610cad4 dons-headless-hackathon-work
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index c300fe55d9..87669574c2 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -61,6 +61,8 @@
// for XUIParse
#include "llquaternion.h"
#include <boost/tokenizer.hpp>
+#include <boost/algorithm/string/find_iterator.hpp>
+#include <boost/algorithm/string/finder.hpp>
//
// Globals
@@ -2020,6 +2022,53 @@ void LLUI::positionViewNearMouse(LLView* view, S32 spawn_x, S32 spawn_y)
view->translateIntoRectWithExclusion( virtual_window_rect, mouse_rect, FALSE );
}
+LLView* LLUI::resolvePath(LLView* context, const std::string& path)
+{
+ // Nothing about resolvePath() should require non-const LLView*. If caller
+ // wants non-const, call the const flavor and then cast away const-ness.
+ return const_cast<LLView*>(resolvePath(const_cast<const LLView*>(context), path));
+}
+
+const LLView* LLUI::resolvePath(const LLView* context, const std::string& path)
+{
+ // Create an iterator over slash-separated parts of 'path'. Dereferencing
+ // this iterator returns an iterator_range over the substring. Unlike
+ // LLStringUtil::getTokens(), this split_iterator doesn't combine adjacent
+ // delimiters: leading/trailing slash produces an empty substring, double
+ // slash produces an empty substring. That's what we need.
+ boost::split_iterator<std::string::const_iterator> ti(path, boost::first_finder("/")), tend;
+
+ if (ti == tend)
+ {
+ // 'path' is completely empty, no navigation
+ return context;
+ }
+
+ // leading / means "start at root"
+ if (ti->empty())
+ {
+ context = getRootView();
+ ++ti;
+ }
+
+ bool recurse = false;
+ for (; ti != tend && context; ++ti)
+ {
+ if (ti->empty())
+ {
+ recurse = true;
+ }
+ else
+ {
+ std::string part(ti->begin(), ti->end());
+ context = context->findChildView(part, recurse);
+ recurse = false;
+ }
+ }
+
+ return context;
+}
+
// LLLocalClipRect and LLScreenClipRect moved to lllocalcliprect.h/cpp
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index 62d10df8b2..50cb9e6632 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -185,6 +185,33 @@ public:
//helper functions (should probably move free standing rendering helper functions here)
static LLView* getRootView() { return sRootView; }
static void setRootView(LLView* view) { sRootView = view; }
+ /**
+ * Walk the LLView tree to resolve a path
+ * Paths can be discovered using Develop > XUI > Show XUI Paths
+ *
+ * A leading "/" indicates the root of the tree is the starting
+ * position of the search, (otherwise the context node is used)
+ *
+ * Adjacent "//" mean that the next level of the search is done
+ * recursively ("descendant" rather than "child").
+ *
+ * Return values: If no match is found, NULL is returned,
+ * otherwise the matching LLView* is returned.
+ *
+ * Examples:
+ *
+ * "/" -> return the root view
+ * "/foo" -> find "foo" as a direct child of the root
+ * "foo" -> find "foo" as a direct child of the context node
+ * "//foo" -> find the first "foo" child anywhere in the tree
+ * "/foo/bar" -> find "foo" as direct child of the root, and
+ * "bar" as a direct child of "foo"
+ * "//foo//bar/baz" -> find the first "foo" anywhere in the
+ * tree, the first "bar" anywhere under it, and "baz"
+ * as a direct child of that
+ */
+ static const LLView* resolvePath(const LLView* context, const std::string& path);
+ static LLView* resolvePath(LLView* context, const std::string& path);
static std::string locateSkin(const std::string& filename);
static void setMousePositionScreen(S32 x, S32 y);
static void getMousePositionScreen(S32 *x, S32 *y);
diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp
index d328567a0e..2fbec6e49e 100644
--- a/indra/newview/llappviewerwin32.cpp
+++ b/indra/newview/llappviewerwin32.cpp
@@ -301,23 +301,44 @@ void create_console()
// redirect unbuffered STDOUT to the console
l_std_handle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
- fp = _fdopen( h_con_handle, "w" );
- *stdout = *fp;
- setvbuf( stdout, NULL, _IONBF, 0 );
+ if (h_con_handle == -1)
+ {
+ llwarns << "create_console() failed to open stdout handle" << llendl;
+ }
+ else
+ {
+ fp = _fdopen( h_con_handle, "w" );
+ *stdout = *fp;
+ setvbuf( stdout, NULL, _IONBF, 0 );
+ }
// redirect unbuffered STDIN to the console
l_std_handle = (long)GetStdHandle(STD_INPUT_HANDLE);
h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
- fp = _fdopen( h_con_handle, "r" );
- *stdin = *fp;
- setvbuf( stdin, NULL, _IONBF, 0 );
+ if (h_con_handle == -1)
+ {
+ llwarns << "create_console() failed to open stdin handle" << llendl;
+ }
+ else
+ {
+ fp = _fdopen( h_con_handle, "r" );
+ *stdin = *fp;
+ setvbuf( stdin, NULL, _IONBF, 0 );
+ }
// redirect unbuffered STDERR to the console
l_std_handle = (long)GetStdHandle(STD_ERROR_HANDLE);
h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
- fp = _fdopen( h_con_handle, "w" );
- *stderr = *fp;
- setvbuf( stderr, NULL, _IONBF, 0 );
+ if (h_con_handle == -1)
+ {
+ llwarns << "create_console() failed to open stderr handle" << llendl;
+ }
+ else
+ {
+ fp = _fdopen( h_con_handle, "w" );
+ *stderr = *fp;
+ setvbuf( stderr, NULL, _IONBF, 0 );
+ }
}
LLAppViewerWin32::LLAppViewerWin32(const char* cmd_line) :
@@ -363,8 +384,10 @@ bool LLAppViewerWin32::initLogging()
void LLAppViewerWin32::initConsole()
{
+ llinfos << "Test before create_console" << llendl;
// pop up debug console
create_console();
+ llinfos << "Test after create_console" << llendl;
return LLAppViewer::initConsole();
}
diff --git a/indra/newview/lluilistener.cpp b/indra/newview/lluilistener.cpp
index 4d6eac4958..6b2cd71d40 100644
--- a/indra/newview/lluilistener.cpp
+++ b/indra/newview/lluilistener.cpp
@@ -34,9 +34,11 @@
// std headers
// external library headers
// other Linden headers
+#include "llui.h" // getRootView(), resolvePath()
#include "lluictrl.h"
#include "llerror.h"
+
LLUIListener::LLUIListener():
LLEventAPI("UI",
"LLUICtrl::CommitCallbackRegistry listener.\n"
@@ -47,6 +49,12 @@ LLUIListener::LLUIListener():
"as if from a user gesture on a menu -- or a button click.",
&LLUIListener::call,
LLSD().with("function", LLSD()));
+
+ add("getValue",
+ "For the UI control identified by the path in [\"path\"], return the control's\n"
+ "current value as [\"value\"] reply.",
+ &LLUIListener::getValue,
+ LLSDMap("path", LLSD())("reply", LLSD()));
}
void LLUIListener::call(const LLSD& event) const
@@ -71,3 +79,23 @@ void LLUIListener::call(const LLSD& event) const
(*func)(NULL, event["parameter"]);
}
}
+
+void LLUIListener::getValue(const LLSD&event) const
+{
+ LLSD reply = LLSD::emptyMap();
+
+ const LLView* root = LLUI::getRootView();
+ const LLView* view = LLUI::resolvePath(root, event["path"].asString());
+ const LLUICtrl* ctrl(dynamic_cast<const LLUICtrl*>(view));
+
+ if (ctrl)
+ {
+ reply["value"] = ctrl->getValue();
+ }
+ else
+ {
+ // *TODO: ??? return something indicating failure to resolve
+ }
+
+ sendReply(reply, event);
+}
diff --git a/indra/newview/lluilistener.h b/indra/newview/lluilistener.h
index e7847f01e8..08724024dc 100644
--- a/indra/newview/lluilistener.h
+++ b/indra/newview/lluilistener.h
@@ -41,6 +41,7 @@ public:
private:
void call(const LLSD& event) const;
+ void getValue(const LLSD&event) const;
};
#endif /* ! defined(LL_LLUILISTENER_H) */