From 7b64357562ceee47d9910f08f4e4fbc1dc108f91 Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Fri, 18 Jun 2010 12:22:02 +0300
Subject: [PATCH] EXT-7754 FIXED Implemented marking of worn outfit accordion
 header text with bold

- Added method to LLAccordionCtrlTabHeader which allows to change style of its textbox
- Added method to LLOutfitsList which marks accordion header of currently selected otfit and tied it up to BOF callbacks

Reviewed by Vadim Savchuk and Neal Orman at https://codereview.productengine.com/secondlife/r/609/

--HG--
branch : product-engine
---
 indra/llui/llaccordionctrltab.cpp | 27 ++++++++++++++++++++++++++-
 indra/llui/llaccordionctrltab.h   |  4 ++++
 indra/newview/lloutfitslist.cpp   | 24 ++++++++++++++++++++++++
 indra/newview/lloutfitslist.h     |  5 +++++
 4 files changed, 59 insertions(+), 1 deletion(-)

diff --git a/indra/llui/llaccordionctrltab.cpp b/indra/llui/llaccordionctrltab.cpp
index 54bb328a18d..20e4b7867c3 100644
--- a/indra/llui/llaccordionctrltab.cpp
+++ b/indra/llui/llaccordionctrltab.cpp
@@ -76,6 +76,8 @@ class LLAccordionCtrlTab::LLAccordionCtrlTabHeader : public LLUICtrl
 	std::string getTitle();
 	void	setTitle(const std::string& title, const std::string& hl);
 
+	void	setTitleFontStyle(std::string style);
+
 	void	setSelected(bool is_selected) { mIsSelected = is_selected; }
 
 	virtual void onMouseEnter(S32 x, S32 y, MASK mask);
@@ -102,6 +104,9 @@ class LLAccordionCtrlTab::LLAccordionCtrlTabHeader : public LLUICtrl
 	LLPointer<LLUIImage> mImageHeaderPressed;
 	LLPointer<LLUIImage> mImageHeaderFocused;
 
+	// style saved when applying it in setTitleFontStyle
+	LLStyle::Params			mStyleParams;
+
 	LLUIColor mHeaderBGColor;
 
 	bool mNeedsHighlight;
@@ -170,12 +175,23 @@ void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitle(const std::string& t
 	{
 		LLTextUtil::textboxSetHighlightedVal(
 			mHeaderTextbox,
-			LLStyle::Params(),
+			mStyleParams,
 			title,
 			hl);
 	}
 }
 
+void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::setTitleFontStyle(std::string style)
+{
+	if (mHeaderTextbox)
+	{
+		std::string text = mHeaderTextbox->getText();
+		mStyleParams.font(mHeaderTextbox->getDefaultFont());
+		mStyleParams.font.style(style);
+		mHeaderTextbox->setText(text, mStyleParams);
+	}
+}
+
 void LLAccordionCtrlTab::LLAccordionCtrlTabHeader::draw()
 {
 	S32 width = getRect().getWidth();
@@ -495,6 +511,15 @@ void LLAccordionCtrlTab::setTitle(const std::string& title, const std::string& h
 	}
 }
 
+void LLAccordionCtrlTab::setTitleFontStyle(std::string style)
+{
+	LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME);
+	if (header)
+	{
+		header->setTitleFontStyle(style);
+	}
+}
+
 boost::signals2::connection LLAccordionCtrlTab::setFocusReceivedCallback(const focus_signal_t::slot_type& cb)
 {
 	LLAccordionCtrlTabHeader* header = findChild<LLAccordionCtrlTabHeader>(DD_HEADER_NAME);
diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h
index 7bf7eeef8fe..e17ecc53198 100644
--- a/indra/llui/llaccordionctrltab.h
+++ b/indra/llui/llaccordionctrltab.h
@@ -37,6 +37,7 @@
 #include "llrect.h"
 #include "lluictrl.h"
 #include "lluicolor.h"
+#include "llstyle.h"
 
 class LLUICtrlFactory;
 class LLUIImage;
@@ -120,6 +121,9 @@ class LLAccordionCtrlTab : public LLUICtrl
 	// Set text and highlight substring in LLAccordionCtrlTabHeader
 	void setTitle(const std::string& title, const std::string& hl = LLStringUtil::null);
 
+	// Set text font style in LLAccordionCtrlTabHeader
+	void setTitleFontStyle(std::string style);
+
 	boost::signals2::connection setFocusReceivedCallback(const focus_signal_t::slot_type& cb);
 	boost::signals2::connection setFocusLostCallback(const focus_signal_t::slot_type& cb);
 
diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp
index e4079c709a6..8dd849f9475 100644
--- a/indra/newview/lloutfitslist.cpp
+++ b/indra/newview/lloutfitslist.cpp
@@ -44,6 +44,7 @@
 #include "llinventorymodel.h"
 #include "lllistcontextmenu.h"
 #include "llnotificationsutil.h"
+#include "lloutfitobserver.h"
 #include "llsidetray.h"
 #include "lltransutil.h"
 #include "llviewermenu.h"
@@ -212,12 +213,16 @@ void LLOutfitsList::onOpen(const LLSD& /*info*/)
 		// Start observing changes in Current Outfit category.
 		mCategoriesObserver->addCategory(cof, boost::bind(&LLOutfitsList::onCOFChanged, this));
 
+		LLOutfitObserver::instance().addBOFChangedCallback(boost::bind(&LLOutfitsList::highlightBaseOutfit, this));
+		LLOutfitObserver::instance().addBOFReplacedCallback(boost::bind(&LLOutfitsList::highlightBaseOutfit, this));
+
 		// Fetch "My Outfits" contents and refresh the list to display
 		// initially fetched items. If not all items are fetched now
 		// the observer will refresh the list as soon as the new items
 		// arrive.
 		category->fetch();
 		refreshList(outfits);
+		highlightBaseOutfit();
 
 		mIsInitialized = true;
 	}
@@ -350,6 +355,25 @@ void LLOutfitsList::refreshList(const LLUUID& category_id)
 	mAccordion->sort();
 }
 
+void LLOutfitsList::highlightBaseOutfit()
+{
+	// id of base outfit
+	LLUUID base_id = LLAppearanceMgr::getInstance()->getBaseOutfitUUID();
+	if (base_id != mHighlightedOutfitUUID)
+	{
+		if (mOutfitsMap[mHighlightedOutfitUUID])
+		{
+			mOutfitsMap[mHighlightedOutfitUUID]->setTitleFontStyle("NORMAL");
+		}
+
+		mHighlightedOutfitUUID = base_id;
+	}
+	if (mOutfitsMap[base_id])
+	{
+		mOutfitsMap[base_id]->setTitleFontStyle("BOLD");
+	}
+}
+
 void LLOutfitsList::onSelectionChange(LLUICtrl* ctrl)
 {
 	LLWearableItemsList* list = dynamic_cast<LLWearableItemsList*>(ctrl);
diff --git a/indra/newview/lloutfitslist.h b/indra/newview/lloutfitslist.h
index 33791fbe621..c984389f877 100644
--- a/indra/newview/lloutfitslist.h
+++ b/indra/newview/lloutfitslist.h
@@ -83,6 +83,9 @@ class LLOutfitsList : public LLPanel
 
 	void refreshList(const LLUUID& category_id);
 
+	// highlits currently worn outfit tab text and unhighlights previously worn
+	void highlightBaseOutfit();
+
 	void performAction(std::string action);
 
 	void setFilterSubString(const std::string& string);
@@ -167,6 +170,8 @@ class LLOutfitsList : public LLPanel
 	wearables_lists_map_t			mSelectedListsMap;
 
 	LLUUID							mSelectedOutfitUUID;
+	// id of currently highlited outfit
+	LLUUID							mHighlightedOutfitUUID;
 	selection_change_signal_t		mSelectionChangeSignal;
 
 	std::string 					mFilterSubString;
-- 
GitLab