From b52d2a2f1b0406becb80862686be7b6f2444006d Mon Sep 17 00:00:00 2001
From: Andrew Dyukov <adyukov@productengine.com>
Date: Wed, 3 Feb 2010 22:16:18 +0200
Subject: [PATCH] Fixed normal bug EXT-4648 (Right segment of Speak button is
 disabled if nearby voice chat is disabled in estate).

- Added methods for separate enabling of left and right parts of speak button and used them instead of simply enabling/disabling LLSpeakButton in bottomtray.

- Made changes to reset() in LLCallFloater to show "no one near..." instead of "loading" in vcp for nearby chat in regions with disabled voice.

--HG--
branch : product-engine
---
 indra/newview/llbottomtray.cpp  | 13 ++++++++++---
 indra/newview/llcallfloater.cpp | 19 +++++++++++++++----
 indra/newview/llcallfloater.h   |  2 +-
 indra/newview/llspeakbutton.cpp | 10 ++++++++++
 indra/newview/llspeakbutton.h   |  4 ++++
 5 files changed, 40 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llbottomtray.cpp b/indra/newview/llbottomtray.cpp
index 0102e9488e..4c8cec3d30 100644
--- a/indra/newview/llbottomtray.cpp
+++ b/indra/newview/llbottomtray.cpp
@@ -280,7 +280,13 @@ void LLBottomTray::onChange(EStatusType status, const std::string &channelURI, b
 		break;
 	}
 
-	mSpeakBtn->setEnabled(enable);
+	// We have to enable/disable right and left parts of speak button separately (EXT-4648)
+	mSpeakBtn->setSpeakBtnEnabled(enable);
+	// skipped to avoid button blinking
+	if (status != STATUS_JOINING && status!= STATUS_LEFT_CHANNEL)
+	{
+		mSpeakBtn->setFlyoutBtnEnabled(LLVoiceClient::voiceEnabled() && gVoiceClient->voiceWorking());
+	}
 }
 
 void LLBottomTray::onMouselookModeOut()
@@ -410,9 +416,10 @@ BOOL LLBottomTray::postBuild()
 	mSpeakPanel = getChild<LLPanel>("speak_panel");
 	mSpeakBtn = getChild<LLSpeakButton>("talk");
 
-	// Speak button should be initially disabled because
+	// Both parts of speak button should be initially disabled because
 	// it takes some time between logging in to world and connecting to voice channel.
-	mSpeakBtn->setEnabled(FALSE);
+	mSpeakBtn->setSpeakBtnEnabled(false);
+	mSpeakBtn->setFlyoutBtnEnabled(false);
 
 	// Localization tool doesn't understand custom buttons like <talk_button>
 	mSpeakBtn->setSpeakToolTip( getString("SpeakBtnToolTip") );
diff --git a/indra/newview/llcallfloater.cpp b/indra/newview/llcallfloater.cpp
index f62fd44bc0..8cb240c7c2 100644
--- a/indra/newview/llcallfloater.cpp
+++ b/indra/newview/llcallfloater.cpp
@@ -52,6 +52,7 @@
 #include "lltransientfloatermgr.h"
 #include "llviewerwindow.h"
 #include "llvoicechannel.h"
+#include "llviewerparcelmgr.h"
 
 static void get_voice_participants_uuids(std::vector<LLUUID>& speakers_uuids);
 void reshape_floater(LLCallFloater* floater, S32 delta_height);
@@ -731,11 +732,11 @@ void LLCallFloater::updateState(const LLVoiceChannel::EState& new_state)
 	}
 	else
 	{
-		reset();
+		reset(new_state);
 	}
 }
 
-void LLCallFloater::reset()
+void LLCallFloater::reset(const LLVoiceChannel::EState& new_state)
 {
 	// lets forget states from the previous session
 	// for timers...
@@ -748,8 +749,18 @@ void LLCallFloater::reset()
 	mParticipants = NULL;
 	mAvatarList->clear();
 
-	// update floater to show Loading while waiting for data.
-	mAvatarList->setNoItemsCommentText(LLTrans::getString("LoadingData"));
+	// "loading" is shown in parcel with disabled voice only when state is "ringing"
+	// to avoid showing it in nearby chat vcp all the time- "no_one_near" is now shown there (EXT-4648)
+	bool show_loading = LLVoiceChannel::STATE_RINGING == new_state;
+	if(!show_loading && !LLViewerParcelMgr::getInstance()->allowAgentVoice() && mVoiceType ==  VC_LOCAL_CHAT)
+	{
+		mAvatarList->setNoItemsCommentText(getString("no_one_near"));
+	}
+	else
+	{
+		// update floater to show Loading while waiting for data.
+		mAvatarList->setNoItemsCommentText(LLTrans::getString("LoadingData"));
+	}
 	mAvatarList->setVisible(TRUE);
 	mNonAvatarCaller->setVisible(FALSE);
 
diff --git a/indra/newview/llcallfloater.h b/indra/newview/llcallfloater.h
index 766191379b..dac4390fa7 100644
--- a/indra/newview/llcallfloater.h
+++ b/indra/newview/llcallfloater.h
@@ -220,7 +220,7 @@ private:
 	 *
 	 * Clears all data from the latest voice session.
 	 */
-	void reset();
+	void reset(const LLVoiceChannel::EState& new_state);
 
 private:
 	speaker_state_map_t mSpeakerStateMap;
diff --git a/indra/newview/llspeakbutton.cpp b/indra/newview/llspeakbutton.cpp
index 8f2c877c7a..c5c311ed33 100644
--- a/indra/newview/llspeakbutton.cpp
+++ b/indra/newview/llspeakbutton.cpp
@@ -66,6 +66,16 @@ void LLSpeakButton::draw()
 	mOutputMonitor->setIsMuted(!voiceenabled);
 	LLUICtrl::draw();
 }
+void LLSpeakButton::setSpeakBtnEnabled(bool enabled)
+{
+	LLButton* speak_btn = getChild<LLButton>("speak_btn");
+	speak_btn->setEnabled(enabled);
+}
+void LLSpeakButton::setFlyoutBtnEnabled(bool enabled)
+{
+	LLButton* show_btn = getChild<LLButton>("speak_flyout_btn");
+	show_btn->setEnabled(enabled);
+}
 
 LLSpeakButton::LLSpeakButton(const Params& p)
 : LLUICtrl(p)
diff --git a/indra/newview/llspeakbutton.h b/indra/newview/llspeakbutton.h
index 6660b50240..85c97f1a2c 100644
--- a/indra/newview/llspeakbutton.h
+++ b/indra/newview/llspeakbutton.h
@@ -61,6 +61,10 @@ public:
 
 	/*virtual*/ ~LLSpeakButton();
 	/*virtual*/ void draw();
+	
+	// methods for enabling/disabling right and left parts of speak button separately(EXT-4648)
+	void setSpeakBtnEnabled(bool enabled);
+	void setFlyoutBtnEnabled(bool enabled);
 
 	// *HACK: Need to put tooltips in a translatable location,
 	// the panel that contains this button.
-- 
GitLab