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 /indra/newview/llpaneleditwearable.cpp | |
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
Diffstat (limited to 'indra/newview/llpaneleditwearable.cpp')
-rw-r--r-- | indra/newview/llpaneleditwearable.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
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) |