diff options
| author | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-03-05 15:41:25 +0200 | 
|---|---|---|
| committer | Sergei Litovchuk <slitovchuk@productengine.com> | 2010-03-05 15:41:25 +0200 | 
| commit | a8e1c2ed134b88b55b713ac53cd63cab4bb526b3 (patch) | |
| tree | 7949ef63bb34cf8c09e116269efa73d5d65bbd1a | |
| parent | baafdf216f482535d675eebcf4220510451d7332 (diff) | |
Implemented (EXT-4705) Show maturity icon on Region/Estate tab.
- Added LLIconsComboBox class - a combobox with icons for maturity ratings.
- Fixed scroll list maximum width calculation. The width was calculated based on text value width for non-text columns.
- Added image overlay alignment getter method to LLButton.
--HG--
branch : product-engine
| -rw-r--r-- | indra/llui/llbutton.h | 1 | ||||
| -rw-r--r-- | indra/llui/llcombobox.cpp | 45 | ||||
| -rw-r--r-- | indra/llui/llcombobox.h | 33 | ||||
| -rw-r--r-- | indra/llui/llscrolllistctrl.cpp | 4 | ||||
| -rw-r--r-- | indra/newview/skins/default/xui/en/panel_region_general.xml | 45 | 
5 files changed, 103 insertions, 25 deletions
| diff --git a/indra/llui/llbutton.h b/indra/llui/llbutton.h index 6a0d8ef3d6..59b551a16d 100644 --- a/indra/llui/llbutton.h +++ b/indra/llui/llbutton.h @@ -216,6 +216,7 @@ public:  	void			setImageOverlay(const std::string& image_name, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white);  	void 			setImageOverlay(const LLUUID& image_id, LLFontGL::HAlign alignment = LLFontGL::HCENTER, const LLColor4& color = LLColor4::white);  	LLPointer<LLUIImage> getImageOverlay() { return mImageOverlay; } +	LLFontGL::HAlign getImageOverlayHAlign() const	{ return mImageOverlayAlignment; }  	void            autoResize();	// resize with label of current btn state   	void            resize(LLUIString label); // resize with label input diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index 9d23daf56d..98c9217306 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -703,19 +703,12 @@ void LLComboBox::onListMouseUp()  void LLComboBox::onItemSelected(const LLSD& data)  { -	const std::string name = mList->getSelectedItemLabel(); +	setValue(data); -	S32 cur_id = getCurrentIndex(); -	mLastSelectedIndex = cur_id; -	if (cur_id != -1) +	if (mAllowTextEntry && mLastSelectedIndex != -1)  	{ -		setLabel(name); - -		if (mAllowTextEntry) -		{ -			gFocusMgr.setKeyboardFocus(mTextEntry); -			mTextEntry->selectAll(); -		} +		gFocusMgr.setKeyboardFocus(mTextEntry); +		mTextEntry->selectAll();  	}  	// hiding the list reasserts the old value stored in the text editor/dropdown button @@ -1069,3 +1062,33 @@ BOOL LLComboBox::selectItemRange( S32 first, S32 last )  {  	return mList->selectItemRange(first, last);  } + + +static LLDefaultChildRegistry::Register<LLIconsComboBox> register_icons_combo_box("icons_combo_box"); + +LLIconsComboBox::Params::Params() +:	icon_column("icon_column", ICON_COLUMN), +	label_column("label_column", LABEL_COLUMN) +{} + +LLIconsComboBox::LLIconsComboBox(const LLIconsComboBox::Params& p) +:	LLComboBox(p), +	mIconColumnIndex(p.icon_column), +	mLabelColumnIndex(p.label_column) +{} + +void LLIconsComboBox::setValue(const LLSD& value) +{ +	BOOL found = mList->selectByValue(value); +	if (found) +	{ +		LLScrollListItem* item = mList->getFirstSelected(); +		if (item) +		{ +			mButton->setImageOverlay(mList->getSelectedItemLabel(mIconColumnIndex), mButton->getImageOverlayHAlign()); + +			setLabel(mList->getSelectedItemLabel(mLabelColumnIndex)); +		} +		mLastSelectedIndex = mList->getFirstSelectedIndex(); +	} +} diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 4f27588467..3cc2a8f5d1 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -221,6 +221,7 @@ protected:  	LLPointer<LLUIImage>	mArrowImage;  	LLUIString			mLabel;  	BOOL				mHasAutocompletedText; +	S32                 mLastSelectedIndex;  private:  	BOOL				mAllowTextEntry; @@ -230,6 +231,36 @@ private:  	commit_callback_t	mPrearrangeCallback;  	commit_callback_t	mTextEntryCallback;  	commit_callback_t	mSelectionCallback; -	S32                 mLastSelectedIndex;  }; + +// A combo box with icons for the list of items. +class LLIconsComboBox +:	public LLComboBox +{ +public: +	struct Params +	:	public LLInitParam::Block<Params, LLComboBox::Params> +	{ +		Optional<S32>		icon_column, +							label_column; +		Params(); +	}; + +	/*virtual*/ void setValue(const LLSD& value); + +private: +	enum EColumnIndex +	{ +		ICON_COLUMN = 0, +		LABEL_COLUMN +	}; + +	friend class LLUICtrlFactory; +	LLIconsComboBox(const Params&); +	virtual ~LLIconsComboBox() {}; + +	S32			mIconColumnIndex; +	S32			mLabelColumnIndex; +}; +  #endif diff --git a/indra/llui/llscrolllistctrl.cpp b/indra/llui/llscrolllistctrl.cpp index 77caaaa425..18ec5b51dd 100644 --- a/indra/llui/llscrolllistctrl.cpp +++ b/indra/llui/llscrolllistctrl.cpp @@ -630,7 +630,9 @@ void LLScrollListCtrl::calcColumnWidths()  			LLScrollListCell* cellp = (*iter)->getColumn(column->mIndex);  			if (!cellp) continue; -			column->mMaxContentWidth = llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth); +			// get text value width only for text cells +			column->mMaxContentWidth = cellp->isText() ? +					llmax(LLFontGL::getFontSansSerifSmall()->getWidth(cellp->getValue().asString()) + mColumnPadding + COLUMN_TEXT_PADDING, column->mMaxContentWidth) : column->mMaxContentWidth;  		}  		max_item_width += column->mMaxContentWidth; diff --git a/indra/newview/skins/default/xui/en/panel_region_general.xml b/indra/newview/skins/default/xui/en/panel_region_general.xml index 1bbe9d80c0..4acfa42c23 100644 --- a/indra/newview/skins/default/xui/en/panel_region_general.xml +++ b/indra/newview/skins/default/xui/en/panel_region_general.xml @@ -171,27 +171,48 @@       width="100">          Rating:      </text> -    <combo_box +    <icons_combo_box +     follows="left|top"       height="20"       label="Moderate"       layout="topleft"       left_delta="100"       name="access_combo"       top_delta="0" -     width="85"> -        <combo_box.item +     width="105"> +        <icons_combo_box.drop_down_button +         image_overlay="Parcel_M_Light" +         image_overlay_alignment="left" +         imgoverlay_label_space="3" +         pad_left="3"/> +        <icons_combo_box.item           label="Adult" -         name="Adult" -         value="42" /> -        <combo_box.item +         value="42"> +            <item.columns +             halign="center" +             type="icon" +             value="Parcel_R_Light" +             width="20"/> +          </icons_combo_box.item> +        <icons_combo_box.item           label="Moderate" -         name="Mature" -         value="21" /> -        <combo_box.item +         value="21"> +            <item.columns +             halign="center" +             type="icon" +             value="Parcel_M_Light" +             width="20"/> +        </icons_combo_box.item> +        <icons_combo_box.item           label="General" -         name="PG" -         value="13" /> -    </combo_box> +         value="13"> +            <item.columns +             halign="center" +             type="icon" +             value="Parcel_PG_Light" +             width="20"/> +        </icons_combo_box.item> +    </icons_combo_box>      <button       enabled="false"       follows="left|top" | 
