From f1fd558dddf43277e024cb918c371d94d0764910 Mon Sep 17 00:00:00 2001
From: Paul Guslisty <pguslisty@productengine.com>
Date: Tue, 28 Dec 2010 19:02:49 +0200
Subject: STORM-714 FIXED Webprim's control bar doesn't dissapear after
 switching to mouselook mode

- After switching to the mouse look mode hide control bar immediately, not fading it with timer

- Added signal for switching mouse look mode out just for convenience. It's not used in this fix.
---
 indra/newview/llagent.cpp                  | 31 +++++++++++++++--
 indra/newview/llagent.h                    |  8 +++++
 indra/newview/llpanelprimmediacontrols.cpp | 53 +++++++++++++++++++++---------
 indra/newview/llpanelprimmediacontrols.h   |  8 ++++-
 4 files changed, 82 insertions(+), 18 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index ea3c2eb312..77552663ab 100644
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -218,7 +218,10 @@ LLAgent::LLAgent() :
 	mFirstLogin(FALSE),
 	mGenderChosen(FALSE),
 
-	mAppearanceSerialNum(0)
+	mAppearanceSerialNum(0),
+
+	mMouselookModeInSignal(NULL),
+	mMouselookModeOutSignal(NULL)
 {
 	for (U32 i = 0; i < TOTAL_CONTROLS; i++)
 	{
@@ -269,6 +272,9 @@ LLAgent::~LLAgent()
 {
 	cleanup();
 
+	delete mMouselookModeInSignal;
+	delete mMouselookModeOutSignal;
+
 	// *Note: this is where LLViewerCamera::getInstance() used to be deleted.
 }
 
@@ -1735,6 +1741,11 @@ void LLAgent::endAnimationUpdateUI()
 
 		LLFloaterCamera::onLeavingMouseLook();
 
+		if (mMouselookModeOutSignal)
+		{
+			(*mMouselookModeOutSignal)();
+		}
+
 		// Only pop if we have pushed...
 		if (TRUE == mViewsPushed)
 		{
@@ -1840,6 +1851,11 @@ void LLAgent::endAnimationUpdateUI()
 
 		mViewsPushed = TRUE;
 
+		if (mMouselookModeInSignal)
+		{
+			(*mMouselookModeInSignal)();
+		}
+
 		// hide all floaters except the mini map
 
 #if 0 // Use this once all floaters are registered
@@ -1899,7 +1915,6 @@ void LLAgent::endAnimationUpdateUI()
 				}
 			}
 		}
-
 	}
 	else if (gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
 	{
@@ -1931,6 +1946,18 @@ void LLAgent::endAnimationUpdateUI()
 	gAgentCamera.updateLastCamera();
 }
 
+boost::signals2::connection LLAgent::setMouselookModeInCallback( const camera_signal_t::slot_type& cb )
+{
+	if (!mMouselookModeInSignal) mMouselookModeInSignal = new camera_signal_t();
+	return mMouselookModeInSignal->connect(cb);
+}
+
+boost::signals2::connection LLAgent::setMouselookModeOutCallback( const camera_signal_t::slot_type& cb )
+{
+	if (!mMouselookModeOutSignal) mMouselookModeOutSignal = new camera_signal_t();
+	return mMouselookModeOutSignal->connect(cb);
+}
+
 //-----------------------------------------------------------------------------
 // heardChat()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index aebebad96a..896408c0dd 100644
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -39,6 +39,8 @@
 #include "llvoavatardefines.h"
 #include "llslurl.h"
 
+#include <boost/signals2.hpp>
+
 extern const BOOL 	ANIMATE;
 extern const U8 	AGENT_STATE_TYPING;  // Typing indication
 extern const U8 	AGENT_STATE_EDITING; // Set when agent has objects selected
@@ -410,7 +412,13 @@ public:
 	BOOL			getCustomAnim() const { return mCustomAnim; }
 	void			setCustomAnim(BOOL anim) { mCustomAnim = anim; }
 	
+	typedef boost::signals2::signal<void ()> camera_signal_t;
+	boost::signals2::connection setMouselookModeInCallback( const camera_signal_t::slot_type& cb );
+	boost::signals2::connection setMouselookModeOutCallback( const camera_signal_t::slot_type& cb );
+
 private:
+	camera_signal_t* mMouselookModeInSignal;
+	camera_signal_t* mMouselookModeOutSignal;
 	BOOL            mCustomAnim; 		// Current animation is ANIM_AGENT_CUSTOMIZE ?
 	LLAnimPauseRequest mPauseRequest;
 	BOOL			mViewsPushed; 		// Keep track of whether or not we have pushed views
diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp
index 8ae3553857..82ff6c3487 100644
--- a/indra/newview/llpanelprimmediacontrols.cpp
+++ b/indra/newview/llpanelprimmediacontrols.cpp
@@ -92,7 +92,8 @@ LLPanelPrimMediaControls::LLPanelPrimMediaControls() :
 	mZoomObjectID(LLUUID::null),
 	mZoomObjectFace(0),
 	mVolumeSliderVisible(0),
-	mWindowShade(NULL)
+	mWindowShade(NULL),
+	mHideImmediately(false)
 {
 	mCommitCallbackRegistrar.add("MediaCtrl.Close",		boost::bind(&LLPanelPrimMediaControls::onClickClose, this));
 	mCommitCallbackRegistrar.add("MediaCtrl.Back",		boost::bind(&LLPanelPrimMediaControls::onClickBack, this));
@@ -207,6 +208,8 @@ BOOL LLPanelPrimMediaControls::postBuild()
 		
 	mMediaAddress->setFocusReceivedCallback(boost::bind(&LLPanelPrimMediaControls::onInputURL, _1, this ));
 	
+	gAgent.setMouselookModeInCallback(boost::bind(&LLPanelPrimMediaControls::onMouselookModeIn, this));
+
 	LLWindowShade::Params window_shade_params;
 	window_shade_params.name = "window_shade";
 
@@ -722,26 +725,22 @@ void LLPanelPrimMediaControls::draw()
 	}
 
 	F32 alpha = getDrawContext().mAlpha;
-	if(mFadeTimer.getStarted())
+	if(mHideImmediately)
+	{
+		//hide this panel
+		clearFaceOnFade();
+
+		mHideImmediately = false;
+	}
+	else if(mFadeTimer.getStarted())
 	{
 		F32 time = mFadeTimer.getElapsedTimeF32();
 		alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f);
 
 		if(time >= mControlFadeTime)
 		{
-			if(mClearFaceOnFade)
-			{
-				// Hiding this object makes scroll events go missing after it fades out 
-				// (see DEV-41755 for a full description of the train wreck).
-				// Only hide the controls when we're untargeting.
-				setVisible(FALSE);
-
-				mClearFaceOnFade = false;
-				mVolumeSliderVisible = 0;
-				mTargetImplID = LLUUID::null;
-				mTargetObjectID = LLUUID::null;
-				mTargetObjectFace = 0;
-			}
+			//hide this panel
+			clearFaceOnFade();
 		}
 	}
 	
@@ -1319,6 +1318,30 @@ bool LLPanelPrimMediaControls::shouldVolumeSliderBeVisible()
 	return mVolumeSliderVisible > 0;
 }
 
+
+void LLPanelPrimMediaControls::clearFaceOnFade()
+{
+	if(mClearFaceOnFade)
+	{
+		// Hiding this object makes scroll events go missing after it fades out
+		// (see DEV-41755 for a full description of the train wreck).
+		// Only hide the controls when we're untargeting.
+		setVisible(FALSE);
+
+		mClearFaceOnFade = false;
+		mVolumeSliderVisible = 0;
+		mTargetImplID = LLUUID::null;
+		mTargetObjectID = LLUUID::null;
+		mTargetObjectFace = 0;
+	}
+}
+
+void LLPanelPrimMediaControls::onMouselookModeIn()
+{
+	LLViewerMediaFocus::getInstance()->clearHover();
+	mHideImmediately = true;
+}
+
 void LLPanelPrimMediaControls::showNotification(LLNotificationPtr notify)
 {
 	delete mWindowShade;
diff --git a/indra/newview/llpanelprimmediacontrols.h b/indra/newview/llpanelprimmediacontrols.h
index 0b9664359c..66956181f2 100644
--- a/indra/newview/llpanelprimmediacontrols.h
+++ b/indra/newview/llpanelprimmediacontrols.h
@@ -59,6 +59,7 @@ public:
 	void showNotification(LLNotificationPtr notify);
 	void hideNotification();
 
+
 	enum EZoomLevel
 	{
 		ZOOM_NONE = 0,
@@ -136,7 +137,11 @@ private:
 	LLPluginClassMedia* getTargetMediaPlugin();
 	
 private:
-	
+
+	void clearFaceOnFade();
+
+	void onMouselookModeIn();
+
 	LLView *mMediaRegion;
 	LLUICtrl *mBackCtrl;
 	LLUICtrl *mFwdCtrl;
@@ -185,6 +190,7 @@ private:
 	bool mPauseFadeout;
 	bool mUpdateSlider;
 	bool mClearFaceOnFade;
+	bool mHideImmediately;
 
 	LLMatrix4 mLastCameraMat;
 	EZoomLevel mCurrentZoom;
-- 
cgit v1.2.3