diff options
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/llflatlistview.cpp | 6 | ||||
-rw-r--r-- | indra/llui/llfloater.cpp | 1 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.cpp | 1 | ||||
-rw-r--r-- | indra/llui/lllayoutstack.h | 5 | ||||
-rw-r--r-- | indra/llui/llmenugl.cpp | 4 | ||||
-rw-r--r-- | indra/llui/llpanel.cpp | 1 | ||||
-rw-r--r-- | indra/llui/llradiogroup.cpp | 105 | ||||
-rw-r--r-- | indra/llui/llradiogroup.h | 47 | ||||
-rw-r--r-- | indra/llui/llsearcheditor.h | 14 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.cpp | 13 | ||||
-rw-r--r-- | indra/llui/lltabcontainer.h | 9 | ||||
-rw-r--r-- | indra/llui/lltextbase.cpp | 11 | ||||
-rw-r--r-- | indra/llui/llui.cpp | 80 | ||||
-rw-r--r-- | indra/llui/llui.h | 12 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.cpp | 10 | ||||
-rw-r--r-- | indra/llui/lluictrlfactory.h | 70 | ||||
-rw-r--r-- | indra/llui/lluiimage.cpp | 22 | ||||
-rw-r--r-- | indra/llui/lluiimage.h | 3 | ||||
-rw-r--r-- | indra/llui/llview.cpp | 11 |
19 files changed, 253 insertions, 172 deletions
diff --git a/indra/llui/llflatlistview.cpp b/indra/llui/llflatlistview.cpp index 64a4824a17..09124c3013 100644 --- a/indra/llui/llflatlistview.cpp +++ b/indra/llui/llflatlistview.cpp @@ -530,7 +530,8 @@ BOOL LLFlatListView::handleKeyHere(KEY key, MASK mask) if ( !selectNextItemPair(true, reset_selection) && reset_selection) { // If case we are in accordion tab notify parent to go to the previous accordion - notifyParent(LLSD().with("action","select_prev")); + if(notifyParent(LLSD().with("action","select_prev")) > 0 )//message was processed + resetSelection(); } break; } @@ -539,7 +540,8 @@ BOOL LLFlatListView::handleKeyHere(KEY key, MASK mask) if ( !selectNextItemPair(false, reset_selection) && reset_selection) { // If case we are in accordion tab notify parent to go to the next accordion - notifyParent(LLSD().with("action","select_next")); + if( notifyParent(LLSD().with("action","select_next")) > 0 ) //message was processed + resetSelection(); } break; } 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/llmenugl.cpp b/indra/llui/llmenugl.cpp index fd5c2b7fef..202ed04fbc 100644 --- a/indra/llui/llmenugl.cpp +++ b/indra/llui/llmenugl.cpp @@ -97,7 +97,7 @@ const U32 SEPARATOR_HEIGHT_PIXELS = 8; const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10; const S32 MENU_ITEM_PADDING = 4; -const std::string BOOLEAN_TRUE_PREFIX( "X" ); +const std::string BOOLEAN_TRUE_PREFIX( "\xE2\x9C\x94" ); // U+2714 HEAVY CHECK MARK const std::string BRANCH_SUFFIX( ">" ); const std::string ARROW_UP ("^^^^^^^"); const std::string ARROW_DOWN("vvvvvvv"); @@ -3905,7 +3905,7 @@ BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu) item = LLUICtrlFactory::create<LLContextMenuBranch>(p); LLMenuGL::sMenuContainer->addChild(item->getBranch()); - item->setFont( LLFontGL::getFontSansSerifSmall() ); + item->setFont( LLFontGL::getFontSansSerif() ); return append( item ); } 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 86bd2f05ce..997b9c13f8 100644 --- a/indra/llui/llradiogroup.cpp +++ b/indra/llui/llradiogroup.cpp @@ -43,15 +43,43 @@ #include "llui.h" #include "llfocusmgr.h" #include "lluictrlfactory.h" +#include "llsdutil.h" static LLDefaultChildRegistry::Register<LLRadioGroup> r1("radio_group"); -static RadioGroupRegistry::Register<LLRadioCtrl> register_radio_ctrl("radio_item"); +/* + * An invisible view containing multiple mutually exclusive toggling + * buttons (usually radio buttons). Automatically handles the mutex + * condition by highlighting only one button at a time. + */ +class LLRadioCtrl : public LLCheckBoxCtrl +{ +public: + typedef LLRadioGroup::ItemParams Params; + /*virtual*/ ~LLRadioCtrl(); + /*virtual*/ void setValue(const LLSD& value); + + /*virtual*/ BOOL postBuild(); + + LLSD getPayload() { return mPayload; } + // Ensure label is in an attribute, not the contents + static void setupParamsForExport(Params& p, LLView* parent); + +protected: + LLRadioCtrl(const LLRadioGroup::ItemParams& p); + friend class LLUICtrlFactory; + + LLSD mPayload; // stores data that this item represents in the radio group +}; +static LLWidgetNameRegistry::StaticRegistrar register_radio_item(&typeid(LLRadioGroup::ItemParams), "radio_item"); LLRadioGroup::Params::Params() -: has_border("draw_border") +: has_border("draw_border"), + items("item") { + addSynonym(items, "radio_item"); + name = "radio_group"; mouse_opaque = true; follows.flags = FOLLOWS_LEFT | FOLLOWS_TOP; @@ -76,6 +104,25 @@ LLRadioGroup::LLRadioGroup(const LLRadioGroup::Params& p) } } +void LLRadioGroup::initFromParams(const Params& p) +{ + LLUICtrl::initFromParams(p); + for (LLInitParam::ParamIterator<ItemParams>::const_iterator it = p.items().begin(); + it != p.items().end(); + ++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; + + LLRadioCtrl* item = LLUICtrlFactory::create<LLRadioCtrl>(item_params, this); + mRadioButtons.push_back(item); + } +} + + LLRadioGroup::~LLRadioGroup() { } @@ -141,7 +188,7 @@ void LLRadioGroup::setIndexEnabled(S32 index, BOOL enabled) BOOL LLRadioGroup::setSelectedIndex(S32 index, BOOL from_event) { - if (index < 0 || index >= (S32)mRadioButtons.size()) + if (index < 0 || (S32)mRadioButtons.size() <= index ) { return FALSE; } @@ -170,7 +217,7 @@ BOOL LLRadioGroup::setSelectedIndex(S32 index, BOOL from_event) if (!from_event) { - setControlValue(getSelectedIndex()); + setControlValue(getValue()); } return TRUE; @@ -235,27 +282,6 @@ BOOL LLRadioGroup::handleKeyHere(KEY key, MASK mask) return handled; } - -// When adding a child button, we need to ensure that the radio -// group gets a message when the button is clicked. - -/*virtual*/ -bool LLRadioGroup::addChild(LLView* view, S32 tab_group) -{ - bool res = LLView::addChild(view, tab_group); - if (res) - { - LLRadioCtrl* radio_ctrl = dynamic_cast<LLRadioCtrl*>(view); - if (radio_ctrl) - { - radio_ctrl->setFont(mFont); - radio_ctrl->setCommitCallback(boost::bind(&LLRadioGroup::onClickButton, this, _1)); - mRadioButtons.push_back(radio_ctrl); - } - } - return res; -} - BOOL LLRadioGroup::handleMouseDown(S32 x, S32 y, MASK mask) { // grab focus preemptively, before child button takes mousecapture @@ -302,13 +328,12 @@ void LLRadioGroup::onClickButton(LLUICtrl* ctrl) void LLRadioGroup::setValue( const LLSD& value ) { - std::string value_name = value.asString(); int idx = 0; for (button_list_t::const_iterator iter = mRadioButtons.begin(); iter != mRadioButtons.end(); ++iter) { LLRadioCtrl* radio = *iter; - if (radio->getName() == value_name) + if (radio->getPayload().asString() == value.asString()) { setSelectedIndex(idx); idx = -1; @@ -325,7 +350,7 @@ void LLRadioGroup::setValue( const LLSD& value ) } else { - llwarns << "LLRadioGroup::setValue: value not found: " << value_name << llendl; + llwarns << "LLRadioGroup::setValue: value not found: " << value.asString() << llendl; } } } @@ -337,7 +362,7 @@ LLSD LLRadioGroup::getValue() const for (button_list_t::const_iterator iter = mRadioButtons.begin(); iter != mRadioButtons.end(); ++iter) { - if (idx == index) return LLSD((*iter)->getName()); + if (idx == index) return LLSD((*iter)->getPayload()); ++idx; } return LLSD(); @@ -357,11 +382,10 @@ LLUUID LLRadioGroup::getCurrentID() const BOOL LLRadioGroup::setSelectedByValue(const LLSD& value, BOOL selected) { S32 idx = 0; - std::string value_string = value.asString(); for (button_list_t::const_iterator iter = mRadioButtons.begin(); iter != mRadioButtons.end(); ++iter) { - if((*iter)->getName() == value_string) + if((*iter)->getPayload().asString() == value.asString()) { setSelectedIndex(idx); return TRUE; @@ -380,11 +404,10 @@ LLSD LLRadioGroup::getSelectedValue() BOOL LLRadioGroup::isSelected(const LLSD& value) const { S32 idx = 0; - std::string value_string = value.asString(); for (button_list_t::const_iterator iter = mRadioButtons.begin(); iter != mRadioButtons.end(); ++iter) { - if((*iter)->getName() == value_string) + if((*iter)->getPayload().asString() == value.asString()) { if (idx == mSelectedIndex) { @@ -406,9 +429,21 @@ BOOL LLRadioGroup::operateOnAll(EOperation op) return FALSE; } -LLRadioCtrl::LLRadioCtrl(const LLRadioCtrl::Params& p) - : LLCheckBoxCtrl(p) +LLRadioGroup::ItemParams::ItemParams() +: value("value") { + addSynonym(value, "initial_value"); +} + +LLRadioCtrl::LLRadioCtrl(const LLRadioGroup::ItemParams& p) +: LLCheckBoxCtrl(p), + mPayload(p.value) +{ + // use name as default "Value" for backwards compatibility + if (!p.value.isProvided()) + { + mPayload = p.name(); + } } BOOL LLRadioCtrl::postBuild() diff --git a/indra/llui/llradiogroup.h b/indra/llui/llradiogroup.h index 1e9b5115f8..b178bb36ca 100644 --- a/indra/llui/llradiogroup.h +++ b/indra/llui/llradiogroup.h @@ -37,35 +37,6 @@ #include "llcheckboxctrl.h" #include "llctrlselectioninterface.h" - -/* - * An invisible view containing multiple mutually exclusive toggling - * buttons (usually radio buttons). Automatically handles the mutex - * condition by highlighting only one button at a time. - */ -class LLRadioCtrl : public LLCheckBoxCtrl -{ -public: - struct Params : public LLInitParam::Block<Params, LLCheckBoxCtrl::Params> - {}; - - /*virtual*/ ~LLRadioCtrl(); - /*virtual*/ void setValue(const LLSD& value); - - /*virtual*/ BOOL postBuild(); - - // Ensure label is in an attribute, not the contents - static void setupParamsForExport(Params& p, LLView* parent); - -protected: - LLRadioCtrl(const Params& p); - friend class LLUICtrlFactory; -}; - - -struct RadioGroupRegistry : public LLChildRegistry<RadioGroupRegistry> -{}; - /* * An invisible view containing multiple mutually exclusive toggling * buttons (usually radio buttons). Automatically handles the mutex @@ -76,25 +47,31 @@ class LLRadioGroup { public: + struct ItemParams : public LLInitParam::Block<ItemParams, LLCheckBoxCtrl::Params> + { + Optional<LLSD> value; + ItemParams(); + }; + struct Params : public LLInitParam::Block<Params, LLUICtrl::Params> { - Optional<bool> has_border; + Optional<bool> has_border; + Multiple<ItemParams, AtLeast<1> > items; Params(); }; - // my valid children are stored in this registry - typedef RadioGroupRegistry child_registry_t; - protected: LLRadioGroup(const Params&); friend class LLUICtrlFactory; public: + + /*virtual*/ void initFromParams(const Params&); + virtual ~LLRadioGroup(); virtual BOOL postBuild(); - virtual bool addChild(LLView* view, S32 tab_group = 0); virtual BOOL handleMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleKeyHere(KEY key, MASK mask); @@ -134,7 +111,7 @@ public: private: const LLFontGL* mFont; S32 mSelectedIndex; - typedef std::vector<LLRadioCtrl*> button_list_t; + typedef std::vector<class LLRadioCtrl*> button_list_t; button_list_t mRadioButtons; BOOL mHasBorder; 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/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp index 2d9106923e..83e2e3db50 100644 --- a/indra/llui/lltabcontainer.cpp +++ b/indra/llui/lltabcontainer.cpp @@ -120,6 +120,8 @@ LLTabContainer::Params::Params() tab_min_width("tab_min_width"), tab_max_width("tab_max_width"), tab_height("tab_height"), + label_pad_bottom("label_pad_bottom"), + label_pad_left("label_pad_left"), tab_position("tab_position"), hide_tabs("hide_tabs", false), tab_padding_right("tab_padding_right"), @@ -145,6 +147,8 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p) mMinTabWidth(0), mMaxTabWidth(p.tab_max_width), mTabHeight(p.tab_height), + mLabelPadBottom(p.label_pad_bottom), + mLabelPadLeft(p.label_pad_left), mPrevArrowBtn(NULL), mNextArrowBtn(NULL), mIsVertical( p.tab_position == LEFT ), @@ -906,7 +910,7 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) if (placeholder) { - btn_rect.translate(0, -3); // *TODO: make configurable + btn_rect.translate(0, -6); // *TODO: make configurable LLTextBox::Params params; params.name(trimmed_label); params.rect(btn_rect); @@ -933,6 +937,7 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) p.image_selected(mMiddleTabParams.tab_left_image_selected); p.scale_image(true); p.font_halign = mFontHalign; + p.pad_bottom( mLabelPadBottom ); p.tab_stop(false); p.label_shadow(false); if (indent) @@ -956,8 +961,9 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel) p.tab_stop(false); p.label_shadow(false); // Try to squeeze in a bit more text - p.pad_left(4); + p.pad_left( mLabelPadLeft ); p.pad_right(2); + p.pad_bottom( mLabelPadBottom ); p.font_halign = mFontHalign; p.follows.flags = FOLLOWS_LEFT; p.follows.flags = FOLLOWS_LEFT; @@ -1897,6 +1903,3 @@ void LLTabContainer::commitHoveredButton(S32 x, S32 y) } } } - - - diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h index be9c6c7d06..5d0f194bf9 100644 --- a/indra/llui/lltabcontainer.h +++ b/indra/llui/lltabcontainer.h @@ -79,7 +79,9 @@ public: Optional<S32> tab_width, tab_min_width, tab_max_width, - tab_height; + tab_height, + label_pad_bottom, + label_pad_left; Optional<bool> hide_tabs; Optional<S32> tab_padding_right; @@ -261,6 +263,11 @@ private: S32 mTotalTabWidth; S32 mTabHeight; + // Padding under the text labels of tab buttons + S32 mLabelPadBottom; + // Padding to the left of text labels of tab buttons + S32 mLabelPadLeft; + LLFrameTimer mDragAndDropDelayTimer; LLFontGL::HAlign mFontHalign; diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 1f120a1483..cb0907a771 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -1137,6 +1137,11 @@ 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; + } seg_offset += character_count; @@ -2464,6 +2469,12 @@ S32 LLNormalTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 lin { LLWString text = mEditor.getWText(); + LLUIImagePtr image = mStyle->getImage(); + if( image.notNull()) + { + num_pixels -= image->getWidth(); + } + // search for newline and if found, truncate there S32 last_char = mStart + segment_offset; for (; last_char != mEnd; ++last_char) 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 3643bf44f7..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()) @@ -393,7 +396,7 @@ BOOL LLUICtrlFactory::getAttributeColor(LLXMLNodePtr node, const std::string& na //static void LLUICtrlFactory::setCtrlParent(LLView* view, LLView* parent, S32 tab_group) { - if (tab_group < 0) tab_group = parent->getLastTabGroup(); + if (tab_group == S32_MAX) tab_group = parent->getLastTabGroup(); parent->addChild(view, tab_group); } @@ -454,8 +457,3 @@ const std::string* LLUICtrlFactory::getWidgetTag(const std::type_info* widget_ty return LLWidgetNameRegistry::instance().getValue(widget_type); } -// static -void LLUICtrlFactory::connect(LLView* parent, LLView* child) -{ - parent->addChild(child); -} diff --git a/indra/llui/lluictrlfactory.h b/indra/llui/lluictrlfactory.h index 55d7d745eb..6788f29ba9 100644 --- a/indra/llui/lluictrlfactory.h +++ b/indra/llui/lluictrlfactory.h @@ -180,34 +180,54 @@ public: void popFactoryFunctions(); template<typename T> - static T* create(typename T::Params& params, LLView* parent = NULL) + static T* createWidget(typename T::Params& params, LLView* parent = NULL) { - //#pragma message("Generating LLUICtrlFactory::create") - params.fillFrom(ParamDefaults<typename T::Params, 0>::instance().get()); - //S32 foo = "test"; + T* widget = NULL; + + T::setupParams(params, parent); if (!params.validateBlock()) { llwarns << getInstance()->getCurFileName() << ": Invalid parameter block for " << typeid(T).name() << llendl; + //return NULL; + } + + { + LLFastTimer timer(FTM_WIDGET_CONSTRUCTION); + widget = new T(params); + } + { + LLFastTimer timer(FTM_INIT_FROM_PARAMS); + widget->initFromParams(params); } - T* widget = new T(params); - widget->initFromParams(params); + if (parent) { - connect(parent, widget); + S32 tab_group = params.tab_group.isProvided() ? params.tab_group() : S32_MAX; + setCtrlParent(widget, parent, tab_group); } return widget; } - // fix for gcc template instantiation annoyance - static void connect(LLView* parent, LLView* child); - + template<typename T> + static T* create(typename T::Params& params, LLView* parent = NULL) + { + params.fillFrom(ParamDefaults<typename T::Params, 0>::instance().get()); + + T* widget = createWidget<T>(params, parent); + if (widget) + { + widget->postBuild(); + } + + return widget; + } + LLView* createFromXML(LLXMLNodePtr node, LLView* parent, const std::string& filename, const widget_registry_t&, LLXMLNodePtr output_node ); template<typename T> static T* createFromFile(const std::string &filename, LLView *parent, const widget_registry_t& registry, LLXMLNodePtr output_node = NULL) { - //#pragma message("Generating LLUICtrlFactory::createFromFile") T* widget = NULL; std::string skinned_filename = findSkinnedFilename(filename); @@ -272,7 +292,6 @@ fail: { LLFastTimer timer(FTM_WIDGET_SETUP); - //#pragma message("Generating LLUICtrlFactory::defaultBuilder") typename T::Params params(getDefaultParams<T>()); LLXUIParser::instance().readXUI(node, params, LLUICtrlFactory::getInstance()->getCurFileName()); @@ -290,36 +309,17 @@ fail: } // Apply layout transformations, usually munging rect - T::setupParams(params, parent); + params.from_xui = true; + T* widget = createWidget<T>(params, parent); - 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); - } - typedef typename T::child_registry_t registry_t; createChildren(widget, node, registry_t::instance(), output_node); - if (!widget->postBuild()) + if (widget && !widget->postBuild()) { delete widget; - return NULL; + widget = NULL; } return widget; 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 8917e4b813..a8d8626e49 100644 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -2494,8 +2494,6 @@ void LLView::setupParams(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) @@ -2503,6 +2501,7 @@ void LLView::setupParams(LLView::Params& p, LLView* parent) p.layout = parent->getLayout(); } + if (parent) { LLRect parent_rect = parent->getLocalRect(); @@ -2510,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; @@ -2518,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) { @@ -2536,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(); @@ -2557,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(); |