From f1d834c50d7155102a6482e1c4e4205ddca65be2 Mon Sep 17 00:00:00 2001
From: Yuri Chebotarev <ychebotarev@productengine.com>
Date: Tue, 3 Nov 2009 17:31:26 +0200
Subject: fix for normal task EXT-239 Save chat window state and position
 between sessions

--HG--
branch : product-engine
---
 indra/llui/llfloater.cpp       |  6 ++++++
 indra/llui/llfloater.h         |  3 +++
 indra/llui/llfloaterreg.cpp    |  3 +--
 indra/newview/llnearbychat.cpp | 37 ++++++++++++++++++++++++++++---------
 indra/newview/llnearbychat.h   |  7 +++----
 5 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 8c72b079ee..99aebbcb30 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -772,6 +772,12 @@ LLMultiFloater* LLFloater::getHost()
 	return (LLMultiFloater*)mHostHandle.get(); 
 }
 
+void    LLFloater::applySavedVariables()
+{
+	applyRectControl();
+	applyDockState();
+}
+
 void LLFloater::applyRectControl()
 {
 	if (mRectControl.size() > 1)
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index ef0d06a58e..95c8dd84f6 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -280,6 +280,9 @@ public:
 protected:
 
 	void			setRectControl(const std::string& rectname) { mRectControl = rectname; };
+
+	virtual void    applySavedVariables();
+
 	void			applyRectControl();
 	void			applyDockState();
 	void			storeRectControl();
diff --git a/indra/llui/llfloaterreg.cpp b/indra/llui/llfloaterreg.cpp
index aca4dc56ee..f8e07913fb 100644
--- a/indra/llui/llfloaterreg.cpp
+++ b/indra/llui/llfloaterreg.cpp
@@ -134,8 +134,7 @@ LLFloater* LLFloaterReg::getInstance(const std::string& name, const LLSD& key)
 				// Note: key should eventually be a non optional LLFloater arg; for now, set mKey to be safe
 				res->mKey = key;
 				res->setInstanceName(name);
-				res->applyRectControl(); // Can't apply rect control until setting instance name
-				res->applyDockState();//same...
+				res->applySavedVariables(); // Can't apply rect and dock state until setting instance name
 				if (res->mAutoTile && !res->getHost() && index > 0)
 				{
 					const LLRect& cur_rect = res->getRect();
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index 12638ab855..81d033d7f9 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -97,14 +97,39 @@ BOOL LLNearbyChat::postBuild()
 	if (getDockControl() == NULL)
 	{
 		setDockControl(new LLDockControl(
-				LLBottomTray::getInstance()->getNearbyChatBar(), this,
-				getDockTongue(), LLDockControl::LEFT, boost::bind(&LLNearbyChat::getAllowedRect, this, _1)));
+			LLBottomTray::getInstance()->getNearbyChatBar(), this,
+			getDockTongue(), LLDockControl::LEFT, boost::bind(&LLNearbyChat::getAllowedRect, this, _1)));
 	}
 
 	return true;
 }
 
 
+void    LLNearbyChat::applySavedVariables()
+{
+
+	if (mRectControl.size() > 1)
+	{
+		const LLRect& rect = LLUI::sSettingGroups["floater"]->getRect(mRectControl);
+		reshape(rect.getWidth(), rect.getHeight());
+		setRect(rect);
+	}
+
+
+	if(!LLUI::sSettingGroups["floater"]->controlExists(mDocStateControl))
+	{
+		setDocked(true);
+	}
+	else
+	{
+		if (mDocStateControl.size() > 1)
+		{
+			bool dockState = LLUI::sSettingGroups["floater"]->getBOOL(mDocStateControl);
+			setDocked(dockState);
+		}
+	}
+}
+
 LLColor4 nearbychat_get_text_color(const LLChat& chat)
 {
 	LLColor4 text_color;
@@ -265,11 +290,5 @@ void LLNearbyChat::getAllowedRect(LLRect& rect)
 {
 	rect = gViewerWindow->getWorldViewRect();
 }
-void LLNearbyChat::setVisible	(BOOL visible)
-{
-	LLDockableFloater::setVisible(visible);
-}
-void LLNearbyChat::toggleWindow()
-{
-}
+
 
diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h
index 20cbf7537d..cb4654654a 100644
--- a/indra/newview/llnearbychat.h
+++ b/indra/newview/llnearbychat.h
@@ -52,16 +52,15 @@ public:
 	void	onNearbyChatContextMenuItemClicked(const LLSD& userdata);
 	bool	onNearbyChatCheckContextMenuItem(const LLSD& userdata);
 
-	void	setDocked			(bool docked, bool pop_on_undock);
-	void	toggleWindow		();
+	void	setDocked			(bool docked, bool pop_on_undock = true);
 
 	/*virtual*/ void	onOpen	(const LLSD& key);
 
-	virtual void setVisible		(BOOL visible);
-
 	virtual void setRect		(const LLRect &rect);
 
 private:
+	virtual void    applySavedVariables();
+
 	void	getAllowedRect		(LLRect& rect);
 
 	void	onNearbySpeakers	();
-- 
cgit v1.2.3