From 3a02b9ec882c98009ae6c24913ee8a7a620b0f87 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 15 Dec 2009 19:33:18 -0800 Subject: added setBlockFromValue so setting a LLRect param in code will set the individual left, right, top, bottom values, for example don't call setupParams when creating widgets from code moved Multiple param constraints into BaseBlock to remove extra scoping --- indra/llui/lllayoutstack.h | 5 ++- indra/llui/llradiogroup.h | 2 +- indra/llui/llsearcheditor.h | 14 ++++---- indra/llui/llui.cpp | 79 +++++++++++++++++++++++++++++------------- indra/llui/llui.h | 12 ++++--- indra/llui/lluictrlfactory.cpp | 3 ++ indra/llui/lluictrlfactory.h | 6 ++-- indra/llui/lluiimage.cpp | 22 ++++++++---- indra/llui/lluiimage.h | 3 +- indra/llui/llview.cpp | 4 ++- 10 files changed, 99 insertions(+), 51 deletions(-) (limited to 'indra/llui') 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 orientation; Optional border_size; - Optional animate; - Optional clip; - // mMinWidth and mMinHeight are calculated, not set in XML + Optional animate, + clip; Params(); }; 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 { Optional has_border; - Multiple > items; + Multiple > 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 { - Optional search_button, clear_button; - Optional search_button_visible, clear_button_visible; + Optional search_button, + clear_button; + Optional search_button_visible, + clear_button_visible; Optional 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/llui.cpp b/indra/llui/llui.cpp index 6603887905..67d3ed408b 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1896,17 +1896,26 @@ namespace LLInitParam control("") {} - LLUIColor TypedParam::getValueFromBlock() const + void TypedParam::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::setBlockFromValue() + { + LLColor4 color = mData.mValue.get(); + red = color.mV[VRED]; + green = color.mV[VGREEN]; + blue = color.mV[VBLUE]; + alpha = color.mV[VALPHA]; + } void TypeValues::declareValues() { @@ -1932,28 +1941,32 @@ namespace LLInitParam addSynonym(name, ""); } - const LLFontGL* TypedParam::getValueFromBlock() const + void TypedParam::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; + } - 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::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::TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count) @@ -1966,7 +1979,7 @@ namespace LLInitParam height("height") {} - LLRect TypedParam::getValueFromBlock() const + void TypedParam::setValueFromBlock() const { LLRect rect; @@ -2027,7 +2040,17 @@ namespace LLInitParam rect.mBottom = bottom; rect.mTop = top; } - return rect; + mData.mValue = rect; + } + + void TypedParam::setBlockFromValue() + { + left = mData.mValue.mLeft; + right = mData.mValue.mRight; + bottom = mData.mValue.mBottom; + top = mData.mValue.mTop; + width.setProvided(false); + height.setProvided(false); } TypedParam::TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count) @@ -2037,9 +2060,15 @@ namespace LLInitParam { } - LLCoordGL TypedParam::getValueFromBlock() const + void TypedParam::setValueFromBlock() const + { + mData.mValue.set(x, y); + } + + void TypedParam::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 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 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 6a7879c8c2..625d3c63e5 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()) diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index e4bac48fd3..6dab9521bb 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -182,9 +182,6 @@ public: template static T* createWidget(typename T::Params& params, LLView* parent = NULL) { - // Apply layout transformations, usually munging rect - T::setupParams(params, parent); - T* widget = NULL; if (!params.validateBlock()) @@ -309,7 +306,8 @@ fail: output_node, output_params, &default_params); } - params.from_xui = true; + // Apply layout transformations, usually munging rect + T::setupParams(params, parent); T* widget = createWidget(params, parent); 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::getValueFromBlock() const + void TypedParam::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::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..9f6fc1f298 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -2501,6 +2501,8 @@ void LLView::setupParams(LLView::Params& p, LLView* parent) p.layout = parent->getLayout(); } + p.from_xui = true; + if (parent) { LLRect parent_rect = parent->getLocalRect(); @@ -2516,7 +2518,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::getValueFromBlock() + // Note: some of this logic matches the logic in TypedParam::setValueFromBlock() if (p.center_horiz) { -- cgit v1.2.3