From 46948d9fcc9149c3c416167f166aff6ce8fa88d5 Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Wed, 23 Dec 2009 20:00:48 +0200
Subject: [PATCH] Work on normal task EXT-3636 (Code Improvements: Voice
 control panels - Make Voice states and fade timeout xml driven) -- made
 Avatar Item Voice States xml driven. Added fake xml panel file with one
 textbox per style.   Style of the appropriate textbox is applied to avatar
 item's name -- It was necessary to change visibility of the
 LLTExtBase::getDefaultStyle() to public.

--HG--
branch : product-engine
---
 indra/llui/lltextbase.h            |  2 +-
 indra/newview/llavatarlistitem.cpp | 65 +++++++++++++++++++++++-------
 indra/newview/llavatarlistitem.h   | 12 +++++-
 indra/newview/llcallfloater.cpp    | 19 ++-------
 4 files changed, 65 insertions(+), 33 deletions(-)

diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index c91578b6377..038b9eaa62b 100644
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -184,6 +184,7 @@ class LLTextBase
 	bool					scrolledToEnd();
 
 	const LLFontGL*			getDefaultFont() const					{ return mDefaultFont; }
+	LLStyle::Params			getDefaultStyle();
 
 public:
 	// Fired when a URL link is clicked
@@ -256,7 +257,6 @@ class LLTextBase
 	LLTextBase(const Params &p);
 	virtual ~LLTextBase();
 	void							initFromParams(const Params& p);
-	LLStyle::Params					getDefaultStyle();
 	virtual void					onValueChange(S32 start, S32 end);
 
 	// draw methods
diff --git a/indra/newview/llavatarlistitem.cpp b/indra/newview/llavatarlistitem.cpp
index c8544bc3fbb..d70e3c61b99 100644
--- a/indra/newview/llavatarlistitem.cpp
+++ b/indra/newview/llavatarlistitem.cpp
@@ -183,28 +183,21 @@ void LLAvatarListItem::setHighlight(const std::string& highlight)
 	setNameInternal(mAvatarName->getText(), mHighlihtSubstring = highlight);
 }
 
-void LLAvatarListItem::setStyle(const LLStyle::Params& new_style)
+void LLAvatarListItem::setStyle(EItemStyle voice_state)
 {
-//	LLTextUtil::textboxSetHighlightedVal(mAvatarName, mAvatarNameStyle = new_style);
+	voice_state_map_t mVoiceStateMap = getItemStylesParams();
 
-	// Active group should be bold.
-	LLFontDescriptor new_desc(mAvatarName->getDefaultFont()->getFontDesc());
-
-	new_desc.setStyle(new_style.font()->getFontDesc().getStyle());
-	// *NOTE dzaporozhan
-	// On Windows LLFontGL::NORMAL will not remove LLFontGL::BOLD if font 
-	// is predefined as bold (SansSerifSmallBold, for example)
-//	new_desc.setStyle(active ? LLFontGL::BOLD : LLFontGL::NORMAL);
-	LLFontGL* new_font = LLFontGL::getFont(new_desc);
-
-//	
-	mAvatarNameStyle.font = new_font;
+	mAvatarNameStyle = mVoiceStateMap[voice_state];
 
 	// *NOTE: You cannot set the style on a text box anymore, you must
 	// rebuild the text.  This will cause problems if the text contains
 	// hyperlinks, as their styles will be wrong.
-	mAvatarName->setText(mAvatarName->getText(), mAvatarNameStyle/* = new_style*/);
+	mAvatarName->setText(mAvatarName->getText(), mAvatarNameStyle);
+
+	// *TODO: move icon colors into colors.xml
+	mAvatarIcon->setColor(voice_state == IS_VOICE_JOINED ? LLColor4::white : LLColor4::smoke);
 }
+
 void LLAvatarListItem::setAvatarId(const LLUUID& id, bool ignore_status_changes)
 {
 	if (mAvatarId.notNull())
@@ -418,3 +411,45 @@ std::string LLAvatarListItem::formatSeconds(U32 secs)
 	args["[COUNT]"] = llformat("%u", count);
 	return getString(fmt, args);
 }
+
+// static
+LLAvatarListItem::voice_state_map_t LLAvatarListItem::getItemStylesParams()
+{
+	static voice_state_map_t item_styles_params_map;
+	if (!item_styles_params_map.empty()) return item_styles_params_map;
+
+	LLPanel::Params params = LLUICtrlFactory::getDefaultParams<LLPanel>();
+	LLPanel* params_panel = LLUICtrlFactory::create<LLPanel>(params);
+
+	BOOL sucsess = LLUICtrlFactory::instance().buildPanel(params_panel, "panel_avatar_list_item_params.xml");
+
+	if (sucsess)
+	{
+
+		item_styles_params_map.insert(
+			std::make_pair(IS_DEFAULT,
+			params_panel->getChild<LLTextBox>("default_style")->getDefaultStyle()));
+
+		item_styles_params_map.insert(
+			std::make_pair(IS_VOICE_INVITED,
+			params_panel->getChild<LLTextBox>("voice_call_invited_style")->getDefaultStyle()));
+
+		item_styles_params_map.insert(
+			std::make_pair(IS_VOICE_JOINED,
+			params_panel->getChild<LLTextBox>("voice_call_joined_style")->getDefaultStyle()));
+
+		item_styles_params_map.insert(
+			std::make_pair(IS_VOICE_LEFT,
+			params_panel->getChild<LLTextBox>("voice_call_left_style")->getDefaultStyle()));
+	}
+	else
+	{
+		item_styles_params_map.insert(std::make_pair(IS_DEFAULT, LLStyle::Params()));
+		item_styles_params_map.insert(std::make_pair(IS_VOICE_INVITED, LLStyle::Params()));
+		item_styles_params_map.insert(std::make_pair(IS_VOICE_JOINED, LLStyle::Params()));
+		item_styles_params_map.insert(std::make_pair(IS_VOICE_LEFT, LLStyle::Params()));
+	}
+	if (params_panel) params_panel->die();
+
+	return item_styles_params_map;
+}
diff --git a/indra/newview/llavatarlistitem.h b/indra/newview/llavatarlistitem.h
index 0e058f75db5..d544ed459e9 100644
--- a/indra/newview/llavatarlistitem.h
+++ b/indra/newview/llavatarlistitem.h
@@ -46,6 +46,13 @@ class LLAvatarIconCtrl;
 class LLAvatarListItem : public LLPanel, public LLFriendObserver
 {
 public:
+	typedef enum e_item_style_type {
+		IS_DEFAULT,
+		IS_VOICE_INVITED,
+		IS_VOICE_JOINED,
+		IS_VOICE_LEFT,
+	} EItemStyle;
+
 	class ContextMenu
 	{
 	public:
@@ -73,7 +80,7 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 	void setOnline(bool online);
 	void setName(const std::string& name);
 	void setHighlight(const std::string& highlight);
-	void setStyle(const LLStyle::Params& new_style);
+	void setStyle(EItemStyle voice_state);
 	void setAvatarId(const LLUUID& id, bool ignore_status_changes = false);
 	void setLastInteractionTime(U32 secs_since);
 	//Show/hide profile/info btn, translating speaker indicator and avatar name coordinates accordingly
@@ -118,6 +125,9 @@ class LLAvatarListItem : public LLPanel, public LLFriendObserver
 
 	std::string formatSeconds(U32 secs);
 
+	typedef std::map<EItemStyle, LLStyle::Params> voice_state_map_t;
+	static voice_state_map_t getItemStylesParams();
+
 	LLAvatarIconCtrl* mAvatarIcon;
 	LLTextBox* mAvatarName;
 	LLTextBox* mLastInteractionTime;
diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp
index a02a30a710d..1c65eaba9c1 100644
--- a/indra/newview/llcallfloater.cpp
+++ b/indra/newview/llcallfloater.cpp
@@ -597,38 +597,25 @@ void LLCallFloater::setState(LLAvatarListItem* item, ESpeakerState state)
 
 	setState(item->getAvatarId(), state);
 
-	LLStyle::Params speaker_style;
-	LLFontDescriptor new_desc(speaker_style.font()->getFontDesc());
-
 	switch (state)
 	{
 	case STATE_INVITED:
-		new_desc.setStyle(LLFontGL::NORMAL);
+		item->setStyle(LLAvatarListItem::IS_VOICE_INVITED);
 		break;
 	case STATE_JOINED:
 		removeVoiceRemoveTimer(item->getAvatarId());
-		new_desc.setStyle(LLFontGL::NORMAL);
+		item->setStyle(LLAvatarListItem::IS_VOICE_JOINED);
 		break;
 	case STATE_LEFT:
 		{
 			setVoiceRemoveTimer(item->getAvatarId());
-			new_desc.setStyle(LLFontGL::ITALIC);
+			item->setStyle(LLAvatarListItem::IS_VOICE_LEFT);
 		}
 		break;
 	default:
 		llwarns << "Unrecognized avatar panel state (" << state << ")" << llendl;
 		break;
 	}
-
-	LLFontGL* new_font = LLFontGL::getFont(new_desc);
-	speaker_style.font = new_font;
-	item->setStyle(speaker_style);
-
-//	if ()
-	{
-		// found speaker is in voice, mark him as online
-		item->setOnline(STATE_JOINED == state);
-	}
 }
 
 void LLCallFloater::setVoiceRemoveTimer(const LLUUID& voice_speaker_id)
-- 
GitLab