summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/llfloater.cpp1
-rw-r--r--indra/llui/lllayoutstack.cpp1
-rw-r--r--indra/llui/lllayoutstack.h5
-rw-r--r--indra/llui/llpanel.cpp1
-rw-r--r--indra/llui/llradiogroup.cpp7
-rw-r--r--indra/llui/llradiogroup.h2
-rw-r--r--indra/llui/llsearcheditor.h14
-rw-r--r--indra/llui/lltextbase.cpp7
-rw-r--r--indra/llui/llui.cpp80
-rw-r--r--indra/llui/llui.h12
-rw-r--r--indra/llui/lluictrlfactory.cpp6
-rw-r--r--indra/llui/lluictrlfactory.h27
-rw-r--r--indra/llui/lluiimage.cpp22
-rw-r--r--indra/llui/lluiimage.h3
-rw-r--r--indra/llui/llview.cpp9
15 files changed, 118 insertions, 79 deletions
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 5fd707fea3..f7fd2dbdfe 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -2716,6 +2716,7 @@ bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
params.rect.left.set(0);
}
+ params.from_xui = true;
setupParams(params, parent);
initFromParams(params);
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 1fb618adee..5e15fa3919 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -246,6 +246,7 @@ LLView* LLLayoutStack::fromXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr o
output_node, output_params, &default_params);
}
+ p.from_xui = true;
setupParams(p, parent);
LLLayoutStack* layout_stackp = LLUICtrlFactory::create<LLLayoutStack>(p);
diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h
index abd5436018..c1af428674 100644
--- a/indra/llui/lllayoutstack.h
+++ b/indra/llui/lllayoutstack.h
@@ -45,9 +45,8 @@ public:
{
Optional<std::string> orientation;
Optional<S32> border_size;
- Optional<bool> animate;
- Optional<bool> clip;
- // mMinWidth and mMinHeight are calculated, not set in XML
+ Optional<bool> animate,
+ clip;
Params();
};
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index de2b43bf13..738a96f730 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -541,6 +541,7 @@ BOOL LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
output_node, output_params, &default_params);
}
+ params.from_xui = true;
setupParams(params, parent);
{
LLFastTimer timer(FTM_PANEL_CONSTRUCTION);
diff --git a/indra/llui/llradiogroup.cpp b/indra/llui/llradiogroup.cpp
index 74e30cd633..997b9c13f8 100644
--- a/indra/llui/llradiogroup.cpp
+++ b/indra/llui/llradiogroup.cpp
@@ -112,6 +112,7 @@ void LLRadioGroup::initFromParams(const Params& p)
++it)
{
LLRadioGroup::ItemParams item_params(*it);
+
item_params.font.setIfNotProvided(mFont); // apply radio group font by default
item_params.commit_callback.function = boost::bind(&LLRadioGroup::onClickButton, this, _1);
item_params.from_xui = p.from_xui;
@@ -332,7 +333,7 @@ void LLRadioGroup::setValue( const LLSD& value )
iter != mRadioButtons.end(); ++iter)
{
LLRadioCtrl* radio = *iter;
- if (llsd_equals(radio->getPayload(), value))
+ if (radio->getPayload().asString() == value.asString())
{
setSelectedIndex(idx);
idx = -1;
@@ -384,7 +385,7 @@ BOOL LLRadioGroup::setSelectedByValue(const LLSD& value, BOOL selected)
for (button_list_t::const_iterator iter = mRadioButtons.begin();
iter != mRadioButtons.end(); ++iter)
{
- if(llsd_equals((*iter)->getPayload(), value))
+ if((*iter)->getPayload().asString() == value.asString())
{
setSelectedIndex(idx);
return TRUE;
@@ -406,7 +407,7 @@ BOOL LLRadioGroup::isSelected(const LLSD& value) const
for (button_list_t::const_iterator iter = mRadioButtons.begin();
iter != mRadioButtons.end(); ++iter)
{
- if(llsd_equals((*iter)->getPayload(), value))
+ if((*iter)->getPayload().asString() == value.asString())
{
if (idx == mSelectedIndex)
{
diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h
index 2edfd7c2ca..b178bb36ca 100644
--- a/indra/llui/llradiogroup.h
+++ b/indra/llui/llradiogroup.h
@@ -56,7 +56,7 @@ public:
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
{
Optional<bool> has_border;
- Multiple<ItemParams, LLInitParam::AtLeast<1> > items;
+ Multiple<ItemParams, AtLeast<1> > items;
Params();
};
diff --git a/indra/llui/llsearcheditor.h b/indra/llui/llsearcheditor.h
index bd2d595174..714aca9337 100644
--- a/indra/llui/llsearcheditor.h
+++ b/indra/llui/llsearcheditor.h
@@ -50,15 +50,17 @@ class LLSearchEditor : public LLUICtrl
public:
struct Params : public LLInitParam::Block<Params, LLLineEditor::Params>
{
- Optional<LLButton::Params> search_button, clear_button;
- Optional<bool> search_button_visible, clear_button_visible;
+ Optional<LLButton::Params> search_button,
+ clear_button;
+ Optional<bool> search_button_visible,
+ clear_button_visible;
Optional<commit_callback_t> keystroke_callback;
Params()
- : search_button("search_button")
- , search_button_visible("search_button_visible")
- , clear_button("clear_button")
- , clear_button_visible("clear_button_visible")
+ : search_button("search_button"),
+ search_button_visible("search_button_visible"),
+ clear_button("clear_button"),
+ clear_button_visible("clear_button_visible")
{
name = "search_editor";
}
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 6c983fd92e..cb0907a771 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1137,9 +1137,12 @@ void LLTextBase::reflow(S32 start_index)
// grow line height as necessary based on reported height of this segment
line_height = llmax(line_height, segment_height);
remaining_pixels -= segment_width;
+ if (remaining_pixels < 0)
+ {
+ // getNumChars() and getDimensions() should return consistent results
+ remaining_pixels = 0;
+ }
- // getNumChars() and getDimensions() should return consistent results
- llassert_always(remaining_pixels >= 0);
seg_offset += character_count;
S32 last_segment_char_on_line = segment->getStart() + seg_offset;
diff --git a/indra/llui/llui.cpp b/indra/llui/llui.cpp
index 6603887905..1ea6b66a93 100644
--- a/indra/llui/llui.cpp
+++ b/indra/llui/llui.cpp
@@ -1896,17 +1896,26 @@ namespace LLInitParam
control("")
{}
- LLUIColor TypedParam<LLUIColor>::getValueFromBlock() const
+ void TypedParam<LLUIColor>::setValueFromBlock() const
{
if (control.isProvided())
{
- return LLUIColorTable::instance().getColor(control);
+ mData.mValue = LLUIColorTable::instance().getColor(control);
}
else
{
- return LLColor4(red, green, blue, alpha);
+ mData.mValue = LLColor4(red, green, blue, alpha);
}
}
+
+ void TypedParam<LLUIColor>::setBlockFromValue()
+ {
+ LLColor4 color = mData.mValue.get();
+ red = color.mV[VRED];
+ green = color.mV[VGREEN];
+ blue = color.mV[VBLUE];
+ alpha = color.mV[VALPHA];
+ }
void TypeValues<LLUIColor>::declareValues()
{
@@ -1932,28 +1941,33 @@ namespace LLInitParam
addSynonym(name, "");
}
- const LLFontGL* TypedParam<const LLFontGL*>::getValueFromBlock() const
+ void TypedParam<const LLFontGL*>::setValueFromBlock() const
{
- if (name.isProvided())
+ const LLFontGL* res_fontp = LLFontGL::getFontByName(name);
+ if (res_fontp)
{
- const LLFontGL* res_fontp = LLFontGL::getFontByName(name);
- if (res_fontp)
- {
- return res_fontp;
- }
+ mData.mValue = res_fontp;
+ return;
+ }
- U8 fontstyle = 0;
- fontstyle = LLFontGL::getStyleFromString(style());
- LLFontDescriptor desc(name(), size(), fontstyle);
- const LLFontGL* fontp = LLFontGL::getFont(desc);
- if (fontp)
- {
- return fontp;
- }
+ U8 fontstyle = 0;
+ fontstyle = LLFontGL::getStyleFromString(style());
+ LLFontDescriptor desc(name(), size(), fontstyle);
+ const LLFontGL* fontp = LLFontGL::getFont(desc);
+ if (fontp)
+ {
+ mData.mValue = fontp;
+ }
+ }
+
+ void TypedParam<const LLFontGL*>::setBlockFromValue()
+ {
+ if (mData.mValue)
+ {
+ name = LLFontGL::nameFromFont(mData.mValue);
+ size = LLFontGL::sizeFromFont(mData.mValue);
+ style = LLFontGL::getStringFromStyle(mData.mValue->getFontDesc().getStyle());
}
-
- // default to current value
- return mData.mValue;
}
TypedParam<LLRect>::TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
@@ -1966,7 +1980,7 @@ namespace LLInitParam
height("height")
{}
- LLRect TypedParam<LLRect>::getValueFromBlock() const
+ void TypedParam<LLRect>::setValueFromBlock() const
{
LLRect rect;
@@ -2027,7 +2041,17 @@ namespace LLInitParam
rect.mBottom = bottom;
rect.mTop = top;
}
- return rect;
+ mData.mValue = rect;
+ }
+
+ void TypedParam<LLRect>::setBlockFromValue()
+ {
+ left = mData.mValue.mLeft;
+ right = mData.mValue.mRight;
+ bottom = mData.mValue.mBottom;
+ top = mData.mValue.mTop;
+ width.setProvided(false);
+ height.setProvided(false);
}
TypedParam<LLCoordGL>::TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
@@ -2037,9 +2061,15 @@ namespace LLInitParam
{
}
- LLCoordGL TypedParam<LLCoordGL>::getValueFromBlock() const
+ void TypedParam<LLCoordGL>::setValueFromBlock() const
+ {
+ mData.mValue.set(x, y);
+ }
+
+ void TypedParam<LLCoordGL>::setBlockFromValue()
{
- return LLCoordGL(x, y);
+ x = mData.mValue.mX;
+ y = mData.mValue.mY;
}
diff --git a/indra/llui/llui.h b/indra/llui/llui.h
index 5ec07f1941..5840e76f5c 100644
--- a/indra/llui/llui.h
+++ b/indra/llui/llui.h
@@ -379,7 +379,8 @@ namespace LLInitParam
TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
- LLRect getValueFromBlock() const;
+ void setValueFromBlock() const;
+ void setBlockFromValue();
};
template<>
@@ -401,7 +402,8 @@ namespace LLInitParam
Optional<std::string> control;
TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
- LLUIColor getValueFromBlock() const;
+ void setValueFromBlock() const;
+ void setBlockFromValue();
};
// provide a better default for Optional<const LLFontGL*> than NULL
@@ -429,7 +431,8 @@ namespace LLInitParam
style;
TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL* const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
- const LLFontGL* getValueFromBlock() const;
+ void setValueFromBlock() const;
+ void setBlockFromValue();
};
template<>
@@ -467,7 +470,8 @@ namespace LLInitParam
y;
TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count);
- LLCoordGL getValueFromBlock() const;
+ void setValueFromBlock() const;
+ void setBlockFromValue();
};
}
diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp
index 53967e4963..27237800d4 100644
--- a/indra/llui/lluictrlfactory.cpp
+++ b/indra/llui/lluictrlfactory.cpp
@@ -105,9 +105,12 @@ void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitPa
}
}
+static LLFastTimer::DeclareTimer FTM_CREATE_CHILDREN("Create XUI Children");
+
//static
void LLUICtrlFactory::createChildren(LLView* viewp, LLXMLNodePtr node, const widget_registry_t& registry, LLXMLNodePtr output_node)
{
+ LLFastTimer ft(FTM_CREATE_CHILDREN);
if (node.isNull()) return;
for (LLXMLNodePtr child_node = node->getFirstChild(); child_node.notNull(); child_node = child_node->getNextSibling())
@@ -452,4 +455,5 @@ dummy_widget_creator_func_t* LLUICtrlFactory::getDefaultWidgetFunc(const std::ty
const std::string* LLUICtrlFactory::getWidgetTag(const std::type_info* widget_type)
{
return LLWidgetNameRegistry::instance().getValue(widget_type);
-} \ No newline at end of file
+}
+
diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h
index 60f5fe9e1c..6788f29ba9 100644
--- a/indra/llui/lluictrlfactory.h
+++ b/indra/llui/lluictrlfactory.h
@@ -182,11 +182,10 @@ public:
template<typename T>
static T* createWidget(typename T::Params& params, LLView* parent = NULL)
{
- // Apply layout transformations, usually munging rect
- T::setupParams(params, parent);
-
T* widget = NULL;
+ T::setupParams(params, parent);
+
if (!params.validateBlock())
{
llwarns << getInstance()->getCurFileName() << ": Invalid parameter block for " << typeid(T).name() << llendl;
@@ -309,27 +308,9 @@ fail:
output_node, output_params, &default_params);
}
+ // Apply layout transformations, usually munging rect
params.from_xui = true;
-
- if (!params.validateBlock())
- {
- llwarns << getInstance()->getCurFileName() << ": Invalid parameter block for " << typeid(T).name() << llendl;
- }
- T* widget;
- {
- LLFastTimer timer(FTM_WIDGET_CONSTRUCTION);
- widget = new T(params);
- }
- {
- LLFastTimer timer(FTM_INIT_FROM_PARAMS);
- widget->initFromParams(params);
- }
-
- if (parent)
- {
- S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : -1;
- setCtrlParent(widget, parent, tab_group);
- }
+ T* widget = createWidget<T>(params, parent);
typedef typename T::child_registry_t registry_t;
diff --git a/indra/llui/lluiimage.cpp b/indra/llui/lluiimage.cpp
index f941f391eb..1dfc281d93 100644
--- a/indra/llui/lluiimage.cpp
+++ b/indra/llui/lluiimage.cpp
@@ -161,22 +161,32 @@ void LLUIImage::onImageLoaded()
namespace LLInitParam
{
- LLUIImage* TypedParam<LLUIImage*>::getValueFromBlock() const
+ void TypedParam<LLUIImage*>::setValueFromBlock() const
{
// The keyword "none" is specifically requesting a null image
// do not default to current value. Used to overwrite template images.
if (name() == "none")
{
- return NULL;
+ mData.mValue = NULL;
}
LLUIImage* imagep = LLUI::getUIImage(name());
- if (!imagep)
+ if (imagep)
{
- // default to current value
- imagep = mData.mValue;
+ mData.mValue = imagep;
+ }
+ }
+
+ void TypedParam<LLUIImage*>::setBlockFromValue()
+ {
+ if (mData.mValue == NULL)
+ {
+ name = "none";
+ }
+ else
+ {
+ name = mData.mValue->getName();
}
- return imagep;
}
diff --git a/indra/llui/lluiimage.h b/indra/llui/lluiimage.h
index 5fa9610ab2..bdfc44262d 100644
--- a/indra/llui/lluiimage.h
+++ b/indra/llui/lluiimage.h
@@ -111,7 +111,8 @@ namespace LLInitParam
{
}
- LLUIImage* getValueFromBlock() const;
+ void setValueFromBlock() const;
+ void setBlockFromValue();
};
// Need custom comparison function for our test app, which only loads
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 7932b749a8..a8d8626e49 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -2501,6 +2501,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
p.layout = parent->getLayout();
}
+
if (parent)
{
LLRect parent_rect = parent->getLocalRect();
@@ -2508,7 +2509,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
LLRect last_rect = parent->getLocalRect();
bool layout_topleft = (p.layout() == "topleft");
- if (layout_topleft)
+ if (layout_topleft && p.from_xui)
{
//invert top to bottom
if (p.rect.top.isProvided()) p.rect.top = parent_rect.getHeight() - p.rect.top;
@@ -2516,7 +2517,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)
{
@@ -2534,7 +2535,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
p.rect.right.setProvided(false); // recalculate the right
}
}
- else
+ else if (p.from_xui) // only do negative coordinate magic for XUI
{
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();
@@ -2555,7 +2556,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent)
p.rect.top.setProvided(false); // recalculate the top
}
}
- else
+ else if (p.from_xui)
{
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();