From e8fe81c4fcbec173606b5ad635e0b774e4d8b24b Mon Sep 17 00:00:00 2001 From: James Cook Date: Wed, 16 Dec 2009 16:04:09 -0800 Subject: Backed out changeset: cfa60aef8061, added setBlockFromValue so setting a LLRect param in code will set the individua --- indra/llrender/llfontgl.cpp | 23 ------------ indra/llrender/llfontgl.h | 1 - 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 +-- indra/llxuixml/llinitparam.h | 78 ++++++++++++++++++++--------------------- 13 files changed, 89 insertions(+), 163 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp index 7ad5f9608f..db1f019a81 100644 --- a/indra/llrender/llfontgl.cpp +++ b/indra/llrender/llfontgl.cpp @@ -760,29 +760,6 @@ U8 LLFontGL::getStyleFromString(const std::string &style) return ret; } -// static -std::string LLFontGL::getStringFromStyle(U8 style) -{ - std::string style_string; - if (style & NORMAL) - { - style_string += "|NORMAL"; - } - if (style & BOLD) - { - style_string += "|BOLD"; - } - if (style & ITALIC) - { - style_string += "|ITALIC"; - } - if (style & UNDERLINE) - { - style_string += "|UNDERLINE"; - } - return style_string; -} - // static std::string LLFontGL::nameFromFont(const LLFontGL* fontp) { diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h index ea8eee7690..bb7d8524e7 100644 --- a/indra/llrender/llfontgl.h +++ b/indra/llrender/llfontgl.h @@ -144,7 +144,6 @@ public: // Takes a string with potentially several flags, i.e. "NORMAL|BOLD|ITALIC" static U8 getStyleFromString(const std::string &style); - static std::string getStringFromStyle(U8 style); static std::string nameFromFont(const LLFontGL* fontp); static std::string sizeFromFont(const LLFontGL* fontp); diff --git a/indra/llui/lllayoutstack.h b/indra/llui/lllayoutstack.h index c1af428674..abd5436018 100644 --- a/indra/llui/lllayoutstack.h +++ b/indra/llui/lllayoutstack.h @@ -45,8 +45,9 @@ public: { Optional orientation; Optional border_size; - Optional animate, - clip; + Optional animate; + Optional clip; + // mMinWidth and mMinHeight are calculated, not set in XML Params(); }; diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h index b178bb36ca..2edfd7c2ca 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 714aca9337..bd2d595174 100644 --- a/indra/llui/llsearcheditor.h +++ b/indra/llui/llsearcheditor.h @@ -50,17 +50,15 @@ 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 67d3ed408b..6603887905 100644 --- a/indra/llui/llui.cpp +++ b/indra/llui/llui.cpp @@ -1896,26 +1896,17 @@ namespace LLInitParam control("") {} - void TypedParam::setValueFromBlock() const + LLUIColor TypedParam::getValueFromBlock() const { if (control.isProvided()) { - mData.mValue = LLUIColorTable::instance().getColor(control); + return LLUIColorTable::instance().getColor(control); } else { - mData.mValue = LLColor4(red, green, blue, alpha); + return 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() { @@ -1941,32 +1932,28 @@ namespace LLInitParam addSynonym(name, ""); } - void TypedParam::setValueFromBlock() const + const LLFontGL* TypedParam::getValueFromBlock() const { - const LLFontGL* res_fontp = LLFontGL::getFontByName(name); - if (res_fontp) + if (name.isProvided()) { - mData.mValue = res_fontp; - } + const LLFontGL* res_fontp = LLFontGL::getFontByName(name); + if (res_fontp) + { + return res_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()); + U8 fontstyle = 0; + fontstyle = LLFontGL::getStyleFromString(style()); + LLFontDescriptor desc(name(), size(), fontstyle); + const LLFontGL* fontp = LLFontGL::getFont(desc); + if (fontp) + { + return fontp; + } } + + // 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) @@ -1979,7 +1966,7 @@ namespace LLInitParam height("height") {} - void TypedParam::setValueFromBlock() const + LLRect TypedParam::getValueFromBlock() const { LLRect rect; @@ -2040,17 +2027,7 @@ namespace LLInitParam rect.mBottom = bottom; rect.mTop = top; } - 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); + return rect; } TypedParam::TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count) @@ -2060,15 +2037,9 @@ namespace LLInitParam { } - void TypedParam::setValueFromBlock() const - { - mData.mValue.set(x, y); - } - - void TypedParam::setBlockFromValue() + LLCoordGL TypedParam::getValueFromBlock() const { - x = mData.mValue.mX; - y = mData.mValue.mY; + return LLCoordGL(x, y); } diff --git a/indra/llui/llui.h b/indra/llui/llui.h index 5840e76f5c..5ec07f1941 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -379,8 +379,7 @@ namespace LLInitParam TypedParam(BlockDescriptor& descriptor, const char* name, const LLRect& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count); - void setValueFromBlock() const; - void setBlockFromValue(); + LLRect getValueFromBlock() const; }; template<> @@ -402,8 +401,7 @@ namespace LLInitParam Optional control; TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count); - void setValueFromBlock() const; - void setBlockFromValue(); + LLUIColor getValueFromBlock() const; }; // provide a better default for Optional than NULL @@ -431,8 +429,7 @@ namespace LLInitParam style; TypedParam(BlockDescriptor& descriptor, const char* name, const LLFontGL* const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count); - void setValueFromBlock() const; - void setBlockFromValue(); + const LLFontGL* getValueFromBlock() const; }; template<> @@ -470,8 +467,7 @@ namespace LLInitParam y; TypedParam(BlockDescriptor& descriptor, const char* name, LLCoordGL value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count); - void setValueFromBlock() const; - void setBlockFromValue(); + LLCoordGL getValueFromBlock() const; }; } diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 625d3c63e5..6a7879c8c2 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -105,12 +105,9 @@ 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 6dab9521bb..e4bac48fd3 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -182,6 +182,9 @@ 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()) @@ -306,8 +309,7 @@ fail: output_node, output_params, &default_params); } - // Apply layout transformations, usually munging rect - T::setupParams(params, parent); + params.from_xui = true; T* widget = createWidget(params, parent); diff --git a/indra/llui/lluiimage.cpp b/indra/llui/lluiimage.cpp index 1dfc281d93..f941f391eb 100644 --- a/indra/llui/lluiimage.cpp +++ b/indra/llui/lluiimage.cpp @@ -161,32 +161,22 @@ void LLUIImage::onImageLoaded() namespace LLInitParam { - void TypedParam::setValueFromBlock() const + LLUIImage* TypedParam::getValueFromBlock() const { // The keyword "none" is specifically requesting a null image // do not default to current value. Used to overwrite template images. if (name() == "none") { - mData.mValue = NULL; + return NULL; } LLUIImage* imagep = LLUI::getUIImage(name()); - if (imagep) + if (!imagep) { - mData.mValue = imagep; - } - } - - void TypedParam::setBlockFromValue() - { - if (mData.mValue == NULL) - { - name = "none"; - } - else - { - name = mData.mValue->getName(); + // default to current value + imagep = mData.mValue; } + return imagep; } diff --git a/indra/llui/lluiimage.h b/indra/llui/lluiimage.h index bdfc44262d..5fa9610ab2 100644 --- a/indra/llui/lluiimage.h +++ b/indra/llui/lluiimage.h @@ -111,8 +111,7 @@ namespace LLInitParam { } - void setValueFromBlock() const; - void setBlockFromValue(); + LLUIImage* getValueFromBlock() const; }; // Need custom comparison function for our test app, which only loads diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index 9f6fc1f298..7932b749a8 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -2501,8 +2501,6 @@ void LLView::setupParams(LLView::Params& p, LLView* parent) p.layout = parent->getLayout(); } - p.from_xui = true; - if (parent) { LLRect parent_rect = parent->getLocalRect(); @@ -2518,7 +2516,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::setValueFromBlock() + // Note: some of this logic matches the logic in TypedParam::getValueFromBlock() if (p.center_horiz) { diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index 7e1e4a3d21..493ddaa378 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -1,5 +1,5 @@ /** -f * @file llinitparam.h + * @file llinitparam.h * @brief parameter block abstraction for creating complex objects and * parsing construction parameters from xml and LLSD * @@ -405,41 +405,6 @@ namespace LLInitParam class BaseBlock { public: - // "Multiple" constraint types - struct AnyAmount - { - static U32 minCount() { return 0; } - static U32 maxCount() { return U32_MAX; } - }; - - template - struct AtLeast - { - static U32 minCount() { return MIN_AMOUNT; } - static U32 maxCount() { return U32_MAX; } - }; - - template - struct AtMost - { - static U32 minCount() { return 0; } - static U32 maxCount() { return MAX_AMOUNT; } - }; - - template - struct Between - { - static U32 minCount() { return MIN_AMOUNT; } - static U32 maxCount() { return MAX_AMOUNT; } - }; - - template - struct Exactly - { - static U32 minCount() { return EXACT_COUNT; } - static U32 maxCount() { return EXACT_COUNT; } - }; - // this typedef identifies derived classes as being blocks typedef void baseblock_base_class_t; LOG_CLASS(BaseBlock); @@ -1400,6 +1365,40 @@ namespace LLInitParam } }; + struct AnyAmount + { + static U32 minCount() { return 0; } + static U32 maxCount() { return U32_MAX; } + }; + + template + struct AtLeast + { + static U32 minCount() { return MIN_AMOUNT; } + static U32 maxCount() { return U32_MAX; } + }; + + template + struct AtMost + { + static U32 minCount() { return 0; } + static U32 maxCount() { return MAX_AMOUNT; } + }; + + template + struct Between + { + static U32 minCount() { return MIN_AMOUNT; } + static U32 maxCount() { return MAX_AMOUNT; } + }; + + template + struct Exactly + { + static U32 minCount() { return EXACT_COUNT; } + static U32 maxCount() { return EXACT_COUNT; } + }; + template class Block : public BASE_BLOCK @@ -1492,7 +1491,7 @@ namespace LLInitParam }; - template > + template > class Multiple : public TypedParam { public: @@ -1712,7 +1711,7 @@ namespace LLInitParam { if (block_t::validateBlock(true)) { - static_cast(this)->setValueFromBlock(); + mData.mValue = static_cast(this)->getValueFromBlock(); // clear stale keyword associated with old value mData.clearKey(); mData.mLastParamVersion = BaseBlock::getLastChangeVersion(); @@ -1738,7 +1737,6 @@ namespace LLInitParam mData.mValue = val; mData.clearKey(); setProvided(flag_as_provided); - static_cast(this)->setBlockFromValue(); } void setIfNotProvided(value_assignment_t val, bool flag_as_provided = true) @@ -1770,7 +1768,7 @@ namespace LLInitParam // go ahead and issue warnings at this point if any param is invalid if(block_t::validateBlock(false)) { - static_cast(this)->setValueFromBlock(); + mData.mValue = static_cast(this)->getValueFromBlock(); mData.clearKey(); mData.mLastParamVersion = BaseBlock::getLastChangeVersion(); } -- cgit v1.2.3