summaryrefslogtreecommitdiff
path: root/indra/llui/llview.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2011-08-25 14:40:53 -0400
committerNat Goodspeed <nat@lindenlab.com>2011-08-25 14:40:53 -0400
commitf7a6ed85e40f53e5e28868bf34ac4dbc9bb204fb (patch)
treefde2bf8e6ec58b8dcad11ee5ca996359c98219a9 /indra/llui/llview.cpp
parenta548fd52e3c938614f213ae7f2b1aa9cbf05b23f (diff)
CHOP-763: Add LLView::TemporaryDrilldownFunc to support UI injection.
Instead of unconditionally calling LLView::pointInView(), LLView::visibleAndContains() now consults a class-static boost::function called sDrilldown -- which is initialized to LLView::pointInView(). Introduce LLView::TemporaryDrilldownFunc, instantiated with a callable whose signature is compatible with LLView::pointInView(). This replaces sDrilldown, but only for the life of the TemporaryDrilldownFunc object. Introduce llview::TargetEvent, an object intended to serve as a TemporaryDrilldownFunc callable. Construct it with a desired target LLView* and pass it to TemporaryDrilldownFunc. When called with each candidate child LLView*, instead of selecting the one containing the particular (x, y) point, it selects the one that will lead to the ultimate desired target LLView*. Add optional 'recur' param to LLView::childFromPoint(); default is current one-level behavior. But when you pass recur=true, it should return the frontmost visible leaf LLView containing the passed (x, y) point.
Diffstat (limited to 'indra/llui/llview.cpp')
-rw-r--r--indra/llui/llview.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 6d0bd4d520..56b09791a4 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -33,6 +33,7 @@
#include <cassert>
#include <boost/tokenizer.hpp>
#include <boost/foreach.hpp>
+#include <boost/bind.hpp>
#include "llrender.h"
#include "llevent.h"
@@ -67,6 +68,8 @@ S32 LLView::sLastLeftXML = S32_MIN;
S32 LLView::sLastBottomXML = S32_MIN;
std::vector<LLViewDrawContext*> LLViewDrawContext::sDrawContextStack;
+LLView::DrilldownFunc LLView::sDrilldown =
+ boost::bind(&LLView::pointInView, _1, _2, _3, HIT_TEST_USE_BOUNDING_RECT);
//#if LL_DEBUG
BOOL LLView::sIsDrawing = FALSE;
@@ -645,7 +648,7 @@ void LLView::onMouseLeave(S32 x, S32 y, MASK mask)
bool LLView::visibleAndContains(S32 local_x, S32 local_y)
{
- return pointInView(local_x, local_y)
+ return sDrilldown(this, local_x, local_y)
&& getVisible();
}
@@ -789,10 +792,11 @@ LLView* LLView::childrenHandleHover(S32 x, S32 y, MASK mask)
return NULL;
}
-LLView* LLView::childFromPoint(S32 x, S32 y)
+LLView* LLView::childFromPoint(S32 x, S32 y, bool recur)
{
- if (!getVisible() )
+ if (!getVisible())
return false;
+
BOOST_FOREACH(LLView* viewp, mChildList)
{
S32 local_x = x - viewp->getRect().mLeft;
@@ -801,6 +805,14 @@ LLView* LLView::childFromPoint(S32 x, S32 y)
{
continue;
}
+ // Here we've found the first (frontmost) visible child at this level
+ // containing the specified point. Is the caller asking us to drill
+ // down and return the innermost leaf child at this point, or just the
+ // top-level child?
+ if (recur)
+ {
+ return viewp->childFromPoint(local_x, local_y, recur);
+ }
return viewp;
}