From f499260782a0c94c4f164a743da9d2690240dad7 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Sat, 6 Mar 2010 01:17:34 +0200
Subject: [PATCH] Implemented (EXT-4715) Add maturity icons to Classifieds -
 create and details.

--HG--
branch : product-engine
---
 indra/llui/llcombobox.cpp                     | 33 +++++++++----
 indra/llui/llcombobox.h                       |  3 +-
 indra/newview/llpanelclassified.cpp           | 10 ++--
 .../default/xui/en/panel_classified_info.xml  | 24 ++++++++--
 .../default/xui/en/panel_edit_classified.xml  | 48 ++++++++++++-------
 5 files changed, 85 insertions(+), 33 deletions(-)

diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp
index 98c92173063..e223e1c0bf1 100644
--- a/indra/llui/llcombobox.cpp
+++ b/indra/llui/llcombobox.cpp
@@ -320,15 +320,19 @@ void LLComboBox::setValue(const LLSD& value)
 		LLScrollListItem* item = mList->getFirstSelected();
 		if (item)
 		{
-			setLabel( mList->getSelectedItemLabel() );
+			setLabel(getSelectedItemLabel());
 		}
 		mLastSelectedIndex = mList->getFirstSelectedIndex();
 	}
+	else
+	{
+		mLastSelectedIndex = -1;
+	}
 }
 
 const std::string LLComboBox::getSimple() const
 {
-	const std::string res = mList->getSelectedItemLabel();
+	const std::string res = getSelectedItemLabel();
 	if (res.empty() && mAllowTextEntry)
 	{
 		return mTextEntry->getText();
@@ -407,7 +411,7 @@ BOOL LLComboBox::remove(S32 index)
 	if (index < mList->getItemCount())
 	{
 		mList->deleteSingleItem(index);
-		setLabel(mList->getSelectedItemLabel());
+		setLabel(getSelectedItemLabel());
 		return TRUE;
 	}
 	return FALSE;
@@ -448,7 +452,7 @@ BOOL LLComboBox::setCurrentByIndex( S32 index )
 	BOOL found = mList->selectNthItem( index );
 	if (found)
 	{
-		setLabel(mList->getSelectedItemLabel());
+		setLabel(getSelectedItemLabel());
 		mLastSelectedIndex = index;
 	}
 	return found;
@@ -905,7 +909,7 @@ void LLComboBox::updateSelection()
 	}
 	else if (mList->selectItemByPrefix(left_wstring, FALSE))
 	{
-		LLWString selected_item = utf8str_to_wstring(mList->getSelectedItemLabel());
+		LLWString selected_item = utf8str_to_wstring(getSelectedItemLabel());
 		LLWString wtext = left_wstring + selected_item.substr(left_wstring.size(), selected_item.size());
 		mTextEntry->setText(wstring_to_utf8str(wtext));
 		mTextEntry->setSelection(left_wstring.size(), mTextEntry->getWText().size());
@@ -1007,7 +1011,7 @@ BOOL LLComboBox::setCurrentByID(const LLUUID& id)
 
 	if (found)
 	{
-		setLabel(mList->getSelectedItemLabel());
+		setLabel(getSelectedItemLabel());
 		mLastSelectedIndex = mList->getFirstSelectedIndex();
 	}
 
@@ -1023,7 +1027,7 @@ BOOL LLComboBox::setSelectedByValue(const LLSD& value, BOOL selected)
 	BOOL found = mList->setSelectedByValue(value, selected);
 	if (found)
 	{
-		setLabel(mList->getSelectedItemLabel());
+		setLabel(getSelectedItemLabel());
 	}
 	return found;
 }
@@ -1085,10 +1089,19 @@ void LLIconsComboBox::setValue(const LLSD& value)
 		LLScrollListItem* item = mList->getFirstSelected();
 		if (item)
 		{
-			mButton->setImageOverlay(mList->getSelectedItemLabel(mIconColumnIndex), mButton->getImageOverlayHAlign());
-
-			setLabel(mList->getSelectedItemLabel(mLabelColumnIndex));
+			setLabel(getSelectedItemLabel());
 		}
 		mLastSelectedIndex = mList->getFirstSelectedIndex();
 	}
+	else
+	{
+		mLastSelectedIndex = -1;
+	}
+}
+
+const std::string LLIconsComboBox::getSelectedItemLabel(S32 column) const
+{
+	mButton->setImageOverlay(LLComboBox::getSelectedItemLabel(mIconColumnIndex), mButton->getImageOverlayHAlign());
+
+	return LLComboBox::getSelectedItemLabel(mLabelColumnIndex);
 }
diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h
index 3cc2a8f5d11..62aab92abc6 100644
--- a/indra/llui/llcombobox.h
+++ b/indra/llui/llcombobox.h
@@ -150,7 +150,7 @@ class LLComboBox
 	// Get name of current item. Returns an empty string if not found.
 	const std::string	getSimple() const;
 	// Get contents of column x of selected row
-	const std::string getSelectedItemLabel(S32 column = 0) const;
+	virtual const std::string getSelectedItemLabel(S32 column = 0) const;
 
 	// Sets the label, which doesn't have to exist in the label.
 	// This is probably a UI abuse.
@@ -247,6 +247,7 @@ class LLIconsComboBox
 	};
 
 	/*virtual*/ void setValue(const LLSD& value);
+	/*virtual*/ const std::string getSelectedItemLabel(S32 column = 0) const;
 
 private:
 	enum EColumnIndex
diff --git a/indra/newview/llpanelclassified.cpp b/indra/newview/llpanelclassified.cpp
index 5c6636676ce..115c7a1aa57 100644
--- a/indra/newview/llpanelclassified.cpp
+++ b/indra/newview/llpanelclassified.cpp
@@ -1325,6 +1325,8 @@ void LLPanelClassifiedInfo::processProperties(void* data, EAvatarProcessorType t
 
 			bool mature = is_cf_mature(c_info->flags);
 			childSetValue("content_type", mature ? mature_str : pg_str);
+			getChild<LLIconCtrl>("content_type_moderate")->setVisible(mature);
+			getChild<LLIconCtrl>("content_type_general")->setVisible(!mature);
 
 			std::string auto_renew_str = is_cf_auto_renew(c_info->flags) ? 
 				getString("auto_renew_on") : getString("auto_renew_off");
@@ -1369,6 +1371,8 @@ void LLPanelClassifiedInfo::resetData()
 	childSetText("auto_renew", LLStringUtil::null);
 	childSetText("creation_date", LLStringUtil::null);
 	childSetText("click_through_text", LLStringUtil::null);
+	getChild<LLIconCtrl>("content_type_moderate")->setVisible(FALSE);
+	getChild<LLIconCtrl>("content_type_general")->setVisible(FALSE);
 }
 
 void LLPanelClassifiedInfo::resetControls()
@@ -1787,7 +1791,7 @@ void LLPanelClassifiedEdit::processProperties(void* data, EAvatarProcessorType t
 			bool mature = is_cf_mature(c_info->flags);
 			bool auto_renew = is_cf_auto_renew(c_info->flags);
 
-			getChild<LLComboBox>("content_type")->setCurrentByIndex(mature ? CB_ITEM_MATURE : CB_ITEM_PG);
+			getChild<LLIconsComboBox>("content_type")->setCurrentByIndex(mature ? CB_ITEM_MATURE : CB_ITEM_PG);
 			childSetValue("auto_renew", auto_renew);
 			childSetValue("price_for_listing", c_info->price_for_listing);
 			childSetEnabled("price_for_listing", isNew());
@@ -1846,7 +1850,7 @@ void LLPanelClassifiedEdit::resetControls()
 	LLPanelClassifiedInfo::resetControls();
 
 	getChild<LLComboBox>("category")->setCurrentByIndex(0);
-	getChild<LLComboBox>("content_type")->setCurrentByIndex(0);
+	getChild<LLIconsComboBox>("content_type")->setCurrentByIndex(0);
 	childSetValue("auto_renew", false);
 	childSetValue("price_for_listing", MINIMUM_PRICE_FOR_LISTING);
 	childSetEnabled("price_for_listing", TRUE);
@@ -1910,7 +1914,7 @@ U8 LLPanelClassifiedEdit::getFlags()
 {
 	bool auto_renew = childGetValue("auto_renew").asBoolean();
 
-	LLComboBox* content_cb = getChild<LLComboBox>("content_type");
+	LLComboBox* content_cb = getChild<LLIconsComboBox>("content_type");
 	bool mature = content_cb->getCurrentIndex() == CB_ITEM_MATURE;
 	
 	return pack_classified_flags_request(auto_renew, false, mature, false);
diff --git a/indra/newview/skins/default/xui/en/panel_classified_info.xml b/indra/newview/skins/default/xui/en/panel_classified_info.xml
index e71498f2f88..e3b331799ca 100644
--- a/indra/newview/skins/default/xui/en/panel_classified_info.xml
+++ b/indra/newview/skins/default/xui/en/panel_classified_info.xml
@@ -156,6 +156,24 @@
          top_pad="10"
          value="Content Type:"
          width="140" />
+        <icon
+         follows="top|left"
+         height="16"
+         image_name="Parcel_M_Light"
+         layout="topleft"
+         left_pad="0"
+         name="content_type_moderate"
+         top_pad="-11"
+         width="18" />
+        <icon
+         follows="top|left"
+         height="16"
+         image_name="Parcel_PG_Light"
+         layout="topleft"
+         left_delta="0"
+         name="content_type_general"
+         top_delta="0"
+         width="18" />
         <text_editor
          allow_scroll="false"
          bg_visible="false"
@@ -163,11 +181,11 @@
          h_pad="0"
          height="18"
          layout="topleft"
-         left_pad="0"
+         left_pad="2"
          name="content_type"
          read_only="true"
-         width="150"
-         top_pad="-10"
+         width="130"
+         top_delta="1"
          v_pad="0"
          value="[content type]" />
         <text
diff --git a/indra/newview/skins/default/xui/en/panel_edit_classified.xml b/indra/newview/skins/default/xui/en/panel_edit_classified.xml
index c1b352031fb..74d63ab3289 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_classified.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_classified.xml
@@ -217,25 +217,41 @@
          top_pad="15"
          value="Content type:"
          width="250" />
-        <combo_box 
-         allow_text_entry="false" 
-         follows="left|top" 
-         height="23" 
+        <icons_combo_box
+         follows="left|top"
+         height="23"
+         label="General Content"
+         layout="topleft"
          left="10"
-         name="content_type" 
+         name="content_type"
          top_pad="5"
          width="156">
-         <combo_item 
-          name="mature_ci" 
-          value="Mature">
-           Moderate Content
-         </combo_item>
-         <combo_item 
-          name="pg_ci" 
-          value="PG">
-           General Content
-         </combo_item>
-        </combo_box>
+            <icons_combo_box.drop_down_button
+             image_overlay="Parcel_PG_Light"
+             image_overlay_alignment="left"
+             imgoverlay_label_space="3"
+             pad_left="3"/>
+            <icons_combo_box.item
+             label="Moderate Content"
+             name="mature_ci"
+             value="Mature">
+                <item.columns
+                 halign="center"
+                 type="icon"
+                 value="Parcel_M_Light"
+                 width="20"/>
+            </icons_combo_box.item>
+            <icons_combo_box.item
+             label="General Content"
+             name="pg_ci"
+             value="PG">
+                <item.columns
+                 halign="center"
+                 type="icon"
+                 value="Parcel_PG_Light"
+                 width="20"/>
+            </icons_combo_box.item>
+        </icons_combo_box>
         <text
          follows="left|top"
          font.style="BOLD"
-- 
GitLab