summaryrefslogtreecommitdiff
path: root/indra/llui/llview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/llview.cpp')
-rw-r--r--indra/llui/llview.cpp52
1 files changed, 35 insertions, 17 deletions
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index fe7fd59de8..63e627ceb5 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -33,6 +33,7 @@
#include "linden_common.h"
+#define LLVIEW_CPP
#include "llview.h"
#include <cassert>
@@ -40,7 +41,6 @@
#include "llrender.h"
#include "llevent.h"
-#include "llfontgl.h"
#include "llfocusmgr.h"
#include "llrect.h"
#include "llstl.h"
@@ -77,8 +77,17 @@ std::vector<LLViewDrawContext*> LLViewDrawContext::sDrawContextStack;
BOOL LLView::sIsDrawing = FALSE;
#endif
+// Compiler optimization, generate extern template
+template class LLView* LLView::getChild<class LLView>(
+ const std::string& name, BOOL recurse) const;
+
static LLDefaultChildRegistry::Register<LLView> r("view");
+LLView::Follows::Follows()
+: string(""),
+ flags("flags", FOLLOWS_LEFT | FOLLOWS_TOP)
+{}
+
LLView::Params::Params()
: name("name", std::string("unnamed")),
enabled("enabled", true),
@@ -117,7 +126,7 @@ LLView::LLView(const LLView::Params& p)
: mName(p.name),
mParentView(NULL),
mReshapeFlags(FOLLOWS_NONE),
- mSaveToXML(p.from_xui),
+ mFromXUI(p.from_xui),
mIsFocusRoot(FALSE),
mLastVisible(FALSE),
mNextInsertionOrdinal(0),
@@ -1698,8 +1707,11 @@ LLView* LLView::getChildView(const std::string& name, BOOL recurse) const
return child;
}
+static LLFastTimer::DeclareTimer FTM_FIND_VIEWS("Find Widgets");
+
LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
{
+ LLFastTimer ft(FTM_FIND_VIEWS);
//richard: should we allow empty names?
//if(name.empty())
// return NULL;
@@ -1708,6 +1720,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
{
LLView* childp = *child_it;
+ llassert(childp);
if (childp->getName() == name)
{
return childp;
@@ -1719,6 +1732,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
{
LLView* childp = *child_it;
+ llassert(childp);
LLView* viewp = childp->findChildView(name, recurse);
if ( viewp )
{
@@ -2467,7 +2481,7 @@ static bool get_last_child_rect(LLView* parent, LLRect *rect)
for (;itor != parent->getChildList()->end(); ++itor)
{
LLView *last_view = (*itor);
- if (last_view->getSaveToXML())
+ if (last_view->getFromXUI())
{
*rect = last_view->getRect();
return true;
@@ -2477,13 +2491,11 @@ static bool get_last_child_rect(LLView* parent, LLRect *rect)
}
//static
-void LLView::setupParams(LLView::Params& p, LLView* parent)
+void LLView::applyXUILayout(LLView::Params& p, LLView* parent)
{
const S32 VPAD = 4;
const S32 MIN_WIDGET_HEIGHT = 10;
- p.from_xui(true);
-
// *NOTE: This will confuse export of floater/panel coordinates unless
// the default is also "topleft". JC
if (p.layout().empty() && parent)
@@ -2491,6 +2503,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
p.layout = parent->getLayout();
}
+
if (parent)
{
LLRect parent_rect = parent->getLocalRect();
@@ -2506,7 +2519,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
}
// convert negative or centered coordinates to parent relative values
- // Note: some of this logic matches the logic in TypedParam<LLRect>::getValueFromBlock()
+ // Note: some of this logic matches the logic in TypedParam<LLRect>::setValueFromBlock()
if (p.center_horiz)
{
@@ -2521,12 +2534,13 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
else
{
p.rect.left = p.rect.left + parent_rect.getWidth()/2 - p.rect.width/2;
+ p.rect.right.setProvided(false); // recalculate the right
}
}
else
{
- if (p.rect.left < 0) p.rect.left = p.rect.left + parent_rect.getWidth();
- if (p.rect.right < 0) p.rect.right = p.rect.right + parent_rect.getWidth();
+ if (p.rect.left.isProvided() && p.rect.left < 0) p.rect.left = p.rect.left + parent_rect.getWidth();
+ if (p.rect.right.isProvided() && p.rect.right < 0) p.rect.right = p.rect.right + parent_rect.getWidth();
}
if (p.center_vert)
{
@@ -2541,17 +2555,18 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
else
{
p.rect.bottom = p.rect.bottom + parent_rect.getHeight()/2 - p.rect.height/2;
+ p.rect.top.setProvided(false); // recalculate the top
}
}
else
{
- if (p.rect.bottom < 0) p.rect.bottom = p.rect.bottom + parent_rect.getHeight();
- if (p.rect.top < 0) p.rect.top = p.rect.top + parent_rect.getHeight();
+ if (p.rect.bottom.isProvided() && p.rect.bottom < 0) p.rect.bottom = p.rect.bottom + parent_rect.getHeight();
+ if (p.rect.top.isProvided() && p.rect.top < 0) p.rect.top = p.rect.top + parent_rect.getHeight();
}
// DEPRECATE: automatically fall back to height of MIN_WIDGET_HEIGHT pixels
- if (!p.rect.height.isProvided() && !p.rect.top.isProvided())
+ if (!p.rect.height.isProvided() && !p.rect.top.isProvided() && p.rect.height == 0)
{
p.rect.height = MIN_WIDGET_HEIGHT;
}
@@ -2650,7 +2665,7 @@ static void convert_to_relative_layout(LLView::Params& p, LLView* parent)
// Use setupParams to get the final widget rectangle
// according to our wacky layout rules.
LLView::Params final = p;
- LLView::setupParams(final, parent);
+ LLView::applyXUILayout(final, parent);
// Must actually extract the rectangle to get consistent
// right = left+width, top = bottom+height
LLRect final_rect = final.rect;
@@ -2836,18 +2851,21 @@ LLView::default_widget_map_t& LLView::getDefaultWidgetMap() const
return *mDefaultWidgets;
}
-void LLView::notifyParent(const LLSD& info)
+S32 LLView::notifyParent(const LLSD& info)
{
LLView* parent = getParent();
if(parent)
- parent->notifyParent(info);
+ return parent->notifyParent(info);
+ return 0;
}
-void LLView::notifyChildren(const LLSD& info)
+bool LLView::notifyChildren(const LLSD& info)
{
+ bool ret = false;
for ( child_list_iter_t child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
{
- (*child_it)->notifyChildren(info);
+ ret |= (*child_it)->notifyChildren(info);
}
+ return ret;
}
// convenient accessor for draw context