diff options
author | Mike Antipov <mantipov@productengine.com> | 2010-06-24 13:16:35 +0300 |
---|---|---|
committer | Mike Antipov <mantipov@productengine.com> | 2010-06-24 13:16:35 +0300 |
commit | c99bfaf6ed7bf280a3355c10630a66f5c5affbc1 (patch) | |
tree | bfc514fbf84c10f2001861e450210ef8215e3bbf | |
parent | a3d8f6ee4549d301fab51a08fbac7a9f48e22be2 (diff) |
EXT-7961 FIXED Added possibility to show label on the back button in Edit Wearables panel.
Implemented behavior:
* Normally Back button appears narrow without label
* When wearable is changed - "Save" label is set and button gets wide. Left Border of Title is moved to the right.
Note: "Save" label is shown without truncation in all languages, Title can be truncated with dots.
* When changes are saved/reverted - label is removed, button shrinks, Title left border is moved to the its default place.
* Added consistent tooltip for title (the same as a title).
* Added tooltip for button: "Save changes if necessary and return back"
Details:
* added getter for button's font
* implemented derived from LLButton class for Back button to enable setting necessary label's padding in xml
Reviewed by Neal Orman at https://codereview.productengine.com/secondlife/r/636/
--HG--
branch : product-engine
-rw-r--r-- | indra/llui/llbutton.h | 2 | ||||
-rw-r--r-- | indra/newview/llpaneleditwearable.cpp | 50 | ||||
-rw-r--r-- | indra/newview/llpaneleditwearable.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/textures/textures.xml | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_edit_wearable.xml | 13 |
5 files changed, 66 insertions, 6 deletions
diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index d7ab030a47..f4af19b696 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -230,6 +230,8 @@ public: void setFont(const LLFontGL *font) { mGLFont = ( font ? font : LLFontGL::getFontSansSerif()); } + const LLFontGL* getFont() const { return mGLFont; } + S32 getLastDrawCharsCount() const { return mLastDrawCharsCount; } diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp index ae54909945..5c85ea849e 100644 --- a/indra/newview/llpaneleditwearable.cpp +++ b/indra/newview/llpaneleditwearable.cpp @@ -382,6 +382,31 @@ LLEditWearableDictionary::PickerControlEntry::PickerControlEntry(ETextureIndex t { } +/** + * Class to prevent hack in LLButton's constructor and use paddings declared in xml. + */ +class LLLabledBackButton : public LLButton +{ +public: + struct Params : public LLInitParam::Block<Params, LLButton::Params> + { + Params() {} + }; +protected: + friend class LLUICtrlFactory; + LLLabledBackButton(const Params&); +}; + +static LLDefaultChildRegistry::Register<LLLabledBackButton> labeled_back_btn("labeled_back_button"); + +LLLabledBackButton::LLLabledBackButton(const Params& params) +: LLButton(params) +{ + // override hack in LLButton's constructor to use paddings have been set in xml + setLeftHPad(params.pad_left); + setRightHPad(params.pad_right); +} + // Helper functions. static const texture_vec_t null_texture_vec; @@ -649,6 +674,8 @@ BOOL LLPanelEditWearable::postBuild() mBtnRevert->setClickedCallback(boost::bind(&LLPanelEditWearable::onRevertButtonClicked, this)); mBtnBack = getChild<LLButton>("back_btn"); + mBackBtnLabel = mBtnBack->getLabelUnselected(); + mBtnBack->setLabel(LLStringUtil::null); // handled at appearance panel level? //mBtnBack->setClickedCallback(boost::bind(&LLPanelEditWearable::onBackButtonClicked, this)); @@ -1016,6 +1043,7 @@ void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show) if (show) { mPanelTitle->setText(title); + mPanelTitle->setToolTip(title); mDescTitle->setText(description_title); // set name @@ -1357,6 +1385,28 @@ void LLPanelEditWearable::updateVerbs() gSavedSettings.setU32("AvatarSex", (gAgentAvatarp->getSex() == SEX_MALE) ); } + // update back button and title according to dirty state. + static BOOL was_dirty = FALSE; + if (was_dirty != is_dirty) // to avoid redundant changes because this method is called from draw + { + static S32 label_width = mBtnBack->getFont()->getWidth(mBackBtnLabel); + const std::string& label = is_dirty ? mBackBtnLabel : LLStringUtil::null; + const S32 delta_width = is_dirty ? label_width : -label_width; + + mBtnBack->setLabel(label); + + // update rect according to label width + LLRect rect = mBtnBack->getRect(); + rect.mRight += delta_width; + mBtnBack->setShape(rect); + + // update title rect according to back button width + rect = mPanelTitle->getRect(); + rect.mLeft += delta_width; + mPanelTitle->setShape(rect); + + was_dirty = is_dirty; + } } void LLPanelEditWearable::configureAlphaCheckbox(LLVOAvatarDefines::ETextureIndex te, const std::string& name) diff --git a/indra/newview/llpaneleditwearable.h b/indra/newview/llpaneleditwearable.h index 61441435cd..bfce2ae56e 100644 --- a/indra/newview/llpaneleditwearable.h +++ b/indra/newview/llpaneleditwearable.h @@ -120,6 +120,7 @@ private: // these are constant no matter what wearable we're editing LLButton *mBtnRevert; LLButton *mBtnBack; + std::string mBackBtnLabel; LLTextBox *mPanelTitle; LLTextBox *mDescTitle; diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index cf632c085f..043077db13 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -68,9 +68,9 @@ with the same filename but different name <texture name="BackArrow_Off" file_name="icons/BackArrow_Off.png" preload="false" /> - <texture name="BackButton_Off" file_name="icons/back_arrow_off.png" preload="false" /> - <texture name="BackButton_Over" file_name="icons/back_arrow_over.png" preload="false" /> - <texture name="BackButton_Press" file_name="icons/back_arrow_press.png" preload="false" /> + <texture name="BackButton_Off" file_name="icons/back_arrow_off.png" preload="false" scale.left="22" scale.top="12" scale.right="25" scale.bottom="12" /> + <texture name="BackButton_Over" file_name="icons/back_arrow_over.png" preload="false" scale.left="22" scale.top="12" scale.right="25" scale.bottom="12" /> + <texture name="BackButton_Press" file_name="icons/back_arrow_press.png" preload="false" scale.left="22" scale.top="12" scale.right="25" scale.bottom="12" /> <texture name="Blank" file_name="Blank.png" preload="false" /> diff --git a/indra/newview/skins/default/xui/en/panel_edit_wearable.xml b/indra/newview/skins/default/xui/en/panel_edit_wearable.xml index fc1caca9e9..484617df34 100644 --- a/indra/newview/skins/default/xui/en/panel_edit_wearable.xml +++ b/indra/newview/skins/default/xui/en/panel_edit_wearable.xml @@ -131,19 +131,25 @@ name="tattoo_desc_text"> Tattoo: </string> - <button + <!-- Default width of the button should be to show it without label. + Button will be extedned in code to show whole label when wearable is being changed. + --> + <labeled_back_button follows="top|left" height="24" image_hover_unselected="BackButton_Over" image_pressed="BackButton_Press" image_unselected="BackButton_Off" layout="topleft" + label="Save" left="11" name="back_btn" + pad_left="24" + tool_tip="Return to Edit Outfit" top="3" width="30" /> <text - follows="top|left" + follows="top|left|right" font="SansSerifHugeBold" height="22" layout="topleft" @@ -152,7 +158,8 @@ text_color="white" top="3" value="Editing Shape" - width="270" /> + use_ellipses="true" + width="274" /> <panel background_opaque="true" background_visible="true" |