From 5c4ae5b11a44ab4711f0148cb721f35be9f18100 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Thu, 23 Feb 2017 17:50:36 -0500
Subject: STORM-2145 Camera Presets -- some initial work

---
 doc/contributions.txt                              |   2 +
 indra/llui/llfloater.cpp                           |  12 +-
 indra/newview/CMakeLists.txt                       |   2 +
 indra/newview/app_settings/settings.xml            |  52 ++++
 indra/newview/llagentcamera.cpp                    |   2 +
 indra/newview/llagentcamera.h                      |   5 +-
 indra/newview/llfloatercamera.cpp                  |  20 ++
 indra/newview/llfloatercamera.h                    |   2 +
 indra/newview/llfloaterdeleteprefpreset.cpp        |  12 +-
 indra/newview/llfloaterpreference.cpp              | 110 +++++++-
 indra/newview/llfloaterpreference.h                |  15 +-
 indra/newview/llpanelpresetscamerapulldown.cpp     | 236 +++++++++++++++++
 indra/newview/llpanelpresetscamerapulldown.h       |  62 +++++
 indra/newview/llpanelpresetspulldown.cpp           |   2 +-
 indra/newview/llpresetsmanager.cpp                 | 291 +++++++++++++++------
 indra/newview/llpresetsmanager.h                   |  19 +-
 indra/newview/llstatusbar.cpp                      |  44 +++-
 indra/newview/llstatusbar.h                        |   6 +-
 .../skins/default/textures/icons/Presets_Icon.png  | Bin 366 -> 0 bytes
 .../default/textures/icons/Presets_Icon_Camera.png | Bin 0 -> 1381 bytes
 .../textures/icons/Presets_Icon_Graphic.png        | Bin 0 -> 366 bytes
 indra/newview/skins/default/textures/textures.xml  |   3 +-
 .../skins/default/xui/en/floater_camera.xml        |  38 ++-
 .../skins/default/xui/en/floater_preferences.xml   |   2 +-
 .../default/xui/en/panel_preferences_graphics1.xml |  16 +-
 .../default/xui/en/panel_preferences_move.xml      | 123 +++++++--
 .../xui/en/panel_presets_camera_pulldown.xml       |  69 +++++
 .../skins/default/xui/en/panel_status_bar.xml      |  14 +-
 28 files changed, 1025 insertions(+), 134 deletions(-)
 create mode 100644 indra/newview/llpanelpresetscamerapulldown.cpp
 create mode 100644 indra/newview/llpanelpresetscamerapulldown.h
 delete mode 100644 indra/newview/skins/default/textures/icons/Presets_Icon.png
 create mode 100644 indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png
 create mode 100644 indra/newview/skins/default/textures/icons/Presets_Icon_Graphic.png
 create mode 100644 indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 521be7b7e2..a84ac7d533 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -751,6 +751,7 @@ Jonathan Yap
 	STORM-2088
 	STORM-2094
 	STORM-2099
+	STORM-2145
 Kadah Coba
 	STORM-1060
     STORM-1843
@@ -1460,6 +1461,7 @@ Whirly Fizzle
 	STORM-1930
 	BUG-6659
 	STORM-2078
+	BUG-17349
 Whoops Babii
 	VWR-631
 	VWR-1640
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 4f664a1ccc..8b0e19e4f6 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -1839,7 +1839,7 @@ void LLFloater::onClickCloseBtn(bool app_quitting)
 // virtual
 void LLFloater::draw()
 {
-	const F32 alpha = getCurrentTransparency();
+	F32 alpha = getCurrentTransparency();
 
 	// draw background
 	if( isBackgroundVisible() )
@@ -1854,6 +1854,16 @@ void LLFloater::draw()
 		LLUIImage* image = NULL;
 		LLColor4 color;
 		LLColor4 overlay_color;
+		std::string help_topic;
+		if (this->findHelpTopic(help_topic))
+		{
+			if("camera_floater" == help_topic)
+			{
+				alpha = llmin(LLCachedControl<F32>(gSavedSettings, "CameraOpacity"),
+                              LLCachedControl<F32>(gSavedSettings, "ActiveFloaterTransparency"));
+			}
+		}
+
 		if (isBackgroundOpaque())
 		{
 			// NOTE: image may not be set
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index d6d7d2c563..395aa785bf 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -460,6 +460,7 @@ set(viewer_SOURCE_FILES
     llpanelplaceprofile.cpp
     llpanelplaces.cpp
     llpanelplacestab.cpp
+    llpanelpresetscamerapulldown.cpp
     llpanelpresetspulldown.cpp
     llpanelprimmediacontrols.cpp
     llpanelprofile.cpp
@@ -1070,6 +1071,7 @@ set(viewer_HEADER_FILES
     llpanelplaceprofile.h
     llpanelplaces.h
     llpanelplacestab.h
+    llpanelpresetscamerapulldown.h
     llpanelpresetspulldown.h
     llpanelprimmediacontrols.h
     llpanelprofile.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 6621b9e269..541a5d070d 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -15975,6 +15975,58 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+  <key>CameraOpacity</key>
+  <map>
+    <key>Comment</key>
+    <string>Opacity of the Camera Controls floater</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>1.0</real>
+  </map>
+  <key>PresetCameraActive</key>
+    <map>
+      <key>Comment</key>
+      <string>Name of currently selected preference</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>String</string>
+      <key>Value</key>
+      <string />
+    </map>
+    <key>CameraOffsetCustom0</key>
+    <map>
+      <key>Comment</key>
+      <string>Customized camera offset from avatar</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3</string>
+      <key>Value</key>
+      <array>
+        <real>-3.0</real>
+        <real>0.0</real>
+        <real>0.75</real>
+      </array>
+    </map>
+    <key>FocusOffsetCustom0</key>
+    <map>
+      <key>Comment</key>
+      <string>Custom focus point offset relative to avatar (x-axis is forward)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3D</string>
+      <key>Value</key>
+      <array>
+        <real>1.0</real>
+        <real>0.0</real>
+        <real>1.0</real>
+      </array>
+    </map>
 </map>
 </llsd>
 
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index e335eabd1a..1b006a2311 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -208,10 +208,12 @@ void LLAgentCamera::init()
 	mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
 	mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
 	mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
+	mCameraOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("CameraOffsetCustom0");
 
 	mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
 	mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
 	mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
+	mFocusOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("FocusOffsetCustom0");
 
 	mCameraCollidePlane.clearVec();
 	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index ab793ff316..29a1891d82 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -56,7 +56,10 @@ enum ECameraPreset
 	CAMERA_PRESET_FRONT_VIEW, 
 
 	/** "Above and to the left, over the shoulder, pulled back a little on the zoom" */
-	CAMERA_PRESET_GROUP_VIEW
+	CAMERA_PRESET_GROUP_VIEW,
+
+	/** Current view when a preset is saved */
+	CAMERA_PRESET_CUSTOM0
 };
 
 //------------------------------------------------------------------------
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 20d650fa37..777963bec5 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -42,6 +42,7 @@
 #include "llslider.h"
 #include "llfirstuse.h"
 #include "llhints.h"
+#include "lltabcontainer.h"
 
 static LLDefaultChildRegistry::Register<LLPanelCameraItem> r("panel_camera_item");
 
@@ -353,6 +354,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val)
 {
 	LLHints::registerHintTarget("view_popup", getHandle());
 	mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
+	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2));
 }
 
 // virtual
@@ -376,6 +378,24 @@ BOOL LLFloaterCamera::postBuild()
 	return LLFloater::postBuild();
 }
 
+void LLFloaterCamera::onViewButtonClick(const LLSD& user_data)
+{
+	// bring up the prefs floater
+	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
+	if (prefsfloater)
+	{
+		// grab the 'view' panel from the preferences floater and
+		// bring it the front!
+		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("move");
+		if (tabcontainer && graphicspanel)
+		{
+			tabcontainer->selectTabPanel(graphicspanel);
+		}
+	}
+}
+
+
 void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel)
 {
 	// copying child list and then iterating over a copy, because list itself
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 4d6d03f22d..3601813bc1 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -91,6 +91,8 @@ private:
 
 	/*virtual*/ BOOL postBuild();
 
+	void onViewButtonClick(const LLSD& user_data);
+
 	ECameraControlMode determineMode();
 
 	/* resets to the previous mode */
diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp
index 7dedbbf984..bd62849b42 100644
--- a/indra/newview/llfloaterdeleteprefpreset.cpp
+++ b/indra/newview/llfloaterdeleteprefpreset.cpp
@@ -60,13 +60,15 @@ void LLFloaterDeletePrefPreset::onOpen(const LLSD& key)
 {
 	mSubdirectory = key.asString();
 	std::string floater_title = getString(std::string("title_") + mSubdirectory);
-
 	setTitle(floater_title);
 
 	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-
 	EDefaultOptions option = DEFAULT_HIDE;
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+	bool action;
+	action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+
+	LLButton* delete_btn = getChild<LLButton>("delete");
+	delete_btn->setEnabled(action);
 }
 
 void LLFloaterDeletePrefPreset::onBtnDelete()
@@ -87,12 +89,10 @@ void LLFloaterDeletePrefPreset::onBtnDelete()
 void LLFloaterDeletePrefPreset::onPresetsListChange()
 {
 	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-	LLButton* delete_btn = getChild<LLButton>("delete");
 
 	EDefaultOptions option = DEFAULT_HIDE;
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 
-	delete_btn->setEnabled(0 != combo->getItemCount());
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterDeletePrefPreset::onBtnCancel()
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 100ee5ab72..6e5a773c33 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -768,7 +768,8 @@ void LLFloaterPreference::onOpen(const LLSD& key)
 	saveSettings();
 
 	// Make sure there is a default preference file
-	LLPresetsManager::getInstance()->createMissingDefault();
+	LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA);
+	LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC);
 
 	bool started = (LLStartUp::getStartupState() == STATE_STARTED);
 
@@ -776,9 +777,23 @@ void LLFloaterPreference::onOpen(const LLSD& key)
 	LLButton* save_btn = findChild<LLButton>("PrefSaveButton");
 	LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton");
 
-	load_btn->setEnabled(started);
-	save_btn->setEnabled(started);
-	delete_btn->setEnabled(started);
+	if (load_btn && save_btn && delete_btn)
+	{
+		load_btn->setEnabled(started);
+		save_btn->setEnabled(started);
+		delete_btn->setEnabled(started);
+	}
+
+	LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
+	LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton");
+	LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton");
+
+	if (load_camera_btn && save_camera_btn && delete_camera_btn)
+	{
+		load_camera_btn->setEnabled(started);
+		save_camera_btn->setEnabled(started);
+		delete_camera_btn->setEnabled(started);
+	}
 }
 
 void LLFloaterPreference::onVertexShaderEnable()
@@ -2128,6 +2143,11 @@ void LLFloaterPreference::changed()
 
 }
 
+void LLFloaterPreference::saveCameraPreset(std::string& preset)
+{
+	mSavedCameraPreset = preset;
+}
+
 void LLFloaterPreference::saveGraphicsPreset(std::string& preset)
 {
 	mSavedGraphicsPreset = preset;
@@ -2474,6 +2494,86 @@ private:
 
 static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
 static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preference_privacy");
+static LLPanelInjector<LLPanelPreferenceView> t_pref_view("panel_preference_view");
+
+BOOL LLPanelPreferenceView::postBuild()
+{
+	setPresetText();
+
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this));
+		presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok
+	}
+
+	return LLPanelPreference::postBuild();
+}
+
+void LLPanelPreferenceView::onPresetsListChangeCamera()
+{
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		presetsMgr->setCameraDirty(false);
+	}
+
+	setPresetText();
+
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance && !gSavedSettings.getString("PresetCameraActive").empty())
+	{
+		instance->saveSettings(); //make cancel work correctly after changing the preset
+	}
+}
+
+void LLPanelPreferenceView::draw()
+{
+	setPresetText();
+	LLPanelPreference::draw();
+}
+
+void LLPanelPreferenceView::setPresetText()
+{
+	LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text");
+
+	std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive");
+
+	if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText())
+	{
+		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+		if (instance)
+		{
+			instance->saveCameraPreset(preset_camera_active);
+		}
+	}
+
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
+		{
+			gSavedSettings.setString("PresetCameraActive", "");
+			preset_camera_active.clear();
+			// This doesn't seem to cause an infinite recursion.  This trigger is needed to cause the pulldown
+			// panel to update.
+			LLPresetsManager::getInstance()->triggerChangeCameraSignal();
+		}
+	}
+
+	if (!preset_camera_active.empty())
+	{
+		if (preset_camera_active == PRESETS_DEFAULT)
+		{
+			preset_camera_active = LLTrans::getString(PRESETS_DEFAULT);
+		}
+		preset_text->setText(preset_camera_active);
+	}
+	else
+	{
+		preset_text->setText(LLTrans::getString("none_paren_cap"));
+	}
+}
 
 BOOL LLPanelPreferenceGraphics::postBuild()
 {
@@ -2497,7 +2597,7 @@ BOOL LLPanelPreferenceGraphics::postBuild()
 
 	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
     presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this));
-    presetsMgr->createMissingDefault(); // a no-op after the first time, but that's ok
+    presetsMgr->createMissingDefault(PRESETS_GRAPHIC); // a no-op after the first time, but that's ok
     
 	return LLPanelPreference::postBuild();
 }
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index fa0c09e97a..ea3a1fc98c 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -174,6 +174,7 @@ public:
 	void buildPopupLists();
 	static void refreshSkin(void* data);
 	void selectPanel(const LLSD& name);
+	void saveCameraPreset(std::string& preset);
 	void saveGraphicsPreset(std::string& preset);
 
 private:
@@ -196,6 +197,7 @@ private:
 	std::string mDirectoryVisibility;
 	
 	LLAvatarData mAvatarProperties;
+	std::string mSavedCameraPreset;
 	std::string mSavedGraphicsPreset;
 	LOG_CLASS(LLFloaterPreference);
 };
@@ -244,6 +246,18 @@ private:
 	LOG_CLASS(LLPanelPreference);
 };
 
+class LLPanelPreferenceView : public LLPanelPreference
+{
+public:
+	BOOL postBuild();
+	void draw();
+	void setPresetText();
+
+private:
+	void onPresetsListChangeCamera();
+	LOG_CLASS(LLPanelPreferenceView);
+};
+
 class LLPanelPreferenceGraphics : public LLPanelPreference
 {
 public:
@@ -261,7 +275,6 @@ protected:
 	bool hasDirtyChilds();
 
 private:
-
 	void onPresetsListChange();
 	LOG_CLASS(LLPanelPreferenceGraphics);
 };
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
new file mode 100644
index 0000000000..2c95c06c31
--- /dev/null
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -0,0 +1,236 @@
+/** 
+ * @file llpanelpresetscamerapulldown.cpp
+ * @brief A panel showing a quick way to pick camera presets
+ *
+ * $LicenseInfo:firstyear=2017&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2017, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llpanelpresetscamerapulldown.h"
+
+#include "llviewercontrol.h"
+#include "llstatusbar.h"
+
+#include "llbutton.h"
+#include "lltabcontainer.h"
+#include "llfloaterreg.h"
+#include "llfloaterpreference.h"
+#include "llpresetsmanager.h"
+#include "llsliderctrl.h"
+#include "llscrolllistctrl.h"
+#include "lltrans.h"
+
+/* static */ const F32 LLPanelPresetsCameraPulldown::sAutoCloseFadeStartTimeSec = 2.0f;
+/* static */ const F32 LLPanelPresetsCameraPulldown::sAutoCloseTotalTimeSec = 3.0f;
+
+///----------------------------------------------------------------------------
+/// Class LLPanelPresetsCameraPulldown
+///----------------------------------------------------------------------------
+
+// Default constructor
+LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown()
+{
+	mHoverTimer.stop();
+
+	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
+	mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
+
+	buildFromFile( "panel_presets_camera_pulldown.xml");
+}
+
+BOOL LLPanelPresetsCameraPulldown::postBuild()
+{
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
+LL_WARNS() << "DBG pulldown" << LL_ENDL;
+		// Make sure there is a default preference file
+		presetsMgr->createMissingDefault(PRESETS_CAMERA);
+		presetsMgr->startWatching(PRESETS_CAMERA);
+	}
+
+	populatePanel();
+
+	return LLPanel::postBuild();
+}
+
+void LLPanelPresetsCameraPulldown::populatePanel()
+{
+	std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
+	LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
+
+	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
+
+	if (scroll && mPresetNames.begin() != mPresetNames.end())
+	{
+		scroll->clearRows();
+
+		std::string active_preset = gSavedSettings.getString("PresetCameraActive");
+		if (active_preset == PRESETS_DEFAULT)
+		{
+			active_preset = LLTrans::getString(PRESETS_DEFAULT);
+		}
+
+		for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it)
+		{
+			const std::string& name = *it;
+            LL_DEBUGS() << "adding '" << name << "'" << LL_ENDL;
+            
+			LLSD row;
+			row["columns"][0]["column"] = "preset_name";
+			row["columns"][0]["value"] = name;
+
+			bool is_selected_preset = false;
+			if (name == active_preset)
+			{
+				row["columns"][1]["column"] = "icon";
+				row["columns"][1]["type"] = "icon";
+				row["columns"][1]["value"] = "Check_Mark";
+
+				is_selected_preset = true;
+			}
+
+			LLScrollListItem* new_item = scroll->addElement(row);
+			new_item->setSelected(is_selected_preset);
+		}
+	}
+}
+
+/*virtual*/
+void LLPanelPresetsCameraPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
+{
+	mHoverTimer.stop();
+	LLPanel::onMouseEnter(x,y,mask);
+}
+
+/*virtual*/
+void LLPanelPresetsCameraPulldown::onTopLost()
+{
+	setVisible(FALSE);
+}
+
+/*virtual*/
+BOOL LLPanelPresetsCameraPulldown::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+    LLPanel::handleMouseDown(x,y,mask);
+    return TRUE;
+}
+
+/*virtual*/
+BOOL LLPanelPresetsCameraPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask)
+{
+    LLPanel::handleRightMouseDown(x, y, mask);
+    return TRUE;
+}
+
+/*virtual*/
+BOOL LLPanelPresetsCameraPulldown::handleDoubleClick(S32 x, S32 y, MASK mask)
+{
+    LLPanel::handleDoubleClick(x, y, mask);
+    return TRUE;
+}
+
+/*virtual*/
+void LLPanelPresetsCameraPulldown::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+	mHoverTimer.start();
+	LLPanel::onMouseLeave(x,y,mask);
+}
+
+/*virtual*/ 
+void LLPanelPresetsCameraPulldown::onVisibilityChange ( BOOL new_visibility )
+{
+	if (new_visibility)	
+	{
+		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
+	}
+	else
+	{
+		mHoverTimer.stop();
+
+	}
+}
+
+void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
+{
+	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
+
+	if (scroll)
+	{
+		LLScrollListItem* item = scroll->getFirstSelected();
+		if (item)
+		{
+			std::string name = item->getColumn(1)->getValue().asString();
+
+            LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL;
+			LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
+
+			setVisible(FALSE);
+		}
+        else
+        {
+            LL_DEBUGS() << "none selected" << LL_ENDL;
+        }
+	}
+    else
+    {
+        LL_DEBUGS() << "no scroll" << LL_ENDL;
+    }
+}
+
+void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data)
+{
+	// close the minicontrol, we're bringing up the big one
+	setVisible(FALSE);
+
+	// bring up the prefs floater
+	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
+	if (prefsfloater)
+	{
+		// grab the 'view' panel from the preferences floater and
+		// bring it the front!
+		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("move");
+		if (tabcontainer && graphicspanel)
+		{
+			tabcontainer->selectTabPanel(graphicspanel);
+		}
+	}
+}
+
+//virtual
+void LLPanelPresetsCameraPulldown::draw()
+{
+	F32 alpha = mHoverTimer.getStarted() 
+		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
+		: 1.0f;
+	LLViewDrawContext context(alpha);
+
+	LLPanel::draw();
+
+	if (alpha == 0.f)
+	{
+		setVisible(FALSE);
+	}
+}
diff --git a/indra/newview/llpanelpresetscamerapulldown.h b/indra/newview/llpanelpresetscamerapulldown.h
new file mode 100644
index 0000000000..12d9bc26ec
--- /dev/null
+++ b/indra/newview/llpanelpresetscamerapulldown.h
@@ -0,0 +1,62 @@
+/** 
+ * @file llpanelpresetscamerapulldown.h
+ * @brief A panel showing a quick way to pick camera presets
+ *
+ * $LicenseInfo:firstyear=2017&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2017, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLPANELPRESETSCAMERAPULLDOWN_H
+#define LL_LLPANELPRESETSCAMERAPULLDOWN_H
+
+#include "linden_common.h"
+
+#include "llpanel.h"
+
+class LLFrameTimer;
+
+class LLPanelPresetsCameraPulldown : public LLPanel
+{
+ public:
+	LLPanelPresetsCameraPulldown();
+	/*virtual*/ void draw();
+	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
+	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
+	/*virtual*/ void onTopLost();
+	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ BOOL postBuild();
+	void populatePanel();
+	
+ private:
+	void onViewButtonClick(const LLSD& user_data);
+	void onRowClick(const LLSD& user_data);
+
+	std::list<std::string> mPresetNames;
+	LLFrameTimer mHoverTimer;
+	static const F32 sAutoCloseFadeStartTimeSec;
+	static const F32 sAutoCloseTotalTimeSec;
+    LOG_CLASS(LLPanelPresetsCameraPulldown);
+};
+
+#endif // LL_LLPANELPRESETSCAMERAPULLDOWN_H
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index 9b4dc5474a..0bbf1781a5 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -63,7 +63,7 @@ BOOL LLPanelPresetsPulldown::postBuild()
 	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
     presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPresetsPulldown::populatePanel, this));
 	// Make sure there is a default preference file
-    presetsMgr->createMissingDefault();
+    presetsMgr->createMissingDefault(PRESETS_GRAPHIC);
 
 	populatePanel();
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 836f63bffa..16721a6efc 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -39,6 +39,7 @@
 #include "llfloaterpreference.h"
 #include "llfloaterreg.h"
 #include "llfeaturemanager.h"
+#include "llagentcamera.h"
 
 LLPresetsManager::LLPresetsManager()
 {
@@ -46,6 +47,12 @@ LLPresetsManager::LLPresetsManager()
 
 LLPresetsManager::~LLPresetsManager()
 {
+	mCameraChangedSignal.disconnect();
+}
+
+void LLPresetsManager::triggerChangeCameraSignal()
+{
+	mPresetListChangeCameraSignal();
 }
 
 void LLPresetsManager::triggerChangeSignal()
@@ -53,15 +60,16 @@ void LLPresetsManager::triggerChangeSignal()
 	mPresetListChangeSignal();
 }
 
-void LLPresetsManager::createMissingDefault()
+void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 {
-	std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_GRAPHIC, PRESETS_DEFAULT + ".xml");
+	std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
+															  subdirectory, PRESETS_DEFAULT + ".xml");
 	if (!gDirUtilp->fileExists(default_file))
 	{
 		LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
 
-		// Write current graphic settings as the default
-        savePreset(PRESETS_GRAPHIC, PRESETS_DEFAULT, true);
+		// Write current settings as the default
+        savePreset(subdirectory, PRESETS_DEFAULT, true);
 	}
     else
     {
@@ -69,6 +77,34 @@ void LLPresetsManager::createMissingDefault()
     }
 }
 
+void LLPresetsManager::startWatching(const std::string& subdirectory)
+{
+	if (PRESETS_CAMERA == subdirectory)
+	{
+		std::vector<std::string> name_list;
+		getControlNames(name_list);
+
+		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+		{
+			std::string ctrl_name = *it;
+LL_WARNS() << "DBG starting watch on " << ctrl_name << LL_ENDL;
+			if (gSavedSettings.controlExists(ctrl_name))
+			{
+				LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
+				if (cntrl_ptr.isNull())
+				{
+					LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
+									<< "'" << LL_ENDL;
+				}
+				else
+				{
+					mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged));
+				}
+			}
+		}
+	}
+}
+
 std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 {
 	std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR);
@@ -134,6 +170,49 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 	presets = mPresetNames;
 }
 
+bool LLPresetsManager::mCameraDirty = false;
+
+void LLPresetsManager::setCameraDirty(bool dirty)
+{
+	mCameraDirty = dirty;
+}
+
+bool LLPresetsManager::isCameraDirty()
+{
+	return mCameraDirty;
+}
+
+void LLPresetsManager::settingChanged()
+{
+LL_WARNS() << "DBG setting changed" << LL_ENDL;
+	setCameraDirty(true);
+}
+
+void LLPresetsManager::getControlNames(std::vector<std::string>& names)
+{
+	names = boost::assign::list_of
+		("CameraOffsetCustom0")
+		("FocusOffsetCustom0")
+		// From panel_preferences_move.xml
+		("CameraAngle")
+		("CameraOffsetScale")
+		("CameraOpacity")
+		("EditCameraMovement")
+		("AppearanceCameraMovement")
+		// From llagentcamera.cpp
+		("RenderFarClip")
+		("CameraOffsetBuild")
+		("CameraPreset")
+		("CameraOffsetRearView")
+		("CameraOffsetFrontView")
+		("CameraOffsetGroupView")
+		("FocusOffsetRearView")
+		("FocusOffsetFrontView")
+		("FocusOffsetGroupView")
+		("CameraOffsetScale")
+		("TrackFocusObject");
+}
+
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
 {
 	if (LLTrans::getString(PRESETS_DEFAULT) == name)
@@ -149,94 +228,110 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
 		if (instance && !createDefault)
 		{
-            gSavedSettings.setString("PresetGraphicActive", name);
+			gSavedSettings.setString("PresetGraphicActive", name);
 			instance->getControlNames(name_list);
-            LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
+			LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
 			name_list.push_back("PresetGraphicActive");
 		}
-        else
+		else
         {
-            LL_WARNS() << "preferences floater instance not found" << LL_ENDL;
-        }
+			LL_WARNS() << "preferences floater instance not found" << LL_ENDL;
+		}
 	}
-    else if(PRESETS_CAMERA == subdirectory)
+	else if(PRESETS_CAMERA == subdirectory)
 	{
-		name_list = boost::assign::list_of
-			("Placeholder");
+		gSavedSettings.setString("PresetGraphicActive", name);
+//		gSavedSettings.setU32("CameraPreset", CAMERA_PRESET_CUSTOM0);
+
+//		gSavedSettings.setVector3d("CameraOffsetCustom0", gAgentCamera.calcCameraPositionTargetGlobal());
+//		gSavedSettings.setVector3d("FocusOffsetCustom0", gAgentCamera.calcFocusPositionTargetGlobal());
+
+		getControlNames(name_list);
+		name_list.push_back("PresetCameraActive");
 	}
-    else
-    {
-        LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
-    }
-    
-    if (name_list.size() > 1 // if the active preset name is the only thing in the list, don't save the list
-        || (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)) // or create a default graphics preset from hw recommended settings 
-    {
-        // make an empty llsd
-        LLSD paramsData(LLSD::emptyMap());
+	else
+	{
+		LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
+	}
+ 
+	// make an empty llsd
+	LLSD paramsData(LLSD::emptyMap());
 
-        if (createDefault)
-        {
-            paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
-            if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
-            {
-                // use the recommended setting as an initial one (MAINT-6435)
-                gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
-            }
-        }
-        else
-        {
-            for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
-            {
-                std::string ctrl_name = *it;
-                LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
-                std::string comment = ctrl->getComment();
-                std::string type = LLControlGroup::typeEnumToString(ctrl->type());
-                LLSD value = ctrl->getValue();
-
-                paramsData[ctrl_name]["Comment"] = comment;
-                paramsData[ctrl_name]["Persist"] = 1;
-                paramsData[ctrl_name]["Type"] = type;
-                paramsData[ctrl_name]["Value"] = value;
-            }
-        }
-
-        std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
-
-        // write to file
-        llofstream presetsXML(pathName.c_str());
-        if (presetsXML.is_open())
-        {
-            
-            LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
-            formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
-            presetsXML.close();
-            saved = true;
+	// Create a default graphics preset from hw recommended settings 
+	if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)
+	{
+		paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
+		if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
+		{
+			// use the recommended setting as an initial one (MAINT-6435)
+			gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
+		}
+	}
+	else
+	{
+		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+		{
+			std::string ctrl_name = *it;
+			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
+			std::string comment = ctrl->getComment();
+			std::string type = LLControlGroup::typeEnumToString(ctrl->type());
+			LLSD value = ctrl->getValue();
+
+			paramsData[ctrl_name]["Comment"] = comment;
+			paramsData[ctrl_name]["Persist"] = 1;
+			paramsData[ctrl_name]["Type"] = type;
+			paramsData[ctrl_name]["Value"] = value;
+		}
+	}
+
+	std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
+
+ // If the active preset name is the only thing in the list, don't save the list
+	if (paramsData.size() > 1)
+	{
+		// write to file
+		llofstream presetsXML(pathName.c_str());
+		if (presetsXML.is_open())
+		{
+			LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
+			formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
+			presetsXML.close();
+			saved = true;
             
-            LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
-
-            if (!createDefault)
-            {
-                gSavedSettings.setString("PresetGraphicActive", name);
-                // signal interested parties
-                triggerChangeSignal();
-            }
-        }
-        else
-        {
-            LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
-        }
-    }
+			LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
+
+			if (subdirectory == PRESETS_GRAPHIC)
+			{
+				gSavedSettings.setString("PresetGraphicActive", name);
+				// signal interested parties
+				triggerChangeSignal();
+			}
+
+			if (subdirectory == PRESETS_CAMERA)
+			{
+				gSavedSettings.setString("PresetCameraActive", name);
+				setCameraDirty(false);
+				// signal interested parties
+				triggerChangeCameraSignal();
+			}
+		}
+		else
+		{
+			LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
+		}
+	}
     else
-    {
-        LL_INFOS() << "No settings found; preferences floater has not yet been created" << LL_ENDL;
-    }
+	{
+		LL_INFOS() << "No settings available to be saved" << LL_ENDL;
+	}
     
 	return saved;
 }
 
-void LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option)
+bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option)
 {
+	bool sts = true;
+
 	combo->clearRows();
 
 	std::string presets_dir = getPresetsDir(subdirectory);
@@ -259,8 +354,10 @@ void LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 		else
 		{
 			combo->setLabel(LLTrans::getString("preset_combo_label"));
+			sts = false;
 		}
 	}
+	return sts;
 }
 
 void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string name)
@@ -279,14 +376,19 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n
 		if(PRESETS_GRAPHIC == subdirectory)
 		{
 			gSavedSettings.setString("PresetGraphicActive", name);
-		}
 
-		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-		if (instance)
+			LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+			if (instance)
+			{
+				instance->refreshEnabledGraphics();
+			}
+			triggerChangeSignal();
+		}
+		if(PRESETS_CAMERA == subdirectory)
 		{
-			instance->refreshEnabledGraphics();
+			gSavedSettings.setString("PresetCameraActive", name);
+			triggerChangeCameraSignal();
 		}
-		triggerChangeSignal();
 	}
     else
     {
@@ -317,17 +419,34 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string
 	}
 
 	// If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded.
-	if (gSavedSettings.getString("PresetGraphicActive") == name)
+	if(PRESETS_GRAPHIC == subdirectory)
 	{
-		gSavedSettings.setString("PresetGraphicActive", "");
+		if (gSavedSettings.getString("PresetGraphicActive") == name)
+		{
+			gSavedSettings.setString("PresetGraphicActive", "");
+		}
+		// signal interested parties
+		triggerChangeSignal();
 	}
 
-	// signal interested parties
-	triggerChangeSignal();
+	if(PRESETS_CAMERA == subdirectory)
+	{
+		if (gSavedSettings.getString("PresetCameraActive") == name)
+		{
+			gSavedSettings.setString("PresetCameraActive", "");
+		}
+		// signal interested parties
+		triggerChangeCameraSignal();
+	}
 
 	return sts;
 }
 
+boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
+{
+	return mPresetListChangeCameraSignal.connect(cb);
+}
+
 boost::signals2::connection LLPresetsManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb)
 {
 	return mPresetListChangeSignal.connect(cb);
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 21f9885f27..71ec4736b2 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -51,16 +51,21 @@ public:
 	typedef std::list<std::string> preset_name_list_t;
 	typedef boost::signals2::signal<void()> preset_list_signal_t;
 
-	void createMissingDefault();
+	void createMissingDefault(const std::string& subdirectory);
+	void startWatching(const std::string& subdirectory);
+	void triggerChangeCameraSignal();
 	void triggerChangeSignal();
 	static std::string getPresetsDir(const std::string& subdirectory);
-	void setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
+	bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
 	void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
 	bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
 	void loadPreset(const std::string& subdirectory, std::string name);
 	bool deletePreset(const std::string& subdirectory, std::string name);
+	bool isCameraDirty();
+	static void setCameraDirty(bool dirty);
 
 	// Emitted when a preset gets loaded, deleted, or saved.
+	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
 	boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
 
 	// Emitted when a preset gets loaded or saved.
@@ -70,10 +75,18 @@ public:
 	LLPresetsManager();
 	~LLPresetsManager();
 
+	preset_list_signal_t mPresetListChangeCameraSignal;
 	preset_list_signal_t mPresetListChangeSignal;
 
   private:
-    LOG_CLASS(LLPresetsManager);
+	LOG_CLASS(LLPresetsManager);
+
+	void getControlNames(std::vector<std::string>& names);
+	static void LLPresetsManager::settingChanged();
+
+	boost::signals2::connection	mCameraChangedSignal;
+
+	static bool	mCameraDirty;
 };
 
 #endif // LL_PRESETSMANAGER_H
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 041eae4b3c..702b9a8484 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -38,6 +38,7 @@
 #include "llfloaterbuycurrency.h"
 #include "llbuycurrencyhtml.h"
 #include "llpanelnearbymedia.h"
+#include "llpanelpresetscamerapulldown.h"
 #include "llpanelpresetspulldown.h"
 #include "llpanelvolumepulldown.h"
 #include "llfloaterregioninfo.h"
@@ -171,8 +172,11 @@ BOOL LLStatusBar::postBuild()
 	
 	mBtnStats = getChildView("stat_btn");
 
-	mIconPresets = getChild<LLIconCtrl>( "presets_icon" );
-	mIconPresets->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
+	mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" );
+	mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this));
+
+	mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" );
+	mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
 
 	mBtnVolume = getChild<LLButton>( "volume_btn" );
 	mBtnVolume->setClickedCallback( onClickVolume, this );
@@ -227,6 +231,11 @@ BOOL LLStatusBar::postBuild()
 	mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
 	addChild(mSGPacketLoss);
 
+	mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown();
+	addChild(mPanelPresetsCameraPulldown);
+	mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+	mPanelPresetsCameraPulldown->setVisible(FALSE);
+
 	mPanelPresetsPulldown = new LLPanelPresetsPulldown();
 	addChild(mPanelPresetsPulldown);
 	mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
@@ -325,7 +334,8 @@ void LLStatusBar::setVisibleForMouselook(bool visible)
 	mSGBandwidth->setVisible(visible);
 	mSGPacketLoss->setVisible(visible);
 	setBackgroundVisible(visible);
-	mIconPresets->setVisible(visible);
+	mIconPresetsCamera->setVisible(visible);
+	mIconPresetsGraphic->setVisible(visible);
 }
 
 void LLStatusBar::debitBalance(S32 debit)
@@ -470,10 +480,34 @@ void LLStatusBar::onClickBuyCurrency()
 	LLFirstUse::receiveLindens(false);
 }
 
+void LLStatusBar::onMouseEnterPresetsCamera()
+{
+	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_camera" );
+	LLRect icon_rect = icon->getRect();
+	LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect();
+	pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
+	     (pulldown_rect.getWidth() - icon_rect.getWidth()),
+			       icon_rect.mBottom,
+			       pulldown_rect.getWidth(),
+			       pulldown_rect.getHeight());
+
+	pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
+	mPanelPresetsCameraPulldown->setShape(pulldown_rect);
+
+	// show the master presets pull-down
+	LLUI::clearPopups();
+	LLUI::addPopup(mPanelPresetsCameraPulldown);
+	mPanelNearByMedia->setVisible(FALSE);
+	mPanelVolumePulldown->setVisible(FALSE);
+	mPanelPresetsPulldown->setVisible(FALSE);
+	mPanelPresetsCameraPulldown->setVisible(TRUE);
+}
+
 void LLStatusBar::onMouseEnterPresets()
 {
 	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon" );
+	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_graphic" );
 	LLRect icon_rect = icon->getRect();
 	LLRect pulldown_rect = mPanelPresetsPulldown->getRect();
 	pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
@@ -512,6 +546,7 @@ void LLStatusBar::onMouseEnterVolume()
 	// show the master volume pull-down
 	LLUI::clearPopups();
 	LLUI::addPopup(mPanelVolumePulldown);
+	mPanelPresetsCameraPulldown->setVisible(FALSE);
 	mPanelPresetsPulldown->setVisible(FALSE);
 	mPanelNearByMedia->setVisible(FALSE);
 	mPanelVolumePulldown->setVisible(TRUE);
@@ -536,6 +571,7 @@ void LLStatusBar::onMouseEnterNearbyMedia()
 	LLUI::clearPopups();
 	LLUI::addPopup(mPanelNearByMedia);
 
+	mPanelPresetsCameraPulldown->setVisible(FALSE);
 	mPanelPresetsPulldown->setVisible(FALSE);
 	mPanelVolumePulldown->setVisible(FALSE);
 	mPanelNearByMedia->setVisible(TRUE);
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index 277f039f20..507afcd147 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -41,6 +41,7 @@ class LLUICtrl;
 class LLUUID;
 class LLFrameTimer;
 class LLStatGraph;
+class LLPanelPresetsCameraPulldown;
 class LLPanelPresetsPulldown;
 class LLPanelVolumePulldown;
 class LLPanelNearByMedia;
@@ -91,6 +92,7 @@ private:
 	void onClickBuyCurrency();
 	void onVolumeChanged(const LLSD& newvalue);
 
+	void onMouseEnterPresetsCamera();
 	void onMouseEnterPresets();
 	void onMouseEnterVolume();
 	void onMouseEnterNearbyMedia();
@@ -106,7 +108,8 @@ private:
 	LLStatGraph *mSGPacketLoss;
 
 	LLView		*mBtnStats;
-	LLIconCtrl	*mIconPresets;
+	LLIconCtrl	*mIconPresetsCamera;
+	LLIconCtrl	*mIconPresetsGraphic;
 	LLButton	*mBtnVolume;
 	LLTextBox	*mBoxBalance;
 	LLButton	*mMediaToggle;
@@ -119,6 +122,7 @@ private:
 	S32				mSquareMetersCommitted;
 	LLFrameTimer*	mBalanceTimer;
 	LLFrameTimer*	mHealthTimer;
+	LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown;
 	LLPanelPresetsPulldown* mPanelPresetsPulldown;
 	LLPanelVolumePulldown* mPanelVolumePulldown;
 	LLPanelNearByMedia*	mPanelNearByMedia;
diff --git a/indra/newview/skins/default/textures/icons/Presets_Icon.png b/indra/newview/skins/default/textures/icons/Presets_Icon.png
deleted file mode 100644
index 5a6628816b..0000000000
Binary files a/indra/newview/skins/default/textures/icons/Presets_Icon.png and /dev/null differ
diff --git a/indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png b/indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png
new file mode 100644
index 0000000000..8cb51cdc8e
Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png differ
diff --git a/indra/newview/skins/default/textures/icons/Presets_Icon_Graphic.png b/indra/newview/skins/default/textures/icons/Presets_Icon_Graphic.png
new file mode 100644
index 0000000000..5a6628816b
Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Presets_Icon_Graphic.png differ
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index f2da22256c..de9ed4d479 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -205,7 +205,8 @@ with the same filename but different name
 
   <texture name="Facebook_Icon" file_name="icons/Facebook.png" preload="false" />
 
-  <texture name="Presets_Icon" file_name="icons/Presets_Icon.png" preload="true" />
+  <texture name="Presets_Icon_Graphic" file_name="icons/Presets_Icon_Graphic.png" preload="true" />
+  <texture name="Presets_Icon_Camera" file_name="icons/Presets_Icon_Camera.png" preload="true" />
 
   <texture name="Favorite_Star_Active" file_name="navbar/Favorite_Star_Active.png" preload="false" />
   <texture name="Favorite_Star_Off" file_name="navbar/Favorite_Star_Off.png" preload="false" />
diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 521389d7b3..4eec922915 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -150,8 +150,26 @@
             left="0"
             mouse_opaque="false"
             name="zoom"
-            top="20"
+            top="0"
             width="226">
+         <slider
+            can_edit_text="true"
+            control_name="CameraAngle"
+            decimal_digits="2"
+            follows="left|top"
+            height="16"
+            top="20"
+            increment="0.025"
+            initial_value="1.57"
+            layout="topleft"
+            label_width="112"
+            label="View angle"
+            left="10"
+            max_val="1.6"
+            min_val="0.17"
+            name="camera_fov"
+            show_text="false"
+            width="200" />
            <joystick_rotate
               follows="top|left"
               height="78"
@@ -162,7 +180,7 @@
               sound_flags="3"
               visible="true"
               tool_tip="Orbit camera around focus"
-              top="20"
+              top_delta="20"
               width="78" />                      
            <button
               follows="top|left"
@@ -174,7 +192,7 @@
               left_pad="14" 
               name="zoom_plus_btn"
               width="18"
-              top="18">
+              top="38">
              <commit_callback
                 function="Zoom.plus" />
              <mouse_held_callback
@@ -219,7 +237,7 @@
          scale_image="false"
          sound_flags="3"
          tool_tip="Move camera up and down, left and right"
-         top="20"
+         top="40"
          width="78"/>
         </panel>
     </panel>
@@ -270,5 +288,17 @@
          tool_tip="Camera modes"
          width="25">
         </button>
+
+	<button
+		name="open_prefs_btn"
+		image_overlay="Icon_Gear_Foreground"
+		tool_tip = "Open view preferences"
+		left_pad="45"
+		height="22"
+		width="28">
+	  <button.commit_callback
+		  function="Presets.GoViewPrefs" />
+	</button>
+
     </panel>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_preferences.xml b/indra/newview/skins/default/xui/en/floater_preferences.xml
index 9a9101e0da..cbaeae5b94 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences.xml
@@ -79,7 +79,7 @@
          help_topic="preferences_chat_tab"
          name="chat" />
         <panel
-		 class="panel_preference"
+		 class="panel_preference_view"
          filename="panel_preferences_move.xml"
          label="Move &amp; View"
          layout="topleft"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
index 32cbbff8b7..f0979915ce 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_graphics1.xml
@@ -266,6 +266,21 @@
        0
   </text>
 
+<text
+type="string"
+length="1"
+follows="left|top"
+height="16"
+layout="topleft"
+left_delta="68"
+name="IndirectMaxComplexityLink"
+mouse_opaque="false"
+top_delta="0"
+width="120">
+[https://community.secondlife.com/t5/Featured-News/Why-are-all-these-people-made-of-colored-jelly/ba-p/3031255 What's this?]
+</text>
+
+
   <check_box
     control_name="WindLightUseAtmosShaders"
     height="16"
@@ -323,7 +338,6 @@
       function="Pref.PrefLoad"
 	  parameter="graphic"/>
   </button>
-         min_val="0.125"
 
   <button
     follows="top|left"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
index 8794e3bf95..e4a5f5e283 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
@@ -2,13 +2,14 @@
 <panel
  border="true"
  follows="left|top|right|bottom"
- height="408"
+ height="418"
  label="Move"
  layout="topleft"
  left="102"
  name="move_panel"
  top="1"
  width="517">
+
   <icon
      follows="left|top"
      height="18"
@@ -19,19 +20,41 @@
      visible="true"
      width="18"
      left="30"
-     top="10"/>
+     top="4"/>
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left="80"
+    top_delta="0"
+    width="100">
+      Preset in use:
+  </text>
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left_delta="100"
+    name="preset_camera_text"
+    width="120">
+      (None)
+  </text>
+
   <slider
    can_edit_text="true"
    control_name="CameraAngle"
    decimal_digits="2"
    follows="left|top"
    height="16"
+   top_pad="5"
    increment="0.025"
    initial_value="1.57"
    layout="topleft"
    label_width="100"
    label="View angle"
-   left_pad="30"
+   left="80"
    max_val="2.97"
    min_val="0.17"
    name="camera_fov"
@@ -62,21 +85,38 @@
   height="10"
   left="80"
   name="heading2"
-  width="270"
+  width="200"
   top_pad="5">
     Automatic position for:
   </text>
+
+  <spinner
+   control_name="CameraOpacity"
+   decimal_digits="1"
+   follows="top|left|right"
+   height="24"
+   max_val="1.0"
+   min_val="0.0"
+   increment="0.1"
+   initial_value="1.0"
+   label="Camera controls opacity:"
+   label_width="180"
+   layout="topleft"
+   top_pad="-10"
+   left_pad="10"
+   width="220" />
+
   <check_box
      control_name="EditCameraMovement"
      height="20"
      follows="left|top"
      label="Build/Edit"
      layout="topleft"
-     left_delta="30"
+     left="100"
      name="edit_camera_movement"
      tool_tip="Use automatic camera positioning when entering and exiting edit mode"
      width="280"
-     top_pad="5" />
+     top_pad="-10" />
   <check_box
    control_name="AppearanceCameraMovement"
    follows="left|top"
@@ -86,16 +126,68 @@
    name="appearance_camera_movement"
    tool_tip="Use automatic camera positioning while in edit mode"
    width="242" />
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Save settings as a preset..."
+    layout="topleft"
+    left="30"
+    name="PrefCameraSaveButton"
+    top_pad="10"
+    width="200">
+    <button.commit_callback
+      function="Pref.PrefSave"
+      parameter="camera" />
+  </button>
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Load preset..."
+    layout="topleft"
+    left_pad="10"
+    name="PrefCameraLoadButton"
+    top_delta="0"
+    width="115">
+    <button.commit_callback
+      function="Pref.PrefLoad"
+	  parameter="camera"/>
+  </button>
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Delete preset..."
+    layout="topleft"
+    left_pad="10"
+    name="PrefCameraDeleteButton"
+    top_delta="0"
+    width="115">
+    <button.commit_callback
+      function="Pref.PrefDelete"
+	  parameter="camera"/>
+  </button>
+
+  <view_border
+    bevel_style="in"
+    follows="left|top|right"
+    height="0"
+    layout="topleft"
+    left="10"
+    top_pad="5"
+    width="500"/>
+
   <icon
-	 follows="left|top"
-	 height="18"
-	 image_name="Move_Walk_Off"
+   follows="left|top"
+   height="18"
+   image_name="Move_Walk_Off"
    layout="topleft"
-	 name="avatar_icon"
-	 mouse_opaque="false"
-	 visible="true"
-	 width="18"
-   top_pad="10"
+   name="avatar_icon"
+   mouse_opaque="false"
+   visible="true"
+   width="18"
+   top_pad="4"
    left="30" />
   <text
    follows="left|top"
@@ -264,10 +356,11 @@
    label="Other Devices"
    left="30"
    name="joystick_setup_button"
-   top="30"
+   top_pad="5"
    width="155">
     <button.commit_callback
      function="Floater.Show"
      parameter="pref_joystick" />
   </button>
+
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml b/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml
new file mode 100644
index 0000000000..dc37270751
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel
+ background_opaque="true"
+ background_visible="true"
+ bg_opaque_image="Volume_Background"
+ bg_alpha_image="Volume_Background"
+ border_visible="false"
+ border="false"
+ chrome="true"
+ follows="bottom"
+ height="155"
+ layout="topleft"
+ name="presets_camera_pulldown"
+ width="225">
+  <text
+    type="string"
+    length="1"
+    follows="left|top"
+    height="12"
+    layout="topleft"
+    top="4"
+    left_delta="5"
+    font.style="BOLD"
+    name="Camera Presets"
+    width="120">
+      Camera Presets
+  </text>
+  <scroll_list
+    follows="left|top"
+    layout="topleft"
+    column_padding="0"
+    height="100"
+    width="215"
+    draw_heading="false"
+    draw_stripes="false"
+    bg_stripe_color="0.25 0.25 0.25 0.25"
+    top_delta="15"
+    left_delta="0"
+    name="preset_camera_list">
+    <scroll_list.columns
+      name="icon"
+      width="16" />
+    <scroll_list.columns
+      relative_width="1"
+      name="preset_name" />
+      <scroll_list.commit_callback
+      function="PresetsCamera.RowClick" />
+  </scroll_list>
+  <view_border
+    bevel_style="none"
+    follows="top|left"
+    height="0"
+    layout="topleft"
+    left="5"
+    name="horiz_separator"
+    top_delta="105"
+    width="215" />
+  <button
+    name="open_prefs_btn"
+    label="Open View Preferences"
+    tool_tip = "Bring up view preferences"
+    top_delta="5"
+    left="15"
+    height="20"
+    width="200">
+    <button.commit_callback
+      function="Presets.GoViewPrefs" />
+  </button>
+</panel>
diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml
index 998f1ce599..c6a42ea612 100644
--- a/indra/newview/skins/default/xui/en/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml
@@ -35,7 +35,7 @@
     </panel.string>
   <panel
     height="18"
-    left="-416"
+    left="-458"
     width="185"
     top="1"
     follows="right|top" 
@@ -108,10 +108,18 @@
     <icon
      follows="right|top"
      height="16"
-     image_name="Presets_Icon"
+     image_name="Presets_Icon_Camera"
      left_pad="8"
      top="2"
-     name="presets_icon"
+     name="presets_icon_camera"
+     width="18" />
+    <icon
+     follows="right|top"
+     height="16"
+     image_name="Presets_Icon_Graphic"
+     left_pad="8"
+     top="2"
+     name="presets_icon_graphic"
      width="18" />
     <button
      follows="right|top"
-- 
cgit v1.2.3


From 83809eb6e40b307ec671ff9662ea891de4d75e33 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Fri, 3 Mar 2017 12:29:14 -0500
Subject: STORM-2145 Attempt to fix Mac build failure

---
 indra/newview/llpresetsmanager.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 71ec4736b2..5819fec0b4 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -82,7 +82,7 @@ public:
 	LOG_CLASS(LLPresetsManager);
 
 	void getControlNames(std::vector<std::string>& names);
-	static void LLPresetsManager::settingChanged();
+	static void settingChanged();
 
 	boost::signals2::connection	mCameraChangedSignal;
 
-- 
cgit v1.2.3


From 32f16633c77564d567ed0752e56eb38abb916ccd Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Thu, 11 Jan 2018 18:35:35 -0500
Subject: STORM-2145 A few small changes

---
 .../default/textures/icons/Presets_Icon_Camera.png | Bin 1381 -> 0 bytes
 indra/newview/skins/default/textures/textures.xml  |   3 +--
 .../skins/default/xui/en/floater_camera.xml        |  29 +++++----------------
 .../skins/default/xui/en/panel_status_bar.xml      |   2 +-
 4 files changed, 9 insertions(+), 25 deletions(-)
 delete mode 100644 indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png

diff --git a/indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png b/indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png
deleted file mode 100644
index 8cb51cdc8e..0000000000
Binary files a/indra/newview/skins/default/textures/icons/Presets_Icon_Camera.png and /dev/null differ
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index de9ed4d479..bc2abd0c02 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -98,7 +98,7 @@ with the same filename but different name
   <texture name="BuyArrow_Over" file_name="navbar/BuyArrow_Over.png" preload="true" scale.left="0" scale.top="1" scale.right="0" scale.bottom="0"  />
   <texture name="BuyArrow_Press" file_name="navbar/BuyArrow_Press.png" preload="true" scale.left="1" scale.top="1" scale.right="0" scale.bottom="0"  />
 
-  <texture name="Cam_Avatar_Off" file_name="bottomtray/Cam_Avatar_Off.png" preload="false" />
+  <texture name="Cam_Avatar_Off" file_name="bottomtray/Cam_Avatar_Off.png" preload="true" />
   <texture name="Cam_FreeCam_Off" file_name="bottomtray/Cam_FreeCam_Off.png" preload="false" />
   <texture name="Cam_Orbit_Off" file_name="bottomtray/Cam_Orbit_Off.png" preload="false" />
   <texture name="Cam_Pan_Off" file_name="bottomtray/Cam_Pan_Off.png" preload="false" />
@@ -206,7 +206,6 @@ with the same filename but different name
   <texture name="Facebook_Icon" file_name="icons/Facebook.png" preload="false" />
 
   <texture name="Presets_Icon_Graphic" file_name="icons/Presets_Icon_Graphic.png" preload="true" />
-  <texture name="Presets_Icon_Camera" file_name="icons/Presets_Icon_Camera.png" preload="true" />
 
   <texture name="Favorite_Star_Active" file_name="navbar/Favorite_Star_Active.png" preload="false" />
   <texture name="Favorite_Star_Off" file_name="navbar/Favorite_Star_Off.png" preload="false" />
diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 4eec922915..fdd27b35c2 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -250,18 +250,15 @@
      name="buttons"
      width="226">
         <button
-         height="23"
-         label=""
+         name="open_prefs_btn"
+         image_overlay="Icon_Gear_Foreground"
+         tool_tip = "Open view preferences"
          layout="topleft"
          left="70"
-         is_toggle="true"
-         image_overlay="Cam_Avatar_Off"
-         image_selected="PushButton_Selected_Press"
-         name="presets_btn"
-         tab_stop="false"
-         tool_tip="Preset Views"
-         top="13" 
-         width="25">
+         height="23"
+         width="28">
+           <button.commit_callback
+             function="Presets.GoViewPrefs" />
         </button>
         <button
          height="23"
@@ -288,17 +285,5 @@
          tool_tip="Camera modes"
          width="25">
         </button>
-
-	<button
-		name="open_prefs_btn"
-		image_overlay="Icon_Gear_Foreground"
-		tool_tip = "Open view preferences"
-		left_pad="45"
-		height="22"
-		width="28">
-	  <button.commit_callback
-		  function="Presets.GoViewPrefs" />
-	</button>
-
     </panel>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml
index c6a42ea612..299f019145 100644
--- a/indra/newview/skins/default/xui/en/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml
@@ -108,7 +108,7 @@
     <icon
      follows="right|top"
      height="16"
-     image_name="Presets_Icon_Camera"
+     image_name="Cam_Avatar_Off"
      left_pad="8"
      top="2"
      name="presets_icon_camera"
-- 
cgit v1.2.3


From 527388694a8bb3f3c3bf1510e1e79562dd426385 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Sat, 13 Jan 2018 12:18:40 -0500
Subject: STORM-2145 Added a small floater

---
 indra/llui/llfloater.cpp                           |   2 +
 indra/newview/CMakeLists.txt                       |   2 +
 indra/newview/app_settings/settings.xml            |  31 -----
 indra/newview/llagentcamera.cpp                    |   2 -
 indra/newview/llfloaterpreference.cpp              |   2 +-
 indra/newview/llfloaterpreferencemoveadvanced.cpp  | 151 +++++++++++++++++++++
 indra/newview/llfloaterpreferencemoveadvanced.h    |  58 ++++++++
 indra/newview/llpanelpresetscamerapulldown.cpp     |   2 +-
 indra/newview/llpresetsmanager.cpp                 |  10 --
 indra/newview/llviewerfloaterreg.cpp               |   2 +
 .../xui/en/floater_preferences_move_advanced.xml   | 140 +++++++++++++++++++
 .../default/xui/en/panel_preferences_move.xml      |  14 ++
 12 files changed, 371 insertions(+), 45 deletions(-)
 create mode 100644 indra/newview/llfloaterpreferencemoveadvanced.cpp
 create mode 100644 indra/newview/llfloaterpreferencemoveadvanced.h
 create mode 100644 indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index e5fe6967d1..663d96bdd4 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -64,6 +64,8 @@
 // use this to control "jumping" behavior when Ctrl-Tabbing
 const S32 TABBED_FLOATER_OFFSET = 0;
 
+extern LLControlGroup gSavedSettings;
+
 namespace LLInitParam
 {
 	void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 658c3c56fc..7de4e85316 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -277,6 +277,7 @@ set(viewer_SOURCE_FILES
     llfloaterperms.cpp
     llfloaterpostprocess.cpp
     llfloaterpreference.cpp
+    llfloaterpreferencemoveadvanced.cpp
     llfloaterpreviewtrash.cpp
     llfloaterproperties.cpp
     llfloaterregiondebugconsole.cpp
@@ -901,6 +902,7 @@ set(viewer_HEADER_FILES
     llfloaterperms.h
     llfloaterpostprocess.h
     llfloaterpreference.h
+    llfloaterpreferencemoveadvanced.h
     llfloaterpreviewtrash.h
     llfloaterproperties.h
     llfloaterregiondebugconsole.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 9b5b614111..bcce87dc13 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -16176,36 +16176,5 @@
       <key>Value</key>
       <string />
     </map>
-    <key>CameraOffsetCustom0</key>
-    <map>
-      <key>Comment</key>
-      <string>Customized camera offset from avatar</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Vector3</string>
-      <key>Value</key>
-      <array>
-        <real>-3.0</real>
-        <real>0.0</real>
-        <real>0.75</real>
-      </array>
-    </map>
-    <key>FocusOffsetCustom0</key>
-    <map>
-      <key>Comment</key>
-      <string>Custom focus point offset relative to avatar (x-axis is forward)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Vector3D</string>
-      <key>Value</key>
-      <array>
-        <real>1.0</real>
-        <real>0.0</real>
-        <real>1.0</real>
-      </array>
-    </map>
 </map>
 </llsd>
-
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index e0ade4d395..5b9f1b9d4f 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -208,12 +208,10 @@ void LLAgentCamera::init()
 	mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
 	mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
 	mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
-	mCameraOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("CameraOffsetCustom0");
 
 	mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
 	mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
 	mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
-	mFocusOffsetInitial[CAMERA_PRESET_CUSTOM0] = gSavedSettings.getControl("FocusOffsetCustom0");
 
 	mCameraCollidePlane.clearVec();
 	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 212cb922f2..872e961a70 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -661,7 +661,7 @@ void LLFloaterPreference::cancel()
 	// hide spellchecker settings folder
 	LLFloaterReg::hideInstance("prefs_spellchecker");
 
-	// hide advancede floater
+	// hide advanced graphics floater
 	LLFloaterReg::hideInstance("prefs_graphics_advanced");
 	
 	// reverts any changes to current skin
diff --git a/indra/newview/llfloaterpreferencemoveadvanced.cpp b/indra/newview/llfloaterpreferencemoveadvanced.cpp
new file mode 100644
index 0000000000..3ff19147b1
--- /dev/null
+++ b/indra/newview/llfloaterpreferencemoveadvanced.cpp
@@ -0,0 +1,151 @@
+/** 
+ * @file llfloaterpreferencemoveadvanced.cpp
+ * @brief floater for adjusting camera position
+ *
+ * $LicenseInfo:firstyear=2018&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2018, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llfloaterpreferencemoveadvanced.h"
+#include "llfloater.h"
+#include "llfloaterreg.h"
+#include "lluictrlfactory.h"
+#include "llspinctrl.h"
+#include "llviewercontrol.h"
+
+
+LLFloaterPreferenceMoveAdvanced::LLFloaterPreferenceMoveAdvanced(const LLSD& key) 
+:	LLFloater(key)
+{
+	mCommitCallbackRegistrar.add("Cancel",	boost::bind(&LLFloaterPreferenceMoveAdvanced::onClickCancel, this));
+	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceMoveAdvanced::onCommitSettings, this));
+	mCommitCallbackRegistrar.add("Ok",	boost::bind(&LLFloaterPreferenceMoveAdvanced::onClickOk, this));
+
+}
+
+LLFloaterPreferenceMoveAdvanced::~LLFloaterPreferenceMoveAdvanced()
+{}
+
+void LLFloaterPreferenceMoveAdvanced::onClickOk()
+{
+	closeFloater();
+}
+
+void LLFloaterPreferenceMoveAdvanced::onClickCancel()
+{
+	gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
+	gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
+
+	updateCameraControl(mCameraSaved);
+	updateFocusControl(mFocusSaved);
+}
+
+BOOL LLFloaterPreferenceMoveAdvanced::postBuild()
+{
+	mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
+	mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
+
+	updateCameraControl(mCameraSaved);
+	updateFocusControl(mFocusSaved);
+
+	return TRUE;
+}
+
+void LLFloaterPreferenceMoveAdvanced::updateCameraControl(LLVector3 vector)
+{
+	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("camera_x");
+	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("camera_y");
+	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("camera_z");
+
+	if (!spinnerx || !spinnery || !spinnerz)
+	{
+		LL_WARNS() << "Could not find all desired UI camera elements"
+			<< LL_ENDL;
+		return;
+	}
+
+	if (!spinnerx->hasFocus())
+	{
+		spinnerx->setValue(vector[VX]);
+	}
+
+	if (!spinnery->hasFocus())
+	{
+		spinnery->setValue(vector[VY]);
+	}
+
+	if (!spinnerz->hasFocus())
+	{
+		spinnerz->setValue(vector[VZ]);
+	}
+}
+
+void LLFloaterPreferenceMoveAdvanced::updateFocusControl(LLVector3d vector3d)
+{
+	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("focus_x");
+	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("focus_y");
+	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("focus_z");
+
+	if (!spinnerx || !spinnery || !spinnerz)
+	{
+		LL_WARNS() << "Could not find all desired UI focus elements"
+			<< LL_ENDL;
+		return;
+	}
+
+	if (!spinnerx->hasFocus())
+	{
+		spinnerx->setValue(vector3d[VX]);
+	}
+
+	if (!spinnery->hasFocus())
+	{
+		spinnery->setValue(vector3d[VY]);
+	}
+
+	if (!spinnerz->hasFocus())
+	{
+		spinnerz->setValue(vector3d[VZ]);
+	}
+}
+
+ void LLFloaterPreferenceMoveAdvanced::draw()
+{
+//	updateControl();
+	LLFloater::draw();
+}
+
+void LLFloaterPreferenceMoveAdvanced::onCommitSettings()
+{
+	LLVector3 vector;
+	LLVector3d vector3d;
+
+	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
+	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
+	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
+	gSavedSettings.setVector3("CameraOffsetRearView", vector);
+
+	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
+	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
+	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
+	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
+}
diff --git a/indra/newview/llfloaterpreferencemoveadvanced.h b/indra/newview/llfloaterpreferencemoveadvanced.h
new file mode 100644
index 0000000000..98648af19e
--- /dev/null
+++ b/indra/newview/llfloaterpreferencemoveadvanced.h
@@ -0,0 +1,58 @@
+/** 
+ * @file llfloaterpreferencemoveadvanced.h
+ * @brief floater for adjusting camera position
+ *
+ * $LicenseInfo:firstyear=2018&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2018, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LLFLOATERPREFERENCEMOVEADVANCED_H
+#define LLFLOATERPREFERENCEMOVEADVANCED_H
+
+#include "llcontrol.h"
+#include "llfloater.h"
+
+class LLFloaterPreferenceMoveAdvanced
+:	public LLFloater
+{
+	friend class LLFloaterReg;
+
+public:
+	LLFloaterPreferenceMoveAdvanced(const LLSD& key);
+	virtual BOOL postBuild();
+	virtual void draw();
+
+	void onCommitSettings();
+	void onClickCancel();
+	void onClickOk();
+	void updateCameraControl(LLVector3 vector);
+	void updateFocusControl(LLVector3d vector3d);
+
+private:
+	virtual ~LLFloaterPreferenceMoveAdvanced();
+
+	LLVector3	mCameraSaved;
+	LLVector3d	mFocusSaved;
+	
+};
+
+#endif //LLFLOATERPREFERENCEMOVEADVANCED_H
+
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index 2c95c06c31..ffdfc445ce 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -64,9 +64,9 @@ BOOL LLPanelPresetsCameraPulldown::postBuild()
 	if (presetsMgr)
 	{
 		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
-LL_WARNS() << "DBG pulldown" << LL_ENDL;
 		// Make sure there is a default preference file
 		presetsMgr->createMissingDefault(PRESETS_CAMERA);
+
 		presetsMgr->startWatching(PRESETS_CAMERA);
 	}
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 80386b61f7..3daa6894f0 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -92,7 +92,6 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
 			std::string ctrl_name = *it;
-LL_WARNS() << "DBG starting watch on " << ctrl_name << LL_ENDL;
 			if (gSavedSettings.controlExists(ctrl_name))
 			{
 				LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
@@ -189,23 +188,18 @@ bool LLPresetsManager::isCameraDirty()
 
 void LLPresetsManager::settingChanged()
 {
-LL_WARNS() << "DBG setting changed" << LL_ENDL;
 	setCameraDirty(true);
 }
 
 void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 {
 	names = boost::assign::list_of
-		("CameraOffsetCustom0")
-		("FocusOffsetCustom0")
 		// From panel_preferences_move.xml
 		("CameraAngle")
 		("CameraOffsetScale")
-		("CameraOpacity")
 		("EditCameraMovement")
 		("AppearanceCameraMovement")
 		// From llagentcamera.cpp
-		("RenderFarClip")
 		("CameraOffsetBuild")
 		("CameraPreset")
 		("CameraOffsetRearView")
@@ -246,10 +240,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	else if(PRESETS_CAMERA == subdirectory)
 	{
 		gSavedSettings.setString("PresetGraphicActive", name);
-//		gSavedSettings.setU32("CameraPreset", CAMERA_PRESET_CUSTOM0);
-
-//		gSavedSettings.setVector3d("CameraOffsetCustom0", gAgentCamera.calcCameraPositionTargetGlobal());
-//		gSavedSettings.setVector3d("FocusOffsetCustom0", gAgentCamera.calcFocusPositionTargetGlobal());
 
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 0ebacddd9b..440bf46b1e 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -104,6 +104,7 @@
 #include "llfloaterperms.h"
 #include "llfloaterpostprocess.h"
 #include "llfloaterpreference.h"
+#include "llfloaterpreferencemoveadvanced.h"
 #include "llfloaterpreviewtrash.h"
 #include "llfloaterproperties.h"
 #include "llfloaterregiondebugconsole.h"
@@ -295,6 +296,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
 	LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>);
+	LLFloaterReg::add("prefs_move_advanced", "floater_preferences_move_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceMoveAdvanced>);
 	LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
 	LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>);
 	LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml
new file mode 100644
index 0000000000..28e5d2c607
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ height="170"
+ layout="topleft"
+ name="floaterpreferencesmoveadvanced"
+ help_topic="floatermoveadvanced"
+ title="ADJUST CAMERA VIEW"
+ save_rect="true"
+ width="280">
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left="10"
+    top="10"
+    width="100">
+      Camera offset:
+  </text>
+
+  <spinner
+   height="20"
+   label="X"
+   label_width="12"
+   follows="topl|eft"
+   left="10"
+   name="camera_x"
+   top_pad="5"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Y"
+   label_width="12"
+   follows="topl|eft"
+   name="camera_y"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Z"
+   label_width="12"
+   follows="topl|eft"
+   name="camera_z"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left="10"
+    top_pad="20"
+    width="100">
+      Focus offset:
+  </text>
+
+  <spinner
+   height="20"
+   label="X"
+   label_width="12"
+   follows="topl|eft"
+   left="10"
+   name="focus_x"
+   top_pad="5"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Y"
+   label_width="12"
+   follows="topl|eft"
+   name="focus_y"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Z"
+   label_width="12"
+   follows="topl|eft"
+   name="focus_z"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <button
+   follows="left|top"
+   height="23"
+   label="OK"
+   layout="topleft"
+   left="90"
+   name="ok"
+   top_pad="30"
+   width="90">
+    <button.commit_callback
+     function="Ok"/>
+  </button>
+  <button
+   follows="left|top"
+   height="23"
+   label="Cancel"
+   layout="topleft"
+   left_pad="5"
+   name="cancel"
+   width="90">
+    <button.commit_callback
+     function="Cancel"/>
+  </button>
+</floater>
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
index e4a5f5e283..d832dac4ff 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
@@ -127,6 +127,20 @@
    tool_tip="Use automatic camera positioning while in edit mode"
    width="242" />
 
+  <button
+    follows="top|left"
+    height="23"
+    label="Advanced..."
+    layout="topleft"
+    left_pad="-102"
+    name="PreferencesMoveAdvanced"
+    tool_tip="Adjust camera positioning"
+    width="115">
+    <button.commit_callback
+     function="Floater.Show"
+     parameter="prefs_move_advanced" />
+  </button>  
+
   <button
     follows="top|left"
     height="23"
-- 
cgit v1.2.3


From fc29786cb24dd54530169d82a19dbf54ca4fdb31 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Sun, 14 Jan 2018 19:14:46 -0500
Subject: STORM-2145 Added copying of initial preset files

---
 indra/newview/app_settings/Camera/Front.xml        | 20 +++++++++++++
 indra/newview/app_settings/Camera/Pennys Gamer.xml | 20 +++++++++++++
 indra/newview/app_settings/Camera/Rear.xml         | 20 +++++++++++++
 indra/newview/app_settings/Camera/Side.xml         | 20 +++++++++++++
 indra/newview/llpresetsmanager.cpp                 | 33 +++++++++++++++++-----
 5 files changed, 106 insertions(+), 7 deletions(-)
 create mode 100644 indra/newview/app_settings/Camera/Front.xml
 create mode 100644 indra/newview/app_settings/Camera/Pennys Gamer.xml
 create mode 100644 indra/newview/app_settings/Camera/Rear.xml
 create mode 100644 indra/newview/app_settings/Camera/Side.xml

diff --git a/indra/newview/app_settings/Camera/Front.xml b/indra/newview/app_settings/Camera/Front.xml
new file mode 100644
index 0000000000..6f2ea9da17
--- /dev/null
+++ b/indra/newview/app_settings/Camera/Front.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="llsd.xsd">
+
+    <key>FocusOffsetRearView</key>
+    <map>
+      <key>Comment</key>
+      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3D</string>
+      <key>Value</key>
+      <array>
+        <real>1.0</real>
+        <real>0.0</real>
+        <real>1.0</real>
+      </array>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/Camera/Pennys Gamer.xml b/indra/newview/app_settings/Camera/Pennys Gamer.xml
new file mode 100644
index 0000000000..6f2ea9da17
--- /dev/null
+++ b/indra/newview/app_settings/Camera/Pennys Gamer.xml	
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="llsd.xsd">
+
+    <key>FocusOffsetRearView</key>
+    <map>
+      <key>Comment</key>
+      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3D</string>
+      <key>Value</key>
+      <array>
+        <real>1.0</real>
+        <real>0.0</real>
+        <real>1.0</real>
+      </array>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/Camera/Rear.xml b/indra/newview/app_settings/Camera/Rear.xml
new file mode 100644
index 0000000000..6f2ea9da17
--- /dev/null
+++ b/indra/newview/app_settings/Camera/Rear.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="llsd.xsd">
+
+    <key>FocusOffsetRearView</key>
+    <map>
+      <key>Comment</key>
+      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3D</string>
+      <key>Value</key>
+      <array>
+        <real>1.0</real>
+        <real>0.0</real>
+        <real>1.0</real>
+      </array>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/Camera/Side.xml b/indra/newview/app_settings/Camera/Side.xml
new file mode 100644
index 0000000000..6f2ea9da17
--- /dev/null
+++ b/indra/newview/app_settings/Camera/Side.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="llsd.xsd">
+
+    <key>FocusOffsetRearView</key>
+    <map>
+      <key>Comment</key>
+      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3D</string>
+      <key>Value</key>
+      <array>
+        <real>1.0</real>
+        <real>0.0</real>
+        <real>1.0</real>
+      </array>
+    </map>
+</llsd>
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 3daa6894f0..d4535c69c8 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -40,6 +40,7 @@
 #include "llfloaterreg.h"
 #include "llfeaturemanager.h"
 #include "llagentcamera.h"
+#include "llfile.h"
 
 LLPresetsManager::LLPresetsManager()
 {
@@ -112,20 +113,38 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
 std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 {
 	std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR);
-	std::string full_path;
 
 	if (!gDirUtilp->fileExists(presets_path))
 	{
 		LLFile::mkdir(presets_path);
 	}
 
-	full_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory);
-	if (!gDirUtilp->fileExists(full_path))
+	std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory);
+	if (!gDirUtilp->fileExists(dest_path))
 	{
-		LLFile::mkdir(full_path);
+		LLFile::mkdir(dest_path);
+
+		if (PRESETS_CAMERA == subdirectory)
+		{
+			std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "Camera");
+			LLDirIterator dir_iter(source_dir, "*.xml");
+			bool found = true;
+			while (found)
+			{
+				std::string file;
+				found = dir_iter.next(file);
+
+				if (found)
+				{
+					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "Camera", file);
+					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, "Camera", file);
+					LLFile::copy(source, dest);
+				}
+			}
+		}
 	}
 
-	return full_path;
+	return dest_path;
 }
 
 void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option)
@@ -234,7 +253,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		}
 		else
         {
-			LL_WARNS() << "preferences floater instance not found" << LL_ENDL;
+			LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL;
 		}
 	}
 	else if(PRESETS_CAMERA == subdirectory)
@@ -387,7 +406,7 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n
 	}
     else
     {
-        LL_WARNS() << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
+        LL_WARNS("Presets") << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
     }
 }
 
-- 
cgit v1.2.3


From 3afaa799628c74abdd1542514bc3852432c3925b Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Mon, 15 Jan 2018 11:40:32 -0500
Subject: STORM-2145 Fixed bug.  Now you can only have one of the
 load/save/delete floaters open at once.

---
 indra/newview/CMakeLists.txt                       |   4 +-
 indra/newview/llfloaterloadprefpreset.cpp          |   3 +-
 indra/newview/llfloaterpreference.cpp              |  10 +-
 indra/newview/llfloaterpreferencemoveadvanced.cpp  | 151 ---------------------
 indra/newview/llfloaterpreferencemoveadvanced.h    |  58 --------
 indra/newview/llfloaterpreferenceviewadvanced.cpp  | 151 +++++++++++++++++++++
 indra/newview/llfloaterpreferenceviewadvanced.h    |  58 ++++++++
 indra/newview/llfloatersaveprefpreset.cpp          |   3 +-
 indra/newview/llviewerfloaterreg.cpp               |   4 +-
 .../default/xui/en/floater_delete_pref_preset.xml  |   2 +-
 .../default/xui/en/floater_load_pref_preset.xml    |   2 +-
 .../xui/en/floater_preferences_move_advanced.xml   | 140 -------------------
 .../xui/en/floater_preferences_view_advanced.xml   | 140 +++++++++++++++++++
 .../default/xui/en/floater_save_pref_preset.xml    |   2 +-
 .../default/xui/en/panel_preferences_move.xml      |   2 +-
 15 files changed, 369 insertions(+), 361 deletions(-)
 delete mode 100644 indra/newview/llfloaterpreferencemoveadvanced.cpp
 delete mode 100644 indra/newview/llfloaterpreferencemoveadvanced.h
 create mode 100644 indra/newview/llfloaterpreferenceviewadvanced.cpp
 create mode 100644 indra/newview/llfloaterpreferenceviewadvanced.h
 delete mode 100644 indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml
 create mode 100644 indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 7de4e85316..291f32e8b0 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -277,7 +277,7 @@ set(viewer_SOURCE_FILES
     llfloaterperms.cpp
     llfloaterpostprocess.cpp
     llfloaterpreference.cpp
-    llfloaterpreferencemoveadvanced.cpp
+    llfloaterpreferenceviewadvanced.cpp
     llfloaterpreviewtrash.cpp
     llfloaterproperties.cpp
     llfloaterregiondebugconsole.cpp
@@ -902,7 +902,7 @@ set(viewer_HEADER_FILES
     llfloaterperms.h
     llfloaterpostprocess.h
     llfloaterpreference.h
-    llfloaterpreferencemoveadvanced.h
+    llfloaterpreferenceviewadvanced.h
     llfloaterpreviewtrash.h
     llfloaterproperties.h
     llfloaterregiondebugconsole.h
diff --git a/indra/newview/llfloaterloadprefpreset.cpp b/indra/newview/llfloaterloadprefpreset.cpp
index 403db35cc0..fa17a9d40e 100644
--- a/indra/newview/llfloaterloadprefpreset.cpp
+++ b/indra/newview/llfloaterloadprefpreset.cpp
@@ -42,7 +42,8 @@ LLFloaterLoadPrefPreset::LLFloaterLoadPrefPreset(const LLSD &key)
 
 // virtual
 BOOL LLFloaterLoadPrefPreset::postBuild()
-{	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+{
+	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
 	if (preferences)
 	{
 		preferences->addDependentFloater(this);
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 872e961a70..df21bec0bc 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -790,12 +790,12 @@ void LLFloaterPreference::onOpen(const LLSD& key)
 	LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton");
 	LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton");
 
-	if (load_btn && save_btn && delete_btn)
+	if (load_btn && save_btn && delete_btn && exceptions_btn)
 	{
 		load_btn->setEnabled(started);
 		save_btn->setEnabled(started);
 		delete_btn->setEnabled(started);
-	exceptions_btn->setEnabled(started);
+		exceptions_btn->setEnabled(started);
 	}
 
 	LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
@@ -2519,18 +2519,24 @@ void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
 void LLPanelPreference::deletePreset(const LLSD& user_data)
 {
 	std::string subdirectory = user_data.asString();
+	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
+	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
 	LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::savePreset(const LLSD& user_data)
 {
 	std::string subdirectory = user_data.asString();
+	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
+	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
 	LLFloaterReg::showInstance("save_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::loadPreset(const LLSD& user_data)
 {
 	std::string subdirectory = user_data.asString();
+	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
+	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
 	LLFloaterReg::showInstance("load_pref_preset", subdirectory);
 }
 
diff --git a/indra/newview/llfloaterpreferencemoveadvanced.cpp b/indra/newview/llfloaterpreferencemoveadvanced.cpp
deleted file mode 100644
index 3ff19147b1..0000000000
--- a/indra/newview/llfloaterpreferencemoveadvanced.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/** 
- * @file llfloaterpreferencemoveadvanced.cpp
- * @brief floater for adjusting camera position
- *
- * $LicenseInfo:firstyear=2018&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2018, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-#include "llfloaterpreferencemoveadvanced.h"
-#include "llfloater.h"
-#include "llfloaterreg.h"
-#include "lluictrlfactory.h"
-#include "llspinctrl.h"
-#include "llviewercontrol.h"
-
-
-LLFloaterPreferenceMoveAdvanced::LLFloaterPreferenceMoveAdvanced(const LLSD& key) 
-:	LLFloater(key)
-{
-	mCommitCallbackRegistrar.add("Cancel",	boost::bind(&LLFloaterPreferenceMoveAdvanced::onClickCancel, this));
-	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceMoveAdvanced::onCommitSettings, this));
-	mCommitCallbackRegistrar.add("Ok",	boost::bind(&LLFloaterPreferenceMoveAdvanced::onClickOk, this));
-
-}
-
-LLFloaterPreferenceMoveAdvanced::~LLFloaterPreferenceMoveAdvanced()
-{}
-
-void LLFloaterPreferenceMoveAdvanced::onClickOk()
-{
-	closeFloater();
-}
-
-void LLFloaterPreferenceMoveAdvanced::onClickCancel()
-{
-	gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
-	gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
-
-	updateCameraControl(mCameraSaved);
-	updateFocusControl(mFocusSaved);
-}
-
-BOOL LLFloaterPreferenceMoveAdvanced::postBuild()
-{
-	mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
-	mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
-
-	updateCameraControl(mCameraSaved);
-	updateFocusControl(mFocusSaved);
-
-	return TRUE;
-}
-
-void LLFloaterPreferenceMoveAdvanced::updateCameraControl(LLVector3 vector)
-{
-	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("camera_x");
-	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("camera_y");
-	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("camera_z");
-
-	if (!spinnerx || !spinnery || !spinnerz)
-	{
-		LL_WARNS() << "Could not find all desired UI camera elements"
-			<< LL_ENDL;
-		return;
-	}
-
-	if (!spinnerx->hasFocus())
-	{
-		spinnerx->setValue(vector[VX]);
-	}
-
-	if (!spinnery->hasFocus())
-	{
-		spinnery->setValue(vector[VY]);
-	}
-
-	if (!spinnerz->hasFocus())
-	{
-		spinnerz->setValue(vector[VZ]);
-	}
-}
-
-void LLFloaterPreferenceMoveAdvanced::updateFocusControl(LLVector3d vector3d)
-{
-	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("focus_x");
-	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("focus_y");
-	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("focus_z");
-
-	if (!spinnerx || !spinnery || !spinnerz)
-	{
-		LL_WARNS() << "Could not find all desired UI focus elements"
-			<< LL_ENDL;
-		return;
-	}
-
-	if (!spinnerx->hasFocus())
-	{
-		spinnerx->setValue(vector3d[VX]);
-	}
-
-	if (!spinnery->hasFocus())
-	{
-		spinnery->setValue(vector3d[VY]);
-	}
-
-	if (!spinnerz->hasFocus())
-	{
-		spinnerz->setValue(vector3d[VZ]);
-	}
-}
-
- void LLFloaterPreferenceMoveAdvanced::draw()
-{
-//	updateControl();
-	LLFloater::draw();
-}
-
-void LLFloaterPreferenceMoveAdvanced::onCommitSettings()
-{
-	LLVector3 vector;
-	LLVector3d vector3d;
-
-	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
-	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
-	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
-	gSavedSettings.setVector3("CameraOffsetRearView", vector);
-
-	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
-	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
-	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
-	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
-}
diff --git a/indra/newview/llfloaterpreferencemoveadvanced.h b/indra/newview/llfloaterpreferencemoveadvanced.h
deleted file mode 100644
index 98648af19e..0000000000
--- a/indra/newview/llfloaterpreferencemoveadvanced.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/** 
- * @file llfloaterpreferencemoveadvanced.h
- * @brief floater for adjusting camera position
- *
- * $LicenseInfo:firstyear=2018&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2018, Linden Research, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- * 
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
- * $/LicenseInfo$
- */
-
-#ifndef LLFLOATERPREFERENCEMOVEADVANCED_H
-#define LLFLOATERPREFERENCEMOVEADVANCED_H
-
-#include "llcontrol.h"
-#include "llfloater.h"
-
-class LLFloaterPreferenceMoveAdvanced
-:	public LLFloater
-{
-	friend class LLFloaterReg;
-
-public:
-	LLFloaterPreferenceMoveAdvanced(const LLSD& key);
-	virtual BOOL postBuild();
-	virtual void draw();
-
-	void onCommitSettings();
-	void onClickCancel();
-	void onClickOk();
-	void updateCameraControl(LLVector3 vector);
-	void updateFocusControl(LLVector3d vector3d);
-
-private:
-	virtual ~LLFloaterPreferenceMoveAdvanced();
-
-	LLVector3	mCameraSaved;
-	LLVector3d	mFocusSaved;
-	
-};
-
-#endif //LLFLOATERPREFERENCEMOVEADVANCED_H
-
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
new file mode 100644
index 0000000000..ff80328acc
--- /dev/null
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -0,0 +1,151 @@
+/** 
+ * @file llfloaterpreferenceviewadvanced.cpp
+ * @brief floater for adjusting camera position
+ *
+ * $LicenseInfo:firstyear=2018&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2018, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+#include "llfloaterpreferenceviewadvanced.h"
+#include "llfloater.h"
+#include "llfloaterreg.h"
+#include "lluictrlfactory.h"
+#include "llspinctrl.h"
+#include "llviewercontrol.h"
+
+
+LLFloaterPreferenceViewAdvanced::LLFloaterPreferenceViewAdvanced(const LLSD& key) 
+:	LLFloater(key)
+{
+	mCommitCallbackRegistrar.add("Cancel",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this));
+	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
+	mCommitCallbackRegistrar.add("Ok",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this));
+
+}
+
+LLFloaterPreferenceViewAdvanced::~LLFloaterPreferenceViewAdvanced()
+{}
+
+void LLFloaterPreferenceViewAdvanced::onClickOk()
+{
+	closeFloater();
+}
+
+void LLFloaterPreferenceViewAdvanced::onClickCancel()
+{
+	gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
+	gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
+
+	updateCameraControl(mCameraSaved);
+	updateFocusControl(mFocusSaved);
+}
+
+BOOL LLFloaterPreferenceViewAdvanced::postBuild()
+{
+	mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
+	mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
+
+	updateCameraControl(mCameraSaved);
+	updateFocusControl(mFocusSaved);
+
+	return TRUE;
+}
+
+void LLFloaterPreferenceViewAdvanced::updateCameraControl(LLVector3 vector)
+{
+	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("camera_x");
+	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("camera_y");
+	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("camera_z");
+
+	if (!spinnerx || !spinnery || !spinnerz)
+	{
+		LL_WARNS() << "Could not find all desired UI camera elements"
+			<< LL_ENDL;
+		return;
+	}
+
+	if (!spinnerx->hasFocus())
+	{
+		spinnerx->setValue(vector[VX]);
+	}
+
+	if (!spinnery->hasFocus())
+	{
+		spinnery->setValue(vector[VY]);
+	}
+
+	if (!spinnerz->hasFocus())
+	{
+		spinnerz->setValue(vector[VZ]);
+	}
+}
+
+void LLFloaterPreferenceViewAdvanced::updateFocusControl(LLVector3d vector3d)
+{
+	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("focus_x");
+	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("focus_y");
+	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("focus_z");
+
+	if (!spinnerx || !spinnery || !spinnerz)
+	{
+		LL_WARNS() << "Could not find all desired UI focus elements"
+			<< LL_ENDL;
+		return;
+	}
+
+	if (!spinnerx->hasFocus())
+	{
+		spinnerx->setValue(vector3d[VX]);
+	}
+
+	if (!spinnery->hasFocus())
+	{
+		spinnery->setValue(vector3d[VY]);
+	}
+
+	if (!spinnerz->hasFocus())
+	{
+		spinnerz->setValue(vector3d[VZ]);
+	}
+}
+
+ void LLFloaterPreferenceViewAdvanced::draw()
+{
+//	updateControl();
+	LLFloater::draw();
+}
+
+void LLFloaterPreferenceViewAdvanced::onCommitSettings()
+{
+	LLVector3 vector;
+	LLVector3d vector3d;
+
+	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
+	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
+	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
+	gSavedSettings.setVector3("CameraOffsetRearView", vector);
+
+	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
+	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
+	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
+	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
+}
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h
new file mode 100644
index 0000000000..5b63770059
--- /dev/null
+++ b/indra/newview/llfloaterpreferenceviewadvanced.h
@@ -0,0 +1,58 @@
+/** 
+ * @file llfloaterpreferenceviewadvanced.h
+ * @brief floater for adjusting camera position
+ *
+ * $LicenseInfo:firstyear=2018&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2018, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LLFLOATERPREFERENCEVIEWADVANCED_H
+#define LLFLOATERPREFERENCEVIEWADVANCED_H
+
+#include "llcontrol.h"
+#include "llfloater.h"
+
+class LLFloaterPreferenceViewAdvanced
+:	public LLFloater
+{
+	friend class LLFloaterReg;
+
+public:
+	LLFloaterPreferenceViewAdvanced(const LLSD& key);
+	virtual BOOL postBuild();
+	virtual void draw();
+
+	void onCommitSettings();
+	void onClickCancel();
+	void onClickOk();
+	void updateCameraControl(LLVector3 vector);
+	void updateFocusControl(LLVector3d vector3d);
+
+private:
+	virtual ~LLFloaterPreferenceViewAdvanced();
+
+	LLVector3	mCameraSaved;
+	LLVector3d	mFocusSaved;
+	
+};
+
+#endif //LLFLOATERPREFERENCEVIEWADVANCED_H
+
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index bdef718d0e..eaacba893d 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -42,7 +42,8 @@ LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key)
 
 // virtual
 BOOL LLFloaterSavePrefPreset::postBuild()
-{	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+{
+	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
 	if (preferences)
 	{
 		preferences->addDependentFloater(this);
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 440bf46b1e..5237986cd6 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -104,7 +104,7 @@
 #include "llfloaterperms.h"
 #include "llfloaterpostprocess.h"
 #include "llfloaterpreference.h"
-#include "llfloaterpreferencemoveadvanced.h"
+#include "llfloaterpreferenceviewadvanced.h"
 #include "llfloaterpreviewtrash.h"
 #include "llfloaterproperties.h"
 #include "llfloaterregiondebugconsole.h"
@@ -296,7 +296,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
 	LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>);
-	LLFloaterReg::add("prefs_move_advanced", "floater_preferences_move_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceMoveAdvanced>);
+	LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>);
 	LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
 	LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>);
 	LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
diff --git a/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml
index 0688fdb42c..3360d7bec9 100644
--- a/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_delete_pref_preset.xml
@@ -4,7 +4,7 @@
  height="130"
  help_topic="floater_delete_preset"
  layout="topleft"
- name="Delete Pref Preset"
+ name="delete_pref_preset"
  save_rect="true"
  title="DELETE PREF PRESET"
  width="300">
diff --git a/indra/newview/skins/default/xui/en/floater_load_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_load_pref_preset.xml
index 5f2eb770e2..49c21f1ea7 100644
--- a/indra/newview/skins/default/xui/en/floater_load_pref_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_load_pref_preset.xml
@@ -4,7 +4,7 @@
  height="130"
  help_topic="floater_load_preset"
  layout="topleft"
- name="Load Pref Preset"
+ name="load_pref_preset"
  save_rect="true"
  title="LOAD PREF PRESET"
  width="300">
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml
deleted file mode 100644
index 28e5d2c607..0000000000
--- a/indra/newview/skins/default/xui/en/floater_preferences_move_advanced.xml
+++ /dev/null
@@ -1,140 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<floater
- height="170"
- layout="topleft"
- name="floaterpreferencesmoveadvanced"
- help_topic="floatermoveadvanced"
- title="ADJUST CAMERA VIEW"
- save_rect="true"
- width="280">
-
-  <text
-    follows="top|left|right"
-    height="16"
-    layout="topleft"
-    left="10"
-    top="10"
-    width="100">
-      Camera offset:
-  </text>
-
-  <spinner
-   height="20"
-   label="X"
-   label_width="12"
-   follows="topl|eft"
-   left="10"
-   name="camera_x"
-   top_pad="5"
-   min_val="-1e+007"
-   max_val="1e+007"
-   width="70">
-    <spinner.commit_callback
-     function="CommitSettings" />
-  </spinner>
-
-  <spinner
-   height="20"
-   label="Y"
-   label_width="12"
-   follows="topl|eft"
-   name="camera_y"
-   left_pad="20"
-   min_val="-1e+007"
-   max_val="1e+007"
-   width="70">
-    <spinner.commit_callback
-     function="CommitSettings" />
-  </spinner>
-
-  <spinner
-   height="20"
-   label="Z"
-   label_width="12"
-   follows="topl|eft"
-   name="camera_z"
-   left_pad="20"
-   min_val="-1e+007"
-   max_val="1e+007"
-   width="70">
-    <spinner.commit_callback
-     function="CommitSettings" />
-  </spinner>
-
-  <text
-    follows="top|left|right"
-    height="16"
-    layout="topleft"
-    left="10"
-    top_pad="20"
-    width="100">
-      Focus offset:
-  </text>
-
-  <spinner
-   height="20"
-   label="X"
-   label_width="12"
-   follows="topl|eft"
-   left="10"
-   name="focus_x"
-   top_pad="5"
-   min_val="-1e+007"
-   max_val="1e+007"
-   width="70">
-    <spinner.commit_callback
-     function="CommitSettings" />
-  </spinner>
-
-  <spinner
-   height="20"
-   label="Y"
-   label_width="12"
-   follows="topl|eft"
-   name="focus_y"
-   left_pad="20"
-   min_val="-1e+007"
-   max_val="1e+007"
-   width="70">
-    <spinner.commit_callback
-     function="CommitSettings" />
-  </spinner>
-
-  <spinner
-   height="20"
-   label="Z"
-   label_width="12"
-   follows="topl|eft"
-   name="focus_z"
-   left_pad="20"
-   min_val="-1e+007"
-   max_val="1e+007"
-   width="70">
-    <spinner.commit_callback
-     function="CommitSettings" />
-  </spinner>
-
-  <button
-   follows="left|top"
-   height="23"
-   label="OK"
-   layout="topleft"
-   left="90"
-   name="ok"
-   top_pad="30"
-   width="90">
-    <button.commit_callback
-     function="Ok"/>
-  </button>
-  <button
-   follows="left|top"
-   height="23"
-   label="Cancel"
-   layout="topleft"
-   left_pad="5"
-   name="cancel"
-   width="90">
-    <button.commit_callback
-     function="Cancel"/>
-  </button>
-</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
new file mode 100644
index 0000000000..5b2cbee914
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
@@ -0,0 +1,140 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ height="170"
+ layout="topleft"
+ name="floaterpreferencesviewadvanced"
+ help_topic="floaterviewadvanced"
+ title="ADJUST CAMERA VIEW"
+ save_rect="true"
+ width="280">
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left="10"
+    top="10"
+    width="100">
+      Camera offset:
+  </text>
+
+  <spinner
+   height="20"
+   label="X"
+   label_width="12"
+   follows="topl|eft"
+   left="10"
+   name="camera_x"
+   top_pad="5"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Y"
+   label_width="12"
+   follows="topl|eft"
+   name="camera_y"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Z"
+   label_width="12"
+   follows="topl|eft"
+   name="camera_z"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left="10"
+    top_pad="20"
+    width="100">
+      Focus offset:
+  </text>
+
+  <spinner
+   height="20"
+   label="X"
+   label_width="12"
+   follows="topl|eft"
+   left="10"
+   name="focus_x"
+   top_pad="5"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Y"
+   label_width="12"
+   follows="topl|eft"
+   name="focus_y"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <spinner
+   height="20"
+   label="Z"
+   label_width="12"
+   follows="topl|eft"
+   name="focus_z"
+   left_pad="20"
+   min_val="-1e+007"
+   max_val="1e+007"
+   width="70">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
+  <button
+   follows="left|top"
+   height="23"
+   label="OK"
+   layout="topleft"
+   left="90"
+   name="ok"
+   top_pad="30"
+   width="90">
+    <button.commit_callback
+     function="Ok"/>
+  </button>
+  <button
+   follows="left|top"
+   height="23"
+   label="Cancel"
+   layout="topleft"
+   left_pad="5"
+   name="cancel"
+   width="90">
+    <button.commit_callback
+     function="Cancel"/>
+  </button>
+</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
index 7dee28eff3..a9cda26f0b 100644
--- a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
@@ -4,7 +4,7 @@
  height="145"
  help_topic="floater_save_preset"
  layout="topleft"
- name="Save Pref Preset"
+ name="save_pref_preset"
  save_rect="true"
  title="SAVE PREF PRESET"
  width="300">
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
index d832dac4ff..8d8441695f 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
@@ -138,7 +138,7 @@
     width="115">
     <button.commit_callback
      function="Floater.Show"
-     parameter="prefs_move_advanced" />
+     parameter="prefs_view_advanced" />
   </button>  
 
   <button
-- 
cgit v1.2.3


From a1b3436586514c6be5c4d7703dfc68a66d942075 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Mon, 15 Jan 2018 16:01:24 -0500
Subject: STORM-2145 Get current preset indicator to work properly

---
 indra/newview/llfloaterpreference.cpp          | 4 ----
 indra/newview/llpanelpresetscamerapulldown.cpp | 3 ++-
 indra/newview/llpresetsmanager.cpp             | 6 ++++++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index df21bec0bc..0a717cc834 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -2643,11 +2643,7 @@ void LLPanelPreferenceView::setPresetText()
 	{
 		if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
 		{
-			gSavedSettings.setString("PresetCameraActive", "");
 			preset_camera_active.clear();
-			// This doesn't seem to cause an infinite recursion.  This trigger is needed to cause the pulldown
-			// panel to update.
-			LLPresetsManager::getInstance()->triggerChangeCameraSignal();
 		}
 	}
 
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index ffdfc445ce..e2b9c080fb 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -63,11 +63,12 @@ BOOL LLPanelPresetsCameraPulldown::postBuild()
 	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
 	if (presetsMgr)
 	{
-		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
 		// Make sure there is a default preference file
 		presetsMgr->createMissingDefault(PRESETS_CAMERA);
 
 		presetsMgr->startWatching(PRESETS_CAMERA);
+
+		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
 	}
 
 	populatePanel();
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index d4535c69c8..7368615365 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -208,6 +208,12 @@ bool LLPresetsManager::isCameraDirty()
 void LLPresetsManager::settingChanged()
 {
 	setCameraDirty(true);
+
+	gSavedSettings.setString("PresetCameraActive", "");
+
+// Hack call because this is a static routine
+	LLPresetsManager::getInstance()->triggerChangeCameraSignal();
+
 }
 
 void LLPresetsManager::getControlNames(std::vector<std::string>& names)
-- 
cgit v1.2.3


From 9c7b634ba60d7a0b3687472ce22f7bbfd3e28010 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Tue, 16 Jan 2018 11:27:49 -0500
Subject: STORM-2145 Change line ending type of preset files

---
 indra/newview/app_settings/Camera/Front.xml        | 129 ++++++++++++++++++---
 indra/newview/app_settings/Camera/Pennys Gamer.xml |  20 ----
 .../newview/app_settings/Camera/Pennys%20Gamer.xml | 115 ++++++++++++++++++
 indra/newview/app_settings/Camera/Rear.xml         | 129 ++++++++++++++++++---
 indra/newview/app_settings/Camera/Side.xml         | 129 ++++++++++++++++++---
 indra/newview/llpresetsmanager.cpp                 |   5 -
 6 files changed, 451 insertions(+), 76 deletions(-)
 delete mode 100644 indra/newview/app_settings/Camera/Pennys Gamer.xml
 create mode 100644 indra/newview/app_settings/Camera/Pennys%20Gamer.xml

diff --git a/indra/newview/app_settings/Camera/Front.xml b/indra/newview/app_settings/Camera/Front.xml
index 6f2ea9da17..d5ead526b7 100644
--- a/indra/newview/app_settings/Camera/Front.xml
+++ b/indra/newview/app_settings/Camera/Front.xml
@@ -1,20 +1,115 @@
-<?xml version="1.0" ?>
-<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:noNamespaceSchemaLocation="llsd.xsd">
-
-    <key>FocusOffsetRearView</key>
+<llsd>
     <map>
-      <key>Comment</key>
-      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Vector3D</string>
-      <key>Value</key>
-      <array>
-        <real>1.0</real>
-        <real>0.0</real>
-        <real>1.0</real>
-      </array>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>2.2</real>
+                <real>0.0</real>
+                <real>0.0</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>0.0</real>
+                <real>0.0</real>
+                <real>0.0</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
     </map>
 </llsd>
diff --git a/indra/newview/app_settings/Camera/Pennys Gamer.xml b/indra/newview/app_settings/Camera/Pennys Gamer.xml
deleted file mode 100644
index 6f2ea9da17..0000000000
--- a/indra/newview/app_settings/Camera/Pennys Gamer.xml	
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" ?>
-<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:noNamespaceSchemaLocation="llsd.xsd">
-
-    <key>FocusOffsetRearView</key>
-    <map>
-      <key>Comment</key>
-      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Vector3D</string>
-      <key>Value</key>
-      <array>
-        <real>1.0</real>
-        <real>0.0</real>
-        <real>1.0</real>
-      </array>
-    </map>
-</llsd>
diff --git a/indra/newview/app_settings/Camera/Pennys%20Gamer.xml b/indra/newview/app_settings/Camera/Pennys%20Gamer.xml
new file mode 100644
index 0000000000..5d249153a0
--- /dev/null
+++ b/indra/newview/app_settings/Camera/Pennys%20Gamer.xml
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-3.0</real>
+                <real>0.0</real>
+                <real>-0.2</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>0.9</real>
+                <real>0.0</real>
+                <real>0.2</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/Camera/Rear.xml b/indra/newview/app_settings/Camera/Rear.xml
index 6f2ea9da17..0bfe5a9ed8 100644
--- a/indra/newview/app_settings/Camera/Rear.xml
+++ b/indra/newview/app_settings/Camera/Rear.xml
@@ -1,20 +1,115 @@
-<?xml version="1.0" ?>
-<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:noNamespaceSchemaLocation="llsd.xsd">
-
-    <key>FocusOffsetRearView</key>
+<llsd>
     <map>
-      <key>Comment</key>
-      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Vector3D</string>
-      <key>Value</key>
-      <array>
-        <real>1.0</real>
-        <real>0.0</real>
-        <real>1.0</real>
-      </array>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-3</real>
+                <real>0</real>
+                <real>0.75</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>1.0</real>
+                <real>0.0</real>
+                <real>1.0</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
     </map>
 </llsd>
diff --git a/indra/newview/app_settings/Camera/Side.xml b/indra/newview/app_settings/Camera/Side.xml
index 6f2ea9da17..4cd5f2f5a4 100644
--- a/indra/newview/app_settings/Camera/Side.xml
+++ b/indra/newview/app_settings/Camera/Side.xml
@@ -1,20 +1,115 @@
-<?xml version="1.0" ?>
-<llsd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:noNamespaceSchemaLocation="llsd.xsd">
-
-    <key>FocusOffsetRearView</key>
+<llsd>
     <map>
-      <key>Comment</key>
-      <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-      <key>Persist</key>
-      <integer>1</integer>
-      <key>Type</key>
-      <string>Vector3D</string>
-      <key>Value</key>
-      <array>
-        <real>1.0</real>
-        <real>0.0</real>
-        <real>1.0</real>
-      </array>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-1.0</real>
+                <real>0.7</real>
+                <real>0.5</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>1.5</real>
+                <real>0.7</real>
+                <real>1.0</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
     </map>
 </llsd>
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 7368615365..be6dd89aba 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -226,13 +226,8 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 		("AppearanceCameraMovement")
 		// From llagentcamera.cpp
 		("CameraOffsetBuild")
-		("CameraPreset")
 		("CameraOffsetRearView")
-		("CameraOffsetFrontView")
-		("CameraOffsetGroupView")
 		("FocusOffsetRearView")
-		("FocusOffsetFrontView")
-		("FocusOffsetGroupView")
 		("CameraOffsetScale")
 		("TrackFocusObject");
 }
-- 
cgit v1.2.3


From 23925816774eaf5baf0756f32435c32db408370f Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Tue, 16 Jan 2018 18:02:47 -0500
Subject: STORM-2145 Deal with preset files with spaces correctly

---
 indra/newview/app_settings/Camera/Pennys Gamer.xml | 115 +++++++++++++++++++++
 .../newview/app_settings/Camera/Pennys%20Gamer.xml | 115 ---------------------
 indra/newview/llpresetsmanager.cpp                 |   1 +
 3 files changed, 116 insertions(+), 115 deletions(-)
 create mode 100644 indra/newview/app_settings/Camera/Pennys Gamer.xml
 delete mode 100644 indra/newview/app_settings/Camera/Pennys%20Gamer.xml

diff --git a/indra/newview/app_settings/Camera/Pennys Gamer.xml b/indra/newview/app_settings/Camera/Pennys Gamer.xml
new file mode 100644
index 0000000000..5d249153a0
--- /dev/null
+++ b/indra/newview/app_settings/Camera/Pennys Gamer.xml	
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-3.0</real>
+                <real>0.0</real>
+                <real>-0.2</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>0.9</real>
+                <real>0.0</real>
+                <real>0.2</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/Camera/Pennys%20Gamer.xml b/indra/newview/app_settings/Camera/Pennys%20Gamer.xml
deleted file mode 100644
index 5d249153a0..0000000000
--- a/indra/newview/app_settings/Camera/Pennys%20Gamer.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-3.0</real>
-                <real>0.0</real>
-                <real>-0.2</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>0.9</real>
-                <real>0.0</real>
-                <real>0.2</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index be6dd89aba..ec4f5fd864 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -137,6 +137,7 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 				if (found)
 				{
 					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "Camera", file);
+					file = LLURI::escape(file);
 					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, "Camera", file);
 					LLFile::copy(source, dest);
 				}
-- 
cgit v1.2.3


From 0cde8e88586a4a9cde8a1c91a71882c8fffa8c93 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Thu, 18 Jan 2018 08:23:49 -0500
Subject: copy all versions of libnghttp for tests

---
 indra/llcorehttp/CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt
index 40ec836f12..bff329f4a5 100644
--- a/indra/llcorehttp/CMakeLists.txt
+++ b/indra/llcorehttp/CMakeLists.txt
@@ -180,6 +180,10 @@ if (DARWIN)
     COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib ${LL_TEST_DESTINATION_DIR}
     DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libexception_handler.dylib
   )
+  add_custom_command(TARGET INTEGRATION_TEST_llcorehttp PRE_BUILD
+    COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/libnghttp2*.dylib ${LL_TEST_DESTINATION_DIR}
+    DEPENDS ${AUTOBUILD_INSTALL_DIR}/lib/release/libnghttp2.dylib
+  )
   foreach(expat ${EXPAT_COPY})
     add_custom_command(TARGET INTEGRATION_TEST_llcorehttp PRE_BUILD
       COMMAND ${CMAKE_COMMAND} -E copy ${AUTOBUILD_INSTALL_DIR}/lib/release/${expat} ${LL_TEST_DESTINATION_DIR}
-- 
cgit v1.2.3


From 33db84d7015d9e61c0702a5b8f581eff7145ebbf Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Thu, 18 Jan 2018 17:03:24 -0500
Subject: STORM-2145 Step 1 of renaming a directory

---
 indra/newview/app_settings/Camera/Front.xml        | 115 ---------------------
 indra/newview/app_settings/Camera/Pennys Gamer.xml | 115 ---------------------
 indra/newview/app_settings/Camera/Rear.xml         | 115 ---------------------
 indra/newview/app_settings/Camera/Side.xml         | 115 ---------------------
 4 files changed, 460 deletions(-)
 delete mode 100644 indra/newview/app_settings/Camera/Front.xml
 delete mode 100644 indra/newview/app_settings/Camera/Pennys Gamer.xml
 delete mode 100644 indra/newview/app_settings/Camera/Rear.xml
 delete mode 100644 indra/newview/app_settings/Camera/Side.xml

diff --git a/indra/newview/app_settings/Camera/Front.xml b/indra/newview/app_settings/Camera/Front.xml
deleted file mode 100644
index d5ead526b7..0000000000
--- a/indra/newview/app_settings/Camera/Front.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>2.2</real>
-                <real>0.0</real>
-                <real>0.0</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>0.0</real>
-                <real>0.0</real>
-                <real>0.0</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
diff --git a/indra/newview/app_settings/Camera/Pennys Gamer.xml b/indra/newview/app_settings/Camera/Pennys Gamer.xml
deleted file mode 100644
index 5d249153a0..0000000000
--- a/indra/newview/app_settings/Camera/Pennys Gamer.xml	
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-3.0</real>
-                <real>0.0</real>
-                <real>-0.2</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>0.9</real>
-                <real>0.0</real>
-                <real>0.2</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
diff --git a/indra/newview/app_settings/Camera/Rear.xml b/indra/newview/app_settings/Camera/Rear.xml
deleted file mode 100644
index 0bfe5a9ed8..0000000000
--- a/indra/newview/app_settings/Camera/Rear.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-3</real>
-                <real>0</real>
-                <real>0.75</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>1.0</real>
-                <real>0.0</real>
-                <real>1.0</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
diff --git a/indra/newview/app_settings/Camera/Side.xml b/indra/newview/app_settings/Camera/Side.xml
deleted file mode 100644
index 4cd5f2f5a4..0000000000
--- a/indra/newview/app_settings/Camera/Side.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-1.0</real>
-                <real>0.7</real>
-                <real>0.5</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>1.5</real>
-                <real>0.7</real>
-                <real>1.0</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
-- 
cgit v1.2.3


From 96481c159335cf27f5c49d842f6df6f35000209c Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Thu, 18 Jan 2018 17:04:05 -0500
Subject: STORM-2145 Step 2 of renaming a directory

---
 indra/newview/app_settings/camera/Front.xml        | 115 +++++++++++++++++++++
 indra/newview/app_settings/camera/Pennys Gamer.xml | 115 +++++++++++++++++++++
 indra/newview/app_settings/camera/Rear.xml         | 115 +++++++++++++++++++++
 indra/newview/app_settings/camera/Side.xml         | 115 +++++++++++++++++++++
 4 files changed, 460 insertions(+)
 create mode 100644 indra/newview/app_settings/camera/Front.xml
 create mode 100644 indra/newview/app_settings/camera/Pennys Gamer.xml
 create mode 100644 indra/newview/app_settings/camera/Rear.xml
 create mode 100644 indra/newview/app_settings/camera/Side.xml

diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
new file mode 100644
index 0000000000..d5ead526b7
--- /dev/null
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>2.2</real>
+                <real>0.0</real>
+                <real>0.0</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>0.0</real>
+                <real>0.0</real>
+                <real>0.0</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/camera/Pennys Gamer.xml b/indra/newview/app_settings/camera/Pennys Gamer.xml
new file mode 100644
index 0000000000..5d249153a0
--- /dev/null
+++ b/indra/newview/app_settings/camera/Pennys Gamer.xml	
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-3.0</real>
+                <real>0.0</real>
+                <real>-0.2</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>0.9</real>
+                <real>0.0</real>
+                <real>0.2</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml
new file mode 100644
index 0000000000..0bfe5a9ed8
--- /dev/null
+++ b/indra/newview/app_settings/camera/Rear.xml
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-3</real>
+                <real>0</real>
+                <real>0.75</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>1.0</real>
+                <real>0.0</real>
+                <real>1.0</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
new file mode 100644
index 0000000000..4cd5f2f5a4
--- /dev/null
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-1.0</real>
+                <real>0.7</real>
+                <real>0.5</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>1.5</real>
+                <real>0.7</real>
+                <real>1.0</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
-- 
cgit v1.2.3


From 9954d8d82391a129ca2c4c9fe9a339bc80bc0817 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Thu, 18 Jan 2018 17:13:07 -0500
Subject: STORM-2145 Use string constant rather than a hardcoded string.

---
 indra/newview/llpresetsmanager.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index ec4f5fd864..8b0a05984d 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -126,7 +126,7 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 
 		if (PRESETS_CAMERA == subdirectory)
 		{
-			std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "Camera");
+			std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
 			LLDirIterator dir_iter(source_dir, "*.xml");
 			bool found = true;
 			while (found)
@@ -136,9 +136,9 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 
 				if (found)
 				{
-					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "Camera", file);
+					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
 					file = LLURI::escape(file);
-					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, "Camera", file);
+					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
 					LLFile::copy(source, dest);
 				}
 			}
-- 
cgit v1.2.3


From 444643aeb0b80fdfbe28e0e2faae56de9d4f6e4a Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Fri, 19 Jan 2018 09:52:05 -0500
Subject: package the default camera position presets

---
 indra/newview/viewer_manifest.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 66d730d1ac..a811f16b53 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -76,6 +76,9 @@ class ViewerManifest(LLManifest):
                 contributor_names = self.extract_names(contributions_path)
                 self.put_in_file(contributor_names, "contributors.txt", src=contributions_path)
 
+                # ... and the default camera position settings
+                self.path("camera")
+
                 # ... and the entire windlight directory
                 self.path("windlight")
 
-- 
cgit v1.2.3


From b92b131f6df3bfc19f05804a13ee5aa505d372e4 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Fri, 26 Jan 2018 09:55:04 -0500
Subject: STORM-2145 Update floater spinners if values are changed elsewhere

---
 indra/newview/llfloaterpreferenceviewadvanced.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
index ff80328acc..055c6f2232 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -130,7 +130,12 @@ void LLFloaterPreferenceViewAdvanced::updateFocusControl(LLVector3d vector3d)
 
  void LLFloaterPreferenceViewAdvanced::draw()
 {
-//	updateControl();
+	static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView");
+	static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView");
+
+	updateCameraControl(camera);
+	updateFocusControl(focus);
+
 	LLFloater::draw();
 }
 
-- 
cgit v1.2.3


From b778abe02b80d68ea0894f237c001e8a5505cc13 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Tue, 30 Jan 2018 09:21:14 -0500
Subject: disambiguate boost list assignment by using a const for the value

---
 indra/newview/llpresetsmanager.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index e0fa085658..52964a125f 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -214,7 +214,7 @@ void LLPresetsManager::settingChanged()
 
 void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 {
-	names = boost::assign::list_of
+	const std::vector<std::string> camera_controls = boost::assign::list_of
 		// From panel_preferences_move.xml
 		("CameraAngle")
 		("CameraOffsetScale")
@@ -225,7 +225,9 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 		("CameraOffsetRearView")
 		("FocusOffsetRearView")
 		("CameraOffsetScale")
-		("TrackFocusObject");
+		("TrackFocusObject")
+        ;
+    names = camera_controls;
 }
 
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
-- 
cgit v1.2.3


From 149d4ce795a9bcfe8d0a9d83521b94d25ca8deab Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Tue, 30 Jan 2018 09:22:23 -0500
Subject: remove cross-library reference (needs to be moved to newview)

---
 indra/llui/llfloater.cpp | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 663d96bdd4..2dcc62ce79 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -1,5 +1,4 @@
 /** 
-
  * @file llfloater.cpp
  * @brief LLFloater base class
  *
@@ -64,8 +63,6 @@
 // use this to control "jumping" behavior when Ctrl-Tabbing
 const S32 TABBED_FLOATER_OFFSET = 0;
 
-extern LLControlGroup gSavedSettings;
-
 namespace LLInitParam
 {
 	void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
@@ -1833,7 +1830,7 @@ void LLFloater::onClickCloseBtn(bool app_quitting)
 // virtual
 void LLFloater::draw()
 {
-	F32 alpha = getCurrentTransparency();
+	const F32 alpha = getCurrentTransparency();
 
 	// draw background
 	if( isBackgroundVisible() )
@@ -1848,16 +1845,6 @@ void LLFloater::draw()
 		LLUIImage* image = NULL;
 		LLColor4 color;
 		LLColor4 overlay_color;
-		std::string help_topic;
-		if (this->findHelpTopic(help_topic))
-		{
-			if("camera_floater" == help_topic)
-			{
-				alpha = llmin(LLCachedControl<F32>(gSavedSettings, "CameraOpacity"),
-                              LLCachedControl<F32>(gSavedSettings, "ActiveFloaterTransparency"));
-			}
-		}
-
 		if (isBackgroundOpaque())
 		{
 			// NOTE: image may not be set
-- 
cgit v1.2.3


From 98792b9363f81c34c9e3ea773fc544122bea5cc3 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Tue, 30 Jan 2018 10:45:08 -0500
Subject: STORM-2145 Split move and view panels

---
 indra/newview/llfloatercamera.cpp                  |   2 +-
 indra/newview/llpanelpresetscamerapulldown.cpp     |   2 +-
 .../skins/default/xui/en/floater_preferences.xml   |   9 +-
 .../default/xui/en/panel_preferences_move.xml      | 182 --------------------
 .../default/xui/en/panel_preferences_view.xml      | 185 +++++++++++++++++++++
 5 files changed, 195 insertions(+), 185 deletions(-)
 create mode 100644 indra/newview/skins/default/xui/en/panel_preferences_view.xml

diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 777963bec5..5bebebf21f 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -387,7 +387,7 @@ void LLFloaterCamera::onViewButtonClick(const LLSD& user_data)
 		// grab the 'view' panel from the preferences floater and
 		// bring it the front!
 		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("move");
+		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
 		if (tabcontainer && graphicspanel)
 		{
 			tabcontainer->selectTabPanel(graphicspanel);
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index e2b9c080fb..7612c428d9 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -212,7 +212,7 @@ void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data)
 		// grab the 'view' panel from the preferences floater and
 		// bring it the front!
 		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("move");
+		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
 		if (tabcontainer && graphicspanel)
 		{
 			tabcontainer->selectTabPanel(graphicspanel);
diff --git a/indra/newview/skins/default/xui/en/floater_preferences.xml b/indra/newview/skins/default/xui/en/floater_preferences.xml
index 7fcc91ffe9..545816c78a 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences.xml
@@ -87,10 +87,17 @@ https://accounts.secondlife.com/change_email/
         <panel
 		 class="panel_preference_view"
          filename="panel_preferences_move.xml"
-         label="Move &amp; View"
+         label="Move"
          layout="topleft"
          help_topic="preferences_move_tab"
          name="move" />
+        <panel
+		 class="panel_preference_view"
+         filename="panel_preferences_view.xml"
+         label="View"
+         layout="topleft"
+         help_topic="preferences_view_tab"
+         name="view" />
         <panel
 		 class="panel_preference"
          filename="panel_preferences_alerts.xml"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
index 8d8441695f..79fbf66139 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
@@ -10,188 +10,6 @@
  top="1"
  width="517">
 
-  <icon
-     follows="left|top"
-     height="18"
-     image_name="Cam_FreeCam_Off"
-     layout="topleft"
-     name="camera_icon"
-     mouse_opaque="false"
-     visible="true"
-     width="18"
-     left="30"
-     top="4"/>
-
-  <text
-    follows="top|left|right"
-    height="16"
-    layout="topleft"
-    left="80"
-    top_delta="0"
-    width="100">
-      Preset in use:
-  </text>
-
-  <text
-    follows="top|left|right"
-    height="16"
-    layout="topleft"
-    left_delta="100"
-    name="preset_camera_text"
-    width="120">
-      (None)
-  </text>
-
-  <slider
-   can_edit_text="true"
-   control_name="CameraAngle"
-   decimal_digits="2"
-   follows="left|top"
-   height="16"
-   top_pad="5"
-   increment="0.025"
-   initial_value="1.57"
-   layout="topleft"
-   label_width="100"
-   label="View angle"
-   left="80"
-   max_val="2.97"
-   min_val="0.17"
-   name="camera_fov"
-   show_text="false"
-   width="240" />
-  <slider
-   can_edit_text="true"
-   control_name="CameraOffsetScale"
-   decimal_digits="2"
-   follows="left|top"
-   height="16"
-   increment="0.025"
-   initial_value="1"
-   layout="topleft"
-   label="Distance"
-   left_delta="0"
-   label_width="100"
-   max_val="3"
-   min_val="0.5"
-   name="camera_offset_scale"
-   show_text="false"
-   width="240"
-   top_pad="5"/>
-  <text
-  follows="left|top"
-  type="string"
-  length="1"
-  height="10"
-  left="80"
-  name="heading2"
-  width="200"
-  top_pad="5">
-    Automatic position for:
-  </text>
-
-  <spinner
-   control_name="CameraOpacity"
-   decimal_digits="1"
-   follows="top|left|right"
-   height="24"
-   max_val="1.0"
-   min_val="0.0"
-   increment="0.1"
-   initial_value="1.0"
-   label="Camera controls opacity:"
-   label_width="180"
-   layout="topleft"
-   top_pad="-10"
-   left_pad="10"
-   width="220" />
-
-  <check_box
-     control_name="EditCameraMovement"
-     height="20"
-     follows="left|top"
-     label="Build/Edit"
-     layout="topleft"
-     left="100"
-     name="edit_camera_movement"
-     tool_tip="Use automatic camera positioning when entering and exiting edit mode"
-     width="280"
-     top_pad="-10" />
-  <check_box
-   control_name="AppearanceCameraMovement"
-   follows="left|top"
-   height="16"
-   label="Appearance"
-   layout="topleft"
-   name="appearance_camera_movement"
-   tool_tip="Use automatic camera positioning while in edit mode"
-   width="242" />
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Advanced..."
-    layout="topleft"
-    left_pad="-102"
-    name="PreferencesMoveAdvanced"
-    tool_tip="Adjust camera positioning"
-    width="115">
-    <button.commit_callback
-     function="Floater.Show"
-     parameter="prefs_view_advanced" />
-  </button>  
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Save settings as a preset..."
-    layout="topleft"
-    left="30"
-    name="PrefCameraSaveButton"
-    top_pad="10"
-    width="200">
-    <button.commit_callback
-      function="Pref.PrefSave"
-      parameter="camera" />
-  </button>
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Load preset..."
-    layout="topleft"
-    left_pad="10"
-    name="PrefCameraLoadButton"
-    top_delta="0"
-    width="115">
-    <button.commit_callback
-      function="Pref.PrefLoad"
-	  parameter="camera"/>
-  </button>
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Delete preset..."
-    layout="topleft"
-    left_pad="10"
-    name="PrefCameraDeleteButton"
-    top_delta="0"
-    width="115">
-    <button.commit_callback
-      function="Pref.PrefDelete"
-	  parameter="camera"/>
-  </button>
-
-  <view_border
-    bevel_style="in"
-    follows="left|top|right"
-    height="0"
-    layout="topleft"
-    left="10"
-    top_pad="5"
-    width="500"/>
-
   <icon
    follows="left|top"
    height="18"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_view.xml b/indra/newview/skins/default/xui/en/panel_preferences_view.xml
new file mode 100644
index 0000000000..a7a69eb829
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/panel_preferences_view.xml
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel
+ border="true"
+ follows="left|top|right|bottom"
+ height="418"
+ label="View"
+ layout="topleft"
+ left="102"
+ name="view_panel"
+ top="1"
+ width="517">
+
+  <icon
+     follows="left|top"
+     height="18"
+     image_name="Cam_FreeCam_Off"
+     layout="topleft"
+     name="camera_icon"
+     mouse_opaque="false"
+     visible="true"
+     width="18"
+     left="30"
+     top="4"/>
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left="80"
+    top_delta="0"
+    width="100">
+      Preset in use:
+  </text>
+
+  <text
+    follows="top|left|right"
+    height="16"
+    layout="topleft"
+    left_delta="100"
+    name="preset_camera_text"
+    width="120">
+      (None)
+  </text>
+
+  <slider
+   can_edit_text="true"
+   control_name="CameraAngle"
+   decimal_digits="2"
+   follows="left|top"
+   height="16"
+   top_pad="5"
+   increment="0.025"
+   initial_value="1.57"
+   layout="topleft"
+   label_width="100"
+   label="View angle"
+   left="80"
+   max_val="2.97"
+   min_val="0.17"
+   name="camera_fov"
+   show_text="false"
+   width="240" />
+  <slider
+   can_edit_text="true"
+   control_name="CameraOffsetScale"
+   decimal_digits="2"
+   follows="left|top"
+   height="16"
+   increment="0.025"
+   initial_value="1"
+   layout="topleft"
+   label="Distance"
+   left_delta="0"
+   label_width="100"
+   max_val="3"
+   min_val="0.5"
+   name="camera_offset_scale"
+   show_text="false"
+   width="240"
+   top_pad="5"/>
+  <text
+  follows="left|top"
+  type="string"
+  length="1"
+  height="10"
+  left="80"
+  name="heading2"
+  width="200"
+  top_pad="5">
+    Automatic position for:
+  </text>
+
+  <spinner
+   control_name="CameraOpacity"
+   decimal_digits="1"
+   follows="top|left|right"
+   height="24"
+   max_val="1.0"
+   min_val="0.0"
+   increment="0.1"
+   initial_value="1.0"
+   label="Camera controls opacity:"
+   label_width="180"
+   layout="topleft"
+   top_pad="-10"
+   left_pad="10"
+   width="220" />
+
+  <check_box
+     control_name="EditCameraMovement"
+     height="20"
+     follows="left|top"
+     label="Build/Edit"
+     layout="topleft"
+     left="100"
+     name="edit_camera_movement"
+     tool_tip="Use automatic camera positioning when entering and exiting edit mode"
+     width="280"
+     top_pad="-10" />
+  <check_box
+   control_name="AppearanceCameraMovement"
+   follows="left|top"
+   height="16"
+   label="Appearance"
+   layout="topleft"
+   name="appearance_camera_movement"
+   tool_tip="Use automatic camera positioning while in edit mode"
+   width="242" />
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Advanced..."
+    layout="topleft"
+    left_pad="-102"
+    name="PreferencesViewAdvanced"
+    tool_tip="Adjust camera positioning"
+    width="115">
+    <button.commit_callback
+     function="Floater.Show"
+     parameter="prefs_view_advanced" />
+  </button>  
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Save settings as a preset..."
+    layout="topleft"
+    left="30"
+    name="PrefCameraSaveButton"
+    top_pad="10"
+    width="200">
+    <button.commit_callback
+      function="Pref.PrefSave"
+      parameter="camera" />
+  </button>
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Load preset..."
+    layout="topleft"
+    left_pad="10"
+    name="PrefCameraLoadButton"
+    top_delta="0"
+    width="115">
+    <button.commit_callback
+      function="Pref.PrefLoad"
+	  parameter="camera"/>
+  </button>
+
+  <button
+    follows="top|left"
+    height="23"
+    label="Delete preset..."
+    layout="topleft"
+    left_pad="10"
+    name="PrefCameraDeleteButton"
+    top_delta="0"
+    width="115">
+    <button.commit_callback
+      function="Pref.PrefDelete"
+	  parameter="camera"/>
+  </button>
+</panel>
-- 
cgit v1.2.3


From 7bf2a8c0a8b3baeade7ce5c828c4cfec41bef085 Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Tue, 30 Jan 2018 11:28:24 -0500
Subject: replace space in "Pennys Gamer" settings with an underscore

---
 indra/newview/app_settings/camera/Pennys Gamer.xml | 115 ---------------------
 indra/newview/app_settings/camera/Pennys_Gamer.xml | 115 +++++++++++++++++++++
 2 files changed, 115 insertions(+), 115 deletions(-)
 delete mode 100644 indra/newview/app_settings/camera/Pennys Gamer.xml
 create mode 100644 indra/newview/app_settings/camera/Pennys_Gamer.xml

diff --git a/indra/newview/app_settings/camera/Pennys Gamer.xml b/indra/newview/app_settings/camera/Pennys Gamer.xml
deleted file mode 100644
index 5d249153a0..0000000000
--- a/indra/newview/app_settings/camera/Pennys Gamer.xml	
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-3.0</real>
-                <real>0.0</real>
-                <real>-0.2</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>0.9</real>
-                <real>0.0</real>
-                <real>0.2</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
diff --git a/indra/newview/app_settings/camera/Pennys_Gamer.xml b/indra/newview/app_settings/camera/Pennys_Gamer.xml
new file mode 100644
index 0000000000..5d249153a0
--- /dev/null
+++ b/indra/newview/app_settings/camera/Pennys_Gamer.xml
@@ -0,0 +1,115 @@
+<llsd>
+    <map>
+    <key>AppearanceCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    <key>CameraAngle</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera field of view angle (Radians)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1.047197551</real>
+        </map>
+    <key>CameraOffsetBuild</key>
+        <map>
+        <key>Comment</key>
+            <string>Default camera position relative to focus point when entering build mode</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-6</real>
+                <real>0</real>
+                <real>6</real>
+            </array>
+        </map>
+    <key>CameraOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial camera offset from avatar in Rear View</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3</string>
+        <key>Value</key>
+            <array>
+                <real>-3.0</real>
+                <real>0.0</real>
+                <real>-0.2</real>
+            </array>
+        </map>
+    <key>CameraOffsetScale</key>
+        <map>
+        <key>Comment</key>
+            <string>Scales the default offset</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>1</real>
+        </map>
+    <key>EditCameraMovement</key>
+        <map>
+        <key>Comment</key>
+            <string>When entering build mode, camera moves up above avatar</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>0</integer>
+        </map>
+    <key>FocusOffsetRearView</key>
+        <map>
+        <key>Comment</key>
+            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Vector3D</string>
+        <key>Value</key>
+            <array>
+                <real>0.9</real>
+                <real>0.0</real>
+                <real>0.2</real>
+            </array>
+        </map>
+    <key>PresetCameraActive</key>
+        <map>
+        <key>Comment</key>
+            <string>Name of currently selected preference</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>String</string>
+        <key>Value</key>
+            <string>Default</string>
+        </map>
+    <key>TrackFocusObject</key>
+        <map>
+        <key>Comment</key>
+            <string>Camera tracks last object zoomed on</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>Boolean</string>
+        <key>Value</key>
+            <integer>1</integer>
+        </map>
+    </map>
+</llsd>
-- 
cgit v1.2.3


From bff875d25f03501ddad9a2be7cc45d1c949d83e0 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Fri, 2 Feb 2018 10:39:59 -0500
Subject: STORM-2145 Camera controls opacity is now working

---
 doc/contributions.txt             | 2 ++
 indra/llui/lluictrl.h             | 3 ++-
 indra/newview/llfloatercamera.cpp | 9 +++++++++
 indra/newview/llfloatercamera.h   | 2 ++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/doc/contributions.txt b/doc/contributions.txt
index 68b87a41f5..8909084587 100755
--- a/doc/contributions.txt
+++ b/doc/contributions.txt
@@ -217,6 +217,7 @@ Ansariel Hiller
 	MAINT-6519
 	MAINT-7899
 	STORM-2105
+	STORM-2145
 Aralara Rajal
 Arare Chantilly
 	CHUIBUG-191
@@ -770,6 +771,7 @@ Jonathan Yap
 	STORM-2100
 	STORM-2104
 	STORM-2142
+	STORM-2145
 Kadah Coba
 	STORM-1060
     STORM-1843
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 550bee5c70..e53ecd30c2 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -212,7 +212,8 @@ public:
 
 	virtual void	setColor(const LLColor4& color);
 
-	F32 			getCurrentTransparency();
+	// Ansariel: Changed to virtual. We might want to change the transparency ourself!
+	virtual F32	getCurrentTransparency();
 
 	void				setTransparencyType(ETypeTransparency type);
 	ETypeTransparency	getTransparencyType() const {return mTransparencyType;}
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 5bebebf21f..c12ccb386e 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -378,6 +378,15 @@ BOOL LLFloaterCamera::postBuild()
 	return LLFloater::postBuild();
 }
 
+F32	LLFloaterCamera::getCurrentTransparency()
+{
+
+	static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity");
+	static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency");
+	return llmin(camera_opacity(), active_floater_transparency());
+
+}
+
 void LLFloaterCamera::onViewButtonClick(const LLSD& user_data)
 {
 	// bring up the prefs floater
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 3601813bc1..481e9aec1b 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -91,6 +91,8 @@ private:
 
 	/*virtual*/ BOOL postBuild();
 
+	F32 getCurrentTransparency();
+
 	void onViewButtonClick(const LLSD& user_data);
 
 	ECameraControlMode determineMode();
-- 
cgit v1.2.3


From f0ae109b696671c5773a5084a7329d0b164b7735 Mon Sep 17 00:00:00 2001
From: Jonathan Yap <jhwelch@gmail.com>
Date: Fri, 2 Feb 2018 12:36:15 -0500
Subject: STORM-2145 Tiny optimizations

---
 indra/newview/llfloaterpreferenceviewadvanced.cpp | 60 +++--------------------
 indra/newview/llfloaterpreferenceviewadvanced.h   |  4 +-
 2 files changed, 10 insertions(+), 54 deletions(-)

diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
index 055c6f2232..791ff79d87 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -70,62 +70,18 @@ BOOL LLFloaterPreferenceViewAdvanced::postBuild()
 	return TRUE;
 }
 
-void LLFloaterPreferenceViewAdvanced::updateCameraControl(LLVector3 vector)
+void LLFloaterPreferenceViewAdvanced::updateCameraControl(const LLVector3& vector)
 {
-	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("camera_x");
-	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("camera_y");
-	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("camera_z");
-
-	if (!spinnerx || !spinnery || !spinnerz)
-	{
-		LL_WARNS() << "Could not find all desired UI camera elements"
-			<< LL_ENDL;
-		return;
-	}
-
-	if (!spinnerx->hasFocus())
-	{
-		spinnerx->setValue(vector[VX]);
-	}
-
-	if (!spinnery->hasFocus())
-	{
-		spinnery->setValue(vector[VY]);
-	}
-
-	if (!spinnerz->hasFocus())
-	{
-		spinnerz->setValue(vector[VZ]);
-	}
+	getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
+	getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]);
+	getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]);
 }
 
-void LLFloaterPreferenceViewAdvanced::updateFocusControl(LLVector3d vector3d)
+void LLFloaterPreferenceViewAdvanced::updateFocusControl(const LLVector3d& vector3d)
 {
-	LLSpinCtrl* spinnerx = getChild<LLSpinCtrl>("focus_x");
-	LLSpinCtrl* spinnery = getChild<LLSpinCtrl>("focus_y");
-	LLSpinCtrl* spinnerz = getChild<LLSpinCtrl>("focus_z");
-
-	if (!spinnerx || !spinnery || !spinnerz)
-	{
-		LL_WARNS() << "Could not find all desired UI focus elements"
-			<< LL_ENDL;
-		return;
-	}
-
-	if (!spinnerx->hasFocus())
-	{
-		spinnerx->setValue(vector3d[VX]);
-	}
-
-	if (!spinnery->hasFocus())
-	{
-		spinnery->setValue(vector3d[VY]);
-	}
-
-	if (!spinnerz->hasFocus())
-	{
-		spinnerz->setValue(vector3d[VZ]);
-	}
+	getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]);
+	getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]);
+	getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]);
 }
 
  void LLFloaterPreferenceViewAdvanced::draw()
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h
index 5b63770059..8f4b594605 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.h
+++ b/indra/newview/llfloaterpreferenceviewadvanced.h
@@ -43,8 +43,8 @@ public:
 	void onCommitSettings();
 	void onClickCancel();
 	void onClickOk();
-	void updateCameraControl(LLVector3 vector);
-	void updateFocusControl(LLVector3d vector3d);
+	void updateCameraControl(const LLVector3& vector);
+	void updateFocusControl(const LLVector3d& vector3d);
 
 private:
 	virtual ~LLFloaterPreferenceViewAdvanced();
-- 
cgit v1.2.3


From 34d595716bb9224cc4f173bd968db86bc88cbaed Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Thu, 21 Jun 2018 20:07:59 +0100
Subject: Fix mismerge of main CMakeLists.txt which dropped new
 floaterviewadvanced .cpp

---
 indra/newview/CMakeLists.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 87783c224e..789112c819 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -278,6 +278,7 @@ set(viewer_SOURCE_FILES
     llfloaterperms.cpp
     llfloaterpostprocess.cpp
     llfloaterpreference.cpp
+    llfloaterpreferenceviewadvanced.cpp
     llfloaterpreviewtrash.cpp
     llfloaterproperties.cpp
     llfloaterregiondebugconsole.cpp
@@ -466,6 +467,7 @@ set(viewer_SOURCE_FILES
     llpanelplaceprofile.cpp
     llpanelplaces.cpp
     llpanelplacestab.cpp
+    llpanelpresetscamerapulldown.cpp
     llpanelpresetspulldown.cpp
     llpanelprimmediacontrols.cpp
     llpanelprofile.cpp
-- 
cgit v1.2.3


From 4789fb3819a54954c9912a6c8442d8a37b594d28 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Fri, 3 Aug 2018 19:25:54 +0100
Subject: Fix merge fail in llagentcamera.cpp

---
 indra/newview/llagentcamera.cpp | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index bc92b5e1d9..bbe1354fc3 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -76,6 +76,8 @@ const F32 AVATAR_ZOOM_MIN_Y_FACTOR = 0.7f;
 const F32 AVATAR_ZOOM_MIN_Z_FACTOR = 1.15f;
 
 const F32 MAX_CAMERA_DISTANCE_FROM_AGENT = 50.f;
+const F32 MAX_CAMERA_DISTANCE_FROM_OBJECT = 496.f;
+const F32 CAMERA_FUDGE_FROM_OBJECT = 16.f;
 
 const F32 MAX_CAMERA_SMOOTH_DISTANCE = 50.0f;
 
@@ -738,10 +740,7 @@ F32 LLAgentCamera::getCameraZoomFraction()
 	else
 	{
 		F32 min_zoom;
-		const F32 DIST_FUDGE = 16.f; // meters
-		F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, 
-								LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE,
-								MAX_CAMERA_DISTANCE_FROM_AGENT);
+		F32 max_zoom = getCameraMaxZoomDistance();
 
 		F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
 		if (mFocusObject.notNull())
@@ -787,10 +786,7 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction)
 	else
 	{
 		F32 min_zoom = LAND_MIN_ZOOM;
-		const F32 DIST_FUDGE = 16.f; // meters
-		F32 max_zoom = llmin(mDrawDistance - DIST_FUDGE, 
-								LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE,
-								MAX_CAMERA_DISTANCE_FROM_AGENT);
+		F32 max_zoom = getCameraMaxZoomDistance();
 
 		if (mFocusObject.notNull())
 		{
@@ -909,10 +905,7 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction)
 
 	new_distance = llmax(new_distance, min_zoom); 
 
-	// Don't zoom too far back
-	const F32 DIST_FUDGE = 16.f; // meters
-	F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, 
-							 LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE );
+	F32 max_distance = getCameraMaxZoomDistance();
 
     max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance.  MAINT-3154
 
@@ -978,10 +971,7 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters)
 
 		new_distance = llmax(new_distance, min_zoom);
 
-		// Don't zoom too far back
-		const F32 DIST_FUDGE = 16.f; // meters
-		F32 max_distance = llmin(mDrawDistance - DIST_FUDGE, 
-								 LLWorld::getInstance()->getRegionWidthInMeters() - DIST_FUDGE );
+		F32 max_distance = getCameraMaxZoomDistance();
 
 		if (new_distance > max_distance)
 		{
-- 
cgit v1.2.3


From 2069891d736544da3c1460a5b63113b75fe7d61e Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Wed, 28 Nov 2018 14:33:10 -0800
Subject: Remove windows pragma for optimization disable.

---
 indra/newview/lldrawpoolwater.cpp | 4 ----
 indra/newview/llvosky.cpp         | 4 ----
 2 files changed, 8 deletions(-)

diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 9316890156..df06ad31e6 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -48,10 +48,6 @@
 #include "llviewershadermgr.h"
 #include "llwaterparammanager.h"
 
-#if LL_WINDOWS
-#pragma optimize("", off)
-#endif
-
 const LLUUID TRANSPARENT_WATER_TEXTURE("2bfd3884-7e27-69b9-ba3a-3e673f680004");
 const LLUUID OPAQUE_WATER_TEXTURE("43c32285-d658-1793-c123-bf86315de055");
 
diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp
index 54ec238fde..c131cb886f 100644
--- a/indra/newview/llvosky.cpp
+++ b/indra/newview/llvosky.cpp
@@ -54,10 +54,6 @@
 #undef min
 #undef max
 
-#if LL_WINDOWS
-#pragma optimize("", off)
-#endif
-
 static const S32 NUM_TILES_X = 8;
 static const S32 NUM_TILES_Y = 4;
 static const S32 NUM_TILES = NUM_TILES_X * NUM_TILES_Y;
-- 
cgit v1.2.3


From 3e560022459bf3534b873a7f6499dfb5eb75a7d9 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Mon, 11 Mar 2019 08:11:09 -0700
Subject: Tabs -> spaces.

---
 indra/llcorehttp/tests/llcorehttp_test.cpp        |  148 +-
 indra/llui/llfloater.cpp                          | 5446 ++++++++++-----------
 indra/llui/lluictrl.h                             |  518 +-
 indra/llui/tests/llurlentry_stub.cpp              |  128 +-
 indra/newview/llagentcamera.cpp                   | 4578 ++++++++---------
 indra/newview/llagentcamera.h                     |  564 +--
 indra/newview/lldrawpoolwater.cpp                 | 1178 ++---
 indra/newview/llfloatercamera.cpp                 |  670 +--
 indra/newview/llfloatercamera.h                   |  166 +-
 indra/newview/llfloaterdeleteprefpreset.cpp       |   66 +-
 indra/newview/llfloaterloadprefpreset.cpp         |   50 +-
 indra/newview/llfloaterpreference.cpp             | 4160 ++++++++--------
 indra/newview/llfloaterpreference.h               |  474 +-
 indra/newview/llfloaterpreferenceviewadvanced.cpp |   74 +-
 indra/newview/llfloaterpreferenceviewadvanced.h   |   28 +-
 indra/newview/llfloatersaveprefpreset.cpp         |   86 +-
 indra/newview/llnavigationbar.h                   |  178 +-
 indra/newview/llpanelpresetscamerapulldown.cpp    |  192 +-
 indra/newview/llpanelpresetscamerapulldown.h      |   30 +-
 indra/newview/llpresetsmanager.cpp                |  648 +--
 indra/newview/llpresetsmanager.h                  |   62 +-
 indra/newview/llstatusbar.cpp                     |  752 +--
 indra/newview/llstatusbar.h                       |  118 +-
 indra/newview/llviewerfloaterreg.cpp              |  360 +-
 24 files changed, 10337 insertions(+), 10337 deletions(-)

diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp
index a310fc0508..35bda78463 100755
--- a/indra/llcorehttp/tests/llcorehttp_test.cpp
+++ b/indra/llcorehttp/tests/llcorehttp_test.cpp
@@ -51,26 +51,26 @@
 unsigned long ssl_thread_id_callback(void);
 void ssl_locking_callback(int mode, int type, const char * file, int line);
 
-#if 0	// lltut provides main and runner
+#if 0   // lltut provides main and runner
 
 namespace tut
 {
-	test_runner_singleton runner;
+    test_runner_singleton runner;
 }
 
 int main()
 {
-	curl_global_init(CURL_GLOBAL_ALL);
+    curl_global_init(CURL_GLOBAL_ALL);
 
-	// *FIXME:  Need threaded/SSL curl setup here.
-	
-	tut::reporter reporter;
+    // *FIXME:  Need threaded/SSL curl setup here.
+    
+    tut::reporter reporter;
 
-	tut::runner.get().set_callback(&reporter);
-	tut::runner.get().run_tests();
-	return !reporter.all_ok();
+    tut::runner.get().set_callback(&reporter);
+    tut::runner.get().run_tests();
+    return !reporter.all_ok();
 
-	curl_global_cleanup();
+    curl_global_cleanup();
 }
 
 #endif // 0
@@ -80,97 +80,97 @@ LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
 
 void init_curl()
 {
-	curl_global_init(CURL_GLOBAL_ALL);
-
-	ssl_mutex_count = CRYPTO_num_locks();
-	if (ssl_mutex_count > 0)
-	{
-		ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
-		
-		for (int i(0); i < ssl_mutex_count; ++i)
-		{
-			ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
-		}
-
-		CRYPTO_set_locking_callback(ssl_locking_callback);
-		CRYPTO_set_id_callback(ssl_thread_id_callback);
-	}
-
-	LLProxy::getInstance();
+    curl_global_init(CURL_GLOBAL_ALL);
+
+    ssl_mutex_count = CRYPTO_num_locks();
+    if (ssl_mutex_count > 0)
+    {
+        ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
+        
+        for (int i(0); i < ssl_mutex_count; ++i)
+        {
+            ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
+        }
+
+        CRYPTO_set_locking_callback(ssl_locking_callback);
+        CRYPTO_set_id_callback(ssl_thread_id_callback);
+    }
+
+    LLProxy::getInstance();
 }
 
 
 void term_curl()
 {
-	SUBSYSTEM_CLEANUP(LLProxy);
-	
-	CRYPTO_set_locking_callback(NULL);
-	for (int i(0); i < ssl_mutex_count; ++i)
-	{
-		delete ssl_mutex_list[i];
-	}
-	delete [] ssl_mutex_list;
+    SUBSYSTEM_CLEANUP(LLProxy);
+    
+    CRYPTO_set_locking_callback(NULL);
+    for (int i(0); i < ssl_mutex_count; ++i)
+    {
+        delete ssl_mutex_list[i];
+    }
+    delete [] ssl_mutex_list;
 }
 
 
 unsigned long ssl_thread_id_callback(void)
 {
 #if defined(WIN32)
-	return (unsigned long) GetCurrentThread();
+    return (unsigned long) GetCurrentThread();
 #else
-	return (unsigned long) pthread_self();
+    return (unsigned long) pthread_self();
 #endif
 }
 
 
 void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
 {
-	if (type >= 0 && type < ssl_mutex_count)
-	{
-		if (mode & CRYPTO_LOCK)
-		{
-			ssl_mutex_list[type]->lock();
-		}
-		else
-		{
-			ssl_mutex_list[type]->unlock();
-		}
-	}
+    if (type >= 0 && type < ssl_mutex_count)
+    {
+        if (mode & CRYPTO_LOCK)
+        {
+            ssl_mutex_list[type]->lock();
+        }
+        else
+        {
+            ssl_mutex_list[type]->unlock();
+        }
+    }
 }
 
 
 std::string get_base_url()
 {
-	const char * env(getenv("LL_TEST_PORT"));
-
-	if (! env)
-	{
-		std::cerr << "LL_TEST_PORT environment variable missing." << std::endl;
-		std::cerr << "Test expects to run in test_llcorehttp_peer.py script." << std::endl;
-		tut::ensure("LL_TEST_PORT set in environment", NULL != env);
-	}
-
-	int port(atoi(env));
-	std::ostringstream out;
-	out << "http://localhost:" << port << "/";
-	return out.str();
+    const char * env(getenv("LL_TEST_PORT"));
+
+    if (! env)
+    {
+        std::cerr << "LL_TEST_PORT environment variable missing." << std::endl;
+        std::cerr << "Test expects to run in test_llcorehttp_peer.py script." << std::endl;
+        tut::ensure("LL_TEST_PORT set in environment", NULL != env);
+    }
+
+    int port(atoi(env));
+    std::ostringstream out;
+    out << "http://localhost:" << port << "/";
+    return out.str();
 }
 
 
 void stop_thread(LLCore::HttpRequest * req)
 {
-	if (req)
-	{
-		req->requestStopThread(LLCore::HttpHandler::ptr_t());
-	
-		int count = 0;
-		int limit = 10;
-		while (count++ < limit && ! HttpService::isStopped())
-		{
-			req->update(1000);
-			usleep(100000);
-		}
-	}
+    if (req)
+    {
+        req->requestStopThread(LLCore::HttpHandler::ptr_t());
+    
+        int count = 0;
+        int limit = 10;
+        while (count++ < limit && ! HttpService::isStopped())
+        {
+            req->update(1000);
+            usleep(100000);
+        }
+    }
 }
 
-	
+    
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 2dcc62ce79..6b325f6232 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -43,7 +43,7 @@
 #include "llresizebar.h"
 #include "llresizehandle.h"
 #include "llkeyboard.h"
-#include "llmenugl.h"	// MENU_BAR_HEIGHT
+#include "llmenugl.h"   // MENU_BAR_HEIGHT
 #include "llmodaldialog.h"
 #include "lltextbox.h"
 #include "llresmgr.h"
@@ -65,23 +65,23 @@ const S32 TABBED_FLOATER_OFFSET = 0;
 
 namespace LLInitParam
 {
-	void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
-	{
-		declare("relative",   LLFloaterEnums::POSITIONING_RELATIVE);
-		declare("cascading",  LLFloaterEnums::POSITIONING_CASCADING);
-		declare("centered",   LLFloaterEnums::POSITIONING_CENTERED);
-		declare("specified",  LLFloaterEnums::POSITIONING_SPECIFIED);
-	}
+    void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
+    {
+        declare("relative",   LLFloaterEnums::POSITIONING_RELATIVE);
+        declare("cascading",  LLFloaterEnums::POSITIONING_CASCADING);
+        declare("centered",   LLFloaterEnums::POSITIONING_CENTERED);
+        declare("specified",  LLFloaterEnums::POSITIONING_SPECIFIED);
+    }
 }
 
-std::string	LLFloater::sButtonNames[BUTTON_COUNT] = 
+std::string LLFloater::sButtonNames[BUTTON_COUNT] = 
 {
-	"llfloater_close_btn",		//BUTTON_CLOSE
-	"llfloater_restore_btn",	//BUTTON_RESTORE
-	"llfloater_minimize_btn",	//BUTTON_MINIMIZE
-	"llfloater_tear_off_btn",	//BUTTON_TEAR_OFF
-	"llfloater_dock_btn",		//BUTTON_DOCK
-	"llfloater_help_btn"		//BUTTON_HELP
+    "llfloater_close_btn",      //BUTTON_CLOSE
+    "llfloater_restore_btn",    //BUTTON_RESTORE
+    "llfloater_minimize_btn",   //BUTTON_MINIMIZE
+    "llfloater_tear_off_btn",   //BUTTON_TEAR_OFF
+    "llfloater_dock_btn",       //BUTTON_DOCK
+    "llfloater_help_btn"        //BUTTON_HELP
 };
 
 std::string LLFloater::sButtonToolTips[BUTTON_COUNT];
@@ -89,29 +89,29 @@ std::string LLFloater::sButtonToolTips[BUTTON_COUNT];
 std::string LLFloater::sButtonToolTipsIndex[BUTTON_COUNT]=
 {
 #ifdef LL_DARWIN
-	"BUTTON_CLOSE_DARWIN",	//"Close (Cmd-W)",	//BUTTON_CLOSE
+    "BUTTON_CLOSE_DARWIN",  //"Close (Cmd-W)",  //BUTTON_CLOSE
 #else
-	"BUTTON_CLOSE_WIN",		//"Close (Ctrl-W)",	//BUTTON_CLOSE
+    "BUTTON_CLOSE_WIN",     //"Close (Ctrl-W)", //BUTTON_CLOSE
 #endif
-	"BUTTON_RESTORE",		//"Restore",	//BUTTON_RESTORE
-	"BUTTON_MINIMIZE",		//"Minimize",	//BUTTON_MINIMIZE
-	"BUTTON_TEAR_OFF",		//"Tear Off",	//BUTTON_TEAR_OFF
-	"BUTTON_DOCK",
-	"BUTTON_HELP"
+    "BUTTON_RESTORE",       //"Restore",    //BUTTON_RESTORE
+    "BUTTON_MINIMIZE",      //"Minimize",   //BUTTON_MINIMIZE
+    "BUTTON_TEAR_OFF",      //"Tear Off",   //BUTTON_TEAR_OFF
+    "BUTTON_DOCK",
+    "BUTTON_HELP"
 };
 
 LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
 {
-	LLFloater::onClickClose,	//BUTTON_CLOSE
-	LLFloater::onClickMinimize, //BUTTON_RESTORE
-	LLFloater::onClickMinimize, //BUTTON_MINIMIZE
-	LLFloater::onClickTearOff,	//BUTTON_TEAR_OFF
-	LLFloater::onClickDock,		//BUTTON_DOCK
-	LLFloater::onClickHelp		//BUTTON_HELP
+    LLFloater::onClickClose,    //BUTTON_CLOSE
+    LLFloater::onClickMinimize, //BUTTON_RESTORE
+    LLFloater::onClickMinimize, //BUTTON_MINIMIZE
+    LLFloater::onClickTearOff,  //BUTTON_TEAR_OFF
+    LLFloater::onClickDock,     //BUTTON_DOCK
+    LLFloater::onClickHelp      //BUTTON_HELP
 };
 
 LLMultiFloater* LLFloater::sHostp = NULL;
-BOOL			LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting
+BOOL            LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting
 
 LLFloaterView* gFloaterView = NULL;
 
@@ -128,105 +128,105 @@ LLFloaterView* gFloaterView = NULL;
 //static
 bool LLFloater::KeyCompare::compare(const LLSD& a, const LLSD& b)
 {
-	if (a.type() != b.type())
-	{
-		//LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL;
-		return false;
-	}
-	else if (a.isUndefined())
-		return false;
-	else if (a.isInteger())
-		return a.asInteger() < b.asInteger();
-	else if (a.isReal())
-		return a.asReal() < b.asReal();
-	else if (a.isString())
-		return a.asString() < b.asString();
-	else if (a.isUUID())
-		return a.asUUID() < b.asUUID();
-	else if (a.isDate())
-		return a.asDate() < b.asDate();
-	else if (a.isURI())
-		return a.asString() < b.asString(); // compare URIs as strings
-	else if (a.isBoolean())
-		return a.asBoolean() < b.asBoolean();
-	else
-		return false; // no valid operation for Binary
+    if (a.type() != b.type())
+    {
+        //LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL;
+        return false;
+    }
+    else if (a.isUndefined())
+        return false;
+    else if (a.isInteger())
+        return a.asInteger() < b.asInteger();
+    else if (a.isReal())
+        return a.asReal() < b.asReal();
+    else if (a.isString())
+        return a.asString() < b.asString();
+    else if (a.isUUID())
+        return a.asUUID() < b.asUUID();
+    else if (a.isDate())
+        return a.asDate() < b.asDate();
+    else if (a.isURI())
+        return a.asString() < b.asString(); // compare URIs as strings
+    else if (a.isBoolean())
+        return a.asBoolean() < b.asBoolean();
+    else
+        return false; // no valid operation for Binary
 }
 |*==========================================================================*/
 
 bool LLFloater::KeyCompare::equate(const LLSD& a, const LLSD& b)
 {
-	return llsd_equals(a, b);
+    return llsd_equals(a, b);
 }
 
 //************************************
 
 LLFloater::Params::Params()
-:	title("title"),
-	short_title("short_title"),
-	single_instance("single_instance", false),
-	reuse_instance("reuse_instance", false),
-	can_resize("can_resize", false),
-	can_minimize("can_minimize", true),
-	can_close("can_close", true),
-	can_drag_on_left("can_drag_on_left", false),
-	can_tear_off("can_tear_off", true),
-	save_dock_state("save_dock_state", false),
-	save_rect("save_rect", false),
-	save_visibility("save_visibility", false),
-	can_dock("can_dock", false),
-	show_title("show_title", true),
-	positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE),
-	header_height("header_height", 0),
-	legacy_header_height("legacy_header_height", 0),
-	close_image("close_image"),
-	restore_image("restore_image"),
-	minimize_image("minimize_image"),
-	tear_off_image("tear_off_image"),
-	dock_image("dock_image"),
-	help_image("help_image"),
-	close_pressed_image("close_pressed_image"),
-	restore_pressed_image("restore_pressed_image"),
-	minimize_pressed_image("minimize_pressed_image"),
-	tear_off_pressed_image("tear_off_pressed_image"),
-	dock_pressed_image("dock_pressed_image"),
-	help_pressed_image("help_pressed_image"),
-	open_callback("open_callback"),
-	close_callback("close_callback"),
-	follows("follows")
-{
-	changeDefault(visible, false);
+:   title("title"),
+    short_title("short_title"),
+    single_instance("single_instance", false),
+    reuse_instance("reuse_instance", false),
+    can_resize("can_resize", false),
+    can_minimize("can_minimize", true),
+    can_close("can_close", true),
+    can_drag_on_left("can_drag_on_left", false),
+    can_tear_off("can_tear_off", true),
+    save_dock_state("save_dock_state", false),
+    save_rect("save_rect", false),
+    save_visibility("save_visibility", false),
+    can_dock("can_dock", false),
+    show_title("show_title", true),
+    positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE),
+    header_height("header_height", 0),
+    legacy_header_height("legacy_header_height", 0),
+    close_image("close_image"),
+    restore_image("restore_image"),
+    minimize_image("minimize_image"),
+    tear_off_image("tear_off_image"),
+    dock_image("dock_image"),
+    help_image("help_image"),
+    close_pressed_image("close_pressed_image"),
+    restore_pressed_image("restore_pressed_image"),
+    minimize_pressed_image("minimize_pressed_image"),
+    tear_off_pressed_image("tear_off_pressed_image"),
+    dock_pressed_image("dock_pressed_image"),
+    help_pressed_image("help_pressed_image"),
+    open_callback("open_callback"),
+    close_callback("close_callback"),
+    follows("follows")
+{
+    changeDefault(visible, false);
 }
 
 
 //static 
 const LLFloater::Params& LLFloater::getDefaultParams()
 {
-	return LLUICtrlFactory::getDefaultParams<LLFloater>();
+    return LLUICtrlFactory::getDefaultParams<LLFloater>();
 }
 
 //static
 void LLFloater::initClass()
 {
-	// translate tooltips for floater buttons
-	for (S32 i = 0; i < BUTTON_COUNT; i++)
-	{
-		sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] );
-	}
+    // translate tooltips for floater buttons
+    for (S32 i = 0; i < BUTTON_COUNT; i++)
+    {
+        sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] );
+    }
 
-	LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get();
-	if (ctrl)
-	{
-		ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency));
-		updateActiveFloaterTransparency();
-	}
+    LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get();
+    if (ctrl)
+    {
+        ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency));
+        updateActiveFloaterTransparency();
+    }
 
-	ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get();
-	if (ctrl)
-	{
-		ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency));
-		updateInactiveFloaterTransparency();
-	}
+    ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get();
+    if (ctrl)
+    {
+        ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency));
+        updateInactiveFloaterTransparency();
+    }
 
 }
 
@@ -234,1998 +234,1998 @@ void LLFloater::initClass()
 static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater");
 
 LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
-:	LLPanel(),	// intentionally do not pass params here, see initFromParams
- 	mDragHandle(NULL),
-	mTitle(p.title),
-	mShortTitle(p.short_title),
-	mSingleInstance(p.single_instance),
-	mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default
-	mKey(key),
-	mCanTearOff(p.can_tear_off),
-	mCanMinimize(p.can_minimize),
-	mCanClose(p.can_close),
-	mDragOnLeft(p.can_drag_on_left),
-	mResizable(p.can_resize),
-	mPositioning(p.positioning),
-	mMinWidth(p.min_width),
-	mMinHeight(p.min_height),
-	mHeaderHeight(p.header_height),
-	mLegacyHeaderHeight(p.legacy_header_height),
-	mMinimized(FALSE),
-	mForeground(FALSE),
-	mFirstLook(TRUE),
-	mButtonScale(1.0f),
-	mAutoFocus(TRUE), // automatically take focus when opened
-	mCanDock(false),
-	mDocked(false),
-	mTornOff(false),
-	mHasBeenDraggedWhileMinimized(FALSE),
-	mPreviousMinimizedBottom(0),
-	mPreviousMinimizedLeft(0),
-	mMinimizeSignal(NULL)
-//	mNotificationContext(NULL)
-{
-	mPosition.setFloater(*this);
-//	mNotificationContext = new LLFloaterNotificationContext(getHandle());
-
-	// Clicks stop here.
-	setMouseOpaque(TRUE);
-	
-	// Floaters always draw their background, unlike every other panel.
-	setBackgroundVisible(TRUE);
-
-	// Floaters start not minimized.  When minimized, they save their
-	// prior rectangle to be used on restore.
-	mExpandedRect.set(0,0,0,0);
-	
-	memset(mButtonsEnabled, 0, BUTTON_COUNT * sizeof(bool));
-	memset(mButtons, 0, BUTTON_COUNT * sizeof(LLButton*));
-	
-	addDragHandle();
-	addResizeCtrls();
-	
-	initFromParams(p);
-	
-	initFloater(p);
+:   LLPanel(),  // intentionally do not pass params here, see initFromParams
+    mDragHandle(NULL),
+    mTitle(p.title),
+    mShortTitle(p.short_title),
+    mSingleInstance(p.single_instance),
+    mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default
+    mKey(key),
+    mCanTearOff(p.can_tear_off),
+    mCanMinimize(p.can_minimize),
+    mCanClose(p.can_close),
+    mDragOnLeft(p.can_drag_on_left),
+    mResizable(p.can_resize),
+    mPositioning(p.positioning),
+    mMinWidth(p.min_width),
+    mMinHeight(p.min_height),
+    mHeaderHeight(p.header_height),
+    mLegacyHeaderHeight(p.legacy_header_height),
+    mMinimized(FALSE),
+    mForeground(FALSE),
+    mFirstLook(TRUE),
+    mButtonScale(1.0f),
+    mAutoFocus(TRUE), // automatically take focus when opened
+    mCanDock(false),
+    mDocked(false),
+    mTornOff(false),
+    mHasBeenDraggedWhileMinimized(FALSE),
+    mPreviousMinimizedBottom(0),
+    mPreviousMinimizedLeft(0),
+    mMinimizeSignal(NULL)
+//  mNotificationContext(NULL)
+{
+    mPosition.setFloater(*this);
+//  mNotificationContext = new LLFloaterNotificationContext(getHandle());
+
+    // Clicks stop here.
+    setMouseOpaque(TRUE);
+    
+    // Floaters always draw their background, unlike every other panel.
+    setBackgroundVisible(TRUE);
+
+    // Floaters start not minimized.  When minimized, they save their
+    // prior rectangle to be used on restore.
+    mExpandedRect.set(0,0,0,0);
+    
+    memset(mButtonsEnabled, 0, BUTTON_COUNT * sizeof(bool));
+    memset(mButtons, 0, BUTTON_COUNT * sizeof(LLButton*));
+    
+    addDragHandle();
+    addResizeCtrls();
+    
+    initFromParams(p);
+    
+    initFloater(p);
 }
 
 // Note: Floaters constructed from XML call init() twice!
 void LLFloater::initFloater(const Params& p)
 {
-	// Close button.
-	if (mCanClose)
-	{
-		mButtonsEnabled[BUTTON_CLOSE] = TRUE;
-	}
+    // Close button.
+    if (mCanClose)
+    {
+        mButtonsEnabled[BUTTON_CLOSE] = TRUE;
+    }
 
-	// Help button: '?'
-	if ( !mHelpTopic.empty() )
-	{
-		mButtonsEnabled[BUTTON_HELP] = TRUE;
-	}
+    // Help button: '?'
+    if ( !mHelpTopic.empty() )
+    {
+        mButtonsEnabled[BUTTON_HELP] = TRUE;
+    }
 
-	// Minimize button only for top draggers
-	if ( !mDragOnLeft && mCanMinimize )
-	{
-		mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
-	}
+    // Minimize button only for top draggers
+    if ( !mDragOnLeft && mCanMinimize )
+    {
+        mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
+    }
 
-	if(mCanDock)
-	{
-		mButtonsEnabled[BUTTON_DOCK] = TRUE;
-	}
+    if(mCanDock)
+    {
+        mButtonsEnabled[BUTTON_DOCK] = TRUE;
+    }
 
-	buildButtons(p);
+    buildButtons(p);
 
-	// Floaters are created in the invisible state	
-	setVisible(FALSE);
+    // Floaters are created in the invisible state  
+    setVisible(FALSE);
 
-	if (!getParent())
-	{
-		gFloaterView->addChild(this);
-	}
+    if (!getParent())
+    {
+        gFloaterView->addChild(this);
+    }
 }
 
 void LLFloater::addDragHandle()
 {
-	if (!mDragHandle)
-	{
-		if (mDragOnLeft)
-		{
-			LLDragHandleLeft::Params p;
-			p.name("drag");
-			p.follows.flags(FOLLOWS_ALL);
-			p.label(mTitle);
-			mDragHandle = LLUICtrlFactory::create<LLDragHandleLeft>(p);
-		}
-		else // drag on top
-		{
-			LLDragHandleTop::Params p;
-			p.name("Drag Handle");
-			p.follows.flags(FOLLOWS_ALL);
-			p.label(mTitle);
-			mDragHandle = LLUICtrlFactory::create<LLDragHandleTop>(p);
-		}
-		addChild(mDragHandle);
-	}
-	layoutDragHandle();
-	applyTitle();
+    if (!mDragHandle)
+    {
+        if (mDragOnLeft)
+        {
+            LLDragHandleLeft::Params p;
+            p.name("drag");
+            p.follows.flags(FOLLOWS_ALL);
+            p.label(mTitle);
+            mDragHandle = LLUICtrlFactory::create<LLDragHandleLeft>(p);
+        }
+        else // drag on top
+        {
+            LLDragHandleTop::Params p;
+            p.name("Drag Handle");
+            p.follows.flags(FOLLOWS_ALL);
+            p.label(mTitle);
+            mDragHandle = LLUICtrlFactory::create<LLDragHandleTop>(p);
+        }
+        addChild(mDragHandle);
+    }
+    layoutDragHandle();
+    applyTitle();
 }
 
 void LLFloater::layoutDragHandle()
 {
-	static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
-	S32 close_box_size = mCanClose ? floater_close_box_size : 0;
-	
-	LLRect rect;
-	if (mDragOnLeft)
-	{
-		rect.setLeftTopAndSize(0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size);
-	}
-	else // drag on top
-	{
-		rect = getLocalRect();
-	}
-	mDragHandle->setShape(rect);
-	updateTitleButtons();
+    static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
+    S32 close_box_size = mCanClose ? floater_close_box_size : 0;
+    
+    LLRect rect;
+    if (mDragOnLeft)
+    {
+        rect.setLeftTopAndSize(0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size);
+    }
+    else // drag on top
+    {
+        rect = getLocalRect();
+    }
+    mDragHandle->setShape(rect);
+    updateTitleButtons();
 }
 
 // static
 void LLFloater::updateActiveFloaterTransparency()
 {
-	sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency");
+    sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency");
 }
 
 // static
 void LLFloater::updateInactiveFloaterTransparency()
 {
-	sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency");
+    sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency");
 }
 
 void LLFloater::addResizeCtrls()
-{	
-	// Resize bars (sides)
-	LLResizeBar::Params p;
-	p.name("resizebar_left");
-	p.resizing_view(this);
-	p.min_size(mMinWidth);
-	p.side(LLResizeBar::LEFT);
-	mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p);
-	addChild( mResizeBar[LLResizeBar::LEFT] );
-
-	p.name("resizebar_top");
-	p.min_size(mMinHeight);
-	p.side(LLResizeBar::TOP);
-
-	mResizeBar[LLResizeBar::TOP] = LLUICtrlFactory::create<LLResizeBar>(p);
-	addChild( mResizeBar[LLResizeBar::TOP] );
-
-	p.name("resizebar_right");
-	p.min_size(mMinWidth);
-	p.side(LLResizeBar::RIGHT);	
-	mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p);
-	addChild( mResizeBar[LLResizeBar::RIGHT] );
-
-	p.name("resizebar_bottom");
-	p.min_size(mMinHeight);
-	p.side(LLResizeBar::BOTTOM);
-	mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p);
-	addChild( mResizeBar[LLResizeBar::BOTTOM] );
-
-	// Resize handles (corners)
-	LLResizeHandle::Params handle_p;
-	// handles must not be mouse-opaque, otherwise they block hover events
-	// to other buttons like the close box. JC
-	handle_p.mouse_opaque(false);
-	handle_p.min_width(mMinWidth);
-	handle_p.min_height(mMinHeight);
-	handle_p.corner(LLResizeHandle::RIGHT_BOTTOM);
-	mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-	addChild(mResizeHandle[0]);
-
-	handle_p.corner(LLResizeHandle::RIGHT_TOP);
-	mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-	addChild(mResizeHandle[1]);
-	
-	handle_p.corner(LLResizeHandle::LEFT_BOTTOM);
-	mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-	addChild(mResizeHandle[2]);
-
-	handle_p.corner(LLResizeHandle::LEFT_TOP);
-	mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-	addChild(mResizeHandle[3]);
-
-	layoutResizeCtrls();
+{   
+    // Resize bars (sides)
+    LLResizeBar::Params p;
+    p.name("resizebar_left");
+    p.resizing_view(this);
+    p.min_size(mMinWidth);
+    p.side(LLResizeBar::LEFT);
+    mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p);
+    addChild( mResizeBar[LLResizeBar::LEFT] );
+
+    p.name("resizebar_top");
+    p.min_size(mMinHeight);
+    p.side(LLResizeBar::TOP);
+
+    mResizeBar[LLResizeBar::TOP] = LLUICtrlFactory::create<LLResizeBar>(p);
+    addChild( mResizeBar[LLResizeBar::TOP] );
+
+    p.name("resizebar_right");
+    p.min_size(mMinWidth);
+    p.side(LLResizeBar::RIGHT); 
+    mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p);
+    addChild( mResizeBar[LLResizeBar::RIGHT] );
+
+    p.name("resizebar_bottom");
+    p.min_size(mMinHeight);
+    p.side(LLResizeBar::BOTTOM);
+    mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p);
+    addChild( mResizeBar[LLResizeBar::BOTTOM] );
+
+    // Resize handles (corners)
+    LLResizeHandle::Params handle_p;
+    // handles must not be mouse-opaque, otherwise they block hover events
+    // to other buttons like the close box. JC
+    handle_p.mouse_opaque(false);
+    handle_p.min_width(mMinWidth);
+    handle_p.min_height(mMinHeight);
+    handle_p.corner(LLResizeHandle::RIGHT_BOTTOM);
+    mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+    addChild(mResizeHandle[0]);
+
+    handle_p.corner(LLResizeHandle::RIGHT_TOP);
+    mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+    addChild(mResizeHandle[1]);
+    
+    handle_p.corner(LLResizeHandle::LEFT_BOTTOM);
+    mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+    addChild(mResizeHandle[2]);
+
+    handle_p.corner(LLResizeHandle::LEFT_TOP);
+    mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+    addChild(mResizeHandle[3]);
+
+    layoutResizeCtrls();
 }
 
 void LLFloater::layoutResizeCtrls()
 {
-	LLRect rect;
+    LLRect rect;
 
-	// Resize bars (sides)
-	const S32 RESIZE_BAR_THICKNESS = 3;
-	rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0);
-	mResizeBar[LLResizeBar::LEFT]->setRect(rect);
+    // Resize bars (sides)
+    const S32 RESIZE_BAR_THICKNESS = 3;
+    rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0);
+    mResizeBar[LLResizeBar::LEFT]->setRect(rect);
 
-	rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS);
-	mResizeBar[LLResizeBar::TOP]->setRect(rect);
+    rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS);
+    mResizeBar[LLResizeBar::TOP]->setRect(rect);
 
-	rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0);
-	mResizeBar[LLResizeBar::RIGHT]->setRect(rect);
+    rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0);
+    mResizeBar[LLResizeBar::RIGHT]->setRect(rect);
 
-	rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0);
-	mResizeBar[LLResizeBar::BOTTOM]->setRect(rect);
+    rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0);
+    mResizeBar[LLResizeBar::BOTTOM]->setRect(rect);
 
-	// Resize handles (corners)
-	rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0);
-	mResizeHandle[0]->setRect(rect);
+    // Resize handles (corners)
+    rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0);
+    mResizeHandle[0]->setRect(rect);
 
-	rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT);
-	mResizeHandle[1]->setRect(rect);
-	
-	rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 );
-	mResizeHandle[2]->setRect(rect);
+    rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT);
+    mResizeHandle[1]->setRect(rect);
+    
+    rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 );
+    mResizeHandle[2]->setRect(rect);
 
-	rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT );
-	mResizeHandle[3]->setRect(rect);
+    rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT );
+    mResizeHandle[3]->setRect(rect);
 }
 
 void LLFloater::enableResizeCtrls(bool enable, bool width, bool height)
 {
-	mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width);
-	mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width);
+    mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width);
+    mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width);
 
-	mResizeBar[LLResizeBar::TOP]->setVisible(enable && height);
-	mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height);
-	
-	mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width);
-	mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width);
-	
-	mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height);
-	mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height);
+    mResizeBar[LLResizeBar::TOP]->setVisible(enable && height);
+    mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height);
+    
+    mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width);
+    mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width);
+    
+    mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height);
+    mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height);
 
-	for (S32 i = 0; i < 4; ++i)
-	{
-		mResizeHandle[i]->setVisible(enable && width && height);
-		mResizeHandle[i]->setEnabled(enable && width && height);
-	}
+    for (S32 i = 0; i < 4; ++i)
+    {
+        mResizeHandle[i]->setVisible(enable && width && height);
+        mResizeHandle[i]->setEnabled(enable && width && height);
+    }
 }
 
 void LLFloater::destroy()
 {
-	// LLFloaterReg should be synchronized with "dead" floater to avoid returning dead instance before
-	// it was deleted via LLMortician::updateClass(). See EXT-8458.
-	LLFloaterReg::removeInstance(mInstanceName, mKey);
-	die();
+    // LLFloaterReg should be synchronized with "dead" floater to avoid returning dead instance before
+    // it was deleted via LLMortician::updateClass(). See EXT-8458.
+    LLFloaterReg::removeInstance(mInstanceName, mKey);
+    die();
 }
 
 // virtual
 LLFloater::~LLFloater()
 {
-	LLFloaterReg::removeInstance(mInstanceName, mKey);
-	
-	if( gFocusMgr.childHasKeyboardFocus(this))
-	{
-		// Just in case we might still have focus here, release it.
-		releaseFocus();
-	}
-
-	// This is important so that floaters with persistent rects (i.e., those
-	// created with rect control rather than an LLRect) are restored in their
-	// correct, non-minimized positions.
-	setMinimized( FALSE );
-
-	delete mDragHandle;
-	for (S32 i = 0; i < 4; i++) 
-	{
-		delete mResizeBar[i];
-		delete mResizeHandle[i];
-	}
-
-	setVisible(false); // We're not visible if we're destroyed
-	storeVisibilityControl();
-	storeDockStateControl();
-	delete mMinimizeSignal;
+    LLFloaterReg::removeInstance(mInstanceName, mKey);
+    
+    if( gFocusMgr.childHasKeyboardFocus(this))
+    {
+        // Just in case we might still have focus here, release it.
+        releaseFocus();
+    }
+
+    // This is important so that floaters with persistent rects (i.e., those
+    // created with rect control rather than an LLRect) are restored in their
+    // correct, non-minimized positions.
+    setMinimized( FALSE );
+
+    delete mDragHandle;
+    for (S32 i = 0; i < 4; i++) 
+    {
+        delete mResizeBar[i];
+        delete mResizeHandle[i];
+    }
+
+    setVisible(false); // We're not visible if we're destroyed
+    storeVisibilityControl();
+    storeDockStateControl();
+    delete mMinimizeSignal;
 }
 
 void LLFloater::storeRectControl()
 {
-	if (!mRectControl.empty())
-	{
-		getControlGroup()->setRect( mRectControl, getRect() );
-	}
-	if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
-	{
-		getControlGroup()->setF32( mPosXControl, mPosition.mX );
-	}
-	if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
-	{
-		getControlGroup()->setF32( mPosYControl, mPosition.mY );
-	}
+    if (!mRectControl.empty())
+    {
+        getControlGroup()->setRect( mRectControl, getRect() );
+    }
+    if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
+    {
+        getControlGroup()->setF32( mPosXControl, mPosition.mX );
+    }
+    if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
+    {
+        getControlGroup()->setF32( mPosYControl, mPosition.mY );
+    }
 }
 
 void LLFloater::storeVisibilityControl()
 {
-	if( !sQuitting && mVisibilityControl.size() > 1 )
-	{
-		getControlGroup()->setBOOL( mVisibilityControl, getVisible() );
-	}
+    if( !sQuitting && mVisibilityControl.size() > 1 )
+    {
+        getControlGroup()->setBOOL( mVisibilityControl, getVisible() );
+    }
 }
 
 void LLFloater::storeDockStateControl()
 {
-	if( !sQuitting && mDocStateControl.size() > 1 )
-	{
-		getControlGroup()->setBOOL( mDocStateControl, isDocked() );
-	}
+    if( !sQuitting && mDocStateControl.size() > 1 )
+    {
+        getControlGroup()->setBOOL( mDocStateControl, isDocked() );
+    }
 }
 
 // static
 std::string LLFloater::getControlName(const std::string& name, const LLSD& key)
 {
-	std::string ctrl_name = name;
+    std::string ctrl_name = name;
 
-	// Add the key to the control name if appropriate.
-	if (key.isString() && !key.asString().empty())
-	{
-		ctrl_name += "_" + key.asString();
-	}
+    // Add the key to the control name if appropriate.
+    if (key.isString() && !key.asString().empty())
+    {
+        ctrl_name += "_" + key.asString();
+    }
 
-	return ctrl_name;
+    return ctrl_name;
 }
 
 // static
-LLControlGroup*	LLFloater::getControlGroup()
+LLControlGroup* LLFloater::getControlGroup()
 {
-	// Floater size, position, visibility, etc are saved in per-account settings.
-	return LLUI::sSettingGroups["account"];
+    // Floater size, position, visibility, etc are saved in per-account settings.
+    return LLUI::sSettingGroups["account"];
 }
 
 void LLFloater::setVisible( BOOL visible )
 {
-	LLPanel::setVisible(visible); // calls onVisibilityChange()
-	if( visible && mFirstLook )
-	{
-		mFirstLook = FALSE;
-	}
+    LLPanel::setVisible(visible); // calls onVisibilityChange()
+    if( visible && mFirstLook )
+    {
+        mFirstLook = FALSE;
+    }
 
-	if( !visible )
-	{
-		LLUI::removePopup(this);
+    if( !visible )
+    {
+        LLUI::removePopup(this);
 
-		if( gFocusMgr.childHasMouseCapture( this ) )
-		{
-			gFocusMgr.setMouseCapture(NULL);
-		}
-	}
+        if( gFocusMgr.childHasMouseCapture( this ) )
+        {
+            gFocusMgr.setMouseCapture(NULL);
+        }
+    }
 
-	for(handle_set_iter_t dependent_it = mDependents.begin();
-		dependent_it != mDependents.end(); )
-	{
-		LLFloater* floaterp = dependent_it->get();
+    for(handle_set_iter_t dependent_it = mDependents.begin();
+        dependent_it != mDependents.end(); )
+    {
+        LLFloater* floaterp = dependent_it->get();
 
-		if (floaterp)
-		{
-			floaterp->setVisible(visible);
-		}
-		++dependent_it;
-	}
+        if (floaterp)
+        {
+            floaterp->setVisible(visible);
+        }
+        ++dependent_it;
+    }
 
-	storeVisibilityControl();
+    storeVisibilityControl();
 }
 
 
 void LLFloater::setIsSingleInstance(BOOL is_single_instance)
 {
-	mSingleInstance = is_single_instance;
-	if (!mIsReuseInitialized)
-	{
-		mReuseInstance = is_single_instance; // reuse single-instance floaters by default
-	}
+    mSingleInstance = is_single_instance;
+    if (!mIsReuseInitialized)
+    {
+        mReuseInstance = is_single_instance; // reuse single-instance floaters by default
+    }
 }
 
 
 // virtual
 void LLFloater::onVisibilityChange ( BOOL new_visibility )
 {
-	if (new_visibility)
-	{
-		if (getHost())
-			getHost()->setFloaterFlashing(this, FALSE);
-	}
-	LLPanel::onVisibilityChange ( new_visibility );
+    if (new_visibility)
+    {
+        if (getHost())
+            getHost()->setFloaterFlashing(this, FALSE);
+    }
+    LLPanel::onVisibilityChange ( new_visibility );
 }
 
 void LLFloater::openFloater(const LLSD& key)
 {
     LL_INFOS() << "Opening floater " << getName() << " full path: " << getPathname() << LL_ENDL;
 
-	LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string
-
-	mKey = key; // in case we need to open ourselves again
-	
-	if (getSoundFlags() != SILENT 
-	// don't play open sound for hosted (tabbed) windows
-		&& !getHost() 
-		&& !getFloaterHost()
-		&& (!getVisible() || isMinimized()))
-	{
-		make_ui_sound("UISndWindowOpen");
-	}
-
-	//RN: for now, we don't allow rehosting from one multifloater to another
-	// just need to fix the bugs
-	if (getFloaterHost() != NULL && getHost() == NULL)
-	{
-		// needs a host
-		// only select tabs if window they are hosted in is visible
-		getFloaterHost()->addFloater(this, getFloaterHost()->getVisible());
-	}
-
-	if (getHost() != NULL)
-	{
-		getHost()->setMinimized(FALSE);
-		getHost()->setVisibleAndFrontmost(mAutoFocus);
-		getHost()->showFloater(this);
-	}
-	else
-	{
-		LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
-		if (!floater_to_stack)
-		{
-			floater_to_stack = LLFloaterReg::getLastFloaterCascading();
-		}
-		applyControlsAndPosition(floater_to_stack);
-		setMinimized(FALSE);
-		setVisibleAndFrontmost(mAutoFocus);
-	}
-
-	mOpenSignal(this, key);
-	onOpen(key);
-
-	dirtyRect();
+    LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string
+
+    mKey = key; // in case we need to open ourselves again
+    
+    if (getSoundFlags() != SILENT 
+    // don't play open sound for hosted (tabbed) windows
+        && !getHost() 
+        && !getFloaterHost()
+        && (!getVisible() || isMinimized()))
+    {
+        make_ui_sound("UISndWindowOpen");
+    }
+
+    //RN: for now, we don't allow rehosting from one multifloater to another
+    // just need to fix the bugs
+    if (getFloaterHost() != NULL && getHost() == NULL)
+    {
+        // needs a host
+        // only select tabs if window they are hosted in is visible
+        getFloaterHost()->addFloater(this, getFloaterHost()->getVisible());
+    }
+
+    if (getHost() != NULL)
+    {
+        getHost()->setMinimized(FALSE);
+        getHost()->setVisibleAndFrontmost(mAutoFocus);
+        getHost()->showFloater(this);
+    }
+    else
+    {
+        LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+        if (!floater_to_stack)
+        {
+            floater_to_stack = LLFloaterReg::getLastFloaterCascading();
+        }
+        applyControlsAndPosition(floater_to_stack);
+        setMinimized(FALSE);
+        setVisibleAndFrontmost(mAutoFocus);
+    }
+
+    mOpenSignal(this, key);
+    onOpen(key);
+
+    dirtyRect();
 }
 
 void LLFloater::closeFloater(bool app_quitting)
 {
-	LL_INFOS() << "Closing floater " << getName() << LL_ENDL;
-	LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string
-	if (app_quitting)
-	{
-		LLFloater::sQuitting = true;
-	}
-	
-	// Always unminimize before trying to close.
-	// Most of the time the user will never see this state.
-	setMinimized(FALSE);
-
-	if (canClose())
-	{
-		if (getHost())
-		{
-			((LLMultiFloater*)getHost())->removeFloater(this);
-			gFloaterView->addChild(this);
-		}
-
-		if (getSoundFlags() != SILENT
-			&& getVisible()
-			&& !getHost()
-			&& !app_quitting)
-		{
-			make_ui_sound("UISndWindowClose");
-		}
-
-		gFocusMgr.clearLastFocusForGroup(this);
-
-			if (hasFocus())
-			{
-				// Do this early, so UI controls will commit before the
-				// window is taken down.
-				releaseFocus();
-
-				// give focus to dependee floater if it exists, and we had focus first
-				if (isDependent())
-				{
-					LLFloater* dependee = mDependeeHandle.get();
-					if (dependee && !dependee->isDead())
-					{
-						dependee->setFocus(TRUE);
-					}
-				}
-			}
-
-
-		//If floater is a dependent, remove it from parent (dependee)
+    LL_INFOS() << "Closing floater " << getName() << LL_ENDL;
+    LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string
+    if (app_quitting)
+    {
+        LLFloater::sQuitting = true;
+    }
+    
+    // Always unminimize before trying to close.
+    // Most of the time the user will never see this state.
+    setMinimized(FALSE);
+
+    if (canClose())
+    {
+        if (getHost())
+        {
+            ((LLMultiFloater*)getHost())->removeFloater(this);
+            gFloaterView->addChild(this);
+        }
+
+        if (getSoundFlags() != SILENT
+            && getVisible()
+            && !getHost()
+            && !app_quitting)
+        {
+            make_ui_sound("UISndWindowClose");
+        }
+
+        gFocusMgr.clearLastFocusForGroup(this);
+
+            if (hasFocus())
+            {
+                // Do this early, so UI controls will commit before the
+                // window is taken down.
+                releaseFocus();
+
+                // give focus to dependee floater if it exists, and we had focus first
+                if (isDependent())
+                {
+                    LLFloater* dependee = mDependeeHandle.get();
+                    if (dependee && !dependee->isDead())
+                    {
+                        dependee->setFocus(TRUE);
+                    }
+                }
+            }
+
+
+        //If floater is a dependent, remove it from parent (dependee)
         LLFloater* dependee = mDependeeHandle.get();
         if (dependee)
         {
             dependee->removeDependentFloater(this);
         }
 
-		// now close dependent floater
-		for(handle_set_iter_t dependent_it = mDependents.begin();
-			dependent_it != mDependents.end(); )
-		{
-			
-			LLFloater* floaterp = dependent_it->get();
-			if (floaterp)
-			{
-				++dependent_it;
-				floaterp->closeFloater(app_quitting);
-			}
-			else
-			{
-				mDependents.erase(dependent_it++);
-			}
-		}
-		
-		cleanupHandles();
-
-		dirtyRect();
-
-		// Close callbacks
-		onClose(app_quitting);
-		mCloseSignal(this, LLSD(app_quitting));
-		
-		// Hide or Destroy
-		if (mSingleInstance)
-		{
-			// Hide the instance
-			if (getHost())
-			{
-				getHost()->setVisible(FALSE);
-			}
-			else
-			{
-				setVisible(FALSE);
-				if (!mReuseInstance)
-				{
-					destroy();
-				}
-			}
-		}
-		else
-		{
-			setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called)
-			if (!mReuseInstance)
-			{
-				destroy();
-			}
-		}
-	}
+        // now close dependent floater
+        for(handle_set_iter_t dependent_it = mDependents.begin();
+            dependent_it != mDependents.end(); )
+        {
+            
+            LLFloater* floaterp = dependent_it->get();
+            if (floaterp)
+            {
+                ++dependent_it;
+                floaterp->closeFloater(app_quitting);
+            }
+            else
+            {
+                mDependents.erase(dependent_it++);
+            }
+        }
+        
+        cleanupHandles();
+
+        dirtyRect();
+
+        // Close callbacks
+        onClose(app_quitting);
+        mCloseSignal(this, LLSD(app_quitting));
+        
+        // Hide or Destroy
+        if (mSingleInstance)
+        {
+            // Hide the instance
+            if (getHost())
+            {
+                getHost()->setVisible(FALSE);
+            }
+            else
+            {
+                setVisible(FALSE);
+                if (!mReuseInstance)
+                {
+                    destroy();
+                }
+            }
+        }
+        else
+        {
+            setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called)
+            if (!mReuseInstance)
+            {
+                destroy();
+            }
+        }
+    }
 }
 
 /*virtual*/
 void LLFloater::closeHostedFloater()
 {
-	// When toggling *visibility*, close the host instead of the floater when hosted
-	if (getHost())
-	{
-		getHost()->closeFloater();
-	}
-	else
-	{
-		closeFloater();
-	}
+    // When toggling *visibility*, close the host instead of the floater when hosted
+    if (getHost())
+    {
+        getHost()->closeFloater();
+    }
+    else
+    {
+        closeFloater();
+    }
 }
 
 /*virtual*/
 void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
-	LLPanel::reshape(width, height, called_from_parent);
+    LLPanel::reshape(width, height, called_from_parent);
 }
 
 void LLFloater::releaseFocus()
 {
-	LLUI::removePopup(this);
+    LLUI::removePopup(this);
 
-	setFocus(FALSE);
+    setFocus(FALSE);
 
-	if( gFocusMgr.childHasMouseCapture( this ) )
-	{
-		gFocusMgr.setMouseCapture(NULL);
-	}
+    if( gFocusMgr.childHasMouseCapture( this ) )
+    {
+        gFocusMgr.setMouseCapture(NULL);
+    }
 }
 
 
 void LLFloater::setResizeLimits( S32 min_width, S32 min_height )
 {
-	mMinWidth = min_width;
-	mMinHeight = min_height;
-
-	for( S32 i = 0; i < 4; i++ )
-	{
-		if( mResizeBar[i] )
-		{
-			if (i == LLResizeBar::LEFT || i == LLResizeBar::RIGHT)
-			{
-				mResizeBar[i]->setResizeLimits( min_width, S32_MAX );
-			}
-			else
-			{
-				mResizeBar[i]->setResizeLimits( min_height, S32_MAX );
-			}
-		}
-		if( mResizeHandle[i] )
-		{
-			mResizeHandle[i]->setResizeLimits( min_width, min_height );
-		}
-	}
+    mMinWidth = min_width;
+    mMinHeight = min_height;
+
+    for( S32 i = 0; i < 4; i++ )
+    {
+        if( mResizeBar[i] )
+        {
+            if (i == LLResizeBar::LEFT || i == LLResizeBar::RIGHT)
+            {
+                mResizeBar[i]->setResizeLimits( min_width, S32_MAX );
+            }
+            else
+            {
+                mResizeBar[i]->setResizeLimits( min_height, S32_MAX );
+            }
+        }
+        if( mResizeHandle[i] )
+        {
+            mResizeHandle[i]->setResizeLimits( min_width, min_height );
+        }
+    }
 }
 
 
 void LLFloater::center()
 {
-	if(getHost())
-	{
-		// hosted floaters can't move
-		return;
-	}
-	centerWithin(gFloaterView->getRect());
+    if(getHost())
+    {
+        // hosted floaters can't move
+        return;
+    }
+    centerWithin(gFloaterView->getRect());
 }
 
 LLMultiFloater* LLFloater::getHost()
 { 
-	return (LLMultiFloater*)mHostHandle.get(); 
+    return (LLMultiFloater*)mHostHandle.get(); 
 }
 
 void LLFloater::applyControlsAndPosition(LLFloater* other)
 {
-	if (!applyDockState())
-	{
-		if (!applyRectControl())
-		{
-			applyPositioning(other, true);
-		}
-	}
+    if (!applyDockState())
+    {
+        if (!applyRectControl())
+        {
+            applyPositioning(other, true);
+        }
+    }
 }
 
 bool LLFloater::applyRectControl()
 {
-	bool saved_rect = false;
-
-	LLRect screen_rect = calcScreenRect();
-	mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
-	
-	LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
-	if (last_in_group && last_in_group != this)
-	{
-		// other floaters in our group, position ourselves relative to them and don't save the rect
-		mRectControl.clear();
-		mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
-	}
-	else
-	{
-		bool rect_specified = false;
-		if (!mRectControl.empty())
-		{
-			// If we have a saved rect, use it
-			const LLRect& rect = getControlGroup()->getRect(mRectControl);
-			if (rect.notEmpty()) saved_rect = true;
-			if (saved_rect)
-			{
-				setOrigin(rect.mLeft, rect.mBottom);
-
-				if (mResizable)
-				{
-					reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
-				}
-				mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-				LLRect screen_rect = calcScreenRect();
-				mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
-				rect_specified = true;
-			}
-		}
-
-		LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl);
-		LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl);
-		if (x_control.notNull() 
-			&& y_control.notNull()
-			&& !x_control->isDefault()
-			&& !y_control->isDefault())
-		{
-			mPosition.mX = x_control->getValue().asReal();
-			mPosition.mY = y_control->getValue().asReal();
-			mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-			applyRelativePosition();
-
-			saved_rect = true;
-		}
-
-		// remember updated position
-		if (rect_specified)
-		{
-			storeRectControl();
-		}
-	}
-
-	if (saved_rect)
-	{
-		// propagate any derived positioning data back to settings file
-		storeRectControl();
-	}
-
-
-	return saved_rect;
+    bool saved_rect = false;
+
+    LLRect screen_rect = calcScreenRect();
+    mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+    
+    LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+    if (last_in_group && last_in_group != this)
+    {
+        // other floaters in our group, position ourselves relative to them and don't save the rect
+        mRectControl.clear();
+        mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
+    }
+    else
+    {
+        bool rect_specified = false;
+        if (!mRectControl.empty())
+        {
+            // If we have a saved rect, use it
+            const LLRect& rect = getControlGroup()->getRect(mRectControl);
+            if (rect.notEmpty()) saved_rect = true;
+            if (saved_rect)
+            {
+                setOrigin(rect.mLeft, rect.mBottom);
+
+                if (mResizable)
+                {
+                    reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
+                }
+                mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+                LLRect screen_rect = calcScreenRect();
+                mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+                rect_specified = true;
+            }
+        }
+
+        LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl);
+        LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl);
+        if (x_control.notNull() 
+            && y_control.notNull()
+            && !x_control->isDefault()
+            && !y_control->isDefault())
+        {
+            mPosition.mX = x_control->getValue().asReal();
+            mPosition.mY = y_control->getValue().asReal();
+            mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+            applyRelativePosition();
+
+            saved_rect = true;
+        }
+
+        // remember updated position
+        if (rect_specified)
+        {
+            storeRectControl();
+        }
+    }
+
+    if (saved_rect)
+    {
+        // propagate any derived positioning data back to settings file
+        storeRectControl();
+    }
+
+
+    return saved_rect;
 }
 
 bool LLFloater::applyDockState()
 {
-	bool docked = false;
+    bool docked = false;
 
-	if (mDocStateControl.size() > 1)
-	{
-		docked = getControlGroup()->getBOOL(mDocStateControl);
-		setDocked(docked);
-	}
+    if (mDocStateControl.size() > 1)
+    {
+        docked = getControlGroup()->getBOOL(mDocStateControl);
+        setDocked(docked);
+    }
 
-	return docked;
+    return docked;
 }
 
 void LLFloater::applyPositioning(LLFloater* other, bool on_open)
 {
-	// Otherwise position according to the positioning code
-	switch (mPositioning)
-	{
-	case LLFloaterEnums::POSITIONING_CENTERED:
-		center();
-		break;
-
-	case LLFloaterEnums::POSITIONING_SPECIFIED:
-		break;
-
-	case LLFloaterEnums::POSITIONING_CASCADING:
-		if (!on_open)
-		{
-			applyRelativePosition();
-		}
-		// fall through
-	case LLFloaterEnums::POSITIONING_CASCADE_GROUP:
-		if (on_open)
-		{
-			if (other != NULL && other != this)
-			{
-				stackWith(*other);
-			}
-			else
-			{
-				static const U32 CASCADING_FLOATER_HOFFSET = 0;
-				static const U32 CASCADING_FLOATER_VOFFSET = 0;
-			
-				const LLRect& snap_rect = gFloaterView->getSnapRect();
-
-				const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET;
-				const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET;
-
-				S32 rect_height = getRect().getHeight();
-				setOrigin(horizontal_offset, vertical_offset - rect_height);
-
-				translate(snap_rect.mLeft, snap_rect.mBottom);
-			}
-			setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-		}
-		break;
-
-	case LLFloaterEnums::POSITIONING_RELATIVE:
-		{
-			applyRelativePosition();
-
-			break;
-		}
-	default:
-		// Do nothing
-		break;
-	}
+    // Otherwise position according to the positioning code
+    switch (mPositioning)
+    {
+    case LLFloaterEnums::POSITIONING_CENTERED:
+        center();
+        break;
+
+    case LLFloaterEnums::POSITIONING_SPECIFIED:
+        break;
+
+    case LLFloaterEnums::POSITIONING_CASCADING:
+        if (!on_open)
+        {
+            applyRelativePosition();
+        }
+        // fall through
+    case LLFloaterEnums::POSITIONING_CASCADE_GROUP:
+        if (on_open)
+        {
+            if (other != NULL && other != this)
+            {
+                stackWith(*other);
+            }
+            else
+            {
+                static const U32 CASCADING_FLOATER_HOFFSET = 0;
+                static const U32 CASCADING_FLOATER_VOFFSET = 0;
+            
+                const LLRect& snap_rect = gFloaterView->getSnapRect();
+
+                const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET;
+                const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET;
+
+                S32 rect_height = getRect().getHeight();
+                setOrigin(horizontal_offset, vertical_offset - rect_height);
+
+                translate(snap_rect.mLeft, snap_rect.mBottom);
+            }
+            setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+        }
+        break;
+
+    case LLFloaterEnums::POSITIONING_RELATIVE:
+        {
+            applyRelativePosition();
+
+            break;
+        }
+    default:
+        // Do nothing
+        break;
+    }
 }
 
 void LLFloater::applyTitle()
 {
-	if (!mDragHandle)
-	{
-		return;
-	}
+    if (!mDragHandle)
+    {
+        return;
+    }
 
-	if (isMinimized() && !mShortTitle.empty())
-	{
-		mDragHandle->setTitle( mShortTitle );
-	}
-	else
-	{
-		mDragHandle->setTitle ( mTitle );
-	}
+    if (isMinimized() && !mShortTitle.empty())
+    {
+        mDragHandle->setTitle( mShortTitle );
+    }
+    else
+    {
+        mDragHandle->setTitle ( mTitle );
+    }
 
-	if (getHost())
-	{
-		getHost()->updateFloaterTitle(this);	
-	}
+    if (getHost())
+    {
+        getHost()->updateFloaterTitle(this);    
+    }
 }
 
 std::string LLFloater::getCurrentTitle() const
 {
-	return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
+    return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
 }
 
 void LLFloater::setTitle( const std::string& title )
 {
-	mTitle = title;
-	applyTitle();
+    mTitle = title;
+    applyTitle();
 }
 
 std::string LLFloater::getTitle() const
 {
-	if (mTitle.empty())
-	{
-		return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
-	}
-	else
-	{
-		return mTitle;
-	}
+    if (mTitle.empty())
+    {
+        return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
+    }
+    else
+    {
+        return mTitle;
+    }
 }
 
 void LLFloater::setShortTitle( const std::string& short_title )
 {
-	mShortTitle = short_title;
-	applyTitle();
+    mShortTitle = short_title;
+    applyTitle();
 }
 
 std::string LLFloater::getShortTitle() const
 {
-	if (mShortTitle.empty())
-	{
-		return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
-	}
-	else
-	{
-		return mShortTitle;
-	}
+    if (mShortTitle.empty())
+    {
+        return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
+    }
+    else
+    {
+        return mShortTitle;
+    }
 }
 
 BOOL LLFloater::canSnapTo(const LLView* other_view)
 {
-	if (NULL == other_view)
-	{
-		LL_WARNS() << "other_view is NULL" << LL_ENDL;
-		return FALSE;
-	}
-
-	if (other_view != getParent())
-	{
-		const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);		
-		if (other_floaterp 
-			&& other_floaterp->getSnapTarget() == getHandle() 
-			&& mDependents.find(other_floaterp->getHandle()) != mDependents.end())
-		{
-			// this is a dependent that is already snapped to us, so don't snap back to it
-			return FALSE;
-		}
-	}
+    if (NULL == other_view)
+    {
+        LL_WARNS() << "other_view is NULL" << LL_ENDL;
+        return FALSE;
+    }
+
+    if (other_view != getParent())
+    {
+        const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);       
+        if (other_floaterp 
+            && other_floaterp->getSnapTarget() == getHandle() 
+            && mDependents.find(other_floaterp->getHandle()) != mDependents.end())
+        {
+            // this is a dependent that is already snapped to us, so don't snap back to it
+            return FALSE;
+        }
+    }
 
-	return LLPanel::canSnapTo(other_view);
+    return LLPanel::canSnapTo(other_view);
 }
 
 void LLFloater::setSnappedTo(const LLView* snap_view)
 {
-	if (!snap_view || snap_view == getParent())
-	{
-		clearSnapTarget();
-	}
-	else
-	{
-		//RN: assume it's a floater as it must be a sibling to our parent floater
-		const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view);
-		if (floaterp)
-		{
-			setSnapTarget(floaterp->getHandle());
-		}
-	}
+    if (!snap_view || snap_view == getParent())
+    {
+        clearSnapTarget();
+    }
+    else
+    {
+        //RN: assume it's a floater as it must be a sibling to our parent floater
+        const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view);
+        if (floaterp)
+        {
+            setSnapTarget(floaterp->getHandle());
+        }
+    }
 }
 
 void LLFloater::handleReshape(const LLRect& new_rect, bool by_user)
 {
-	const LLRect old_rect = getRect();
-	LLView::handleReshape(new_rect, by_user);
-
-	if (by_user && !getHost())
-	{
-		LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent());
-		if (floaterVp)
-		{
-			floaterVp->adjustToFitScreen(this, !isMinimized());
-		}
-	}
-
-	// if not minimized, adjust all snapped dependents to new shape
-	if (!isMinimized())
-	{
-		if (by_user)
-		{
-			if (isDocked())
-			{
-				setDocked( false, false);
-			}
-		mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-		LLRect screen_rect = calcScreenRect();
-		mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
-		}
-		storeRectControl();
-
-		// gather all snapped dependents
-		for(handle_set_iter_t dependent_it = mDependents.begin();
-			dependent_it != mDependents.end(); ++dependent_it)
-		{
-			LLFloater* floaterp = dependent_it->get();
-			// is a dependent snapped to us?
-			if (floaterp && floaterp->getSnapTarget() == getHandle())
-			{
-				S32 delta_x = 0;
-				S32 delta_y = 0;
-				// check to see if it snapped to right or top, and move if dependee floater is resizing
-				LLRect dependent_rect = floaterp->getRect();
-				if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right?
-					dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right
-				{
-					// was snapped directly onto right side or aligned with it
-					delta_x += new_rect.getWidth() - old_rect.getWidth();
-				}
-				if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() ||
-					dependent_rect.mTop == getRect().mBottom + old_rect.getHeight())
-				{
-					// was snapped directly onto top side or aligned with it
-					delta_y += new_rect.getHeight() - old_rect.getHeight();
-				}
-
-				// take translation of dependee floater into account as well
-				delta_x += new_rect.mLeft - old_rect.mLeft;
-				delta_y += new_rect.mBottom - old_rect.mBottom;
-
-				dependent_rect.translate(delta_x, delta_y);
-				floaterp->setShape(dependent_rect, by_user);
-			}
-		}
-	}
-	else
-	{
-		// If minimized, and origin has changed, set
-		// mHasBeenDraggedWhileMinimized to TRUE
-		if ((new_rect.mLeft != old_rect.mLeft) ||
-			(new_rect.mBottom != old_rect.mBottom))
-		{
-			mHasBeenDraggedWhileMinimized = TRUE;
-		}
-	}
+    const LLRect old_rect = getRect();
+    LLView::handleReshape(new_rect, by_user);
+
+    if (by_user && !getHost())
+    {
+        LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent());
+        if (floaterVp)
+        {
+            floaterVp->adjustToFitScreen(this, !isMinimized());
+        }
+    }
+
+    // if not minimized, adjust all snapped dependents to new shape
+    if (!isMinimized())
+    {
+        if (by_user)
+        {
+            if (isDocked())
+            {
+                setDocked( false, false);
+            }
+        mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+        LLRect screen_rect = calcScreenRect();
+        mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+        }
+        storeRectControl();
+
+        // gather all snapped dependents
+        for(handle_set_iter_t dependent_it = mDependents.begin();
+            dependent_it != mDependents.end(); ++dependent_it)
+        {
+            LLFloater* floaterp = dependent_it->get();
+            // is a dependent snapped to us?
+            if (floaterp && floaterp->getSnapTarget() == getHandle())
+            {
+                S32 delta_x = 0;
+                S32 delta_y = 0;
+                // check to see if it snapped to right or top, and move if dependee floater is resizing
+                LLRect dependent_rect = floaterp->getRect();
+                if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right?
+                    dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right
+                {
+                    // was snapped directly onto right side or aligned with it
+                    delta_x += new_rect.getWidth() - old_rect.getWidth();
+                }
+                if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() ||
+                    dependent_rect.mTop == getRect().mBottom + old_rect.getHeight())
+                {
+                    // was snapped directly onto top side or aligned with it
+                    delta_y += new_rect.getHeight() - old_rect.getHeight();
+                }
+
+                // take translation of dependee floater into account as well
+                delta_x += new_rect.mLeft - old_rect.mLeft;
+                delta_y += new_rect.mBottom - old_rect.mBottom;
+
+                dependent_rect.translate(delta_x, delta_y);
+                floaterp->setShape(dependent_rect, by_user);
+            }
+        }
+    }
+    else
+    {
+        // If minimized, and origin has changed, set
+        // mHasBeenDraggedWhileMinimized to TRUE
+        if ((new_rect.mLeft != old_rect.mLeft) ||
+            (new_rect.mBottom != old_rect.mBottom))
+        {
+            mHasBeenDraggedWhileMinimized = TRUE;
+        }
+    }
 }
 
 void LLFloater::setMinimized(BOOL minimize)
 {
-	const LLFloater::Params& default_params = LLFloater::getDefaultParams();
-	S32 floater_header_size = default_params.header_height;
-	static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
-
-	if (minimize == mMinimized) return;
-
-	if (mMinimizeSignal)
-	{
-		(*mMinimizeSignal)(this, LLSD(minimize));
-	}
-
-	if (minimize)
-	{
-		// minimized flag should be turned on before release focus
-		mMinimized = TRUE;
-		mExpandedRect = getRect();
-
-		// If the floater has been dragged while minimized in the
-		// past, then locate it at its previous minimized location.
-		// Otherwise, ask the view for a minimize position.
-		if (mHasBeenDraggedWhileMinimized)
-		{
-			setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom);
-		}
-		else
-		{
-			S32 left, bottom;
-			gFloaterView->getMinimizePosition(&left, &bottom);
-			setOrigin( left, bottom );
-		}
-
-		if (mButtonsEnabled[BUTTON_MINIMIZE])
-		{
-			mButtonsEnabled[BUTTON_MINIMIZE] = FALSE;
-			mButtonsEnabled[BUTTON_RESTORE] = TRUE;
-		}
-
-		setBorderVisible(TRUE);
-
-		for(handle_set_iter_t dependent_it = mDependents.begin();
-			dependent_it != mDependents.end();
-			++dependent_it)
-		{
-			LLFloater* floaterp = dependent_it->get();
-			if (floaterp)
-			{
-				if (floaterp->isMinimizeable())
-				{
-					floaterp->setMinimized(TRUE);
-				}
-				else if (!floaterp->isMinimized())
-				{
-					floaterp->setVisible(FALSE);
-				}
-			}
-		}
-
-		// Lose keyboard focus when minimized
-		releaseFocus();
-
-		for (S32 i = 0; i < 4; i++)
-		{
-			if (mResizeBar[i] != NULL)
-			{
-				mResizeBar[i]->setEnabled(FALSE);
-			}
-			if (mResizeHandle[i] != NULL)
-			{
-				mResizeHandle[i]->setEnabled(FALSE);
-			}
-		}
-		
-		// Reshape *after* setting mMinimized
-		reshape( minimized_width, floater_header_size, TRUE);
-	}
-	else
-	{
-		// If this window has been dragged while minimized (at any time),
-		// remember its position for the next time it's minimized.
-		if (mHasBeenDraggedWhileMinimized)
-		{
-			const LLRect& currentRect = getRect();
-			mPreviousMinimizedLeft = currentRect.mLeft;
-			mPreviousMinimizedBottom = currentRect.mBottom;
-		}
-
-		setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom );
-		if (mButtonsEnabled[BUTTON_RESTORE])
-		{
-			mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
-			mButtonsEnabled[BUTTON_RESTORE] = FALSE;
-		}
-
-		// show dependent floater
-		for(handle_set_iter_t dependent_it = mDependents.begin();
-			dependent_it != mDependents.end();
-			++dependent_it)
-		{
-			LLFloater* floaterp = dependent_it->get();
-			if (floaterp)
-			{
-				floaterp->setMinimized(FALSE);
-				floaterp->setVisible(TRUE);
-			}
-		}
-
-		for (S32 i = 0; i < 4; i++)
-		{
-			if (mResizeBar[i] != NULL)
-			{
-				mResizeBar[i]->setEnabled(isResizable());
-			}
-			if (mResizeHandle[i] != NULL)
-			{
-				mResizeHandle[i]->setEnabled(isResizable());
-			}
-		}
-		
-		mMinimized = FALSE;
-		setFrontmost();
-		// Reshape *after* setting mMinimized
-		reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
-	}
-
-	make_ui_sound("UISndWindowClose");
-	updateTitleButtons();
-	applyTitle ();
+    const LLFloater::Params& default_params = LLFloater::getDefaultParams();
+    S32 floater_header_size = default_params.header_height;
+    static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
+
+    if (minimize == mMinimized) return;
+
+    if (mMinimizeSignal)
+    {
+        (*mMinimizeSignal)(this, LLSD(minimize));
+    }
+
+    if (minimize)
+    {
+        // minimized flag should be turned on before release focus
+        mMinimized = TRUE;
+        mExpandedRect = getRect();
+
+        // If the floater has been dragged while minimized in the
+        // past, then locate it at its previous minimized location.
+        // Otherwise, ask the view for a minimize position.
+        if (mHasBeenDraggedWhileMinimized)
+        {
+            setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom);
+        }
+        else
+        {
+            S32 left, bottom;
+            gFloaterView->getMinimizePosition(&left, &bottom);
+            setOrigin( left, bottom );
+        }
+
+        if (mButtonsEnabled[BUTTON_MINIMIZE])
+        {
+            mButtonsEnabled[BUTTON_MINIMIZE] = FALSE;
+            mButtonsEnabled[BUTTON_RESTORE] = TRUE;
+        }
+
+        setBorderVisible(TRUE);
+
+        for(handle_set_iter_t dependent_it = mDependents.begin();
+            dependent_it != mDependents.end();
+            ++dependent_it)
+        {
+            LLFloater* floaterp = dependent_it->get();
+            if (floaterp)
+            {
+                if (floaterp->isMinimizeable())
+                {
+                    floaterp->setMinimized(TRUE);
+                }
+                else if (!floaterp->isMinimized())
+                {
+                    floaterp->setVisible(FALSE);
+                }
+            }
+        }
+
+        // Lose keyboard focus when minimized
+        releaseFocus();
+
+        for (S32 i = 0; i < 4; i++)
+        {
+            if (mResizeBar[i] != NULL)
+            {
+                mResizeBar[i]->setEnabled(FALSE);
+            }
+            if (mResizeHandle[i] != NULL)
+            {
+                mResizeHandle[i]->setEnabled(FALSE);
+            }
+        }
+        
+        // Reshape *after* setting mMinimized
+        reshape( minimized_width, floater_header_size, TRUE);
+    }
+    else
+    {
+        // If this window has been dragged while minimized (at any time),
+        // remember its position for the next time it's minimized.
+        if (mHasBeenDraggedWhileMinimized)
+        {
+            const LLRect& currentRect = getRect();
+            mPreviousMinimizedLeft = currentRect.mLeft;
+            mPreviousMinimizedBottom = currentRect.mBottom;
+        }
+
+        setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom );
+        if (mButtonsEnabled[BUTTON_RESTORE])
+        {
+            mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
+            mButtonsEnabled[BUTTON_RESTORE] = FALSE;
+        }
+
+        // show dependent floater
+        for(handle_set_iter_t dependent_it = mDependents.begin();
+            dependent_it != mDependents.end();
+            ++dependent_it)
+        {
+            LLFloater* floaterp = dependent_it->get();
+            if (floaterp)
+            {
+                floaterp->setMinimized(FALSE);
+                floaterp->setVisible(TRUE);
+            }
+        }
+
+        for (S32 i = 0; i < 4; i++)
+        {
+            if (mResizeBar[i] != NULL)
+            {
+                mResizeBar[i]->setEnabled(isResizable());
+            }
+            if (mResizeHandle[i] != NULL)
+            {
+                mResizeHandle[i]->setEnabled(isResizable());
+            }
+        }
+        
+        mMinimized = FALSE;
+        setFrontmost();
+        // Reshape *after* setting mMinimized
+        reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
+    }
+
+    make_ui_sound("UISndWindowClose");
+    updateTitleButtons();
+    applyTitle ();
 }
 
 void LLFloater::setFocus( BOOL b )
 {
-	if (b && getIsChrome())
-	{
-		return;
-	}
-	LLView* last_focus = gFocusMgr.getLastFocusForGroup(this);
-	// a descendent already has focus
-	BOOL child_had_focus = hasFocus();
-
-	// give focus to first valid descendent
-	LLPanel::setFocus(b);
-
-	if (b)
-	{
-		// only push focused floaters to front of stack if not in midst of ctrl-tab cycle
-		LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent());
-		if (!getHost() && parent && !parent->getCycleMode())
-		{
-			if (!isFrontmost())
-			{
-				setFrontmost();
-			}
-		}
-
-		// when getting focus, delegate to last descendent which had focus
-		if (last_focus && !child_had_focus && 
-			last_focus->isInEnabledChain() &&
-			last_focus->isInVisibleChain())
-		{
-			// *FIX: should handle case where focus doesn't stick
-			last_focus->setFocus(TRUE);
-		}
-	}
-	updateTransparency(b ? TT_ACTIVE : TT_INACTIVE);
+    if (b && getIsChrome())
+    {
+        return;
+    }
+    LLView* last_focus = gFocusMgr.getLastFocusForGroup(this);
+    // a descendent already has focus
+    BOOL child_had_focus = hasFocus();
+
+    // give focus to first valid descendent
+    LLPanel::setFocus(b);
+
+    if (b)
+    {
+        // only push focused floaters to front of stack if not in midst of ctrl-tab cycle
+        LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent());
+        if (!getHost() && parent && !parent->getCycleMode())
+        {
+            if (!isFrontmost())
+            {
+                setFrontmost();
+            }
+        }
+
+        // when getting focus, delegate to last descendent which had focus
+        if (last_focus && !child_had_focus && 
+            last_focus->isInEnabledChain() &&
+            last_focus->isInVisibleChain())
+        {
+            // *FIX: should handle case where focus doesn't stick
+            last_focus->setFocus(TRUE);
+        }
+    }
+    updateTransparency(b ? TT_ACTIVE : TT_INACTIVE);
 }
 
 // virtual
 void LLFloater::setRect(const LLRect &rect)
 {
-	LLPanel::setRect(rect);
-	layoutDragHandle();
-	layoutResizeCtrls();
+    LLPanel::setRect(rect);
+    layoutDragHandle();
+    layoutResizeCtrls();
 }
 
 // virtual
 void LLFloater::setIsChrome(BOOL is_chrome)
 {
-	// chrome floaters don't take focus at all
-	if (is_chrome)
-	{
-		// remove focus if we're changing to chrome
-		setFocus(FALSE);
-		// can't Ctrl-Tab to "chrome" floaters
-		setFocusRoot(FALSE);
-		mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome)));
-	}
-	
-	LLPanel::setIsChrome(is_chrome);
+    // chrome floaters don't take focus at all
+    if (is_chrome)
+    {
+        // remove focus if we're changing to chrome
+        setFocus(FALSE);
+        // can't Ctrl-Tab to "chrome" floaters
+        setFocusRoot(FALSE);
+        mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome)));
+    }
+    
+    LLPanel::setIsChrome(is_chrome);
 }
 
 // Change the draw style to account for the foreground state.
 void LLFloater::setForeground(BOOL front)
 {
-	if (front != mForeground)
-	{
-		mForeground = front;
-		if (mDragHandle)
-			mDragHandle->setForeground( front );
+    if (front != mForeground)
+    {
+        mForeground = front;
+        if (mDragHandle)
+            mDragHandle->setForeground( front );
 
-		if (!front)
-		{
-			releaseFocus();
-		}
+        if (!front)
+        {
+            releaseFocus();
+        }
 
-		setBackgroundOpaque( front ); 
-	}
+        setBackgroundOpaque( front ); 
+    }
 }
 
 void LLFloater::cleanupHandles()
 {
-	// remove handles to non-existent dependents
-	for(handle_set_iter_t dependent_it = mDependents.begin();
-		dependent_it != mDependents.end(); )
-	{
-		LLFloater* floaterp = dependent_it->get();
-		if (!floaterp)
-		{
-			mDependents.erase(dependent_it++);
-		}
-		else
-		{
-			++dependent_it;
-		}
-	}
+    // remove handles to non-existent dependents
+    for(handle_set_iter_t dependent_it = mDependents.begin();
+        dependent_it != mDependents.end(); )
+    {
+        LLFloater* floaterp = dependent_it->get();
+        if (!floaterp)
+        {
+            mDependents.erase(dependent_it++);
+        }
+        else
+        {
+            ++dependent_it;
+        }
+    }
 }
 
 void LLFloater::setHost(LLMultiFloater* host)
 {
-	if (mHostHandle.isDead() && host)
-	{
-		// make buttons smaller for hosted windows to differentiate from parent
-		mButtonScale = 0.9f;
-
-		// add tear off button
-		if (mCanTearOff)
-		{
-			mButtonsEnabled[BUTTON_TEAR_OFF] = TRUE;
-		}
-	}
-	else if (!mHostHandle.isDead() && !host)
-	{
-		mButtonScale = 1.f;
-		//mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE;
-	}
-	if (host)
-	{
-		mHostHandle = host->getHandle();
-		mLastHostHandle = host->getHandle();
-	}
-	else
-	{
-		mHostHandle.markDead();
-	}
+    if (mHostHandle.isDead() && host)
+    {
+        // make buttons smaller for hosted windows to differentiate from parent
+        mButtonScale = 0.9f;
+
+        // add tear off button
+        if (mCanTearOff)
+        {
+            mButtonsEnabled[BUTTON_TEAR_OFF] = TRUE;
+        }
+    }
+    else if (!mHostHandle.isDead() && !host)
+    {
+        mButtonScale = 1.f;
+        //mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE;
+    }
+    if (host)
+    {
+        mHostHandle = host->getHandle();
+        mLastHostHandle = host->getHandle();
+    }
+    else
+    {
+        mHostHandle.markDead();
+    }
     
-	updateTitleButtons();
+    updateTitleButtons();
 }
 
 void LLFloater::moveResizeHandlesToFront()
 {
-	for( S32 i = 0; i < 4; i++ )
-	{
-		if( mResizeBar[i] )
-		{
-			sendChildToFront(mResizeBar[i]);
-		}
-	}
+    for( S32 i = 0; i < 4; i++ )
+    {
+        if( mResizeBar[i] )
+        {
+            sendChildToFront(mResizeBar[i]);
+        }
+    }
 
-	for( S32 i = 0; i < 4; i++ )
-	{
-		if( mResizeHandle[i] )
-		{
-			sendChildToFront(mResizeHandle[i]);
-		}
-	}
+    for( S32 i = 0; i < 4; i++ )
+    {
+        if( mResizeHandle[i] )
+        {
+            sendChildToFront(mResizeHandle[i]);
+        }
+    }
 }
 
 /*virtual*/
 BOOL LLFloater::isFrontmost()
 {
-	LLFloaterView* floater_view = getParentByType<LLFloaterView>();
-	return getVisible()
-			&& (floater_view 
-				&& floater_view->getFrontmost() == this);
+    LLFloaterView* floater_view = getParentByType<LLFloaterView>();
+    return getVisible()
+            && (floater_view 
+                && floater_view->getFrontmost() == this);
 }
 
 void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition)
 {
-	mDependents.insert(floaterp->getHandle());
-	floaterp->mDependeeHandle = getHandle();
+    mDependents.insert(floaterp->getHandle());
+    floaterp->mDependeeHandle = getHandle();
 
-	if (reposition)
-	{
-		floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp));
-		floaterp->setSnapTarget(getHandle());
-	}
-	gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE);
-	if (floaterp->isFrontmost())
-	{
-		// make sure to bring self and sibling floaters to front
-		gFloaterView->bringToFront(floaterp);
-	}
+    if (reposition)
+    {
+        floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp));
+        floaterp->setSnapTarget(getHandle());
+    }
+    gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE);
+    if (floaterp->isFrontmost())
+    {
+        // make sure to bring self and sibling floaters to front
+        gFloaterView->bringToFront(floaterp);
+    }
 }
 
 void LLFloater::addDependentFloater(LLHandle<LLFloater> dependent, BOOL reposition)
 {
-	LLFloater* dependent_floaterp = dependent.get();
-	if(dependent_floaterp)
-	{
-		addDependentFloater(dependent_floaterp, reposition);
-	}
+    LLFloater* dependent_floaterp = dependent.get();
+    if(dependent_floaterp)
+    {
+        addDependentFloater(dependent_floaterp, reposition);
+    }
 }
 
 void LLFloater::removeDependentFloater(LLFloater* floaterp)
 {
-	mDependents.erase(floaterp->getHandle());
-	floaterp->mDependeeHandle = LLHandle<LLFloater>();
+    mDependents.erase(floaterp->getHandle());
+    floaterp->mDependeeHandle = LLHandle<LLFloater>();
 }
 
 BOOL LLFloater::offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index)
 {
-	if( mButtonsEnabled[index] )
-	{
-		LLButton* my_butt = mButtons[index];
-		S32 local_x = x - my_butt->getRect().mLeft;
-		S32 local_y = y - my_butt->getRect().mBottom;
+    if( mButtonsEnabled[index] )
+    {
+        LLButton* my_butt = mButtons[index];
+        S32 local_x = x - my_butt->getRect().mLeft;
+        S32 local_y = y - my_butt->getRect().mBottom;
 
-		if (
-			my_butt->pointInView(local_x, local_y) &&
-			my_butt->handleMouseDown(local_x, local_y, mask))
-		{
-			// the button handled it
-			return TRUE;
-		}
-	}
-	return FALSE;
+        if (
+            my_butt->pointInView(local_x, local_y) &&
+            my_butt->handleMouseDown(local_x, local_y, mask))
+        {
+            // the button handled it
+            return TRUE;
+        }
+    }
+    return FALSE;
 }
 
 BOOL LLFloater::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-	LLPanel::handleScrollWheel(x,y,clicks);
-	return TRUE;//always
+    LLPanel::handleScrollWheel(x,y,clicks);
+    return TRUE;//always
 }
 
 // virtual
 BOOL LLFloater::handleMouseUp(S32 x, S32 y, MASK mask)
 {
-	LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL;
-	BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView
-	if (handled) {
-		LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname());
-	}
-	return handled;
+    LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL;
+    BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView
+    if (handled) {
+        LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname());
+    }
+    return handled;
 }
 
 // virtual
 BOOL LLFloater::handleMouseDown(S32 x, S32 y, MASK mask)
 {
-	if( mMinimized )
-	{
-		// Offer the click to titlebar buttons.
-		// Note: this block and the offerClickToButton helper method can be removed
-		// because the parent container will handle it for us but we'll keep it here
-		// for safety until after reworking the panel code to manage hidden children.
-		if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE;
-		if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE;
-		if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE;
-		if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE;
-
-		setFrontmost(TRUE, FALSE);
-		// Otherwise pass to drag handle for movement
-		return mDragHandle->handleMouseDown(x, y, mask);
-	}
-	else
-	{
-		bringToFront( x, y );
-		BOOL handled = LLPanel::handleMouseDown( x, y, mask ); 
-		if (handled) {
-			LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); 
-		}
-		return handled;
-	}
+    if( mMinimized )
+    {
+        // Offer the click to titlebar buttons.
+        // Note: this block and the offerClickToButton helper method can be removed
+        // because the parent container will handle it for us but we'll keep it here
+        // for safety until after reworking the panel code to manage hidden children.
+        if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE;
+        if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE;
+        if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE;
+        if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE;
+
+        setFrontmost(TRUE, FALSE);
+        // Otherwise pass to drag handle for movement
+        return mDragHandle->handleMouseDown(x, y, mask);
+    }
+    else
+    {
+        bringToFront( x, y );
+        BOOL handled = LLPanel::handleMouseDown( x, y, mask ); 
+        if (handled) {
+            LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); 
+        }
+        return handled;
+    }
 }
 
 // virtual
 BOOL LLFloater::handleRightMouseDown(S32 x, S32 y, MASK mask)
 {
-	BOOL was_minimized = mMinimized;
-	bringToFront( x, y );
-	return was_minimized || LLPanel::handleRightMouseDown( x, y, mask );
+    BOOL was_minimized = mMinimized;
+    bringToFront( x, y );
+    return was_minimized || LLPanel::handleRightMouseDown( x, y, mask );
 }
 
 BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
 {
-	bringToFront( x, y );
-	return LLPanel::handleMiddleMouseDown( x, y, mask );
+    bringToFront( x, y );
+    return LLPanel::handleMiddleMouseDown( x, y, mask );
 }
 
 
 // virtual
 BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
-	BOOL was_minimized = mMinimized;
-	setMinimized(FALSE);
-	return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
+    BOOL was_minimized = mMinimized;
+    setMinimized(FALSE);
+    return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
 }
 
 void LLFloater::bringToFront( S32 x, S32 y )
 {
-	if (getVisible() && pointInView(x, y))
-	{
-		LLMultiFloater* hostp = getHost();
-		if (hostp)
-		{
-			hostp->showFloater(this);
-		}
-		else
-		{
-			LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() );
-			if (parent)
-			{
-				parent->bringToFront( this );
-			}
-		}
-	}
+    if (getVisible() && pointInView(x, y))
+    {
+        LLMultiFloater* hostp = getHost();
+        if (hostp)
+        {
+            hostp->showFloater(this);
+        }
+        else
+        {
+            LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() );
+            if (parent)
+            {
+                parent->bringToFront( this );
+            }
+        }
+    }
 }
 
 
 // virtual
 void LLFloater::setVisibleAndFrontmost(BOOL take_focus,const LLSD& key)
 {
-	LLMultiFloater* hostp = getHost();
-	if (hostp)
-	{
-		hostp->setVisible(TRUE);
-		hostp->setFrontmost(take_focus);
-	}
-	else
-	{
-		setVisible(TRUE);
-		setFrontmost(take_focus);
-	}
+    LLMultiFloater* hostp = getHost();
+    if (hostp)
+    {
+        hostp->setVisible(TRUE);
+        hostp->setFrontmost(take_focus);
+    }
+    else
+    {
+        setVisible(TRUE);
+        setFrontmost(take_focus);
+    }
 }
 
 void LLFloater::setFrontmost(BOOL take_focus, BOOL restore)
 {
-	LLMultiFloater* hostp = getHost();
-	if (hostp)
-	{
-		// this will bring the host floater to the front and select
-		// the appropriate panel
-		hostp->showFloater(this);
-	}
-	else
-	{
-		// there are more than one floater view
-		// so we need to query our parent directly
-		LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() );
-		if (parent)
-		{
-			parent->bringToFront(this, take_focus, restore);
-		}
-
-		// Make sure to set the appropriate transparency type (STORM-732).
-		updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE);
-	}
+    LLMultiFloater* hostp = getHost();
+    if (hostp)
+    {
+        // this will bring the host floater to the front and select
+        // the appropriate panel
+        hostp->showFloater(this);
+    }
+    else
+    {
+        // there are more than one floater view
+        // so we need to query our parent directly
+        LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() );
+        if (parent)
+        {
+            parent->bringToFront(this, take_focus, restore);
+        }
+
+        // Make sure to set the appropriate transparency type (STORM-732).
+        updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE);
+    }
 }
 
 void LLFloater::setCanDock(bool b)
 {
-	if(b != mCanDock)
-	{
-		mCanDock = b;
-		if(mCanDock)
-		{
-			mButtonsEnabled[BUTTON_DOCK] = !mDocked;
-		}
-		else
-		{
-			mButtonsEnabled[BUTTON_DOCK] = FALSE;
-		}
-	}
-	updateTitleButtons();
+    if(b != mCanDock)
+    {
+        mCanDock = b;
+        if(mCanDock)
+        {
+            mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+        }
+        else
+        {
+            mButtonsEnabled[BUTTON_DOCK] = FALSE;
+        }
+    }
+    updateTitleButtons();
 }
 
 void LLFloater::setDocked(bool docked, bool pop_on_undock)
 {
-	if(docked != mDocked && mCanDock)
-	{
-		mDocked = docked;
-		mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+    if(docked != mDocked && mCanDock)
+    {
+        mDocked = docked;
+        mButtonsEnabled[BUTTON_DOCK] = !mDocked;
 
-		if (mDocked)
-		{
-			setMinimized(FALSE);
-			mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-		}
+        if (mDocked)
+        {
+            setMinimized(FALSE);
+            mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+        }
 
-		updateTitleButtons();
+        updateTitleButtons();
 
-		storeDockStateControl();
-	}
-	
+        storeDockStateControl();
+    }
+    
 }
 
 // static
 void LLFloater::onClickMinimize(LLFloater* self)
 {
-	if (!self)
-		return;
-	self->setMinimized( !self->isMinimized() );
+    if (!self)
+        return;
+    self->setMinimized( !self->isMinimized() );
 }
 
 void LLFloater::onClickTearOff(LLFloater* self)
 {
-	if (!self)
-		return;
-	S32 floater_header_size = self->mHeaderHeight;
-	LLMultiFloater* host_floater = self->getHost();
-	if (host_floater) //Tear off
-	{
-		LLRect new_rect;
-		host_floater->removeFloater(self);
-		// reparent to floater view
-		gFloaterView->addChild(self);
-
-		self->openFloater(self->getKey());
-		if (self->mSaveRect && !self->mRectControl.empty())
-		{
-			self->applyRectControl();
-		}
-		else
-		{   // only force position for floaters that don't have that data saved
-			new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
-			self->setRect(new_rect);
-		}
-		gFloaterView->adjustToFitScreen(self, FALSE);
-		// give focus to new window to keep continuity for the user
-		self->setFocus(TRUE);
-		self->setTornOff(true);
-	}
-	else  //Attach to parent.
-	{
-		LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
-		if (new_host)
-		{
-			if (self->mSaveRect)
-			{
-				self->storeRectControl();
-			}
-			self->setMinimized(FALSE); // to reenable minimize button if it was minimized
-			new_host->showFloater(self);
-			// make sure host is visible
-			new_host->openFloater(new_host->getKey());
-		}
-		self->setTornOff(false);
-	}
-	self->updateTitleButtons();
+    if (!self)
+        return;
+    S32 floater_header_size = self->mHeaderHeight;
+    LLMultiFloater* host_floater = self->getHost();
+    if (host_floater) //Tear off
+    {
+        LLRect new_rect;
+        host_floater->removeFloater(self);
+        // reparent to floater view
+        gFloaterView->addChild(self);
+
+        self->openFloater(self->getKey());
+        if (self->mSaveRect && !self->mRectControl.empty())
+        {
+            self->applyRectControl();
+        }
+        else
+        {   // only force position for floaters that don't have that data saved
+            new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
+            self->setRect(new_rect);
+        }
+        gFloaterView->adjustToFitScreen(self, FALSE);
+        // give focus to new window to keep continuity for the user
+        self->setFocus(TRUE);
+        self->setTornOff(true);
+    }
+    else  //Attach to parent.
+    {
+        LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
+        if (new_host)
+        {
+            if (self->mSaveRect)
+            {
+                self->storeRectControl();
+            }
+            self->setMinimized(FALSE); // to reenable minimize button if it was minimized
+            new_host->showFloater(self);
+            // make sure host is visible
+            new_host->openFloater(new_host->getKey());
+        }
+        self->setTornOff(false);
+    }
+    self->updateTitleButtons();
     self->setOpenPositioning(LLFloaterEnums::POSITIONING_RELATIVE);
 }
 
 // static
 void LLFloater::onClickDock(LLFloater* self)
 {
-	if(self && self->mCanDock)
-	{
-		self->setDocked(!self->mDocked, true);
-	}
+    if(self && self->mCanDock)
+    {
+        self->setDocked(!self->mDocked, true);
+    }
 }
 
 // static
 void LLFloater::onClickHelp( LLFloater* self )
 {
-	if (self && LLUI::sHelpImpl)
-	{
-		// find the current help context for this floater
-		std::string help_topic;
-		if (self->findHelpTopic(help_topic))
-		{
-			LLUI::sHelpImpl->showTopic(help_topic);
-		}
-	}
+    if (self && LLUI::sHelpImpl)
+    {
+        // find the current help context for this floater
+        std::string help_topic;
+        if (self->findHelpTopic(help_topic))
+        {
+            LLUI::sHelpImpl->showTopic(help_topic);
+        }
+    }
 }
 
 void LLFloater::initRectControl()
 {
-	// save_rect and save_visibility only apply to registered floaters
-	if (mSaveRect)
-	{
-		std::string ctrl_name = getControlName(mInstanceName, mKey);
-		mRectControl = LLFloaterReg::declareRectControl(ctrl_name);
-		mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name);
-		mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name);
-	}
+    // save_rect and save_visibility only apply to registered floaters
+    if (mSaveRect)
+    {
+        std::string ctrl_name = getControlName(mInstanceName, mKey);
+        mRectControl = LLFloaterReg::declareRectControl(ctrl_name);
+        mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name);
+        mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name);
+    }
 }
 
 // static
 void LLFloater::closeFrontmostFloater()
 {
-	LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater();
-	if(floater_to_close)
-	{
-		floater_to_close->closeFloater();
-	}
+    LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater();
+    if(floater_to_close)
+    {
+        floater_to_close->closeFloater();
+    }
 
-	// if nothing took focus after closing focused floater
-	// give it to next floater (to allow closing multiple windows via keyboard in rapid succession)
-	if (gFocusMgr.getKeyboardFocus() == NULL)
-	{
-		// HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window
-		// which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view
-		gFloaterView->focusFrontFloater();
-	}
+    // if nothing took focus after closing focused floater
+    // give it to next floater (to allow closing multiple windows via keyboard in rapid succession)
+    if (gFocusMgr.getKeyboardFocus() == NULL)
+    {
+        // HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window
+        // which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view
+        gFloaterView->focusFrontFloater();
+    }
 }
 
 
 // static
 void LLFloater::onClickClose( LLFloater* self )
 {
-	if (!self)
-		return;
-	self->onClickCloseBtn();
+    if (!self)
+        return;
+    self->onClickCloseBtn();
 }
 
 void LLFloater::onClickCloseBtn(bool app_quitting)
 {
-	closeFloater(false);
+    closeFloater(false);
 }
 
 
 // virtual
 void LLFloater::draw()
 {
-	const F32 alpha = getCurrentTransparency();
-
-	// draw background
-	if( isBackgroundVisible() )
-	{
-		drawShadow(this);
-
-		S32 left = LLPANEL_BORDER_WIDTH;
-		S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH;
-		S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH;
-		S32 bottom = LLPANEL_BORDER_WIDTH;
-
-		LLUIImage* image = NULL;
-		LLColor4 color;
-		LLColor4 overlay_color;
-		if (isBackgroundOpaque())
-		{
-			// NOTE: image may not be set
-			image = getBackgroundImage();
-			color = getBackgroundColor();
-			overlay_color = getBackgroundImageOverlay();
-		}
-		else
-		{
-			image = getTransparentImage();
-			color = getTransparentColor();
-			overlay_color = getTransparentImageOverlay();
-		}
-
-		if (image)
-		{
-			// We're using images for this floater's backgrounds
-			image->draw(getLocalRect(), overlay_color % alpha);
-		}
-		else
-		{
-			// We're not using images, use old-school flat colors
-			gl_rect_2d( left, top, right, bottom, color % alpha );
-
-			// draw highlight on title bar to indicate focus.  RDW
-			if(hasFocus() 
-				&& !getIsChrome() 
-				&& !getCurrentTitle().empty())
-			{
-				static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor");
-				
-				const LLFontGL* font = LLFontGL::getFontSansSerif();
-				LLRect r = getRect();
-				gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1, 
-					titlebar_focus_color % alpha, 0, TRUE);
-			}
-		}
-	}
-
-	LLPanel::updateDefaultBtn();
-
-	if( getDefaultButton() )
-	{
-		if (hasFocus() && getDefaultButton()->getEnabled())
-		{
-			LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
-			// is this button a direct descendent and not a nested widget (e.g. checkbox)?
-			BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this;
-			// only enable default button when current focus is not a button
-			getDefaultButton()->setBorderEnabled(!focus_is_child_button);
-		}
-		else
-		{
-			getDefaultButton()->setBorderEnabled(FALSE);
-		}
-	}
-	if (isMinimized())
-	{
-		for (S32 i = 0; i < BUTTON_COUNT; i++)
-		{
-			drawChild(mButtons[i]);
-		}
-		drawChild(mDragHandle, 0, 0, TRUE);
-	}
-	else
-	{
-		// don't call LLPanel::draw() since we've implemented custom background rendering
-		LLView::draw();
-	}
-
-	// update tearoff button for torn off floaters
-	// when last host goes away
-	if (mCanTearOff && !getHost())
-	{
-		LLFloater* old_host = mLastHostHandle.get();
-		if (!old_host)
-		{
-			setCanTearOff(FALSE);
-		}
-	}
-}
-
-void	LLFloater::drawShadow(LLPanel* panel)
-{
-	S32 left = LLPANEL_BORDER_WIDTH;
-	S32 top = panel->getRect().getHeight() - LLPANEL_BORDER_WIDTH;
-	S32 right = panel->getRect().getWidth() - LLPANEL_BORDER_WIDTH;
-	S32 bottom = LLPANEL_BORDER_WIDTH;
-
-	static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0);
-	static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow");
-	LLColor4 shadow_color = shadow_color_cached;
-	F32 shadow_offset = (F32)shadow_offset_S32;
-
-	if (!panel->isBackgroundOpaque())
-	{
-		shadow_offset *= 0.2f;
-		shadow_color.mV[VALPHA] *= 0.5f;
-	}
-	gl_drop_shadow(left, top, right, bottom, 
-		shadow_color % getCurrentTransparency(),
-		ll_round(shadow_offset));
+    const F32 alpha = getCurrentTransparency();
+
+    // draw background
+    if( isBackgroundVisible() )
+    {
+        drawShadow(this);
+
+        S32 left = LLPANEL_BORDER_WIDTH;
+        S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH;
+        S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH;
+        S32 bottom = LLPANEL_BORDER_WIDTH;
+
+        LLUIImage* image = NULL;
+        LLColor4 color;
+        LLColor4 overlay_color;
+        if (isBackgroundOpaque())
+        {
+            // NOTE: image may not be set
+            image = getBackgroundImage();
+            color = getBackgroundColor();
+            overlay_color = getBackgroundImageOverlay();
+        }
+        else
+        {
+            image = getTransparentImage();
+            color = getTransparentColor();
+            overlay_color = getTransparentImageOverlay();
+        }
+
+        if (image)
+        {
+            // We're using images for this floater's backgrounds
+            image->draw(getLocalRect(), overlay_color % alpha);
+        }
+        else
+        {
+            // We're not using images, use old-school flat colors
+            gl_rect_2d( left, top, right, bottom, color % alpha );
+
+            // draw highlight on title bar to indicate focus.  RDW
+            if(hasFocus() 
+                && !getIsChrome() 
+                && !getCurrentTitle().empty())
+            {
+                static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor");
+                
+                const LLFontGL* font = LLFontGL::getFontSansSerif();
+                LLRect r = getRect();
+                gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1, 
+                    titlebar_focus_color % alpha, 0, TRUE);
+            }
+        }
+    }
+
+    LLPanel::updateDefaultBtn();
+
+    if( getDefaultButton() )
+    {
+        if (hasFocus() && getDefaultButton()->getEnabled())
+        {
+            LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
+            // is this button a direct descendent and not a nested widget (e.g. checkbox)?
+            BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this;
+            // only enable default button when current focus is not a button
+            getDefaultButton()->setBorderEnabled(!focus_is_child_button);
+        }
+        else
+        {
+            getDefaultButton()->setBorderEnabled(FALSE);
+        }
+    }
+    if (isMinimized())
+    {
+        for (S32 i = 0; i < BUTTON_COUNT; i++)
+        {
+            drawChild(mButtons[i]);
+        }
+        drawChild(mDragHandle, 0, 0, TRUE);
+    }
+    else
+    {
+        // don't call LLPanel::draw() since we've implemented custom background rendering
+        LLView::draw();
+    }
+
+    // update tearoff button for torn off floaters
+    // when last host goes away
+    if (mCanTearOff && !getHost())
+    {
+        LLFloater* old_host = mLastHostHandle.get();
+        if (!old_host)
+        {
+            setCanTearOff(FALSE);
+        }
+    }
+}
+
+void    LLFloater::drawShadow(LLPanel* panel)
+{
+    S32 left = LLPANEL_BORDER_WIDTH;
+    S32 top = panel->getRect().getHeight() - LLPANEL_BORDER_WIDTH;
+    S32 right = panel->getRect().getWidth() - LLPANEL_BORDER_WIDTH;
+    S32 bottom = LLPANEL_BORDER_WIDTH;
+
+    static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0);
+    static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow");
+    LLColor4 shadow_color = shadow_color_cached;
+    F32 shadow_offset = (F32)shadow_offset_S32;
+
+    if (!panel->isBackgroundOpaque())
+    {
+        shadow_offset *= 0.2f;
+        shadow_color.mV[VALPHA] *= 0.5f;
+    }
+    gl_drop_shadow(left, top, right, bottom, 
+        shadow_color % getCurrentTransparency(),
+        ll_round(shadow_offset));
 }
 
 void LLFloater::updateTransparency(LLView* view, ETypeTransparency transparency_type)
 {
-	if (!view) return;
-	child_list_t children = *view->getChildList();
-	child_list_t::iterator it = children.begin();
+    if (!view) return;
+    child_list_t children = *view->getChildList();
+    child_list_t::iterator it = children.begin();
 
-	LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(view);
-	if (ctrl)
-	{
-		ctrl->setTransparencyType(transparency_type);
-	}
+    LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(view);
+    if (ctrl)
+    {
+        ctrl->setTransparencyType(transparency_type);
+    }
 
-	for(; it != children.end(); ++it)
-	{
-		updateTransparency(*it, transparency_type);
-	}
+    for(; it != children.end(); ++it)
+    {
+        updateTransparency(*it, transparency_type);
+    }
 }
 
 void LLFloater::updateTransparency(ETypeTransparency transparency_type)
 {
-	updateTransparency(this, transparency_type);
+    updateTransparency(this, transparency_type);
 }
 
-void	LLFloater::setCanMinimize(BOOL can_minimize)
+void    LLFloater::setCanMinimize(BOOL can_minimize)
 {
-	// if removing minimize/restore button programmatically,
-	// go ahead and unminimize floater
-	mCanMinimize = can_minimize;
-	if (!can_minimize)
-	{
-		setMinimized(FALSE);
-	}
+    // if removing minimize/restore button programmatically,
+    // go ahead and unminimize floater
+    mCanMinimize = can_minimize;
+    if (!can_minimize)
+    {
+        setMinimized(FALSE);
+    }
 
-	mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized();
-	mButtonsEnabled[BUTTON_RESTORE]  = can_minimize &&  isMinimized();
+    mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized();
+    mButtonsEnabled[BUTTON_RESTORE]  = can_minimize &&  isMinimized();
 
-	updateTitleButtons();
+    updateTitleButtons();
 }
 
-void	LLFloater::setCanClose(BOOL can_close)
+void    LLFloater::setCanClose(BOOL can_close)
 {
-	mCanClose = can_close;
-	mButtonsEnabled[BUTTON_CLOSE] = can_close;
+    mCanClose = can_close;
+    mButtonsEnabled[BUTTON_CLOSE] = can_close;
 
-	updateTitleButtons();
+    updateTitleButtons();
 }
 
-void	LLFloater::setCanTearOff(BOOL can_tear_off)
+void    LLFloater::setCanTearOff(BOOL can_tear_off)
 {
-	mCanTearOff = can_tear_off;
-	mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead();
+    mCanTearOff = can_tear_off;
+    mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead();
 
-	updateTitleButtons();
+    updateTitleButtons();
 }
 
 
 void LLFloater::setCanResize(BOOL can_resize)
 {
-	mResizable = can_resize;
-	enableResizeCtrls(can_resize);
+    mResizable = can_resize;
+    enableResizeCtrls(can_resize);
 }
 
 void LLFloater::setCanDrag(BOOL can_drag)
 {
-	// if we delete drag handle, we no longer have access to the floater's title
-	// so just enable/disable it
-	if (!can_drag && mDragHandle->getEnabled())
-	{
-		mDragHandle->setEnabled(FALSE);
-	}
-	else if (can_drag && !mDragHandle->getEnabled())
-	{
-		mDragHandle->setEnabled(TRUE);
-	}
+    // if we delete drag handle, we no longer have access to the floater's title
+    // so just enable/disable it
+    if (!can_drag && mDragHandle->getEnabled())
+    {
+        mDragHandle->setEnabled(FALSE);
+    }
+    else if (can_drag && !mDragHandle->getEnabled())
+    {
+        mDragHandle->setEnabled(TRUE);
+    }
 }
 
 bool LLFloater::getCanDrag()
 {
-	return mDragHandle->getEnabled();
+    return mDragHandle->getEnabled();
 }
 
 
 void LLFloater::updateTitleButtons()
 {
-	static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
-	static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
-	LLRect buttons_rect;
-	S32 button_count = 0;
-	for (S32 i = 0; i < BUTTON_COUNT; i++)
-	{
-		if (!mButtons[i])
-		{
-			continue;
-		}
-
-		bool enabled = mButtonsEnabled[i];
-		if (i == BUTTON_HELP)
-		{
-			// don't show the help button if the floater is minimized
-			// or if it is a docked tear-off floater
-			if (isMinimized() || (mButtonsEnabled[BUTTON_TEAR_OFF] && ! mTornOff))
-			{
-				enabled = false;
-			}
-		}
-		if (i == BUTTON_CLOSE && mButtonScale != 1.f)
-		{
-			//*HACK: always render close button for hosted floaters so
-			//that users don't accidentally hit the button when
-			//closing multiple windows in the chatterbox
-			enabled = true;
-		}
-
-		mButtons[i]->setEnabled(enabled);
-
-		if (enabled)
-		{
-			button_count++;
-
-			LLRect btn_rect;
-			if (mDragOnLeft)
-			{
-				btn_rect.setLeftTopAndSize(
-					LLPANEL_BORDER_WIDTH,
-					getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * button_count,
-					ll_round((F32)floater_close_box_size * mButtonScale),
-					ll_round((F32)floater_close_box_size * mButtonScale));
-			}
-			else
-			{
-				btn_rect.setLeftTopAndSize(
-					getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * button_count,
-					getRect().getHeight() - close_box_from_top,
-					ll_round((F32)floater_close_box_size * mButtonScale),
-					ll_round((F32)floater_close_box_size * mButtonScale));
-			}
-
-			// first time here, init 'buttons_rect'
-			if(1 == button_count)
-			{
-				buttons_rect = btn_rect;
-			}
-			else
-			{
-				// if mDragOnLeft=true then buttons are on top-left side vertically aligned
-				// title is not displayed in this case, calculating 'buttons_rect' for future use
-				mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : 
-					buttons_rect.mLeft = btn_rect.mLeft;
-			}
-			mButtons[i]->setRect(btn_rect);
-			mButtons[i]->setVisible(TRUE);
-			// the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
-			mButtons[i]->setTabStop(i == BUTTON_RESTORE);
-		}
-		else
-		{
-			mButtons[i]->setVisible(FALSE);
-		}
-	}
-	if (mDragHandle)
-	{
-		localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle);
-		mDragHandle->setButtonsRect(buttons_rect);
-	}
+    static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
+    static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
+    LLRect buttons_rect;
+    S32 button_count = 0;
+    for (S32 i = 0; i < BUTTON_COUNT; i++)
+    {
+        if (!mButtons[i])
+        {
+            continue;
+        }
+
+        bool enabled = mButtonsEnabled[i];
+        if (i == BUTTON_HELP)
+        {
+            // don't show the help button if the floater is minimized
+            // or if it is a docked tear-off floater
+            if (isMinimized() || (mButtonsEnabled[BUTTON_TEAR_OFF] && ! mTornOff))
+            {
+                enabled = false;
+            }
+        }
+        if (i == BUTTON_CLOSE && mButtonScale != 1.f)
+        {
+            //*HACK: always render close button for hosted floaters so
+            //that users don't accidentally hit the button when
+            //closing multiple windows in the chatterbox
+            enabled = true;
+        }
+
+        mButtons[i]->setEnabled(enabled);
+
+        if (enabled)
+        {
+            button_count++;
+
+            LLRect btn_rect;
+            if (mDragOnLeft)
+            {
+                btn_rect.setLeftTopAndSize(
+                    LLPANEL_BORDER_WIDTH,
+                    getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * button_count,
+                    ll_round((F32)floater_close_box_size * mButtonScale),
+                    ll_round((F32)floater_close_box_size * mButtonScale));
+            }
+            else
+            {
+                btn_rect.setLeftTopAndSize(
+                    getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * button_count,
+                    getRect().getHeight() - close_box_from_top,
+                    ll_round((F32)floater_close_box_size * mButtonScale),
+                    ll_round((F32)floater_close_box_size * mButtonScale));
+            }
+
+            // first time here, init 'buttons_rect'
+            if(1 == button_count)
+            {
+                buttons_rect = btn_rect;
+            }
+            else
+            {
+                // if mDragOnLeft=true then buttons are on top-left side vertically aligned
+                // title is not displayed in this case, calculating 'buttons_rect' for future use
+                mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : 
+                    buttons_rect.mLeft = btn_rect.mLeft;
+            }
+            mButtons[i]->setRect(btn_rect);
+            mButtons[i]->setVisible(TRUE);
+            // the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
+            mButtons[i]->setTabStop(i == BUTTON_RESTORE);
+        }
+        else
+        {
+            mButtons[i]->setVisible(FALSE);
+        }
+    }
+    if (mDragHandle)
+    {
+        localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle);
+        mDragHandle->setButtonsRect(buttons_rect);
+    }
 }
 
 void LLFloater::buildButtons(const Params& floater_params)
 {
-	static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
-	static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
-	for (S32 i = 0; i < BUTTON_COUNT; i++)
-	{
-		if (mButtons[i])
-		{
-			removeChild(mButtons[i]);
-			delete mButtons[i];
-			mButtons[i] = NULL;
-		}
-		
-		LLRect btn_rect;
-		if (mDragOnLeft)
-		{
-			btn_rect.setLeftTopAndSize(
-				LLPANEL_BORDER_WIDTH,
-				getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * (i + 1),
-				ll_round(floater_close_box_size * mButtonScale),
-				ll_round(floater_close_box_size * mButtonScale));
-		}
-		else
-		{
-			btn_rect.setLeftTopAndSize(
-				getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * (i + 1),
-				getRect().getHeight() - close_box_from_top,
-				ll_round(floater_close_box_size * mButtonScale),
-				ll_round(floater_close_box_size * mButtonScale));
-		}
-
-		LLButton::Params p;
-		p.name(sButtonNames[i]);
-		p.rect(btn_rect);
-		p.image_unselected = getButtonImage(floater_params, (EFloaterButton)i);
-		// Selected, no matter if hovered or not, is "pressed"
-		LLUIImage* pressed_image = getButtonPressedImage(floater_params, (EFloaterButton)i);
-		p.image_selected = pressed_image;
-		p.image_hover_selected = pressed_image;
-		// Use a glow effect when the user hovers over the button
-		// These icons are really small, need glow amount increased
-		p.hover_glow_amount( 0.33f );
-		p.click_callback.function(boost::bind(sButtonCallbacks[i], this));
-		p.tab_stop(false);
-		p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT);
-		p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome());
-		p.scale_image(true);
-		p.chrome(true);
-
-		LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p);
-		addChild(buttonp);
-		mButtons[i] = buttonp;
-	}
-
-	updateTitleButtons();
+    static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
+    static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
+    for (S32 i = 0; i < BUTTON_COUNT; i++)
+    {
+        if (mButtons[i])
+        {
+            removeChild(mButtons[i]);
+            delete mButtons[i];
+            mButtons[i] = NULL;
+        }
+        
+        LLRect btn_rect;
+        if (mDragOnLeft)
+        {
+            btn_rect.setLeftTopAndSize(
+                LLPANEL_BORDER_WIDTH,
+                getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * (i + 1),
+                ll_round(floater_close_box_size * mButtonScale),
+                ll_round(floater_close_box_size * mButtonScale));
+        }
+        else
+        {
+            btn_rect.setLeftTopAndSize(
+                getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * (i + 1),
+                getRect().getHeight() - close_box_from_top,
+                ll_round(floater_close_box_size * mButtonScale),
+                ll_round(floater_close_box_size * mButtonScale));
+        }
+
+        LLButton::Params p;
+        p.name(sButtonNames[i]);
+        p.rect(btn_rect);
+        p.image_unselected = getButtonImage(floater_params, (EFloaterButton)i);
+        // Selected, no matter if hovered or not, is "pressed"
+        LLUIImage* pressed_image = getButtonPressedImage(floater_params, (EFloaterButton)i);
+        p.image_selected = pressed_image;
+        p.image_hover_selected = pressed_image;
+        // Use a glow effect when the user hovers over the button
+        // These icons are really small, need glow amount increased
+        p.hover_glow_amount( 0.33f );
+        p.click_callback.function(boost::bind(sButtonCallbacks[i], this));
+        p.tab_stop(false);
+        p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT);
+        p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome());
+        p.scale_image(true);
+        p.chrome(true);
+
+        LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p);
+        addChild(buttonp);
+        mButtons[i] = buttonp;
+    }
+
+    updateTitleButtons();
 }
 
 // static
 LLUIImage* LLFloater::getButtonImage(const Params& p, EFloaterButton e)
 {
-	switch(e)
-	{
-		default:
-		case BUTTON_CLOSE:
-			return p.close_image;
-		case BUTTON_RESTORE:
-			return p.restore_image;
-		case BUTTON_MINIMIZE:
-			return p.minimize_image;
-		case BUTTON_TEAR_OFF:
-			return p.tear_off_image;
-		case BUTTON_DOCK:
-			return p.dock_image;
-		case BUTTON_HELP:
-			return p.help_image;
-	}
+    switch(e)
+    {
+        default:
+        case BUTTON_CLOSE:
+            return p.close_image;
+        case BUTTON_RESTORE:
+            return p.restore_image;
+        case BUTTON_MINIMIZE:
+            return p.minimize_image;
+        case BUTTON_TEAR_OFF:
+            return p.tear_off_image;
+        case BUTTON_DOCK:
+            return p.dock_image;
+        case BUTTON_HELP:
+            return p.help_image;
+    }
 }
 
 // static
 LLUIImage* LLFloater::getButtonPressedImage(const Params& p, EFloaterButton e)
 {
-	switch(e)
-	{
-		default:
-		case BUTTON_CLOSE:
-			return p.close_pressed_image;
-		case BUTTON_RESTORE:
-			return p.restore_pressed_image;
-		case BUTTON_MINIMIZE:
-			return p.minimize_pressed_image;
-		case BUTTON_TEAR_OFF:
-			return p.tear_off_pressed_image;
-		case BUTTON_DOCK:
-			return p.dock_pressed_image;
-		case BUTTON_HELP:
-			return p.help_pressed_image;
-	}
+    switch(e)
+    {
+        default:
+        case BUTTON_CLOSE:
+            return p.close_pressed_image;
+        case BUTTON_RESTORE:
+            return p.restore_pressed_image;
+        case BUTTON_MINIMIZE:
+            return p.minimize_pressed_image;
+        case BUTTON_TEAR_OFF:
+            return p.tear_off_pressed_image;
+        case BUTTON_DOCK:
+            return p.dock_pressed_image;
+        case BUTTON_HELP:
+            return p.help_pressed_image;
+    }
 }
 
 // static
 std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool is_chrome)
 {
-	// EXT-4081 (Lag Meter: Ctrl+W does not close floater)
-	// If floater is chrome set 'Close' text for close button's tooltip
-	if(is_chrome && BUTTON_CLOSE == e)
-	{
-		static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME");
-		return close_tooltip_chrome;
-	}
-	// TODO: per-floater localizable tooltips set in XML
-	return sButtonToolTips[e];
+    // EXT-4081 (Lag Meter: Ctrl+W does not close floater)
+    // If floater is chrome set 'Close' text for close button's tooltip
+    if(is_chrome && BUTTON_CLOSE == e)
+    {
+        static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME");
+        return close_tooltip_chrome;
+    }
+    // TODO: per-floater localizable tooltips set in XML
+    return sButtonToolTips[e];
 }
 
 /////////////////////////////////////////////////////
@@ -2234,946 +2234,946 @@ std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool
 static LLDefaultChildRegistry::Register<LLFloaterView> r("floater_view");
 
 LLFloaterView::LLFloaterView (const Params& p)
-:	LLUICtrl (p),
-	mFocusCycleMode(FALSE),
-	mMinimizePositionVOffset(0),
-	mSnapOffsetBottom(0),
-	mSnapOffsetRight(0),
-	mFrontChild(NULL)
+:   LLUICtrl (p),
+    mFocusCycleMode(FALSE),
+    mMinimizePositionVOffset(0),
+    mSnapOffsetBottom(0),
+    mSnapOffsetRight(0),
+    mFrontChild(NULL)
 {
-	mSnapView = getHandle();
+    mSnapView = getHandle();
 }
 
 // By default, adjust vertical.
 void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
-	LLView::reshape(width, height, called_from_parent);
-
-	mLastSnapRect = getSnapRect();
-
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLView* viewp = *child_it;
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
-		if (floaterp->isDependent())
-		{
-			// dependents are moved with their "dependee"
-			continue;
-		}
-
-		if (!floaterp->isMinimized() && floaterp->getCanDrag())
-		{
-			LLRect old_rect = floaterp->getRect();
-			floaterp->applyPositioning(NULL, false);
-			LLRect new_rect = floaterp->getRect();
-
-			//LLRect r = floaterp->getRect();
-
-			//// Compute absolute distance from each edge of screen
-			//S32 left_offset = llabs(r.mLeft - 0);
-			//S32 right_offset = llabs(old_right - r.mRight);
-
-			//S32 top_offset = llabs(old_top - r.mTop);
-			//S32 bottom_offset = llabs(r.mBottom - 0);
-
-			S32 translate_x = new_rect.mLeft - old_rect.mLeft;
-			S32 translate_y = new_rect.mBottom - old_rect.mBottom;
-
-			//if (left_offset > right_offset)
-			//{
-			//	translate_x = new_right - old_right;
-			//}
-
-			//if (top_offset < bottom_offset)
-			//{
-			//	translate_y = new_top - old_top;
-			//}
-
-			// don't reposition immovable floaters
-			//if (floaterp->getCanDrag())
-			//{
-			//	floaterp->translate(translate_x, translate_y);
-			//}
-			BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents)
-			{
-				if (dependent_floater.get())
-				{
-					dependent_floater.get()->translate(translate_x, translate_y);
-				}
-			}
-		}
-	}
+    LLView::reshape(width, height, called_from_parent);
+
+    mLastSnapRect = getSnapRect();
+
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLView* viewp = *child_it;
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
+        if (floaterp->isDependent())
+        {
+            // dependents are moved with their "dependee"
+            continue;
+        }
+
+        if (!floaterp->isMinimized() && floaterp->getCanDrag())
+        {
+            LLRect old_rect = floaterp->getRect();
+            floaterp->applyPositioning(NULL, false);
+            LLRect new_rect = floaterp->getRect();
+
+            //LLRect r = floaterp->getRect();
+
+            //// Compute absolute distance from each edge of screen
+            //S32 left_offset = llabs(r.mLeft - 0);
+            //S32 right_offset = llabs(old_right - r.mRight);
+
+            //S32 top_offset = llabs(old_top - r.mTop);
+            //S32 bottom_offset = llabs(r.mBottom - 0);
+
+            S32 translate_x = new_rect.mLeft - old_rect.mLeft;
+            S32 translate_y = new_rect.mBottom - old_rect.mBottom;
+
+            //if (left_offset > right_offset)
+            //{
+            //  translate_x = new_right - old_right;
+            //}
+
+            //if (top_offset < bottom_offset)
+            //{
+            //  translate_y = new_top - old_top;
+            //}
+
+            // don't reposition immovable floaters
+            //if (floaterp->getCanDrag())
+            //{
+            //  floaterp->translate(translate_x, translate_y);
+            //}
+            BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents)
+            {
+                if (dependent_floater.get())
+                {
+                    dependent_floater.get()->translate(translate_x, translate_y);
+                }
+            }
+        }
+    }
 }
 
 
 void LLFloaterView::restoreAll()
 {
-	// make sure all subwindows aren't minimized
-	child_list_t child_list = *(getChildList());
-	for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it)
-	{
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
-		if (floaterp)
-		{
-			floaterp->setMinimized(FALSE);
-		}
-	}
+    // make sure all subwindows aren't minimized
+    child_list_t child_list = *(getChildList());
+    for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it)
+    {
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+        if (floaterp)
+        {
+            floaterp->setMinimized(FALSE);
+        }
+    }
 
-	// *FIX: make sure dependents are restored
+    // *FIX: make sure dependents are restored
 
-	// children then deleted by default view constructor
+    // children then deleted by default view constructor
 }
 
 
 LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLFloater* neighbor )
 {
-	LLRect base_rect = reference_floater->getRect();
-	LLRect::tCoordType width = neighbor->getRect().getWidth();
-	LLRect::tCoordType height = neighbor->getRect().getHeight();
-	LLRect new_rect = neighbor->getRect();
-
-	LLRect expanded_base_rect = base_rect;
-	expanded_base_rect.stretch(10);
-	for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin();
-		dependent_it != reference_floater->mDependents.end(); ++dependent_it)
-	{
-		LLFloater* sibling = dependent_it->get();
-		// check for dependents within 10 pixels of base floater
-		if (sibling && 
-			sibling != neighbor && 
-			sibling->getVisible() && 
-			expanded_base_rect.overlaps(sibling->getRect()))
-		{
-			base_rect.unionWith(sibling->getRect());
-		}
-	}
-
-	LLRect::tCoordType left_margin = llmax(0, base_rect.mLeft);
-	LLRect::tCoordType right_margin = llmax(0, getRect().getWidth() - base_rect.mRight);
-	LLRect::tCoordType top_margin = llmax(0, getRect().getHeight() - base_rect.mTop);
-	LLRect::tCoordType bottom_margin = llmax(0, base_rect.mBottom);
-
-	// find position for floater in following order
-	// right->left->bottom->top
-	for (S32 i = 0; i < 5; i++)
-	{
-		if (right_margin > width)
-		{
-			new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop);
-			return new_rect;
-		}
-		else if (left_margin > width)
-		{
-			new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop);
-			return new_rect;
-		}
-		else if (bottom_margin > height)
-		{
-			new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop);
-			return new_rect;
-		}
-		else if (top_margin > height)
-		{
-			new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom);
-			return new_rect;
-		}
-
-		// keep growing margins to find "best" fit
-		left_margin += 20;
-		right_margin += 20;
-		top_margin += 20;
-		bottom_margin += 20;
-	}
-
-	// didn't find anything, return initial rect
-	return new_rect;
+    LLRect base_rect = reference_floater->getRect();
+    LLRect::tCoordType width = neighbor->getRect().getWidth();
+    LLRect::tCoordType height = neighbor->getRect().getHeight();
+    LLRect new_rect = neighbor->getRect();
+
+    LLRect expanded_base_rect = base_rect;
+    expanded_base_rect.stretch(10);
+    for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin();
+        dependent_it != reference_floater->mDependents.end(); ++dependent_it)
+    {
+        LLFloater* sibling = dependent_it->get();
+        // check for dependents within 10 pixels of base floater
+        if (sibling && 
+            sibling != neighbor && 
+            sibling->getVisible() && 
+            expanded_base_rect.overlaps(sibling->getRect()))
+        {
+            base_rect.unionWith(sibling->getRect());
+        }
+    }
+
+    LLRect::tCoordType left_margin = llmax(0, base_rect.mLeft);
+    LLRect::tCoordType right_margin = llmax(0, getRect().getWidth() - base_rect.mRight);
+    LLRect::tCoordType top_margin = llmax(0, getRect().getHeight() - base_rect.mTop);
+    LLRect::tCoordType bottom_margin = llmax(0, base_rect.mBottom);
+
+    // find position for floater in following order
+    // right->left->bottom->top
+    for (S32 i = 0; i < 5; i++)
+    {
+        if (right_margin > width)
+        {
+            new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop);
+            return new_rect;
+        }
+        else if (left_margin > width)
+        {
+            new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop);
+            return new_rect;
+        }
+        else if (bottom_margin > height)
+        {
+            new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop);
+            return new_rect;
+        }
+        else if (top_margin > height)
+        {
+            new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom);
+            return new_rect;
+        }
+
+        // keep growing margins to find "best" fit
+        left_margin += 20;
+        right_margin += 20;
+        top_margin += 20;
+        bottom_margin += 20;
+    }
+
+    // didn't find anything, return initial rect
+    return new_rect;
 }
 
 
 void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus, BOOL restore)
 {
-	if (!child)
-		return;
-
-	if (mFrontChild == child)
-	{
-		if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
-		{
-			child->setFocus(TRUE);
-		}
-		return;
-	}
-
-	mFrontChild = child;
-
-	// *TODO: make this respect floater's mAutoFocus value, instead of
-	// using parameter
-	if (child->getHost())
- 	{
-		// this floater is hosted elsewhere and hence not one of our children, abort
-		return;
-	}
-	std::vector<LLFloater*> floaters_to_move;
-	// Look at all floaters...tab
-	for (child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it)
-	{
-		LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
-
-		// ...but if I'm a dependent floater...
-		if (floater && child->isDependent())
-		{
-			// ...look for floaters that have me as a dependent...
-			LLFloater::handle_set_iter_t found_dependent = floater->mDependents.find(child->getHandle());
-
-			if (found_dependent != floater->mDependents.end())
-			{
-				// ...and make sure all children of that floater (including me) are brought to front...
-				for (LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
-					dependent_it != floater->mDependents.end(); ++dependent_it)
-				{
-					LLFloater* sibling = dependent_it->get();
-					if (sibling)
-					{
-						floaters_to_move.push_back(sibling);
-					}
-				}
-				//...before bringing my parent to the front...
-				floaters_to_move.push_back(floater);
-			}
-		}
-	}
-
-	std::vector<LLFloater*>::iterator floater_it;
-	for(floater_it = floaters_to_move.begin(); floater_it != floaters_to_move.end(); ++floater_it)
-	{
-		LLFloater* floaterp = *floater_it;
-		sendChildToFront(floaterp);
-
-		// always unminimize dependee, but allow dependents to stay minimized
-		if (!floaterp->isDependent())
-		{
-			floaterp->setMinimized(FALSE);
-		}
-	}
-	floaters_to_move.clear();
-
-	// ...then bringing my own dependents to the front...
-	for (LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin();
-		dependent_it != child->mDependents.end(); ++dependent_it)
-	{
-		LLFloater* dependent = dependent_it->get();
-		if (dependent)
-		{
-			sendChildToFront(dependent);
-		}
-	}
-
-	// ...and finally bringing myself to front 
-	// (do this last, so that I'm left in front at end of this call)
-	if (*beginChild() != child)
-	{
-		sendChildToFront(child);
-	}
-
-	if(restore)
-	{
-		child->setMinimized(FALSE);
-	}
-
-	if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
-	{
-		child->setFocus(TRUE);
-		// floater did not take focus, so relinquish focus to world
-		if (!child->hasFocus())
-		{
-			gFocusMgr.setKeyboardFocus(NULL);
-		}
-	}
+    if (!child)
+        return;
+
+    if (mFrontChild == child)
+    {
+        if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
+        {
+            child->setFocus(TRUE);
+        }
+        return;
+    }
+
+    mFrontChild = child;
+
+    // *TODO: make this respect floater's mAutoFocus value, instead of
+    // using parameter
+    if (child->getHost())
+    {
+        // this floater is hosted elsewhere and hence not one of our children, abort
+        return;
+    }
+    std::vector<LLFloater*> floaters_to_move;
+    // Look at all floaters...tab
+    for (child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it)
+    {
+        LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
+
+        // ...but if I'm a dependent floater...
+        if (floater && child->isDependent())
+        {
+            // ...look for floaters that have me as a dependent...
+            LLFloater::handle_set_iter_t found_dependent = floater->mDependents.find(child->getHandle());
+
+            if (found_dependent != floater->mDependents.end())
+            {
+                // ...and make sure all children of that floater (including me) are brought to front...
+                for (LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
+                    dependent_it != floater->mDependents.end(); ++dependent_it)
+                {
+                    LLFloater* sibling = dependent_it->get();
+                    if (sibling)
+                    {
+                        floaters_to_move.push_back(sibling);
+                    }
+                }
+                //...before bringing my parent to the front...
+                floaters_to_move.push_back(floater);
+            }
+        }
+    }
+
+    std::vector<LLFloater*>::iterator floater_it;
+    for(floater_it = floaters_to_move.begin(); floater_it != floaters_to_move.end(); ++floater_it)
+    {
+        LLFloater* floaterp = *floater_it;
+        sendChildToFront(floaterp);
+
+        // always unminimize dependee, but allow dependents to stay minimized
+        if (!floaterp->isDependent())
+        {
+            floaterp->setMinimized(FALSE);
+        }
+    }
+    floaters_to_move.clear();
+
+    // ...then bringing my own dependents to the front...
+    for (LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin();
+        dependent_it != child->mDependents.end(); ++dependent_it)
+    {
+        LLFloater* dependent = dependent_it->get();
+        if (dependent)
+        {
+            sendChildToFront(dependent);
+        }
+    }
+
+    // ...and finally bringing myself to front 
+    // (do this last, so that I'm left in front at end of this call)
+    if (*beginChild() != child)
+    {
+        sendChildToFront(child);
+    }
+
+    if(restore)
+    {
+        child->setMinimized(FALSE);
+    }
+
+    if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
+    {
+        child->setFocus(TRUE);
+        // floater did not take focus, so relinquish focus to world
+        if (!child->hasFocus())
+        {
+            gFocusMgr.setKeyboardFocus(NULL);
+        }
+    }
 }
 
 void LLFloaterView::highlightFocusedFloater()
 {
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLFloater *floater = (LLFloater *)(*child_it);
-
-		// skip dependent floaters, as we'll handle them in a batch along with their dependee(?)
-		if (floater->isDependent())
-		{
-			continue;
-		}
-
-		BOOL floater_or_dependent_has_focus = gFocusMgr.childHasKeyboardFocus(floater);
-		for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
-			dependent_it != floater->mDependents.end(); 
-			++dependent_it)
-		{
-			LLFloater* dependent_floaterp = dependent_it->get();
-			if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp))
-			{
-				floater_or_dependent_has_focus = TRUE;
-			}
-		}
-
-		// now set this floater and all its dependents
-		floater->setForeground(floater_or_dependent_has_focus);
-
-		for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
-			dependent_it != floater->mDependents.end(); )
-		{
-			LLFloater* dependent_floaterp = dependent_it->get();
-			if (dependent_floaterp)
-			{
-				dependent_floaterp->setForeground(floater_or_dependent_has_focus);
-			}
-			++dependent_it;
-		}
-			
-		floater->cleanupHandles();
-	}
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLFloater *floater = (LLFloater *)(*child_it);
+
+        // skip dependent floaters, as we'll handle them in a batch along with their dependee(?)
+        if (floater->isDependent())
+        {
+            continue;
+        }
+
+        BOOL floater_or_dependent_has_focus = gFocusMgr.childHasKeyboardFocus(floater);
+        for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
+            dependent_it != floater->mDependents.end(); 
+            ++dependent_it)
+        {
+            LLFloater* dependent_floaterp = dependent_it->get();
+            if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp))
+            {
+                floater_or_dependent_has_focus = TRUE;
+            }
+        }
+
+        // now set this floater and all its dependents
+        floater->setForeground(floater_or_dependent_has_focus);
+
+        for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
+            dependent_it != floater->mDependents.end(); )
+        {
+            LLFloater* dependent_floaterp = dependent_it->get();
+            if (dependent_floaterp)
+            {
+                dependent_floaterp->setForeground(floater_or_dependent_has_focus);
+            }
+            ++dependent_it;
+        }
+            
+        floater->cleanupHandles();
+    }
 }
 
 LLFloater* LLFloaterView::getFrontmostClosableFloater()
 {
-	child_list_const_iter_t child_it;
-	LLFloater* frontmost_floater = NULL;
+    child_list_const_iter_t child_it;
+    LLFloater* frontmost_floater = NULL;
 
-	for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		frontmost_floater = (LLFloater *)(*child_it);
+    for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        frontmost_floater = (LLFloater *)(*child_it);
 
-		if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable())
-		{
-			return frontmost_floater;
-		}
-	}
+        if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable())
+        {
+            return frontmost_floater;
+        }
+    }
 
-	return NULL;
+    return NULL;
 }
 
 void LLFloaterView::unhighlightFocusedFloater()
 {
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLFloater *floater = (LLFloater *)(*child_it);
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLFloater *floater = (LLFloater *)(*child_it);
 
-		floater->setForeground(FALSE);
-	}
+        floater->setForeground(FALSE);
+    }
 }
 
 void LLFloaterView::focusFrontFloater()
 {
-	LLFloater* floaterp = getFrontmost();
-	if (floaterp)
-	{
-		floaterp->setFocus(TRUE);
-	}
+    LLFloater* floaterp = getFrontmost();
+    if (floaterp)
+    {
+        floaterp->setFocus(TRUE);
+    }
 }
 
 void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom)
 {
-	const LLFloater::Params& default_params = LLFloater::getDefaultParams();
-	S32 floater_header_size = default_params.header_height;
-	static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
-	LLRect snap_rect_local = getLocalSnapRect();
-	snap_rect_local.mTop += mMinimizePositionVOffset;
-	for(S32 col = snap_rect_local.mLeft;
-		col < snap_rect_local.getWidth() - minimized_width;
-		col += minimized_width)
-	{	
-		for(S32 row = snap_rect_local.mTop - floater_header_size;
-		row > floater_header_size;
-		row -= floater_header_size ) //loop rows
-		{
-
-			bool foundGap = TRUE;
-			for(child_list_const_iter_t child_it = getChildList()->begin();
-				child_it != getChildList()->end();
-				++child_it) //loop floaters
-			{
-				// Examine minimized children.
-				LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
-				if(floater->isMinimized()) 
-				{
-					LLRect r = floater->getRect();
-					if((r.mBottom < (row + floater_header_size))
-					   && (r.mBottom > (row - floater_header_size))
-					   && (r.mLeft < (col + minimized_width))
-					   && (r.mLeft > (col - minimized_width)))
-					{
-						// needs the check for off grid. can't drag,
-						// but window resize makes them off
-						foundGap = FALSE;
-						break;
-					}
-				}
-			} //done floaters
-			if(foundGap)
-			{
-				*left = col;
-				*bottom = row;
-				return; //done
-			}
-		} //done this col
-	}
-
-	// crude - stack'em all at 0,0 when screen is full of minimized
-	// floaters.
-	*left = snap_rect_local.mLeft;
-	*bottom = snap_rect_local.mBottom;
+    const LLFloater::Params& default_params = LLFloater::getDefaultParams();
+    S32 floater_header_size = default_params.header_height;
+    static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
+    LLRect snap_rect_local = getLocalSnapRect();
+    snap_rect_local.mTop += mMinimizePositionVOffset;
+    for(S32 col = snap_rect_local.mLeft;
+        col < snap_rect_local.getWidth() - minimized_width;
+        col += minimized_width)
+    {   
+        for(S32 row = snap_rect_local.mTop - floater_header_size;
+        row > floater_header_size;
+        row -= floater_header_size ) //loop rows
+        {
+
+            bool foundGap = TRUE;
+            for(child_list_const_iter_t child_it = getChildList()->begin();
+                child_it != getChildList()->end();
+                ++child_it) //loop floaters
+            {
+                // Examine minimized children.
+                LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
+                if(floater->isMinimized()) 
+                {
+                    LLRect r = floater->getRect();
+                    if((r.mBottom < (row + floater_header_size))
+                       && (r.mBottom > (row - floater_header_size))
+                       && (r.mLeft < (col + minimized_width))
+                       && (r.mLeft > (col - minimized_width)))
+                    {
+                        // needs the check for off grid. can't drag,
+                        // but window resize makes them off
+                        foundGap = FALSE;
+                        break;
+                    }
+                }
+            } //done floaters
+            if(foundGap)
+            {
+                *left = col;
+                *bottom = row;
+                return; //done
+            }
+        } //done this col
+    }
+
+    // crude - stack'em all at 0,0 when screen is full of minimized
+    // floaters.
+    *left = snap_rect_local.mLeft;
+    *bottom = snap_rect_local.mBottom;
 }
 
 
 void LLFloaterView::destroyAllChildren()
 {
-	LLView::deleteAllChildren();
+    LLView::deleteAllChildren();
 }
 
 void LLFloaterView::closeAllChildren(bool app_quitting)
 {
-	// iterate over a copy of the list, because closing windows will destroy
-	// some windows on the list.
-	child_list_t child_list = *(getChildList());
-
-	for (child_list_const_iter_t it = child_list.begin(); it != child_list.end(); ++it)
-	{
-		LLView* viewp = *it;
-		child_list_const_iter_t exists = std::find(getChildList()->begin(), getChildList()->end(), viewp);
-		if (exists == getChildList()->end())
-		{
-			// this floater has already been removed
-			continue;
-		}
-
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
-
-		// Attempt to close floater.  This will cause the "do you want to save"
-		// dialogs to appear.
-		// Skip invisible floaters if we're not quitting (STORM-192).
-		if (floaterp->canClose() && !floaterp->isDead() &&
-			(app_quitting || floaterp->getVisible()))
-		{
-			floaterp->closeFloater(app_quitting);
-		}
-	}
+    // iterate over a copy of the list, because closing windows will destroy
+    // some windows on the list.
+    child_list_t child_list = *(getChildList());
+
+    for (child_list_const_iter_t it = child_list.begin(); it != child_list.end(); ++it)
+    {
+        LLView* viewp = *it;
+        child_list_const_iter_t exists = std::find(getChildList()->begin(), getChildList()->end(), viewp);
+        if (exists == getChildList()->end())
+        {
+            // this floater has already been removed
+            continue;
+        }
+
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
+
+        // Attempt to close floater.  This will cause the "do you want to save"
+        // dialogs to appear.
+        // Skip invisible floaters if we're not quitting (STORM-192).
+        if (floaterp->canClose() && !floaterp->isDead() &&
+            (app_quitting || floaterp->getVisible()))
+        {
+            floaterp->closeFloater(app_quitting);
+        }
+    }
 }
 
 void LLFloaterView::hiddenFloaterClosed(LLFloater* floater)
 {
-	for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
-		it != end_it;
-		++it)
-	{
-		if (it->first.get() == floater)
-		{
-			it->second.disconnect();
-			mHiddenFloaters.erase(it);
-			break;
-		}
-	}
+    for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
+        it != end_it;
+        ++it)
+    {
+        if (it->first.get() == floater)
+        {
+            it->second.disconnect();
+            mHiddenFloaters.erase(it);
+            break;
+        }
+    }
 }
 
 void LLFloaterView::hideAllFloaters()
 {
-	child_list_t child_list = *(getChildList());
+    child_list_t child_list = *(getChildList());
 
-	for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it)
-	{
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
-		if (floaterp && floaterp->getVisible())
-		{
-			floaterp->setVisible(false);
-			boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp));
-			mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection));
-		}
-	}
+    for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it)
+    {
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+        if (floaterp && floaterp->getVisible())
+        {
+            floaterp->setVisible(false);
+            boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp));
+            mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection));
+        }
+    }
 }
 
 void LLFloaterView::showHiddenFloaters()
 {
-	for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
-		it != end_it;
-		++it)
-	{
-		LLFloater* floaterp = it->first.get();
-		if (floaterp)
-		{
-			floaterp->setVisible(true);
-		}
-		it->second.disconnect();
-	}
-	mHiddenFloaters.clear();
+    for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
+        it != end_it;
+        ++it)
+    {
+        LLFloater* floaterp = it->first.get();
+        if (floaterp)
+        {
+            floaterp->setVisible(true);
+        }
+        it->second.disconnect();
+    }
+    mHiddenFloaters.clear();
 }
 
 BOOL LLFloaterView::allChildrenClosed()
 {
-	// see if there are any visible floaters (some floaters "close"
-	// by setting themselves invisible)
-	for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
-	{
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+    // see if there are any visible floaters (some floaters "close"
+    // by setting themselves invisible)
+    for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
+    {
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
 
-		if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable())
-		{
-			return false;
-		}
-	}
-	return true;
+        if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable())
+        {
+            return false;
+        }
+    }
+    return true;
 }
 
 void LLFloaterView::shiftFloaters(S32 x_offset, S32 y_offset)
 {
-	for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
-	{
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+    for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
+    {
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
 
-		if (floaterp && floaterp->isMinimized())
-		{
-			floaterp->translate(x_offset, y_offset);
-		}
-	}
+        if (floaterp && floaterp->isMinimized())
+        {
+            floaterp->translate(x_offset, y_offset);
+        }
+    }
 }
 
 void LLFloaterView::refresh()
 {
-	LLRect snap_rect = getSnapRect();
-	if (snap_rect != mLastSnapRect)
-	{
-		reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
-	}
-
-	// Constrain children to be entirely on the screen
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
-		if (floaterp && floaterp->getVisible() )
-		{
-			// minimized floaters are kept fully onscreen
-			adjustToFitScreen(floaterp, !floaterp->isMinimized());
-		}
-	}
+    LLRect snap_rect = getSnapRect();
+    if (snap_rect != mLastSnapRect)
+    {
+        reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
+    }
+
+    // Constrain children to be entirely on the screen
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+        if (floaterp && floaterp->getVisible() )
+        {
+            // minimized floaters are kept fully onscreen
+            adjustToFitScreen(floaterp, !floaterp->isMinimized());
+        }
+    }
 }
 
 void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_outside, BOOL snap_in_toolbars/* = false*/)
 {
-	if (floater->getParent() != this)
-	{
-		// floater is hosted elsewhere, so ignore
-		return;
-	}
-	LLRect::tCoordType screen_width = getSnapRect().getWidth();
-	LLRect::tCoordType screen_height = getSnapRect().getHeight();
-
-	
-	// only automatically resize non-minimized, resizable floaters
-	if( floater->isResizable() && !floater->isMinimized() )
-	{
-		LLRect view_rect = floater->getRect();
-		S32 old_width = view_rect.getWidth();
-		S32 old_height = view_rect.getHeight();
-		S32 min_width;
-		S32 min_height;
-		floater->getResizeLimits( &min_width, &min_height );
-
-		// Make sure floater isn't already smaller than its min height/width?
-		S32 new_width = llmax( min_width, old_width );
-		S32 new_height = llmax( min_height, old_height);
-
-		if((new_width > screen_width) || (new_height > screen_height))
-		{
-			// We have to make this window able to fit on screen
-			new_width = llmin(new_width, screen_width);
-			new_height = llmin(new_height, screen_height);
-
-			// ...while respecting minimum width/height
-			new_width = llmax(new_width, min_width);
-			new_height = llmax(new_height, min_height);
-
-			LLRect new_rect;
-			new_rect.setLeftTopAndSize(view_rect.mLeft,view_rect.mTop,new_width, new_height);
-
-			floater->setShape(new_rect);
-
-			if (floater->followsRight())
-			{
-				floater->translate(old_width - new_width, 0);
-			}
-
-			if (floater->followsTop())
-			{
-				floater->translate(0, old_height - new_height);
-			}
-		}
-	}
-
-	const LLRect& floater_rect = floater->getRect();
-
-	S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0;
-	S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0;
-	S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0;
-
-	// move window fully onscreen
-	if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX ))
-	{
-		floater->clearSnapTarget();
-	}
-	else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom)
-	{
-		floater->translate(delta_left, 0);
-	}
-	else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight)
-	{
-		floater->translate(0, delta_bottom);
-	}
-	else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop	&& floater_rect.mBottom > mToolbarRightRect.mBottom)
-	{
-		floater->translate(delta_right, 0);
-	}
+    if (floater->getParent() != this)
+    {
+        // floater is hosted elsewhere, so ignore
+        return;
+    }
+    LLRect::tCoordType screen_width = getSnapRect().getWidth();
+    LLRect::tCoordType screen_height = getSnapRect().getHeight();
+
+    
+    // only automatically resize non-minimized, resizable floaters
+    if( floater->isResizable() && !floater->isMinimized() )
+    {
+        LLRect view_rect = floater->getRect();
+        S32 old_width = view_rect.getWidth();
+        S32 old_height = view_rect.getHeight();
+        S32 min_width;
+        S32 min_height;
+        floater->getResizeLimits( &min_width, &min_height );
+
+        // Make sure floater isn't already smaller than its min height/width?
+        S32 new_width = llmax( min_width, old_width );
+        S32 new_height = llmax( min_height, old_height);
+
+        if((new_width > screen_width) || (new_height > screen_height))
+        {
+            // We have to make this window able to fit on screen
+            new_width = llmin(new_width, screen_width);
+            new_height = llmin(new_height, screen_height);
+
+            // ...while respecting minimum width/height
+            new_width = llmax(new_width, min_width);
+            new_height = llmax(new_height, min_height);
+
+            LLRect new_rect;
+            new_rect.setLeftTopAndSize(view_rect.mLeft,view_rect.mTop,new_width, new_height);
+
+            floater->setShape(new_rect);
+
+            if (floater->followsRight())
+            {
+                floater->translate(old_width - new_width, 0);
+            }
+
+            if (floater->followsTop())
+            {
+                floater->translate(0, old_height - new_height);
+            }
+        }
+    }
+
+    const LLRect& floater_rect = floater->getRect();
+
+    S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0;
+    S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0;
+    S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0;
+
+    // move window fully onscreen
+    if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX ))
+    {
+        floater->clearSnapTarget();
+    }
+    else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom)
+    {
+        floater->translate(delta_left, 0);
+    }
+    else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight)
+    {
+        floater->translate(0, delta_bottom);
+    }
+    else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop  && floater_rect.mBottom > mToolbarRightRect.mBottom)
+    {
+        floater->translate(delta_right, 0);
+    }
 }
 
 void LLFloaterView::draw()
 {
-	refresh();
+    refresh();
 
-	// hide focused floater if in cycle mode, so that it can be drawn on top
-	LLFloater* focused_floater = getFocusedFloater();
+    // hide focused floater if in cycle mode, so that it can be drawn on top
+    LLFloater* focused_floater = getFocusedFloater();
 
-	if (mFocusCycleMode && focused_floater)
-	{
-		child_list_const_iter_t child_it = getChildList()->begin();
-		for (;child_it != getChildList()->end(); ++child_it)
-		{
-			if ((*child_it) != focused_floater)
-			{
-				drawChild(*child_it);
-			}
-		}
+    if (mFocusCycleMode && focused_floater)
+    {
+        child_list_const_iter_t child_it = getChildList()->begin();
+        for (;child_it != getChildList()->end(); ++child_it)
+        {
+            if ((*child_it) != focused_floater)
+            {
+                drawChild(*child_it);
+            }
+        }
 
-		drawChild(focused_floater, -TABBED_FLOATER_OFFSET, TABBED_FLOATER_OFFSET);
-	}
-	else
-	{
-		LLView::draw();
-	}
+        drawChild(focused_floater, -TABBED_FLOATER_OFFSET, TABBED_FLOATER_OFFSET);
+    }
+    else
+    {
+        LLView::draw();
+    }
 }
 
 LLRect LLFloaterView::getSnapRect() const
 {
-	LLRect snap_rect = getLocalRect();
+    LLRect snap_rect = getLocalRect();
 
-	LLView* snap_view = mSnapView.get();
-	if (snap_view)
-	{
-		snap_view->localRectToOtherView(snap_view->getLocalRect(), &snap_rect, this);
-	}
+    LLView* snap_view = mSnapView.get();
+    if (snap_view)
+    {
+        snap_view->localRectToOtherView(snap_view->getLocalRect(), &snap_rect, this);
+    }
 
-	return snap_rect;
+    return snap_rect;
 }
 
 LLFloater *LLFloaterView::getFocusedFloater() const
 {
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		if ((*child_it)->isCtrl())
-		{
-			LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it);
-			if ( ctrlp && ctrlp->hasFocus() )
-			{
-				return ctrlp;
-			}
-		}
-	}
-	return NULL;
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        if ((*child_it)->isCtrl())
+        {
+            LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it);
+            if ( ctrlp && ctrlp->hasFocus() )
+            {
+                return ctrlp;
+            }
+        }
+    }
+    return NULL;
 }
 
 LLFloater *LLFloaterView::getFrontmost() const
 {
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLView* viewp = *child_it;
-		if ( viewp->getVisible() && !viewp->isDead())
-		{
-			return (LLFloater *)viewp;
-		}
-	}
-	return NULL;
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLView* viewp = *child_it;
+        if ( viewp->getVisible() && !viewp->isDead())
+        {
+            return (LLFloater *)viewp;
+        }
+    }
+    return NULL;
 }
 
 LLFloater *LLFloaterView::getBackmost() const
 {
-	LLFloater* back_most = NULL;
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLView* viewp = *child_it;
-		if ( viewp->getVisible() )
-		{
-			back_most = (LLFloater *)viewp;
-		}
-	}
-	return back_most;
+    LLFloater* back_most = NULL;
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLView* viewp = *child_it;
+        if ( viewp->getVisible() )
+        {
+            back_most = (LLFloater *)viewp;
+        }
+    }
+    return back_most;
 }
 
 void LLFloaterView::syncFloaterTabOrder()
 {
-	// look for a visible modal dialog, starting from first
-	LLModalDialog* modal_dialog = NULL;
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLModalDialog* dialog = dynamic_cast<LLModalDialog*>(*child_it);
-		if (dialog && dialog->isModal() && dialog->getVisible())
-		{
-			modal_dialog = dialog;
-			break;
-		}
-	}
-
-	if (modal_dialog)
-	{
-		// If we have a visible modal dialog, make sure that it has focus
-		LLUI::addPopup(modal_dialog);
-		
-		if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) )
-		{
-			modal_dialog->setFocus(TRUE);
-		}
-				
-		if( !gFocusMgr.childHasMouseCapture( modal_dialog ) )
-		{
-			gFocusMgr.setMouseCapture( modal_dialog );
-		}
-	}
-	else
-	{
-		// otherwise, make sure the focused floater is in the front of the child list
-		for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it)
-		{
-			LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
-			if (gFocusMgr.childHasKeyboardFocus(floaterp))
-			{
-				bringToFront(floaterp, FALSE);
-				break;
-			}
-		}
-	}
-}
-
-LLFloater*	LLFloaterView::getParentFloater(LLView* viewp) const
-{
-	LLView* parentp = viewp->getParent();
-
-	while(parentp && parentp != this)
-	{
-		viewp = parentp;
-		parentp = parentp->getParent();
-	}
-
-	if (parentp == this)
-	{
-		return dynamic_cast<LLFloater*>(viewp);
-	}
-
-	return NULL;
+    // look for a visible modal dialog, starting from first
+    LLModalDialog* modal_dialog = NULL;
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLModalDialog* dialog = dynamic_cast<LLModalDialog*>(*child_it);
+        if (dialog && dialog->isModal() && dialog->getVisible())
+        {
+            modal_dialog = dialog;
+            break;
+        }
+    }
+
+    if (modal_dialog)
+    {
+        // If we have a visible modal dialog, make sure that it has focus
+        LLUI::addPopup(modal_dialog);
+        
+        if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) )
+        {
+            modal_dialog->setFocus(TRUE);
+        }
+                
+        if( !gFocusMgr.childHasMouseCapture( modal_dialog ) )
+        {
+            gFocusMgr.setMouseCapture( modal_dialog );
+        }
+    }
+    else
+    {
+        // otherwise, make sure the focused floater is in the front of the child list
+        for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it)
+        {
+            LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+            if (gFocusMgr.childHasKeyboardFocus(floaterp))
+            {
+                bringToFront(floaterp, FALSE);
+                break;
+            }
+        }
+    }
+}
+
+LLFloater*  LLFloaterView::getParentFloater(LLView* viewp) const
+{
+    LLView* parentp = viewp->getParent();
+
+    while(parentp && parentp != this)
+    {
+        viewp = parentp;
+        parentp = parentp->getParent();
+    }
+
+    if (parentp == this)
+    {
+        return dynamic_cast<LLFloater*>(viewp);
+    }
+
+    return NULL;
 }
 
 S32 LLFloaterView::getZOrder(LLFloater* child)
 {
-	S32 rv = 0;
-	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-	{
-		LLView* viewp = *child_it;
-		if(viewp == child)
-		{
-			break;
-		}
-		++rv;
-	}
-	return rv;
+    S32 rv = 0;
+    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+    {
+        LLView* viewp = *child_it;
+        if(viewp == child)
+        {
+            break;
+        }
+        ++rv;
+    }
+    return rv;
 }
 
 void LLFloaterView::pushVisibleAll(BOOL visible, const skip_list_t& skip_list)
 {
-	for (child_list_const_iter_t child_iter = getChildList()->begin();
-		 child_iter != getChildList()->end(); ++child_iter)
-	{
-		LLView *view = *child_iter;
-		if (skip_list.find(view) == skip_list.end())
-		{
-			view->pushVisible(visible);
-		}
-	}
+    for (child_list_const_iter_t child_iter = getChildList()->begin();
+         child_iter != getChildList()->end(); ++child_iter)
+    {
+        LLView *view = *child_iter;
+        if (skip_list.find(view) == skip_list.end())
+        {
+            view->pushVisible(visible);
+        }
+    }
 
-	LLFloaterReg::blockShowFloaters(true);
+    LLFloaterReg::blockShowFloaters(true);
 }
 
 void LLFloaterView::popVisibleAll(const skip_list_t& skip_list)
 {
-	// make a copy of the list since some floaters change their
-	// order in the childList when changing visibility.
-	child_list_t child_list_copy = *getChildList();
+    // make a copy of the list since some floaters change their
+    // order in the childList when changing visibility.
+    child_list_t child_list_copy = *getChildList();
 
-	for (child_list_const_iter_t child_iter = child_list_copy.begin();
-		 child_iter != child_list_copy.end(); ++child_iter)
-	{
-		LLView *view = *child_iter;
-		if (skip_list.find(view) == skip_list.end())
-		{
-			view->popVisible();
-		}
-	}
+    for (child_list_const_iter_t child_iter = child_list_copy.begin();
+         child_iter != child_list_copy.end(); ++child_iter)
+    {
+        LLView *view = *child_iter;
+        if (skip_list.find(view) == skip_list.end())
+        {
+            view->popVisible();
+        }
+    }
 
-	LLFloaterReg::blockShowFloaters(false);
+    LLFloaterReg::blockShowFloaters(false);
 }
 
 void LLFloaterView::setToolbarRect(LLToolBarEnums::EToolBarLocation tb, const LLRect& toolbar_rect)
 {
-	switch (tb)
-	{
-	case LLToolBarEnums::TOOLBAR_LEFT:
-		mToolbarLeftRect = toolbar_rect;
-		break;
-	case LLToolBarEnums::TOOLBAR_BOTTOM:
-		mToolbarBottomRect = toolbar_rect;
-		break;
-	case LLToolBarEnums::TOOLBAR_RIGHT:
-		mToolbarRightRect = toolbar_rect;
-		break;
-	default:
-		LL_WARNS() << "setToolbarRect() passed odd toolbar number " << (S32) tb << LL_ENDL;
-		break;
-	}
+    switch (tb)
+    {
+    case LLToolBarEnums::TOOLBAR_LEFT:
+        mToolbarLeftRect = toolbar_rect;
+        break;
+    case LLToolBarEnums::TOOLBAR_BOTTOM:
+        mToolbarBottomRect = toolbar_rect;
+        break;
+    case LLToolBarEnums::TOOLBAR_RIGHT:
+        mToolbarRightRect = toolbar_rect;
+        break;
+    default:
+        LL_WARNS() << "setToolbarRect() passed odd toolbar number " << (S32) tb << LL_ENDL;
+        break;
+    }
 }
 
 void LLFloater::setInstanceName(const std::string& name)
 {
-	if (name != mInstanceName)
-	{
-	llassert_always(mInstanceName.empty());
-	mInstanceName = name;
-	if (!mInstanceName.empty())
-	{
-		std::string ctrl_name = getControlName(mInstanceName, mKey);
-			initRectControl();
-		if (!mVisibilityControl.empty())
-		{
-			mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name);
-		}
-		if(!mDocStateControl.empty())
-		{
-			mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
-		}
-	}
+    if (name != mInstanceName)
+    {
+    llassert_always(mInstanceName.empty());
+    mInstanceName = name;
+    if (!mInstanceName.empty())
+    {
+        std::string ctrl_name = getControlName(mInstanceName, mKey);
+            initRectControl();
+        if (!mVisibilityControl.empty())
+        {
+            mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name);
+        }
+        if(!mDocStateControl.empty())
+        {
+            mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
+        }
+    }
 }
 }
 
 void LLFloater::setKey(const LLSD& newkey)
 {
-	// Note: We don't have to do anything special with registration when we change keys
-	mKey = newkey;
+    // Note: We don't have to do anything special with registration when we change keys
+    mKey = newkey;
 }
 
 //static
 void LLFloater::setupParamsForExport(Params& p, LLView* parent)
 {
-	// Do rectangle munging to topleft layout first
-	LLPanel::setupParamsForExport(p, parent);
+    // Do rectangle munging to topleft layout first
+    LLPanel::setupParamsForExport(p, parent);
 
-	// Copy the rectangle out to apply layout constraints
-	LLRect rect = p.rect;
+    // Copy the rectangle out to apply layout constraints
+    LLRect rect = p.rect;
 
-	// Null out other settings
-	p.rect.left.setProvided(false);
-	p.rect.top.setProvided(false);
-	p.rect.right.setProvided(false);
-	p.rect.bottom.setProvided(false);
+    // Null out other settings
+    p.rect.left.setProvided(false);
+    p.rect.top.setProvided(false);
+    p.rect.right.setProvided(false);
+    p.rect.bottom.setProvided(false);
 
-	// Explicitly set width/height
-	p.rect.width.set( rect.getWidth(), true );
-	p.rect.height.set( rect.getHeight(), true );
+    // Explicitly set width/height
+    p.rect.width.set( rect.getWidth(), true );
+    p.rect.height.set( rect.getHeight(), true );
 
-	// If you can't resize this floater, don't export min_height
-	// and min_width
-	bool can_resize = p.can_resize;
-	if (!can_resize)
-	{
-		p.min_height.setProvided(false);
-		p.min_width.setProvided(false);
-	}
+    // If you can't resize this floater, don't export min_height
+    // and min_width
+    bool can_resize = p.can_resize;
+    if (!can_resize)
+    {
+        p.min_height.setProvided(false);
+        p.min_width.setProvided(false);
+    }
 }
 
 void LLFloater::initFromParams(const LLFloater::Params& p)
 {
-	// *NOTE: We have too many classes derived from LLFloater to retrofit them 
-	// all to pass in params via constructors.  So we use this method.
-
-	 // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
-	LLPanel::initFromParams(p);
-
-	// override any follows flags
-	if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED)
-	{
-		setFollows(FOLLOWS_NONE);
-	}
-
-	mTitle = p.title;
-	mShortTitle = p.short_title;
-	applyTitle();
-
-	setCanTearOff(p.can_tear_off);
-	setCanMinimize(p.can_minimize);
-	setCanClose(p.can_close);
-	setCanDock(p.can_dock);
-	setCanResize(p.can_resize);
-	setResizeLimits(p.min_width, p.min_height);
-	
-	mDragOnLeft = p.can_drag_on_left;
-	mHeaderHeight = p.header_height;
-	mLegacyHeaderHeight = p.legacy_header_height;
-	mSingleInstance = p.single_instance;
-	mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance;
-
-	mPositioning = p.positioning;
-
-	mSaveRect = p.save_rect;
-	if (p.save_visibility)
-	{
-		mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
-	}
-	if(p.save_dock_state)
-	{
-		mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set
-	}
-	
-	// open callback 
-	if (p.open_callback.isProvided())
-	{
-		setOpenCallback(initCommitCallback(p.open_callback));
-	}
-	// close callback 
-	if (p.close_callback.isProvided())
-	{
-		setCloseCallback(initCommitCallback(p.close_callback));
-	}
-
-	if (mDragHandle)
-	{
-		mDragHandle->setTitleVisible(p.show_title);
-	}
+    // *NOTE: We have too many classes derived from LLFloater to retrofit them 
+    // all to pass in params via constructors.  So we use this method.
+
+     // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
+    LLPanel::initFromParams(p);
+
+    // override any follows flags
+    if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED)
+    {
+        setFollows(FOLLOWS_NONE);
+    }
+
+    mTitle = p.title;
+    mShortTitle = p.short_title;
+    applyTitle();
+
+    setCanTearOff(p.can_tear_off);
+    setCanMinimize(p.can_minimize);
+    setCanClose(p.can_close);
+    setCanDock(p.can_dock);
+    setCanResize(p.can_resize);
+    setResizeLimits(p.min_width, p.min_height);
+    
+    mDragOnLeft = p.can_drag_on_left;
+    mHeaderHeight = p.header_height;
+    mLegacyHeaderHeight = p.legacy_header_height;
+    mSingleInstance = p.single_instance;
+    mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance;
+
+    mPositioning = p.positioning;
+
+    mSaveRect = p.save_rect;
+    if (p.save_visibility)
+    {
+        mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
+    }
+    if(p.save_dock_state)
+    {
+        mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set
+    }
+    
+    // open callback 
+    if (p.open_callback.isProvided())
+    {
+        setOpenCallback(initCommitCallback(p.open_callback));
+    }
+    // close callback 
+    if (p.close_callback.isProvided())
+    {
+        setCloseCallback(initCommitCallback(p.close_callback));
+    }
+
+    if (mDragHandle)
+    {
+        mDragHandle->setTitleVisible(p.show_title);
+    }
 }
 
 boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_t::slot_type& cb ) 
 { 
-	if (!mMinimizeSignal) mMinimizeSignal = new commit_signal_t();
-	return mMinimizeSignal->connect(cb); 
+    if (!mMinimizeSignal) mMinimizeSignal = new commit_signal_t();
+    return mMinimizeSignal->connect(cb); 
 }
 
 boost::signals2::connection LLFloater::setOpenCallback( const commit_signal_t::slot_type& cb )
 {
-	return mOpenSignal.connect(cb);
+    return mOpenSignal.connect(cb);
 }
 
 boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t::slot_type& cb )
 {
-	return mCloseSignal.connect(cb);
+    return mCloseSignal.connect(cb);
 }
 
 LLTrace::BlockTimerStatHandle POST_BUILD("Floater Post Build");
@@ -3181,127 +3181,127 @@ static LLTrace::BlockTimerStatHandle FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floa
 
 bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node)
 {
-	Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
-	Params params(default_params);
-
-	LLXUIParser parser;
-	parser.readXUI(node, params, filename); // *TODO: Error checking
-
-	std::string xml_filename = params.filename;
-
-	if (!xml_filename.empty())
-	{
-		LLXMLNodePtr referenced_xml;
-
-		if (output_node)
-		{
-			//if we are exporting, we want to export the current xml
-			//not the referenced xml
-			Params output_params;
-			parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName());
-			setupParamsForExport(output_params, parent);
-			output_node->setName(node->getName()->mString);
-			parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
-			return TRUE;
-		}
-
-		LLUICtrlFactory::instance().pushFileName(xml_filename);
-
-		LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_FLOATER_LOAD);
-		if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
-		{
-			LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL;
-
-			return FALSE;
-		}
-
-		Params referenced_params;
-		parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName());
-		params.fillFrom(referenced_params);
-
-		// add children using dimensions from referenced xml for consistent layout
-		setShape(params.rect);
-		LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
-
-		LLUICtrlFactory::instance().popFileName();
-	}
-
-
-	if (output_node)
-	{
-		Params output_params(params);
-		setupParamsForExport(output_params, parent);
-		output_node->setName(node->getName()->mString);
-		parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
-	}
-
-	// Default floater position to top-left corner of screen
-	// However, some legacy floaters have explicit top or bottom
-	// coordinates set, so respect their wishes.
-	if (!params.rect.top.isProvided() && !params.rect.bottom.isProvided())
-	{
-		params.rect.top.set(0);
-	}
-	if (!params.rect.left.isProvided() && !params.rect.right.isProvided())
-	{
-		params.rect.left.set(0);
-	}
-	params.from_xui = true;
-	applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect());
- 	initFromParams(params);
-
-	initFloater(params);
-	
-	LLMultiFloater* last_host = LLFloater::getFloaterHost();
-	if (node->hasName("multi_floater"))
-	{
-		LLFloater::setFloaterHost((LLMultiFloater*) this);
-	}
-
-	LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
-
-	if (node->hasName("multi_floater"))
-	{
-		LLFloater::setFloaterHost(last_host);
-	}
-	
-	// HACK: When we changed the header height to 25 pixels in Viewer 2, rather
-	// than re-layout all the floaters we use this value in pixels to make the
-	// whole floater bigger and change the top-left coordinate for widgets.
-	// The goal is to eventually set mLegacyHeaderHeight to zero, which would
-	// make the top-left corner for widget layout the same as the top-left
-	// corner of the window's content area.  James
-	S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight);
-	if (header_stretch > 0)
-	{
-		// Stretch the floater vertically, don't move widgets
-		LLRect rect = getRect();
-		rect.mTop += header_stretch;
-
-		// This will also update drag handle, title bar, close box, etc.
-		setRect(rect);
-	}
-
-	BOOL result;
-	{
-		LL_RECORD_BLOCK_TIME(POST_BUILD);
-
-		result = postBuild();
-	}
-
-	if (!result)
-	{
-		LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL;
-	}
-
-	applyRectControl(); // If we have a saved rect control, apply it
-	gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen	
-
-	moveResizeHandlesToFront();
-
-	applyDockState();
-
-	return true; // *TODO: Error checking
+    Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
+    Params params(default_params);
+
+    LLXUIParser parser;
+    parser.readXUI(node, params, filename); // *TODO: Error checking
+
+    std::string xml_filename = params.filename;
+
+    if (!xml_filename.empty())
+    {
+        LLXMLNodePtr referenced_xml;
+
+        if (output_node)
+        {
+            //if we are exporting, we want to export the current xml
+            //not the referenced xml
+            Params output_params;
+            parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName());
+            setupParamsForExport(output_params, parent);
+            output_node->setName(node->getName()->mString);
+            parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
+            return TRUE;
+        }
+
+        LLUICtrlFactory::instance().pushFileName(xml_filename);
+
+        LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_FLOATER_LOAD);
+        if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
+        {
+            LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL;
+
+            return FALSE;
+        }
+
+        Params referenced_params;
+        parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName());
+        params.fillFrom(referenced_params);
+
+        // add children using dimensions from referenced xml for consistent layout
+        setShape(params.rect);
+        LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
+
+        LLUICtrlFactory::instance().popFileName();
+    }
+
+
+    if (output_node)
+    {
+        Params output_params(params);
+        setupParamsForExport(output_params, parent);
+        output_node->setName(node->getName()->mString);
+        parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
+    }
+
+    // Default floater position to top-left corner of screen
+    // However, some legacy floaters have explicit top or bottom
+    // coordinates set, so respect their wishes.
+    if (!params.rect.top.isProvided() && !params.rect.bottom.isProvided())
+    {
+        params.rect.top.set(0);
+    }
+    if (!params.rect.left.isProvided() && !params.rect.right.isProvided())
+    {
+        params.rect.left.set(0);
+    }
+    params.from_xui = true;
+    applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect());
+    initFromParams(params);
+
+    initFloater(params);
+    
+    LLMultiFloater* last_host = LLFloater::getFloaterHost();
+    if (node->hasName("multi_floater"))
+    {
+        LLFloater::setFloaterHost((LLMultiFloater*) this);
+    }
+
+    LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
+
+    if (node->hasName("multi_floater"))
+    {
+        LLFloater::setFloaterHost(last_host);
+    }
+    
+    // HACK: When we changed the header height to 25 pixels in Viewer 2, rather
+    // than re-layout all the floaters we use this value in pixels to make the
+    // whole floater bigger and change the top-left coordinate for widgets.
+    // The goal is to eventually set mLegacyHeaderHeight to zero, which would
+    // make the top-left corner for widget layout the same as the top-left
+    // corner of the window's content area.  James
+    S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight);
+    if (header_stretch > 0)
+    {
+        // Stretch the floater vertically, don't move widgets
+        LLRect rect = getRect();
+        rect.mTop += header_stretch;
+
+        // This will also update drag handle, title bar, close box, etc.
+        setRect(rect);
+    }
+
+    BOOL result;
+    {
+        LL_RECORD_BLOCK_TIME(POST_BUILD);
+
+        result = postBuild();
+    }
+
+    if (!result)
+    {
+        LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL;
+    }
+
+    applyRectControl(); // If we have a saved rect control, apply it
+    gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen  
+
+    moveResizeHandlesToFront();
+
+    applyDockState();
+
+    return true; // *TODO: Error checking
 }
 
 bool LLFloater::isShown() const
@@ -3311,7 +3311,7 @@ bool LLFloater::isShown() const
 
 bool LLFloater::isDetachedAndNotMinimized()
 {
-	return !getHost() && !isMinimized();
+    return !getHost() && !isMinimized();
 }
 
 /* static */
@@ -3336,205 +3336,205 @@ static LLTrace::BlockTimerStatHandle FTM_BUILD_FLOATERS("Build Floaters");
 
 bool LLFloater::buildFromFile(const std::string& filename)
 {
-	LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS);
-	LLXMLNodePtr root;
-
-	if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
-	{
-		LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL;
-		return false;
-	}
-	
-	// root must be called floater
-	if( !(root->hasName("floater") || root->hasName("multi_floater")) )
-	{
-		LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL;
-		return false;
-	}
-	
-	bool res = true;
-	
-	LL_DEBUGS() << "Building floater " << filename << LL_ENDL;
-	LLUICtrlFactory::instance().pushFileName(filename);
-	{
-		if (!getFactoryMap().empty())
-		{
-			LLPanel::sFactoryStack.push_front(&getFactoryMap());
-		}
-
-		 // for local registry callbacks; define in constructor, referenced in XUI or postBuild
-		getCommitCallbackRegistrar().pushScope();
-		getEnableCallbackRegistrar().pushScope();
-		
-		res = initFloaterXML(root, getParent(), filename, NULL);
-
-		setXMLFilename(filename);
-		
-		getCommitCallbackRegistrar().popScope();
-		getEnableCallbackRegistrar().popScope();
-		
-		if (!getFactoryMap().empty())
-		{
-			LLPanel::sFactoryStack.pop_front();
-		}
-	}
-	LLUICtrlFactory::instance().popFileName();
-	
-	return res;
+    LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS);
+    LLXMLNodePtr root;
+
+    if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
+    {
+        LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL;
+        return false;
+    }
+    
+    // root must be called floater
+    if( !(root->hasName("floater") || root->hasName("multi_floater")) )
+    {
+        LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL;
+        return false;
+    }
+    
+    bool res = true;
+    
+    LL_DEBUGS() << "Building floater " << filename << LL_ENDL;
+    LLUICtrlFactory::instance().pushFileName(filename);
+    {
+        if (!getFactoryMap().empty())
+        {
+            LLPanel::sFactoryStack.push_front(&getFactoryMap());
+        }
+
+         // for local registry callbacks; define in constructor, referenced in XUI or postBuild
+        getCommitCallbackRegistrar().pushScope();
+        getEnableCallbackRegistrar().pushScope();
+        
+        res = initFloaterXML(root, getParent(), filename, NULL);
+
+        setXMLFilename(filename);
+        
+        getCommitCallbackRegistrar().popScope();
+        getEnableCallbackRegistrar().popScope();
+        
+        if (!getFactoryMap().empty())
+        {
+            LLPanel::sFactoryStack.pop_front();
+        }
+    }
+    LLUICtrlFactory::instance().popFileName();
+    
+    return res;
 }
 
 void LLFloater::stackWith(LLFloater& other)
 {
-	static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16);
+    static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16);
 
-	LLRect next_rect;
-	if (other.getHost())
-	{
-		next_rect = other.getHost()->getRect();
-	}
-	else
-	{
-		next_rect = other.getRect();
-	}
-	next_rect.translate(floater_offset, -floater_offset);
+    LLRect next_rect;
+    if (other.getHost())
+    {
+        next_rect = other.getHost()->getRect();
+    }
+    else
+    {
+        next_rect = other.getRect();
+    }
+    next_rect.translate(floater_offset, -floater_offset);
 
-	next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight());
-	
-	setShape(next_rect);
+    next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight());
+    
+    setShape(next_rect);
 
-	if (!other.getHost())
-	{
-		other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
-		other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
-	}
+    if (!other.getHost())
+    {
+        other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
+        other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
+    }
 }
 
 void LLFloater::applyRelativePosition()
 {
-	LLRect snap_rect = gFloaterView->getSnapRect();
-	LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
-	snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
-	LLRect floater_screen_rect = calcScreenRect();
+    LLRect snap_rect = gFloaterView->getSnapRect();
+    LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+    snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+    LLRect floater_screen_rect = calcScreenRect();
 
-	LLCoordGL new_center = mPosition.convert();
-	LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY());
-	translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY);
+    LLCoordGL new_center = mPosition.convert();
+    LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY());
+    translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY);
 }
 
 
 LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater)
-:	coord_t((S32)x, (S32)y)
+:   coord_t((S32)x, (S32)y)
 {
-	mFloater = floater.getHandle();
+    mFloater = floater.getHandle();
 }
 
 
 LLCoordFloater::LLCoordFloater(const LLCoordCommon& other, LLFloater& floater)
 {
-	mFloater = floater.getHandle();
-	convertFromCommon(other);
+    mFloater = floater.getHandle();
+    convertFromCommon(other);
 }
 
 LLCoordFloater& LLCoordFloater::operator=(const LLCoordFloater& other)
 {
-	mFloater = other.mFloater;
-	coord_t::operator =(other);
-	return *this;
+    mFloater = other.mFloater;
+    coord_t::operator =(other);
+    return *this;
 }
 
 void LLCoordFloater::setFloater(LLFloater& floater)
 {
-	mFloater = floater.getHandle();
+    mFloater = floater.getHandle();
 }
 
 bool LLCoordFloater::operator==(const LLCoordFloater& other) const 
 { 
-	return mX == other.mX && mY == other.mY && mFloater == other.mFloater; 
+    return mX == other.mX && mY == other.mY && mFloater == other.mFloater; 
 }
 
 LLCoordCommon LL_COORD_FLOATER::convertToCommon() const
 {
-	const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
-
-	LLRect snap_rect = gFloaterView->getSnapRect();
-	LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
-	snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
-
-	LLFloater* floaterp = mFloater.get();
-	S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
-	S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
-	LLCoordCommon out;
-	if (self.mX < -0.5f)
-	{
-		out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft));
-	}
-	else if (self.mX > 0.5f)
-	{
-		out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS));
-	}
-	else
-	{
-		out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width));
-	}
-
-	if (self.mY < -0.5f)
-	{
-		out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom));
-	}
-	else if (self.mY > 0.5f)
-	{
-		out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS));
-	}
-	else
-	{
-		out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height));
-	}
-
-	// return center point instead of lower left
-	out.mX += floater_width / 2;
-	out.mY += floater_height / 2;
-
-	return out;
+    const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
+
+    LLRect snap_rect = gFloaterView->getSnapRect();
+    LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+    snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+
+    LLFloater* floaterp = mFloater.get();
+    S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
+    S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
+    LLCoordCommon out;
+    if (self.mX < -0.5f)
+    {
+        out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft));
+    }
+    else if (self.mX > 0.5f)
+    {
+        out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS));
+    }
+    else
+    {
+        out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width));
+    }
+
+    if (self.mY < -0.5f)
+    {
+        out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom));
+    }
+    else if (self.mY > 0.5f)
+    {
+        out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS));
+    }
+    else
+    {
+        out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height));
+    }
+
+    // return center point instead of lower left
+    out.mX += floater_width / 2;
+    out.mY += floater_height / 2;
+
+    return out;
 }
 
 void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from)
 {
-	LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
-	LLRect snap_rect = gFloaterView->getSnapRect();
-	LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
-	snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
-
-
-	LLFloater* floaterp = mFloater.get();
-	S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
-	S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
-
-	S32 from_x = from.mX - floater_width / 2;
-	S32 from_y = from.mY - floater_height / 2;
-
-	if (from_x < snap_rect.mLeft)
-	{
-		self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f);
-	}
-	else if (from_x + floater_width > snap_rect.mRight)
-	{
-		self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
-	}
-	else
-	{
-		self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f);
-	}
-
-	if (from_y < snap_rect.mBottom)
-	{
-		self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f);
-	}
-	else if (from_y + floater_height > snap_rect.mTop)
-	{
-		self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
-	}
-	else
-	{
-		self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f);
-	}
+    LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
+    LLRect snap_rect = gFloaterView->getSnapRect();
+    LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+    snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+
+
+    LLFloater* floaterp = mFloater.get();
+    S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
+    S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
+
+    S32 from_x = from.mX - floater_width / 2;
+    S32 from_y = from.mY - floater_height / 2;
+
+    if (from_x < snap_rect.mLeft)
+    {
+        self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f);
+    }
+    else if (from_x + floater_width > snap_rect.mRight)
+    {
+        self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
+    }
+    else
+    {
+        self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f);
+    }
+
+    if (from_y < snap_rect.mBottom)
+    {
+        self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f);
+    }
+    else if (from_y + floater_height > snap_rect.mTop)
+    {
+        self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
+    }
+    else
+    {
+        self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f);
+    }
 }
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index e53ecd30c2..1386f1290a 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -36,298 +36,298 @@
 
 #include "llinitparam.h"
 #include "llview.h"
-#include "llviewmodel.h"		// *TODO move dependency to .cpp file
+#include "llviewmodel.h"        // *TODO move dependency to .cpp file
 
 const BOOL TAKE_FOCUS_YES = TRUE;
 const BOOL TAKE_FOCUS_NO  = FALSE;
 
 class LLUICtrl
-	: public LLView, public boost::signals2::trackable
+    : public LLView, public boost::signals2::trackable
 {
 public:
-	typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t;
-	typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
-	// *TODO: add xml support for this type of signal in the future
-	typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t;
-	
-	typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t;
-	typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t;
-	
-	struct CallbackParam : public LLInitParam::Block<CallbackParam>
-	{
-		Ignored					name;
-
-		Optional<std::string>	function_name;
-		Optional<LLSD>			parameter;
-
-		Optional<std::string>	control_name;
-		
-		CallbackParam();
-	};
-
-	struct CommitCallbackParam : public LLInitParam::Block<CommitCallbackParam, CallbackParam >
-	{
-		Optional<commit_callback_t> function;
-	};
-
-	// also used for visible callbacks
-	struct EnableCallbackParam : public LLInitParam::Block<EnableCallbackParam, CallbackParam >
-	{
-		Optional<enable_callback_t> function;
-	};
-		
-	struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls>
-	{
-		Alternative<std::string> enabled;
-		Alternative<std::string> disabled;
-		
-		EnableControls();
-	};	
-	struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility>
-	{
-		Alternative<std::string> visible;
-		Alternative<std::string> invisible;
-
-		ControlVisibility();
-	};	
-	struct Params : public LLInitParam::Block<Params, LLView::Params>
-	{
-		Optional<std::string>			label;
-		Optional<bool>					tab_stop,
-										chrome,
-										requests_front;
-		Optional<LLSD>					initial_value;
-
-		Optional<CommitCallbackParam>	init_callback,
-										commit_callback;
-		Optional<EnableCallbackParam>	validate_callback;
-		
-		Optional<CommitCallbackParam>	mouseenter_callback,
-										mouseleave_callback;
-		
-		Optional<std::string>			control_name;
-		Optional<EnableControls>		enabled_controls;
-		Optional<ControlVisibility>		controls_visibility;
-		
-		// font params
-		Optional<const LLFontGL*>		font;
-		Optional<LLFontGL::HAlign>		font_halign;
-		Optional<LLFontGL::VAlign>		font_valign;
-
-		// cruft from LLXMLNode implementation
-		Ignored							type,
-										length;
-
-		Params();
-	};
-
-	enum ETypeTransparency
-	{
-		TT_DEFAULT,
-		TT_ACTIVE,		// focused floater
-		TT_INACTIVE,	// other floaters
-		TT_FADING,		// fading toast
-	};
-	/*virtual*/ ~LLUICtrl();
-
-	void initFromParams(const Params& p);
+    typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t;
+    typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
+    // *TODO: add xml support for this type of signal in the future
+    typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t;
+    
+    typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t;
+    typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t;
+    
+    struct CallbackParam : public LLInitParam::Block<CallbackParam>
+    {
+        Ignored                 name;
+
+        Optional<std::string>   function_name;
+        Optional<LLSD>          parameter;
+
+        Optional<std::string>   control_name;
+        
+        CallbackParam();
+    };
+
+    struct CommitCallbackParam : public LLInitParam::Block<CommitCallbackParam, CallbackParam >
+    {
+        Optional<commit_callback_t> function;
+    };
+
+    // also used for visible callbacks
+    struct EnableCallbackParam : public LLInitParam::Block<EnableCallbackParam, CallbackParam >
+    {
+        Optional<enable_callback_t> function;
+    };
+        
+    struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls>
+    {
+        Alternative<std::string> enabled;
+        Alternative<std::string> disabled;
+        
+        EnableControls();
+    };  
+    struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility>
+    {
+        Alternative<std::string> visible;
+        Alternative<std::string> invisible;
+
+        ControlVisibility();
+    };  
+    struct Params : public LLInitParam::Block<Params, LLView::Params>
+    {
+        Optional<std::string>           label;
+        Optional<bool>                  tab_stop,
+                                        chrome,
+                                        requests_front;
+        Optional<LLSD>                  initial_value;
+
+        Optional<CommitCallbackParam>   init_callback,
+                                        commit_callback;
+        Optional<EnableCallbackParam>   validate_callback;
+        
+        Optional<CommitCallbackParam>   mouseenter_callback,
+                                        mouseleave_callback;
+        
+        Optional<std::string>           control_name;
+        Optional<EnableControls>        enabled_controls;
+        Optional<ControlVisibility>     controls_visibility;
+        
+        // font params
+        Optional<const LLFontGL*>       font;
+        Optional<LLFontGL::HAlign>      font_halign;
+        Optional<LLFontGL::VAlign>      font_valign;
+
+        // cruft from LLXMLNode implementation
+        Ignored                         type,
+                                        length;
+
+        Params();
+    };
+
+    enum ETypeTransparency
+    {
+        TT_DEFAULT,
+        TT_ACTIVE,      // focused floater
+        TT_INACTIVE,    // other floaters
+        TT_FADING,      // fading toast
+    };
+    /*virtual*/ ~LLUICtrl();
+
+    void initFromParams(const Params& p);
 protected:
-	friend class LLUICtrlFactory;
-	static const Params& getDefaultParams();
-	LLUICtrl(const Params& p = getDefaultParams(),
+    friend class LLUICtrlFactory;
+    static const Params& getDefaultParams();
+    LLUICtrl(const Params& p = getDefaultParams(),
              const LLViewModelPtr& viewmodel=LLViewModelPtr(new LLViewModel));
-	
-	commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb);
-	enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb);
+    
+    commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb);
+    enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb);
 
-	// We need this virtual so we can override it with derived versions
-	virtual LLViewModel* getViewModel() const;
+    // We need this virtual so we can override it with derived versions
+    virtual LLViewModel* getViewModel() const;
     // We shouldn't ever need to set this directly
     //virtual void    setViewModel(const LLViewModelPtr&);
 
-	virtual BOOL	postBuild();
-	
+    virtual BOOL    postBuild();
+    
 public:
-	// LLView interface
-	/*virtual*/ BOOL	setLabelArg( const std::string& key, const LLStringExplicit& text );
-	/*virtual*/ BOOL	isCtrl() const;
-	/*virtual*/ void	onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void	onMouseLeave(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL	canFocusChildren() const;
-	/*virtual*/ BOOL 	handleMouseDown(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL 	handleMouseUp(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL	handleRightMouseUp(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL	handleDoubleClick(S32 x, S32 y, MASK mask);
-
-	// From LLFocusableElement
-	/*virtual*/ void	setFocus( BOOL b );
-	/*virtual*/ BOOL	hasFocus() const;
-	
-	// New virtuals
-
-	// Return NULL by default (overrride if the class has the appropriate interface)
-	virtual class LLCtrlSelectionInterface* getSelectionInterface();
-	virtual class LLCtrlListInterface* getListInterface();
-	virtual class LLCtrlScrollInterface* getScrollInterface();
-
-	bool setControlValue(const LLSD& value);
-	void setControlVariable(LLControlVariable* control);
-	virtual void setControlName(const std::string& control, LLView *context = NULL);
-	
-	LLControlVariable* getControlVariable() { return mControlVariable; } 
-	
-	void setEnabledControlVariable(LLControlVariable* control);
-	void setDisabledControlVariable(LLControlVariable* control);
-	void setMakeVisibleControlVariable(LLControlVariable* control);
-	void setMakeInvisibleControlVariable(LLControlVariable* control);
-
-	virtual void	setTentative(BOOL b);
-	virtual BOOL	getTentative() const;
-	virtual void	setValue(const LLSD& value);
-	virtual LLSD	getValue() const;
+    // LLView interface
+    /*virtual*/ BOOL    setLabelArg( const std::string& key, const LLStringExplicit& text );
+    /*virtual*/ BOOL    isCtrl() const;
+    /*virtual*/ void    onMouseEnter(S32 x, S32 y, MASK mask);
+    /*virtual*/ void    onMouseLeave(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL    canFocusChildren() const;
+    /*virtual*/ BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL    handleRightMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL    handleRightMouseUp(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL    handleDoubleClick(S32 x, S32 y, MASK mask);
+
+    // From LLFocusableElement
+    /*virtual*/ void    setFocus( BOOL b );
+    /*virtual*/ BOOL    hasFocus() const;
+    
+    // New virtuals
+
+    // Return NULL by default (overrride if the class has the appropriate interface)
+    virtual class LLCtrlSelectionInterface* getSelectionInterface();
+    virtual class LLCtrlListInterface* getListInterface();
+    virtual class LLCtrlScrollInterface* getScrollInterface();
+
+    bool setControlValue(const LLSD& value);
+    void setControlVariable(LLControlVariable* control);
+    virtual void setControlName(const std::string& control, LLView *context = NULL);
+    
+    LLControlVariable* getControlVariable() { return mControlVariable; } 
+    
+    void setEnabledControlVariable(LLControlVariable* control);
+    void setDisabledControlVariable(LLControlVariable* control);
+    void setMakeVisibleControlVariable(LLControlVariable* control);
+    void setMakeInvisibleControlVariable(LLControlVariable* control);
+
+    virtual void    setTentative(BOOL b);
+    virtual BOOL    getTentative() const;
+    virtual void    setValue(const LLSD& value);
+    virtual LLSD    getValue() const;
     /// When two widgets are displaying the same data (e.g. during a skin
     /// change), share their ViewModel.
     virtual void    shareViewModelFrom(const LLUICtrl& other);
 
-	virtual BOOL	setTextArg(  const std::string& key, const LLStringExplicit& text );
-	virtual void	setIsChrome(BOOL is_chrome);
-
-	virtual BOOL	acceptsTextInput() const; // Defaults to false
-
-	// A control is dirty if the user has modified its value.
-	// Editable controls should override this.
-	virtual BOOL	isDirty() const; // Defauls to false
-	virtual void	resetDirty(); //Defaults to no-op
-	
-	// Call appropriate callback
-	virtual void	onCommit();
-	
-	// Default to no-op:
-	virtual void	onTabInto();
-
-	// Clear any user-provided input (text in a text editor, checked checkbox,
-	// selected radio button, etc.).  Defaults to no-op.
-	virtual void	clear();
-
-	virtual void	setColor(const LLColor4& color);
-
-	// Ansariel: Changed to virtual. We might want to change the transparency ourself!
-	virtual F32	getCurrentTransparency();
-
-	void				setTransparencyType(ETypeTransparency type);
-	ETypeTransparency	getTransparencyType() const {return mTransparencyType;}
-
-	BOOL	focusNextItem(BOOL text_entry_only);
-	BOOL	focusPrevItem(BOOL text_entry_only);
-	BOOL 	focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE );
-
-	// Non Virtuals
-	LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); }
-	BOOL			getIsChrome() const;
-	
-	void			setTabStop( BOOL b );
-	BOOL			hasTabStop() const;
-
-	LLUICtrl*		getParentUICtrl() const;
-
-	// return true if help topic found by crawling through parents -
-	// topic then put in help_topic_out
-	bool                    findHelpTopic(std::string& help_topic_out);
-
-	boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb);
-	boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb);
-
-	boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
-	boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
-
-	boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb );
-	boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb );
-	
-	boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb );
-	boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb );
-	boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb );
-	boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb );
-	
-	boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb );
-
-	// *TODO: Deprecate; for backwards compatability only:
-	boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data);	
-	boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb );
-
-	LLUICtrl* findRootMostFocusRoot();
-
-	class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
-	{
-		LLSINGLETON_EMPTY_CTOR(LLTextInputFilter);
-		/*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const 
-		{
-			return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
-		}
-	};
-
-	template <typename F, typename DERIVED> class CallbackRegistry : public LLRegistrySingleton<std::string, F, DERIVED >
-	{};	
-
-	class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry>
-	{
-		LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry);
-	};
-	// the enable callback registry is also used for visiblity callbacks
-	class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry>
-	{
-		LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry);
-	};
-		
+    virtual BOOL    setTextArg(  const std::string& key, const LLStringExplicit& text );
+    virtual void    setIsChrome(BOOL is_chrome);
+
+    virtual BOOL    acceptsTextInput() const; // Defaults to false
+
+    // A control is dirty if the user has modified its value.
+    // Editable controls should override this.
+    virtual BOOL    isDirty() const; // Defauls to false
+    virtual void    resetDirty(); //Defaults to no-op
+    
+    // Call appropriate callback
+    virtual void    onCommit();
+    
+    // Default to no-op:
+    virtual void    onTabInto();
+
+    // Clear any user-provided input (text in a text editor, checked checkbox,
+    // selected radio button, etc.).  Defaults to no-op.
+    virtual void    clear();
+
+    virtual void    setColor(const LLColor4& color);
+
+    // Ansariel: Changed to virtual. We might want to change the transparency ourself!
+    virtual F32 getCurrentTransparency();
+
+    void                setTransparencyType(ETypeTransparency type);
+    ETypeTransparency   getTransparencyType() const {return mTransparencyType;}
+
+    BOOL    focusNextItem(BOOL text_entry_only);
+    BOOL    focusPrevItem(BOOL text_entry_only);
+    BOOL    focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE );
+
+    // Non Virtuals
+    LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); }
+    BOOL            getIsChrome() const;
+    
+    void            setTabStop( BOOL b );
+    BOOL            hasTabStop() const;
+
+    LLUICtrl*       getParentUICtrl() const;
+
+    // return true if help topic found by crawling through parents -
+    // topic then put in help_topic_out
+    bool                    findHelpTopic(std::string& help_topic_out);
+
+    boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb);
+    boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb);
+
+    boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
+    boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
+
+    boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb );
+    boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb );
+    
+    boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb );
+    boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb );
+    boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb );
+    boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb );
+    
+    boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb );
+
+    // *TODO: Deprecate; for backwards compatability only:
+    boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); 
+    boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb );
+
+    LLUICtrl* findRootMostFocusRoot();
+
+    class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
+    {
+        LLSINGLETON_EMPTY_CTOR(LLTextInputFilter);
+        /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const 
+        {
+            return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
+        }
+    };
+
+    template <typename F, typename DERIVED> class CallbackRegistry : public LLRegistrySingleton<std::string, F, DERIVED >
+    {}; 
+
+    class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry>
+    {
+        LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry);
+    };
+    // the enable callback registry is also used for visiblity callbacks
+    class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry>
+    {
+        LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry);
+    };
+        
 protected:
 
-	static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type);
+    static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type);
 
-	commit_signal_t*		mCommitSignal;
-	enable_signal_t*		mValidateSignal;
+    commit_signal_t*        mCommitSignal;
+    enable_signal_t*        mValidateSignal;
 
-	commit_signal_t*		mMouseEnterSignal;
-	commit_signal_t*		mMouseLeaveSignal;
-	
-	mouse_signal_t*		mMouseDownSignal;
-	mouse_signal_t*		mMouseUpSignal;
-	mouse_signal_t*		mRightMouseDownSignal;
-	mouse_signal_t*		mRightMouseUpSignal;
+    commit_signal_t*        mMouseEnterSignal;
+    commit_signal_t*        mMouseLeaveSignal;
+    
+    mouse_signal_t*     mMouseDownSignal;
+    mouse_signal_t*     mMouseUpSignal;
+    mouse_signal_t*     mRightMouseDownSignal;
+    mouse_signal_t*     mRightMouseUpSignal;
 
-	mouse_signal_t*		mDoubleClickSignal;
-	
+    mouse_signal_t*     mDoubleClickSignal;
+    
     LLViewModelPtr  mViewModel;
 
-	LLControlVariable* mControlVariable;
-	boost::signals2::connection mControlConnection;
-	LLControlVariable* mEnabledControlVariable;
-	boost::signals2::connection mEnabledControlConnection;
-	LLControlVariable* mDisabledControlVariable;
-	boost::signals2::connection mDisabledControlConnection;
-	LLControlVariable* mMakeVisibleControlVariable;
-	boost::signals2::connection mMakeVisibleControlConnection;
-	LLControlVariable* mMakeInvisibleControlVariable;
-	boost::signals2::connection mMakeInvisibleControlConnection;
-
-	static F32 sActiveControlTransparency;
-	static F32 sInactiveControlTransparency;
-	
-	virtual void addInfo(LLSD & info);
-	
+    LLControlVariable* mControlVariable;
+    boost::signals2::connection mControlConnection;
+    LLControlVariable* mEnabledControlVariable;
+    boost::signals2::connection mEnabledControlConnection;
+    LLControlVariable* mDisabledControlVariable;
+    boost::signals2::connection mDisabledControlConnection;
+    LLControlVariable* mMakeVisibleControlVariable;
+    boost::signals2::connection mMakeVisibleControlConnection;
+    LLControlVariable* mMakeInvisibleControlVariable;
+    boost::signals2::connection mMakeInvisibleControlConnection;
+
+    static F32 sActiveControlTransparency;
+    static F32 sInactiveControlTransparency;
+    
+    virtual void addInfo(LLSD & info);
+    
 private:
 
-	BOOL			mIsChrome;
-	BOOL			mRequestsFront;
-	BOOL			mTabStop;
-	BOOL			mTentative;
+    BOOL            mIsChrome;
+    BOOL            mRequestsFront;
+    BOOL            mTabStop;
+    BOOL            mTentative;
 
-	ETypeTransparency mTransparencyType;
+    ETypeTransparency mTransparencyType;
 };
 
 // Build time optimization, generate once in .cpp file
 #ifndef LLUICTRL_CPP
 extern template class LLUICtrl* LLView::getChild<class LLUICtrl>(
-	const std::string& name, BOOL recurse) const;
+    const std::string& name, BOOL recurse) const;
 #endif
 
 #endif  // LL_LLUICTRL_H
diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp
index 338be1808d..be0ea8bb69 100755
--- a/indra/llui/tests/llurlentry_stub.cpp
+++ b/indra/llui/tests/llurlentry_stub.cpp
@@ -38,13 +38,13 @@
 // Stub for LLAvatarNameCache
 bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 {
-	return false;
+    return false;
 }
 
 LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
 {
-	callback_connection_t connection;
-	return connection;
+    callback_connection_t connection;
+    return connection;
 }
 
 //
@@ -52,24 +52,24 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag
 //
 BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname)
 {
-	fullname = "Lynx Linden";
-	return TRUE;
+    fullname = "Lynx Linden";
+    return TRUE;
 }
 
 BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group)
 {
-	group = "My Group";
-	return TRUE;
+    group = "My Group";
+    return TRUE;
 }
 
 boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback)
 {
-	return boost::signals2::connection();
+    return boost::signals2::connection();
 }
 
 boost::signals2::connection LLCacheName::getGroup(const LLUUID& id, const LLCacheNameCallback& callback)
 {
-	return boost::signals2::connection();
+    return boost::signals2::connection();
 }
 
 LLCacheName* gCacheName = NULL;
@@ -80,12 +80,12 @@ LLCacheName* gCacheName = NULL;
 class LLTrans
 {
 public:
-	static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
+    static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
 };
 
 std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args)
 {
-	return std::string();
+    return std::string();
 }
 
 //
@@ -102,65 +102,65 @@ LLStyle::Params::Params()
 
 namespace LLInitParam
 {
-	ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
-	:	super_t(color)
-	{}
-
-	void ParamValue<LLUIColor>::updateValueFromBlock() 
-	{}
-	
-	void ParamValue<LLUIColor>::updateBlockFromValue(bool)
-	{}
-
-	bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
-	{
-		return false;
-	}
-
-	ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
-	:	super_t(fontp)
-	{}
-
-	void ParamValue<const LLFontGL*>::updateValueFromBlock()
-	{}
-	
-	void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
-	{}
-
-	void TypeValues<LLFontGL::HAlign>::declareValues()
-	{}
-
-	void TypeValues<LLFontGL::VAlign>::declareValues()
-	{}
-
-	void TypeValues<LLFontGL::ShadowType>::declareValues()
-	{}
-
-	void ParamValue<LLUIImage*>::updateValueFromBlock()
-	{}
-	
-	void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
-	{}
-
-	
-	bool ParamCompare<LLUIImage*, false>::equals(
-		LLUIImage* const &a,
-		LLUIImage* const &b)
-	{
-		return false;
-	}
-
-	bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
-	{
-		return false;
-	}
+    ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
+    :   super_t(color)
+    {}
+
+    void ParamValue<LLUIColor>::updateValueFromBlock() 
+    {}
+    
+    void ParamValue<LLUIColor>::updateBlockFromValue(bool)
+    {}
+
+    bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
+    {
+        return false;
+    }
+
+    ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
+    :   super_t(fontp)
+    {}
+
+    void ParamValue<const LLFontGL*>::updateValueFromBlock()
+    {}
+    
+    void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
+    {}
+
+    void TypeValues<LLFontGL::HAlign>::declareValues()
+    {}
+
+    void TypeValues<LLFontGL::VAlign>::declareValues()
+    {}
+
+    void TypeValues<LLFontGL::ShadowType>::declareValues()
+    {}
+
+    void ParamValue<LLUIImage*>::updateValueFromBlock()
+    {}
+    
+    void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
+    {}
+
+    
+    bool ParamCompare<LLUIImage*, false>::equals(
+        LLUIImage* const &a,
+        LLUIImage* const &b)
+    {
+        return false;
+    }
+
+    bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
+    {
+        return false;
+    }
 
 }
 
 //static
 LLFontGL* LLFontGL::getFontDefault()
 {
-	return NULL; 
+    return NULL; 
 }
 
 char const* const _PREHASH_AgentData = (char *)"AgentData";
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index bbe1354fc3..7b395491e6 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -60,8 +60,8 @@ const F32 MIN_ZOOM_FRACTION = 0.25f;
 const F32 INITIAL_ZOOM_FRACTION = 1.f;
 const F32 MAX_ZOOM_FRACTION = 8.f;
 
-const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f;	// seconds
-const F32 FOV_ZOOM_HALF_LIFE = 0.07f;	// seconds
+const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f;    // seconds
+const F32 FOV_ZOOM_HALF_LIFE = 0.07f;   // seconds
 
 const F32 CAMERA_FOCUS_HALF_LIFE = 0.f;//0.02f;
 const F32 CAMERA_LAG_HALF_LIFE = 0.25f;
@@ -107,83 +107,83 @@ LLAgentCamera gAgentCamera;
 // LLAgentCamera()
 //-----------------------------------------------------------------------------
 LLAgentCamera::LLAgentCamera() :
-	mInitialized(false),
-
-	mDrawDistance( DEFAULT_FAR_PLANE ),
-
-	mLookAt(NULL),
-	mPointAt(NULL),
-
-	mHUDTargetZoom(1.f),
-	mHUDCurZoom(1.f),
-
-	mForceMouselook(FALSE),
-
-	mCameraMode( CAMERA_MODE_THIRD_PERSON ),
-	mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
-
-	mCameraPreset(CAMERA_PRESET_REAR_VIEW),
-
-	mCameraAnimating( FALSE ),
-	mAnimationCameraStartGlobal(),
-	mAnimationFocusStartGlobal(),
-	mAnimationTimer(),
-	mAnimationDuration(0.33f),
-	
-	mCameraFOVZoomFactor(0.f),
-	mCameraCurrentFOVZoomFactor(0.f),
-	mCameraFocusOffset(),
-	mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW),
-
-	mCameraCollidePlane(),
-
-	mCurrentCameraDistance(2.f),		// meters, set in init()
-	mTargetCameraDistance(2.f),
-	mCameraZoomFraction(1.f),			// deprecated
-	mThirdPersonHeadOffset(0.f, 0.f, 1.f),
-	mSitCameraEnabled(FALSE),
-	mCameraSmoothingLastPositionGlobal(),
-	mCameraSmoothingLastPositionAgent(),
-	mCameraSmoothingStop(false),
-
-	mCameraUpVector(LLVector3::z_axis), // default is straight up
-
-	mFocusOnAvatar(TRUE),
-	mAllowChangeToFollow(FALSE),
-	mFocusGlobal(),
-	mFocusTargetGlobal(),
-	mFocusObject(NULL),
-	mFocusObjectDist(0.f),
-	mFocusObjectOffset(),
-	mFocusDotRadius( 0.1f ),			// meters
-	mTrackFocusObject(TRUE),
-
-	mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed
-	mWalkKey(0), // like AtKey, but causes less forward thrust
-	mLeftKey(0),
-	mUpKey(0),
-	mYawKey(0.f),
-	mPitchKey(0.f),
-
-	mOrbitLeftKey(0.f),
-	mOrbitRightKey(0.f),
-	mOrbitUpKey(0.f),
-	mOrbitDownKey(0.f),
-	mOrbitInKey(0.f),
-	mOrbitOutKey(0.f),
-
-	mPanUpKey(0.f),
-	mPanDownKey(0.f),
-	mPanLeftKey(0.f),
-	mPanRightKey(0.f),
-	mPanInKey(0.f),
-	mPanOutKey(0.f)
+    mInitialized(false),
+
+    mDrawDistance( DEFAULT_FAR_PLANE ),
+
+    mLookAt(NULL),
+    mPointAt(NULL),
+
+    mHUDTargetZoom(1.f),
+    mHUDCurZoom(1.f),
+
+    mForceMouselook(FALSE),
+
+    mCameraMode( CAMERA_MODE_THIRD_PERSON ),
+    mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
+
+    mCameraPreset(CAMERA_PRESET_REAR_VIEW),
+
+    mCameraAnimating( FALSE ),
+    mAnimationCameraStartGlobal(),
+    mAnimationFocusStartGlobal(),
+    mAnimationTimer(),
+    mAnimationDuration(0.33f),
+    
+    mCameraFOVZoomFactor(0.f),
+    mCameraCurrentFOVZoomFactor(0.f),
+    mCameraFocusOffset(),
+    mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW),
+
+    mCameraCollidePlane(),
+
+    mCurrentCameraDistance(2.f),        // meters, set in init()
+    mTargetCameraDistance(2.f),
+    mCameraZoomFraction(1.f),           // deprecated
+    mThirdPersonHeadOffset(0.f, 0.f, 1.f),
+    mSitCameraEnabled(FALSE),
+    mCameraSmoothingLastPositionGlobal(),
+    mCameraSmoothingLastPositionAgent(),
+    mCameraSmoothingStop(false),
+
+    mCameraUpVector(LLVector3::z_axis), // default is straight up
+
+    mFocusOnAvatar(TRUE),
+    mAllowChangeToFollow(FALSE),
+    mFocusGlobal(),
+    mFocusTargetGlobal(),
+    mFocusObject(NULL),
+    mFocusObjectDist(0.f),
+    mFocusObjectOffset(),
+    mFocusDotRadius( 0.1f ),            // meters
+    mTrackFocusObject(TRUE),
+
+    mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed
+    mWalkKey(0), // like AtKey, but causes less forward thrust
+    mLeftKey(0),
+    mUpKey(0),
+    mYawKey(0.f),
+    mPitchKey(0.f),
+
+    mOrbitLeftKey(0.f),
+    mOrbitRightKey(0.f),
+    mOrbitUpKey(0.f),
+    mOrbitDownKey(0.f),
+    mOrbitInKey(0.f),
+    mOrbitOutKey(0.f),
+
+    mPanUpKey(0.f),
+    mPanDownKey(0.f),
+    mPanLeftKey(0.f),
+    mPanRightKey(0.f),
+    mPanInKey(0.f),
+    mPanOutKey(0.f)
 {
-	mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
+    mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
 
-	clearGeneralKeys();
-	clearOrbitKeys();
-	clearPanKeys();
+    clearGeneralKeys();
+    clearOrbitKeys();
+    clearPanKeys();
 }
 
 // Requires gSavedSettings to be initialized.
@@ -192,36 +192,36 @@ LLAgentCamera::LLAgentCamera() :
 //-----------------------------------------------------------------------------
 void LLAgentCamera::init()
 {
-	// *Note: this is where LLViewerCamera::getInstance() used to be constructed.
+    // *Note: this is where LLViewerCamera::getInstance() used to be constructed.
 
-	mDrawDistance = gSavedSettings.getF32("RenderFarClip");
+    mDrawDistance = gSavedSettings.getF32("RenderFarClip");
 
-	LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW);
-	// Leave at 0.1 meters until we have real near clip management
-	LLViewerCamera::getInstance()->setNear(0.1f);
-	LLViewerCamera::getInstance()->setFar(mDrawDistance);			// if you want to change camera settings, do so in camera.h
-	LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() );		// default, overridden in LLViewerWindow::reshape
-	LLViewerCamera::getInstance()->setViewHeightInPixels(768);			// default, overridden in LLViewerWindow::reshape
+    LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW);
+    // Leave at 0.1 meters until we have real near clip management
+    LLViewerCamera::getInstance()->setNear(0.1f);
+    LLViewerCamera::getInstance()->setFar(mDrawDistance);           // if you want to change camera settings, do so in camera.h
+    LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() );       // default, overridden in LLViewerWindow::reshape
+    LLViewerCamera::getInstance()->setViewHeightInPixels(768);          // default, overridden in LLViewerWindow::reshape
 
-	mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
-	
-	mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
+    mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
+    
+    mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
 
-	mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
-	mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
-	mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
+    mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
+    mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
+    mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
 
-	mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
-	mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
-	mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
+    mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
+    mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
+    mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
 
-	mCameraCollidePlane.clearVec();
-	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
-	mTargetCameraDistance = mCurrentCameraDistance;
-	mCameraZoomFraction = 1.f;
-	mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
+    mCameraCollidePlane.clearVec();
+    mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
+    mTargetCameraDistance = mCurrentCameraDistance;
+    mCameraZoomFraction = 1.f;
+    mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
 
-	mInitialized = true;
+    mInitialized = true;
 }
 
 //-----------------------------------------------------------------------------
@@ -229,40 +229,40 @@ void LLAgentCamera::init()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cleanup()
 {
-	setSitCamera(LLUUID::null);
-
-	if(mLookAt)
-	{
-		mLookAt->markDead() ;
-		mLookAt = NULL;
-	}
-	if(mPointAt)
-	{
-		mPointAt->markDead() ;
-		mPointAt = NULL;
-	}
-	setFocusObject(NULL);
+    setSitCamera(LLUUID::null);
+
+    if(mLookAt)
+    {
+        mLookAt->markDead() ;
+        mLookAt = NULL;
+    }
+    if(mPointAt)
+    {
+        mPointAt->markDead() ;
+        mPointAt = NULL;
+    }
+    setFocusObject(NULL);
 }
 
 void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar)
 {
-	if (!mLookAt)
-	{
-		mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
-	}
-	if (!mPointAt)
-	{
-		mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
-	}
-	
-	if (!mLookAt.isNull())
-	{
-		mLookAt->setSourceObject(avatar);
-	}
-	if (!mPointAt.isNull())
-	{
-		mPointAt->setSourceObject(avatar);
-	}	
+    if (!mLookAt)
+    {
+        mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
+    }
+    if (!mPointAt)
+    {
+        mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
+    }
+    
+    if (!mLookAt.isNull())
+    {
+        mLookAt->setSourceObject(avatar);
+    }
+    if (!mPointAt.isNull())
+    {
+        mPointAt->setSourceObject(avatar);
+    }   
 }
 
 //-----------------------------------------------------------------------------
@@ -270,9 +270,9 @@ void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar)
 //-----------------------------------------------------------------------------
 LLAgentCamera::~LLAgentCamera()
 {
-	cleanup();
+    cleanup();
 
-	// *Note: this is where LLViewerCamera::getInstance() used to be deleted.
+    // *Note: this is where LLViewerCamera::getInstance() used to be deleted.
 }
 
 // Change camera back to third person, stop the autopilot,
@@ -282,74 +282,74 @@ LLAgentCamera::~LLAgentCamera()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 {
-	if (gAgent.getAutoPilot())
-	{
-		gAgent.stopAutoPilot(TRUE);
-	}
-
-	LLSelectMgr::getInstance()->unhighlightAll();
-
-	// By popular request, keep land selection while walking around. JC
-	// LLViewerParcelMgr::getInstance()->deselectLand();
-
-	// force deselect when walking and attachment is selected
-	// this is so people don't wig out when their avatar moves without animating
-	if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
-	{
-		LLSelectMgr::getInstance()->deselectAll();
-	}
-
-	if (gMenuHolder != NULL)
-	{
-		// Hide all popup menus
-		gMenuHolder->hideMenus();
-	}
-
-	if (change_camera && !gSavedSettings.getBOOL("FreezeTime"))
-	{
-		changeCameraToDefault();
-		
-		if (LLViewerJoystick::getInstance()->getOverrideCamera())
-		{
-			handle_toggle_flycam();
-		}
-
-		// reset avatar mode from eventual residual motion
-		if (LLToolMgr::getInstance()->inBuildMode())
-		{
-			LLViewerJoystick::getInstance()->moveAvatar(true);
-		}
-
-		//Camera Tool is needed for Free Camera Control Mode
-		if (!LLFloaterCamera::inFreeCameraMode())
-		{
-			LLFloaterReg::hideInstance("build");
-
-			// Switch back to basic toolset
-			LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
-		}
-		
-		gViewerWindow->showCursor();
-	}
-
-
-	if (reset_camera && !gSavedSettings.getBOOL("FreezeTime"))
-	{
-		if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson())
-		{
-			// leaving mouse-steer mode
-			LLVector3 agent_at_axis = gAgent.getAtAxis();
-			agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector());
-			agent_at_axis.normalize();
-			gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f)));
-		}
-
-		setFocusOnAvatar(TRUE, ANIMATE);
-
-		mCameraFOVZoomFactor = 0.f;
-	}
-
-	mHUDTargetZoom = 1.f;
+    if (gAgent.getAutoPilot())
+    {
+        gAgent.stopAutoPilot(TRUE);
+    }
+
+    LLSelectMgr::getInstance()->unhighlightAll();
+
+    // By popular request, keep land selection while walking around. JC
+    // LLViewerParcelMgr::getInstance()->deselectLand();
+
+    // force deselect when walking and attachment is selected
+    // this is so people don't wig out when their avatar moves without animating
+    if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
+    {
+        LLSelectMgr::getInstance()->deselectAll();
+    }
+
+    if (gMenuHolder != NULL)
+    {
+        // Hide all popup menus
+        gMenuHolder->hideMenus();
+    }
+
+    if (change_camera && !gSavedSettings.getBOOL("FreezeTime"))
+    {
+        changeCameraToDefault();
+        
+        if (LLViewerJoystick::getInstance()->getOverrideCamera())
+        {
+            handle_toggle_flycam();
+        }
+
+        // reset avatar mode from eventual residual motion
+        if (LLToolMgr::getInstance()->inBuildMode())
+        {
+            LLViewerJoystick::getInstance()->moveAvatar(true);
+        }
+
+        //Camera Tool is needed for Free Camera Control Mode
+        if (!LLFloaterCamera::inFreeCameraMode())
+        {
+            LLFloaterReg::hideInstance("build");
+
+            // Switch back to basic toolset
+            LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
+        }
+        
+        gViewerWindow->showCursor();
+    }
+
+
+    if (reset_camera && !gSavedSettings.getBOOL("FreezeTime"))
+    {
+        if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson())
+        {
+            // leaving mouse-steer mode
+            LLVector3 agent_at_axis = gAgent.getAtAxis();
+            agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector());
+            agent_at_axis.normalize();
+            gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f)));
+        }
+
+        setFocusOnAvatar(TRUE, ANIMATE);
+
+        mCameraFOVZoomFactor = 0.f;
+    }
+
+    mHUDTargetZoom = 1.f;
 }
 
 // Allow camera to be moved somewhere other than behind avatar.
@@ -358,14 +358,14 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::unlockView()
 {
-	if (getFocusOnAvatar())
-	{
-		if (isAgentAvatarValid())
-		{
-			setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID);
-		}
-		setFocusOnAvatar(FALSE, FALSE);	// no animation
-	}
+    if (getFocusOnAvatar())
+    {
+        if (isAgentAvatarValid())
+        {
+            setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID);
+        }
+        setFocusOnAvatar(FALSE, FALSE); // no animation
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -373,10 +373,10 @@ void LLAgentCamera::unlockView()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
 {
-	LLVector3 look_at_norm = look_at;
-	look_at_norm.mV[VZ] = 0.f;
-	look_at_norm.normalize();
-	gAgent.resetAxes(look_at_norm);
+    LLVector3 look_at_norm = look_at;
+    look_at_norm.mV[VZ] = 0.f;
+    look_at_norm.normalize();
+    gAgent.resetAxes(look_at_norm);
 }
 
 //-----------------------------------------------------------------------------
@@ -384,169 +384,169 @@ void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
 //-----------------------------------------------------------------------------
 LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y)
 {
-	LLMatrix4 obj_matrix = object->getRenderMatrix();
-	LLQuaternion obj_rot = object->getRenderRotation();
-	LLVector3 obj_pos = object->getRenderPosition();
-
-	BOOL is_avatar = object->isAvatar();
-	// if is avatar - don't do any funk heuristics to position the focal point
-	// see DEV-30589
-	if (is_avatar)
-	{
-		return original_focus_point - obj_pos;
-	}
-	
-	LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation
-	LLVector3 object_extents = object->getScale();	
-	
-	// make sure they object extents are non-zero
-	object_extents.clamp(0.001f, F32_MAX);
-
-	// obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object
-	LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin();
-	obj_to_cam_ray.rotVec(inv_obj_rot);
-	obj_to_cam_ray.normalize();
-
-	// obj_to_cam_ray_proportions are the (positive) ratios of 
-	// the obj_to_cam_ray x,y,z components with the x,y,z object dimensions.
-	LLVector3 obj_to_cam_ray_proportions;
-	obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]);
-	obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]);
-	obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]);
-
-	// find the largest ratio stored in obj_to_cam_ray_proportions
-	// this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera
-	LLVector3 longest_object_axis;
-	// is x-axis longest?
-	if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] 
-		&& obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ])
-	{
-		// then grab it
-		longest_object_axis.setVec(obj_matrix.getFwdRow4());
-	}
-	// is y-axis longest?
-	else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ])
-	{
-		// then grab it
-		longest_object_axis.setVec(obj_matrix.getLeftRow4());
-	}
-	// otherwise, use z axis
-	else
-	{
-		longest_object_axis.setVec(obj_matrix.getUpRow4());
-	}
-
-	// Use this axis as the normal to project mouse click on to plane with that normal, at the object center.
-	// This generates a point behind the mouse cursor that is approximately in the middle of the object in
-	// terms of depth.  
-	// We do this to allow the camera rotation tool to "tumble" the object by rotating the camera.
-	// If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable
-	// eccentricity to the object orientation
-	LLVector3 focus_plane_normal(longest_object_axis);
-	focus_plane_normal.normalize();
-
-	LLVector3d focus_pt_global;
-	gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal);
-	LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global);
-
-	// find vector from camera to focus point in object space
-	LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin();
-	camera_to_focus_vec.rotVec(inv_obj_rot);
-
-	// find vector from object origin to focus point in object coordinates
-	LLVector3 focus_offset_from_object_center = focus_pt - obj_pos;
-	// convert to object-local space
-	focus_offset_from_object_center.rotVec(inv_obj_rot);
-
-	// We need to project the focus point back into the bounding box of the focused object.
-	// Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis
-	LLVector3 clip_fraction;
-
-	// for each axis...
-	for (U32 axis = VX; axis <= VZ; axis++)
-	{
-		//...calculate distance that focus offset sits outside of bounding box along that axis...
-		//NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center 
-		F32 dist_out_of_bounds;
-		if (focus_offset_from_object_center.mV[axis] > 0.f)
-		{
-			dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f));
-		}
-		else
-		{
-			dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f));
-		}
-
-		//...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis
-		if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f)
-		{
-			// don't divide by very small number
-			clip_fraction.mV[axis] = 0.f;
-		}
-		else
-		{
-			clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis];
-		}
-	}
-
-	LLVector3 abs_clip_fraction = clip_fraction;
-	abs_clip_fraction.abs();
-
-	// find axis of focus offset that is *most* outside the bounding box and use that to
-	// rescale focus offset to inside object extents
-	if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY]
-		&& abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ])
-	{
-		focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec;
-	}
-	else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ])
-	{
-		focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec;
-	}
-	else
-	{
-		focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec;
-	}
-
-	// convert back to world space
-	focus_offset_from_object_center.rotVec(obj_rot);
-	
-	// now, based on distance of camera from object relative to object size
-	// push the focus point towards the near surface of the object when (relatively) close to the objcet
-	// or keep the focus point in the object middle when (relatively) far
-	// NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars
-	// is almost always "tumble about middle" and not "spin around surface point"
-	if (!is_avatar) 
-	{
-		LLVector3 obj_rel = original_focus_point - object->getRenderPosition();
-		
-		//now that we have the object relative position, we should bias toward the center of the object 
-		//based on the distance of the camera to the focus point vs. the distance of the camera to the focus
-
-		F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis());
-		F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin());
-
-
-		LLBBox obj_bbox = object->getBoundingBoxAgent();
-		F32 bias = 0.f;
-
-		// virtual_camera_pos is the camera position we are simulating by backing the camera off
-		// and adjusting the FOV
-		LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor));
-
-		// if the camera is inside the object (large, hollow objects, for example)
-		// leave focus point all the way to destination depth, away from object center
-		if(!obj_bbox.containsPointAgent(virtual_camera_pos))
-		{
-			// perform magic number biasing of focus point towards surface vs. planar center
-			bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f);
-			obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias);
-		}
-			
-		focus_offset_from_object_center = obj_rel;
-	}
-
-	return focus_offset_from_object_center;
+    LLMatrix4 obj_matrix = object->getRenderMatrix();
+    LLQuaternion obj_rot = object->getRenderRotation();
+    LLVector3 obj_pos = object->getRenderPosition();
+
+    BOOL is_avatar = object->isAvatar();
+    // if is avatar - don't do any funk heuristics to position the focal point
+    // see DEV-30589
+    if (is_avatar)
+    {
+        return original_focus_point - obj_pos;
+    }
+    
+    LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation
+    LLVector3 object_extents = object->getScale();  
+    
+    // make sure they object extents are non-zero
+    object_extents.clamp(0.001f, F32_MAX);
+
+    // obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object
+    LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin();
+    obj_to_cam_ray.rotVec(inv_obj_rot);
+    obj_to_cam_ray.normalize();
+
+    // obj_to_cam_ray_proportions are the (positive) ratios of 
+    // the obj_to_cam_ray x,y,z components with the x,y,z object dimensions.
+    LLVector3 obj_to_cam_ray_proportions;
+    obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]);
+    obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]);
+    obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]);
+
+    // find the largest ratio stored in obj_to_cam_ray_proportions
+    // this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera
+    LLVector3 longest_object_axis;
+    // is x-axis longest?
+    if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] 
+        && obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ])
+    {
+        // then grab it
+        longest_object_axis.setVec(obj_matrix.getFwdRow4());
+    }
+    // is y-axis longest?
+    else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ])
+    {
+        // then grab it
+        longest_object_axis.setVec(obj_matrix.getLeftRow4());
+    }
+    // otherwise, use z axis
+    else
+    {
+        longest_object_axis.setVec(obj_matrix.getUpRow4());
+    }
+
+    // Use this axis as the normal to project mouse click on to plane with that normal, at the object center.
+    // This generates a point behind the mouse cursor that is approximately in the middle of the object in
+    // terms of depth.  
+    // We do this to allow the camera rotation tool to "tumble" the object by rotating the camera.
+    // If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable
+    // eccentricity to the object orientation
+    LLVector3 focus_plane_normal(longest_object_axis);
+    focus_plane_normal.normalize();
+
+    LLVector3d focus_pt_global;
+    gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal);
+    LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global);
+
+    // find vector from camera to focus point in object space
+    LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin();
+    camera_to_focus_vec.rotVec(inv_obj_rot);
+
+    // find vector from object origin to focus point in object coordinates
+    LLVector3 focus_offset_from_object_center = focus_pt - obj_pos;
+    // convert to object-local space
+    focus_offset_from_object_center.rotVec(inv_obj_rot);
+
+    // We need to project the focus point back into the bounding box of the focused object.
+    // Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis
+    LLVector3 clip_fraction;
+
+    // for each axis...
+    for (U32 axis = VX; axis <= VZ; axis++)
+    {
+        //...calculate distance that focus offset sits outside of bounding box along that axis...
+        //NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center 
+        F32 dist_out_of_bounds;
+        if (focus_offset_from_object_center.mV[axis] > 0.f)
+        {
+            dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f));
+        }
+        else
+        {
+            dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f));
+        }
+
+        //...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis
+        if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f)
+        {
+            // don't divide by very small number
+            clip_fraction.mV[axis] = 0.f;
+        }
+        else
+        {
+            clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis];
+        }
+    }
+
+    LLVector3 abs_clip_fraction = clip_fraction;
+    abs_clip_fraction.abs();
+
+    // find axis of focus offset that is *most* outside the bounding box and use that to
+    // rescale focus offset to inside object extents
+    if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY]
+        && abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ])
+    {
+        focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec;
+    }
+    else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ])
+    {
+        focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec;
+    }
+    else
+    {
+        focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec;
+    }
+
+    // convert back to world space
+    focus_offset_from_object_center.rotVec(obj_rot);
+    
+    // now, based on distance of camera from object relative to object size
+    // push the focus point towards the near surface of the object when (relatively) close to the objcet
+    // or keep the focus point in the object middle when (relatively) far
+    // NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars
+    // is almost always "tumble about middle" and not "spin around surface point"
+    if (!is_avatar) 
+    {
+        LLVector3 obj_rel = original_focus_point - object->getRenderPosition();
+        
+        //now that we have the object relative position, we should bias toward the center of the object 
+        //based on the distance of the camera to the focus point vs. the distance of the camera to the focus
+
+        F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis());
+        F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin());
+
+
+        LLBBox obj_bbox = object->getBoundingBoxAgent();
+        F32 bias = 0.f;
+
+        // virtual_camera_pos is the camera position we are simulating by backing the camera off
+        // and adjusting the FOV
+        LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor));
+
+        // if the camera is inside the object (large, hollow objects, for example)
+        // leave focus point all the way to destination depth, away from object center
+        if(!obj_bbox.containsPointAgent(virtual_camera_pos))
+        {
+            // perform magic number biasing of focus point towards surface vs. planar center
+            bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f);
+            obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias);
+        }
+            
+        focus_offset_from_object_center = obj_rel;
+    }
+
+    return focus_offset_from_object_center;
 }
 
 //-----------------------------------------------------------------------------
@@ -554,260 +554,260 @@ LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 origi
 //-----------------------------------------------------------------------------
 BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
 {
-	BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
-
-	if (!mFocusObject || mFocusObject->isDead() || 
-		mFocusObject->isMesh() ||
-		gSavedSettings.getBOOL("DisableCameraConstraints"))
-	{
-		obj_min_distance = 0.f;
-		return TRUE;
-	}
-
-	if (mFocusObject->mDrawable.isNull())
-	{
+    BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
+
+    if (!mFocusObject || mFocusObject->isDead() || 
+        mFocusObject->isMesh() ||
+        gSavedSettings.getBOOL("DisableCameraConstraints"))
+    {
+        obj_min_distance = 0.f;
+        return TRUE;
+    }
+
+    if (mFocusObject->mDrawable.isNull())
+    {
 #ifdef LL_RELEASE_FOR_DOWNLOAD
-		LL_WARNS() << "Focus object with no drawable!" << LL_ENDL;
+        LL_WARNS() << "Focus object with no drawable!" << LL_ENDL;
 #else
-		mFocusObject->dump();
-		LL_ERRS() << "Focus object with no drawable!" << LL_ENDL;
+        mFocusObject->dump();
+        LL_ERRS() << "Focus object with no drawable!" << LL_ENDL;
 #endif
-		obj_min_distance = 0.f;
-		return TRUE;
-	}
-	
-	LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation();
-	LLVector3 target_offset_origin = mFocusObjectOffset;
-	LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
-
-	// convert offsets into object local space
-	camera_offset_target.rotVec(inv_object_rot);
-	target_offset_origin.rotVec(inv_object_rot);
-
-	// push around object extents based on target offset
-	LLVector3 object_extents = mFocusObject->getScale();
-	if (mFocusObject->isAvatar())
-	{
-		// fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom)
-		object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR;
-		object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR;
-		object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR;
-		soft_limit = TRUE;
-	}
-	LLVector3 abs_target_offset = target_offset_origin;
-	abs_target_offset.abs();
-
-	LLVector3 target_offset_dir = target_offset_origin;
-
-	BOOL target_outside_object_extents = FALSE;
-
-	for (U32 i = VX; i <= VZ; i++)
-	{
-		if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING)
-		{
-			target_outside_object_extents = TRUE;
-		}
-		if (camera_offset_target.mV[i] > 0.f)
-		{
-			object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f;
-		}
-		else
-		{
-			object_extents.mV[i] += target_offset_origin.mV[i] * 2.f;
-		}
-	}
-
-	// don't shrink the object extents so far that the object inverts
-	object_extents.clamp(0.001f, F32_MAX);
-
-	// move into first octant
-	LLVector3 camera_offset_target_abs_norm = camera_offset_target;
-	camera_offset_target_abs_norm.abs();
-	// make sure offset is non-zero
-	camera_offset_target_abs_norm.clamp(0.001f, F32_MAX);
-	camera_offset_target_abs_norm.normalize();
-
-	// find camera position relative to normalized object extents
-	LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm;
-	camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX];
-	camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY];
-	camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ];
-
-	if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && 
-		camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ])
-	{
-		if (camera_offset_target_abs_norm.mV[VX] < 0.001f)
-		{
-			obj_min_distance = object_extents.mV[VX] * 0.5f;
-		}
-		else
-		{
-			obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX];
-		}
-	}
-	else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ])
-	{
-		if (camera_offset_target_abs_norm.mV[VY] < 0.001f)
-		{
-			obj_min_distance = object_extents.mV[VY] * 0.5f;
-		}
-		else
-		{
-			obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY];
-		}
-	}
-	else
-	{
-		if (camera_offset_target_abs_norm.mV[VZ] < 0.001f)
-		{
-			obj_min_distance = object_extents.mV[VZ] * 0.5f;
-		}
-		else
-		{
-			obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ];
-		}
-	}
-
-	LLVector3 object_split_axis;
-	LLVector3 target_offset_scaled = target_offset_origin;
-	target_offset_scaled.abs();
-	target_offset_scaled.normalize();
-	target_offset_scaled.mV[VX] /= object_extents.mV[VX];
-	target_offset_scaled.mV[VY] /= object_extents.mV[VY];
-	target_offset_scaled.mV[VZ] /= object_extents.mV[VZ];
-
-	if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && 
-		target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ])
-	{
-		object_split_axis = LLVector3::x_axis;
-	}
-	else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ])
-	{
-		object_split_axis = LLVector3::y_axis;
-	}
-	else
-	{
-		object_split_axis = LLVector3::z_axis;
-	}
-
-	LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent());
-
-
-	F32 camera_offset_clip = camera_offset_object * object_split_axis;
-	F32 target_offset_clip = target_offset_dir * object_split_axis;
-
-	// target has moved outside of object extents
-	// check to see if camera and target are on same side 
-	if (target_outside_object_extents)
-	{
-		if (camera_offset_clip > 0.f && target_offset_clip > 0.f)
-		{
-			return FALSE;
-		}
-		else if (camera_offset_clip < 0.f && target_offset_clip < 0.f)
-		{
-			return FALSE;
-		}
-	}
-
-	// clamp obj distance to diagonal of 10 by 10 cube
-	obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
-
-	obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
-	
-	return TRUE;
+        obj_min_distance = 0.f;
+        return TRUE;
+    }
+    
+    LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation();
+    LLVector3 target_offset_origin = mFocusObjectOffset;
+    LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+
+    // convert offsets into object local space
+    camera_offset_target.rotVec(inv_object_rot);
+    target_offset_origin.rotVec(inv_object_rot);
+
+    // push around object extents based on target offset
+    LLVector3 object_extents = mFocusObject->getScale();
+    if (mFocusObject->isAvatar())
+    {
+        // fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom)
+        object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR;
+        object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR;
+        object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR;
+        soft_limit = TRUE;
+    }
+    LLVector3 abs_target_offset = target_offset_origin;
+    abs_target_offset.abs();
+
+    LLVector3 target_offset_dir = target_offset_origin;
+
+    BOOL target_outside_object_extents = FALSE;
+
+    for (U32 i = VX; i <= VZ; i++)
+    {
+        if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING)
+        {
+            target_outside_object_extents = TRUE;
+        }
+        if (camera_offset_target.mV[i] > 0.f)
+        {
+            object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f;
+        }
+        else
+        {
+            object_extents.mV[i] += target_offset_origin.mV[i] * 2.f;
+        }
+    }
+
+    // don't shrink the object extents so far that the object inverts
+    object_extents.clamp(0.001f, F32_MAX);
+
+    // move into first octant
+    LLVector3 camera_offset_target_abs_norm = camera_offset_target;
+    camera_offset_target_abs_norm.abs();
+    // make sure offset is non-zero
+    camera_offset_target_abs_norm.clamp(0.001f, F32_MAX);
+    camera_offset_target_abs_norm.normalize();
+
+    // find camera position relative to normalized object extents
+    LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm;
+    camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX];
+    camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY];
+    camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ];
+
+    if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && 
+        camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ])
+    {
+        if (camera_offset_target_abs_norm.mV[VX] < 0.001f)
+        {
+            obj_min_distance = object_extents.mV[VX] * 0.5f;
+        }
+        else
+        {
+            obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX];
+        }
+    }
+    else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ])
+    {
+        if (camera_offset_target_abs_norm.mV[VY] < 0.001f)
+        {
+            obj_min_distance = object_extents.mV[VY] * 0.5f;
+        }
+        else
+        {
+            obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY];
+        }
+    }
+    else
+    {
+        if (camera_offset_target_abs_norm.mV[VZ] < 0.001f)
+        {
+            obj_min_distance = object_extents.mV[VZ] * 0.5f;
+        }
+        else
+        {
+            obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ];
+        }
+    }
+
+    LLVector3 object_split_axis;
+    LLVector3 target_offset_scaled = target_offset_origin;
+    target_offset_scaled.abs();
+    target_offset_scaled.normalize();
+    target_offset_scaled.mV[VX] /= object_extents.mV[VX];
+    target_offset_scaled.mV[VY] /= object_extents.mV[VY];
+    target_offset_scaled.mV[VZ] /= object_extents.mV[VZ];
+
+    if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && 
+        target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ])
+    {
+        object_split_axis = LLVector3::x_axis;
+    }
+    else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ])
+    {
+        object_split_axis = LLVector3::y_axis;
+    }
+    else
+    {
+        object_split_axis = LLVector3::z_axis;
+    }
+
+    LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent());
+
+
+    F32 camera_offset_clip = camera_offset_object * object_split_axis;
+    F32 target_offset_clip = target_offset_dir * object_split_axis;
+
+    // target has moved outside of object extents
+    // check to see if camera and target are on same side 
+    if (target_outside_object_extents)
+    {
+        if (camera_offset_clip > 0.f && target_offset_clip > 0.f)
+        {
+            return FALSE;
+        }
+        else if (camera_offset_clip < 0.f && target_offset_clip < 0.f)
+        {
+            return FALSE;
+        }
+    }
+
+    // clamp obj distance to diagonal of 10 by 10 cube
+    obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
+
+    obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
+    
+    return TRUE;
 }
 
 F32 LLAgentCamera::getCameraZoomFraction()
 {
-	// 0.f -> camera zoomed all the way out
-	// 1.f -> camera zoomed all the way in
-	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-	{
-		// already [0,1]
-		return mHUDTargetZoom;
-	}
-	else if (mFocusOnAvatar && cameraThirdPerson())
-	{
-		return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f);
-	}
-	else if (cameraCustomizeAvatar())
-	{
-		F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
-		return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
-	}
-	else
-	{
-		F32 min_zoom;
-		F32 max_zoom = getCameraMaxZoomDistance();
-
-		F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
-		if (mFocusObject.notNull())
-		{
-			if (mFocusObject->isAvatar())
-			{
-				min_zoom = AVATAR_MIN_ZOOM;
-			}
-			else
-			{
-				min_zoom = OBJECT_MIN_ZOOM;
-			}
-		}
-		else
-		{
-			min_zoom = LAND_MIN_ZOOM;
-		}
-
-		return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
-	}
+    // 0.f -> camera zoomed all the way out
+    // 1.f -> camera zoomed all the way in
+    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+    {
+        // already [0,1]
+        return mHUDTargetZoom;
+    }
+    else if (mFocusOnAvatar && cameraThirdPerson())
+    {
+        return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f);
+    }
+    else if (cameraCustomizeAvatar())
+    {
+        F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
+        return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
+    }
+    else
+    {
+        F32 min_zoom;
+        F32 max_zoom = getCameraMaxZoomDistance();
+
+        F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
+        if (mFocusObject.notNull())
+        {
+            if (mFocusObject->isAvatar())
+            {
+                min_zoom = AVATAR_MIN_ZOOM;
+            }
+            else
+            {
+                min_zoom = OBJECT_MIN_ZOOM;
+            }
+        }
+        else
+        {
+            min_zoom = LAND_MIN_ZOOM;
+        }
+
+        return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
+    }
 }
 
 void LLAgentCamera::setCameraZoomFraction(F32 fraction)
 {
-	// 0.f -> camera zoomed all the way out
-	// 1.f -> camera zoomed all the way in
-	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-
-	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-	{
-		mHUDTargetZoom = fraction;
-	}
-	else if (mFocusOnAvatar && cameraThirdPerson())
-	{
-		mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
-	}
-	else if (cameraCustomizeAvatar())
-	{
-		LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
-		camera_offset_dir.normalize();
-		mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM);
-	}
-	else
-	{
-		F32 min_zoom = LAND_MIN_ZOOM;
-		F32 max_zoom = getCameraMaxZoomDistance();
-
-		if (mFocusObject.notNull())
-		{
-			if (mFocusObject.notNull())
-			{
-				if (mFocusObject->isAvatar())
-				{
-					min_zoom = AVATAR_MIN_ZOOM;
-				}
-				else
-				{
-					min_zoom = OBJECT_MIN_ZOOM;
-				}
-			}
-		}
-
-		LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
-		camera_offset_dir.normalize();
-		mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
-	}
-	startCameraAnimation();
+    // 0.f -> camera zoomed all the way out
+    // 1.f -> camera zoomed all the way in
+    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+
+    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+    {
+        mHUDTargetZoom = fraction;
+    }
+    else if (mFocusOnAvatar && cameraThirdPerson())
+    {
+        mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
+    }
+    else if (cameraCustomizeAvatar())
+    {
+        LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
+        camera_offset_dir.normalize();
+        mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM);
+    }
+    else
+    {
+        F32 min_zoom = LAND_MIN_ZOOM;
+        F32 max_zoom = getCameraMaxZoomDistance();
+
+        if (mFocusObject.notNull())
+        {
+            if (mFocusObject.notNull())
+            {
+                if (mFocusObject->isAvatar())
+                {
+                    min_zoom = AVATAR_MIN_ZOOM;
+                }
+                else
+                {
+                    min_zoom = OBJECT_MIN_ZOOM;
+                }
+            }
+        }
+
+        LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
+        camera_offset_dir.normalize();
+        mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
+    }
+    startCameraAnimation();
 }
 
 
@@ -816,21 +816,21 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraOrbitAround(const F32 radians)
 {
-	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-	{
-		// do nothing for hud selection
-	}
-	else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW))
-	{
-		gAgent.yaw(radians);
-	}
-	else
-	{
-		mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
-		
-		cameraZoomIn(1.f);
-	}
+    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+    {
+        // do nothing for hud selection
+    }
+    else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW))
+    {
+        gAgent.yaw(radians);
+    }
+    else
+    {
+        mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
+        
+        cameraZoomIn(1.f);
+    }
 }
 
 
@@ -839,29 +839,29 @@ void LLAgentCamera::cameraOrbitAround(const F32 radians)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraOrbitOver(const F32 angle)
 {
-	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-	{
-		// do nothing for hud selection
-	}
-	else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
-	{
-		gAgent.pitch(angle);
-	}
-	else
-	{
-		LLVector3 camera_offset_unit(mCameraFocusOffsetTarget);
-		camera_offset_unit.normalize();
-
-		F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() );
-
-		LLVector3d left_axis;
-		left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
-		F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD);
-		mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis);
-
-		cameraZoomIn(1.f);
-	}
+    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+    {
+        // do nothing for hud selection
+    }
+    else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
+    {
+        gAgent.pitch(angle);
+    }
+    else
+    {
+        LLVector3 camera_offset_unit(mCameraFocusOffsetTarget);
+        camera_offset_unit.normalize();
+
+        F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() );
+
+        LLVector3d left_axis;
+        left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
+        F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD);
+        mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis);
+
+        cameraZoomIn(1.f);
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -869,65 +869,65 @@ void LLAgentCamera::cameraOrbitOver(const F32 angle)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraZoomIn(const F32 fraction)
 {
-	if (gDisconnected)
-	{
-		return;
-	}
-
-	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-	if (LLToolMgr::getInstance()->inBuildMode() && selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-	{
-		// just update hud zoom level
-		mHUDTargetZoom /= fraction;
-		return;
-	}
-
-
-	LLVector3d	camera_offset_unit(mCameraFocusOffsetTarget);
-	F32 min_zoom = LAND_MIN_ZOOM;
-	F32 current_distance = (F32)camera_offset_unit.normalize();
-	F32 new_distance = current_distance * fraction;
-
-	// Don't move through focus point
-	if (mFocusObject)
-	{
-		LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]);
-
-		if (mFocusObject->isAvatar())
-		{
-			calcCameraMinDistance(min_zoom);
-		}
-		else
-		{
-			min_zoom = OBJECT_MIN_ZOOM;
-		}
-	}
-
-	new_distance = llmax(new_distance, min_zoom); 
-
-	F32 max_distance = getCameraMaxZoomDistance();
+    if (gDisconnected)
+    {
+        return;
+    }
+
+    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+    if (LLToolMgr::getInstance()->inBuildMode() && selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+    {
+        // just update hud zoom level
+        mHUDTargetZoom /= fraction;
+        return;
+    }
+
+
+    LLVector3d  camera_offset_unit(mCameraFocusOffsetTarget);
+    F32 min_zoom = LAND_MIN_ZOOM;
+    F32 current_distance = (F32)camera_offset_unit.normalize();
+    F32 new_distance = current_distance * fraction;
+
+    // Don't move through focus point
+    if (mFocusObject)
+    {
+        LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]);
+
+        if (mFocusObject->isAvatar())
+        {
+            calcCameraMinDistance(min_zoom);
+        }
+        else
+        {
+            min_zoom = OBJECT_MIN_ZOOM;
+        }
+    }
+
+    new_distance = llmax(new_distance, min_zoom); 
+
+    F32 max_distance = getCameraMaxZoomDistance();
 
     max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance.  MAINT-3154
 
-	if (new_distance > max_distance)
-	{
-		new_distance = max_distance;
-
-		/*
-		// Unless camera is unlocked
-		if (!LLViewerCamera::sDisableCameraConstraints)
-		{
-			return;
-		}
-		*/
-	}
-
-	if(cameraCustomizeAvatar())
-	{
-		new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
-	}
-
-	mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
+    if (new_distance > max_distance)
+    {
+        new_distance = max_distance;
+
+        /*
+        // Unless camera is unlocked
+        if (!LLViewerCamera::sDisableCameraConstraints)
+        {
+            return;
+        }
+        */
+    }
+
+    if(cameraCustomizeAvatar())
+    {
+        new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
+    }
+
+    mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
 }
 
 //-----------------------------------------------------------------------------
@@ -935,62 +935,62 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraOrbitIn(const F32 meters)
 {
-	if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
-	{
-		F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"));
-		
-		mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist;
-
-		if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f)
-		{
-			// No need to animate, camera is already there.
-			changeCameraToMouselook(FALSE);
-		}
-
-		mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION);
-	}
-	else
-	{
-		LLVector3d	camera_offset_unit(mCameraFocusOffsetTarget);
-		F32 current_distance = (F32)camera_offset_unit.normalize();
-		F32 new_distance = current_distance - meters;
-		F32 min_zoom = LAND_MIN_ZOOM;
-		
-		// Don't move through focus point
-		if (mFocusObject.notNull())
-		{
-			if (mFocusObject->isAvatar())
-			{
-				min_zoom = AVATAR_MIN_ZOOM;
-			}
-			else
-			{
-				min_zoom = OBJECT_MIN_ZOOM;
-			}
-		}
-
-		new_distance = llmax(new_distance, min_zoom);
-
-		F32 max_distance = getCameraMaxZoomDistance();
-
-		if (new_distance > max_distance)
-		{
-			// Unless camera is unlocked
-			if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
-			{
-				return;
-			}
-		}
-
-		if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() )
-		{
-			new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
-		}
-
-		// Compute new camera offset
-		mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
-		cameraZoomIn(1.f);
-	}
+    if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
+    {
+        F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"));
+        
+        mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist;
+
+        if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f)
+        {
+            // No need to animate, camera is already there.
+            changeCameraToMouselook(FALSE);
+        }
+
+        mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION);
+    }
+    else
+    {
+        LLVector3d  camera_offset_unit(mCameraFocusOffsetTarget);
+        F32 current_distance = (F32)camera_offset_unit.normalize();
+        F32 new_distance = current_distance - meters;
+        F32 min_zoom = LAND_MIN_ZOOM;
+        
+        // Don't move through focus point
+        if (mFocusObject.notNull())
+        {
+            if (mFocusObject->isAvatar())
+            {
+                min_zoom = AVATAR_MIN_ZOOM;
+            }
+            else
+            {
+                min_zoom = OBJECT_MIN_ZOOM;
+            }
+        }
+
+        new_distance = llmax(new_distance, min_zoom);
+
+        F32 max_distance = getCameraMaxZoomDistance();
+
+        if (new_distance > max_distance)
+        {
+            // Unless camera is unlocked
+            if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
+            {
+                return;
+            }
+        }
+
+        if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() )
+        {
+            new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
+        }
+
+        // Compute new camera offset
+        mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
+        cameraZoomIn(1.f);
+    }
 }
 
 
@@ -999,15 +999,15 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraPanIn(F32 meters)
 {
-	LLVector3d at_axis;
-	at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis());
-
-	mFocusTargetGlobal += meters * at_axis;
-	mFocusGlobal = mFocusTargetGlobal;
-	// don't enforce zoom constraints as this is the only way for users to get past them easily
-	updateFocusOffset();
-	// NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
-	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+    LLVector3d at_axis;
+    at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis());
+
+    mFocusTargetGlobal += meters * at_axis;
+    mFocusGlobal = mFocusTargetGlobal;
+    // don't enforce zoom constraints as this is the only way for users to get past them easily
+    updateFocusOffset();
+    // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
+    mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
 //-----------------------------------------------------------------------------
@@ -1015,19 +1015,19 @@ void LLAgentCamera::cameraPanIn(F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraPanLeft(F32 meters)
 {
-	LLVector3d left_axis;
-	left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
-
-	mFocusTargetGlobal += meters * left_axis;
-	mFocusGlobal = mFocusTargetGlobal;
-
-	// disable smoothing for camera pan, which causes some residents unhappiness
-	mCameraSmoothingStop = true;
-	
-	cameraZoomIn(1.f);
-	updateFocusOffset();
-	// NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx
-	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+    LLVector3d left_axis;
+    left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
+
+    mFocusTargetGlobal += meters * left_axis;
+    mFocusGlobal = mFocusTargetGlobal;
+
+    // disable smoothing for camera pan, which causes some residents unhappiness
+    mCameraSmoothingStop = true;
+    
+    cameraZoomIn(1.f);
+    updateFocusOffset();
+    // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx
+    mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
 //-----------------------------------------------------------------------------
@@ -1035,19 +1035,19 @@ void LLAgentCamera::cameraPanLeft(F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraPanUp(F32 meters)
 {
-	LLVector3d up_axis;
-	up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis());
+    LLVector3d up_axis;
+    up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis());
 
-	mFocusTargetGlobal += meters * up_axis;
-	mFocusGlobal = mFocusTargetGlobal;
+    mFocusTargetGlobal += meters * up_axis;
+    mFocusGlobal = mFocusTargetGlobal;
 
-	// disable smoothing for camera pan, which causes some residents unhappiness
-	mCameraSmoothingStop = true;
+    // disable smoothing for camera pan, which causes some residents unhappiness
+    mCameraSmoothingStop = true;
 
-	cameraZoomIn(1.f);
-	updateFocusOffset();
-	// NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
-	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+    cameraZoomIn(1.f);
+    updateFocusOffset();
+    // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
+    mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
 //-----------------------------------------------------------------------------
@@ -1055,67 +1055,67 @@ void LLAgentCamera::cameraPanUp(F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 {
-	static LLVector3 last_at_axis;
-
-	if (!isAgentAvatarValid()) return;
-
-	LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation();
-	LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation();
-
-	if 	(LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
-		&& (root_at * last_at_axis > 0.95f))
-	{
-		LLVector3 vel = gAgentAvatarp->getVelocity();
-		if (vel.magVecSquared() > 4.f)
-		{
-			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot);
-		}
-		else
-		{
-			// *FIX: rotate mframeagent by sit object's rotation?
-			LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
-			LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
-			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset);
-		}
-		last_at_axis = root_at;
-		return;
-	}
-
-	last_at_axis = root_at;
-	
-	if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
-	{
-		setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f));	
-	}
-	else
-	{
-		// Move head based on cursor position
-		ELookAtType lookAtType = LOOKAT_TARGET_NONE;
-		LLVector3 headLookAxis;
-		LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance());
-
-		if (cameraMouselook())
-		{
-			lookAtType = LOOKAT_TARGET_MOUSELOOK;
-		}
-		else if (cameraThirdPerson())
-		{
-			// range from -.5 to .5
-			F32 x_from_center = 
-				((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f;
-			F32 y_from_center = 
-				((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f;
-
-			frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD);
-			frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD);
-			lookAtType = LOOKAT_TARGET_FREELOOK;
-		}
-
-		headLookAxis = frameCamera.getAtAxis();
-		// RN: we use world-space offset for mouselook and freelook
-		//headLookAxis = headLookAxis * av_inv_rot;
-		setLookAt(lookAtType, gAgentAvatarp, headLookAxis);
-	}
+    static LLVector3 last_at_axis;
+
+    if (!isAgentAvatarValid()) return;
+
+    LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation();
+    LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation();
+
+    if  (LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
+        && (root_at * last_at_axis > 0.95f))
+    {
+        LLVector3 vel = gAgentAvatarp->getVelocity();
+        if (vel.magVecSquared() > 4.f)
+        {
+            setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot);
+        }
+        else
+        {
+            // *FIX: rotate mframeagent by sit object's rotation?
+            LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
+            LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
+            setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset);
+        }
+        last_at_axis = root_at;
+        return;
+    }
+
+    last_at_axis = root_at;
+    
+    if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
+    {
+        setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f));    
+    }
+    else
+    {
+        // Move head based on cursor position
+        ELookAtType lookAtType = LOOKAT_TARGET_NONE;
+        LLVector3 headLookAxis;
+        LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance());
+
+        if (cameraMouselook())
+        {
+            lookAtType = LOOKAT_TARGET_MOUSELOOK;
+        }
+        else if (cameraThirdPerson())
+        {
+            // range from -.5 to .5
+            F32 x_from_center = 
+                ((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f;
+            F32 y_from_center = 
+                ((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f;
+
+            frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD);
+            frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD);
+            lookAtType = LOOKAT_TARGET_FREELOOK;
+        }
+
+        headLookAxis = frameCamera.getAtAxis();
+        // RN: we use world-space offset for mouselook and freelook
+        //headLookAxis = headLookAxis * av_inv_rot;
+        setLookAt(lookAtType, gAgentAvatarp, headLookAxis);
+    }
 }
 
 static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera");
@@ -1125,373 +1125,373 @@ static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera");
 //-----------------------------------------------------------------------------
 void LLAgentCamera::updateCamera()
 {
-	LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA);
-
-	// - changed camera_skyward to the new global "mCameraUpVector"
-	mCameraUpVector = LLVector3::z_axis;
-	//LLVector3	camera_skyward(0.f, 0.f, 1.f);
-
-	U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode;
-
-	validateFocusObject();
-
-	if (isAgentAvatarValid() && 
-		gAgentAvatarp->isSitting() &&
-		camera_mode == CAMERA_MODE_MOUSELOOK)
-	{
-		//changed camera_skyward to the new global "mCameraUpVector"
-		mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
-	}
-
-	if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams())
-	{
-		mAllowChangeToFollow = FALSE;
-		mFocusOnAvatar = TRUE;
-		changeCameraToFollow();
-	}
-
-	//NOTE - this needs to be integrated into a general upVector system here within llAgent. 
-	if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar )
-	{
-		mCameraUpVector = mFollowCam.getUpVector();
-	}
-
-	if (mSitCameraEnabled)
-	{
-		if (mSitCameraReferenceObject->isDead())
-		{
-			setSitCamera(LLUUID::null);
-		}
-	}
-
-	// Update UI with our camera inputs
-	LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
-	if (camera_floater)
-	{
-		camera_floater->mRotate->setToggleState(gAgentCamera.getOrbitRightKey() > 0.f,	// left
-												gAgentCamera.getOrbitUpKey() > 0.f,		// top
-												gAgentCamera.getOrbitLeftKey() > 0.f,	// right
-												gAgentCamera.getOrbitDownKey() > 0.f);	// bottom
-		
-		camera_floater->mTrack->setToggleState(gAgentCamera.getPanLeftKey() > 0.f,		// left
-											   gAgentCamera.getPanUpKey() > 0.f,			// top
-											   gAgentCamera.getPanRightKey() > 0.f,		// right
-											   gAgentCamera.getPanDownKey() > 0.f);		// bottom
-	}
-
-	// Handle camera movement based on keyboard.
-	const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD;			// radians per second
-	const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD;		// radians per second
-	const F32 PAN_RATE = 5.f;								// meters per second
-
-	if (gAgentCamera.getOrbitUpKey() || gAgentCamera.getOrbitDownKey())
-	{
-		F32 input_rate = gAgentCamera.getOrbitUpKey() - gAgentCamera.getOrbitDownKey();
-		cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped );
-	}
-
-	if (gAgentCamera.getOrbitLeftKey() || gAgentCamera.getOrbitRightKey())
-	{
-		F32 input_rate = gAgentCamera.getOrbitLeftKey() - gAgentCamera.getOrbitRightKey();
-		cameraOrbitAround(input_rate * ORBIT_AROUND_RATE / gFPSClamped);
-	}
-
-	if (gAgentCamera.getOrbitInKey() || gAgentCamera.getOrbitOutKey())
-	{
-		F32 input_rate = gAgentCamera.getOrbitInKey() - gAgentCamera.getOrbitOutKey();
-		
-		LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal();
-		F32 distance_to_focus = (F32)to_focus.magVec();
-		// Move at distance (in meters) meters per second
-		cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped );
-	}
-
-	if (gAgentCamera.getPanInKey() || gAgentCamera.getPanOutKey())
-	{
-		F32 input_rate = gAgentCamera.getPanInKey() - gAgentCamera.getPanOutKey();
-		cameraPanIn(input_rate * PAN_RATE / gFPSClamped);
-	}
-
-	if (gAgentCamera.getPanRightKey() || gAgentCamera.getPanLeftKey())
-	{
-		F32 input_rate = gAgentCamera.getPanRightKey() - gAgentCamera.getPanLeftKey();
-		cameraPanLeft(input_rate * -PAN_RATE / gFPSClamped );
-	}
-
-	if (gAgentCamera.getPanUpKey() || gAgentCamera.getPanDownKey())
-	{
-		F32 input_rate = gAgentCamera.getPanUpKey() - gAgentCamera.getPanDownKey();
-		cameraPanUp(input_rate * PAN_RATE / gFPSClamped );
-	}
-
-	// Clear camera keyboard keys.
-	gAgentCamera.clearOrbitKeys();
-	gAgentCamera.clearPanKeys();
-
-	// lerp camera focus offset
-	mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
-
-	if ( mCameraMode == CAMERA_MODE_FOLLOW )
-	{
-		if (isAgentAvatarValid())
-		{
-			//--------------------------------------------------------------------------------
-			// this is where the avatar's position and rotation are given to followCam, and 
-			// where it is updated. All three of its attributes are updated: (1) position, 
-			// (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent.
-			//--------------------------------------------------------------------------------
-			// *TODO: use combined rotation of frameagent and sit object
-			LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
-
-			LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
-			if (current_cam)
-			{
-				mFollowCam.copyParams(*current_cam);
-				mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
-				mFollowCam.update();
-				LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
-			}
-			else
-			{
-				changeCameraToThirdPerson(TRUE);
-			}
-		}
-	}
-
-	BOOL hit_limit;
-	LLVector3d camera_pos_global;
-	LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit);
-	mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global);
-	LLVector3d focus_target_global = calcFocusPositionTargetGlobal();
-
-	// perform field of view correction
-	mCameraFOVZoomFactor = calcCameraFOVZoomFactor();
-	camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor);
-
-	gAgent.setShowAvatar(TRUE); // can see avatar by default
-
-	// Adjust position for animation
-	if (mCameraAnimating)
-	{
-		F32 time = mAnimationTimer.getElapsedTimeF32();
-
-		// yet another instance of critically damped motion, hooray!
-		// F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE);
-
-		// linear interpolation
-		F32 fraction_of_animation = time / mAnimationDuration;
-
-		BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK;
-		BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK;
-		F32 fraction_animation_to_skip;
-
-		if (mAnimationCameraStartGlobal == camera_target_global)
-		{
-			fraction_animation_to_skip = 0.f;
-		}
-		else
-		{
-			LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global;
-			fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec();
-		}
-		F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f;
-		F32 animation_finish_fraction =  (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f;
-	
-		if (fraction_of_animation < animation_finish_fraction)
-		{
-			if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction )
-			{
-				gAgent.setShowAvatar(FALSE);
-			}
-
-			// ...adjust position for animation
-			F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation);
-			camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation);
-			mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation);
-		}
-		else
-		{
-			// ...animation complete
-			mCameraAnimating = FALSE;
-
-			camera_pos_global = camera_target_global;
-			mFocusGlobal = focus_target_global;
-
-			gAgent.endAnimationUpdateUI();
-			gAgent.setShowAvatar(TRUE);
-		}
-
-		if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK))
-		{
-			gAgentAvatarp->updateAttachmentVisibility(mCameraMode);
-		}
-	}
-	else 
-	{
-		camera_pos_global = camera_target_global;
-		mFocusGlobal = focus_target_global;
-		gAgent.setShowAvatar(TRUE);
-	}
-
-	// smoothing
-	if (TRUE)
-	{
-		LLVector3d agent_pos = gAgent.getPositionGlobal();
-		LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
-		// Sitting on what you're manipulating can cause camera jitter with smoothing. 
-		// This turns off smoothing while editing. -MG
-		bool in_build_mode = LLToolMgr::getInstance()->inBuildMode();
-		mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode;
-		
-		if (cameraThirdPerson() && !mCameraSmoothingStop)
-		{
-			const F32 SMOOTHING_HALF_LIFE = 0.02f;
-			
-			F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
-					
-			if (!mFocusObject)  // we differentiate on avatar mode 
-			{
-				// for avatar-relative focus, we smooth in avatar space -
-				// the avatar moves too jerkily w/r/t global space to smooth there.
-
-				LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent;
-				if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE)  // only smooth over short distances please
-				{
-					camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing);
-					camera_pos_global = camera_pos_agent + agent_pos;
-				}
-			}
-			else
-			{
-				LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal;
-				if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
-				{
-					camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing);
-				}
-			}
-		}
-								 
-		mCameraSmoothingLastPositionGlobal = camera_pos_global;
-		mCameraSmoothingLastPositionAgent = camera_pos_agent;
-		mCameraSmoothingStop = false;
-	}
-
-	
-	mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE));
-
-//	LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL;
-
-	LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal);
-	
-	mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global);
-
-	// Move the camera
-
-	LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent);
-	//LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent);
-	
-	// Change FOV
-	LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor));
-
-	// follow camera when in customize mode
-	if (cameraCustomizeAvatar())	
-	{
-		setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent);
-	}
-
-	// update the travel distance stat
-	// this isn't directly related to the camera
-	// but this seemed like the best place to do this
-	LLVector3d global_pos = gAgent.getPositionGlobal(); 
-	if (!gAgent.getLastPositionGlobal().isExactlyZero())
-	{
-		LLVector3d delta = global_pos - gAgent.getLastPositionGlobal();
-		gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec());
-	}
-	gAgent.setLastPositionGlobal(global_pos);
-	
-	if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook())
-	{
-		LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + 
-			LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + 
-			LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation();
-		LLVector3 diff = mCameraPositionAgent - head_pos;
-		diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation();
-
-		LLJoint* torso_joint = gAgentAvatarp->mTorsop;
-		LLJoint* chest_joint = gAgentAvatarp->mChestp;
-		LLVector3 torso_scale = torso_joint->getScale();
-		LLVector3 chest_scale = chest_joint->getScale();
-
-		// shorten avatar skeleton to avoid foot interpenetration
-		if (!gAgentAvatarp->mInAir)
-		{
-			LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation();
-			F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f);
-			F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f);
-			torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
-
-			LLJoint* neck_joint = gAgentAvatarp->mNeckp;
-			LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation();
-			scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f);
-			chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
-			diff.mV[VZ] = 0.f;
-		}
-
-		// SL-315
-		gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff);
-
-		gAgentAvatarp->mRoot->updateWorldMatrixChildren();
-
-		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-			 iter != gAgentAvatarp->mAttachmentPoints.end(); )
-		{
-			LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-			LLViewerJointAttachment* attachment = curiter->second;
-			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-				 attachment_iter != attachment->mAttachedObjects.end();
-				 ++attachment_iter)
-			{
-				LLViewerObject *attached_object = (*attachment_iter);
-				if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
-				{
-					// clear any existing "early" movements of attachment
-					attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE);
-					gPipeline.updateMoveNormalAsync(attached_object->mDrawable);
-					attached_object->updateText();
-				}
-			}
-		}
-
-		torso_joint->setScale(torso_scale);
-		chest_joint->setScale(chest_scale);
-	}
+    LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA);
+
+    // - changed camera_skyward to the new global "mCameraUpVector"
+    mCameraUpVector = LLVector3::z_axis;
+    //LLVector3 camera_skyward(0.f, 0.f, 1.f);
+
+    U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode;
+
+    validateFocusObject();
+
+    if (isAgentAvatarValid() && 
+        gAgentAvatarp->isSitting() &&
+        camera_mode == CAMERA_MODE_MOUSELOOK)
+    {
+        //changed camera_skyward to the new global "mCameraUpVector"
+        mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
+    }
+
+    if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams())
+    {
+        mAllowChangeToFollow = FALSE;
+        mFocusOnAvatar = TRUE;
+        changeCameraToFollow();
+    }
+
+    //NOTE - this needs to be integrated into a general upVector system here within llAgent. 
+    if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar )
+    {
+        mCameraUpVector = mFollowCam.getUpVector();
+    }
+
+    if (mSitCameraEnabled)
+    {
+        if (mSitCameraReferenceObject->isDead())
+        {
+            setSitCamera(LLUUID::null);
+        }
+    }
+
+    // Update UI with our camera inputs
+    LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
+    if (camera_floater)
+    {
+        camera_floater->mRotate->setToggleState(gAgentCamera.getOrbitRightKey() > 0.f,  // left
+                                                gAgentCamera.getOrbitUpKey() > 0.f,     // top
+                                                gAgentCamera.getOrbitLeftKey() > 0.f,   // right
+                                                gAgentCamera.getOrbitDownKey() > 0.f);  // bottom
+        
+        camera_floater->mTrack->setToggleState(gAgentCamera.getPanLeftKey() > 0.f,      // left
+                                               gAgentCamera.getPanUpKey() > 0.f,            // top
+                                               gAgentCamera.getPanRightKey() > 0.f,     // right
+                                               gAgentCamera.getPanDownKey() > 0.f);     // bottom
+    }
+
+    // Handle camera movement based on keyboard.
+    const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD;          // radians per second
+    const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD;        // radians per second
+    const F32 PAN_RATE = 5.f;                               // meters per second
+
+    if (gAgentCamera.getOrbitUpKey() || gAgentCamera.getOrbitDownKey())
+    {
+        F32 input_rate = gAgentCamera.getOrbitUpKey() - gAgentCamera.getOrbitDownKey();
+        cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped );
+    }
+
+    if (gAgentCamera.getOrbitLeftKey() || gAgentCamera.getOrbitRightKey())
+    {
+        F32 input_rate = gAgentCamera.getOrbitLeftKey() - gAgentCamera.getOrbitRightKey();
+        cameraOrbitAround(input_rate * ORBIT_AROUND_RATE / gFPSClamped);
+    }
+
+    if (gAgentCamera.getOrbitInKey() || gAgentCamera.getOrbitOutKey())
+    {
+        F32 input_rate = gAgentCamera.getOrbitInKey() - gAgentCamera.getOrbitOutKey();
+        
+        LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal();
+        F32 distance_to_focus = (F32)to_focus.magVec();
+        // Move at distance (in meters) meters per second
+        cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped );
+    }
+
+    if (gAgentCamera.getPanInKey() || gAgentCamera.getPanOutKey())
+    {
+        F32 input_rate = gAgentCamera.getPanInKey() - gAgentCamera.getPanOutKey();
+        cameraPanIn(input_rate * PAN_RATE / gFPSClamped);
+    }
+
+    if (gAgentCamera.getPanRightKey() || gAgentCamera.getPanLeftKey())
+    {
+        F32 input_rate = gAgentCamera.getPanRightKey() - gAgentCamera.getPanLeftKey();
+        cameraPanLeft(input_rate * -PAN_RATE / gFPSClamped );
+    }
+
+    if (gAgentCamera.getPanUpKey() || gAgentCamera.getPanDownKey())
+    {
+        F32 input_rate = gAgentCamera.getPanUpKey() - gAgentCamera.getPanDownKey();
+        cameraPanUp(input_rate * PAN_RATE / gFPSClamped );
+    }
+
+    // Clear camera keyboard keys.
+    gAgentCamera.clearOrbitKeys();
+    gAgentCamera.clearPanKeys();
+
+    // lerp camera focus offset
+    mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
+
+    if ( mCameraMode == CAMERA_MODE_FOLLOW )
+    {
+        if (isAgentAvatarValid())
+        {
+            //--------------------------------------------------------------------------------
+            // this is where the avatar's position and rotation are given to followCam, and 
+            // where it is updated. All three of its attributes are updated: (1) position, 
+            // (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent.
+            //--------------------------------------------------------------------------------
+            // *TODO: use combined rotation of frameagent and sit object
+            LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
+
+            LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
+            if (current_cam)
+            {
+                mFollowCam.copyParams(*current_cam);
+                mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
+                mFollowCam.update();
+                LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
+            }
+            else
+            {
+                changeCameraToThirdPerson(TRUE);
+            }
+        }
+    }
+
+    BOOL hit_limit;
+    LLVector3d camera_pos_global;
+    LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit);
+    mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global);
+    LLVector3d focus_target_global = calcFocusPositionTargetGlobal();
+
+    // perform field of view correction
+    mCameraFOVZoomFactor = calcCameraFOVZoomFactor();
+    camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor);
+
+    gAgent.setShowAvatar(TRUE); // can see avatar by default
+
+    // Adjust position for animation
+    if (mCameraAnimating)
+    {
+        F32 time = mAnimationTimer.getElapsedTimeF32();
+
+        // yet another instance of critically damped motion, hooray!
+        // F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE);
+
+        // linear interpolation
+        F32 fraction_of_animation = time / mAnimationDuration;
+
+        BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK;
+        BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK;
+        F32 fraction_animation_to_skip;
+
+        if (mAnimationCameraStartGlobal == camera_target_global)
+        {
+            fraction_animation_to_skip = 0.f;
+        }
+        else
+        {
+            LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global;
+            fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec();
+        }
+        F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f;
+        F32 animation_finish_fraction =  (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f;
+    
+        if (fraction_of_animation < animation_finish_fraction)
+        {
+            if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction )
+            {
+                gAgent.setShowAvatar(FALSE);
+            }
+
+            // ...adjust position for animation
+            F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation);
+            camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation);
+            mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation);
+        }
+        else
+        {
+            // ...animation complete
+            mCameraAnimating = FALSE;
+
+            camera_pos_global = camera_target_global;
+            mFocusGlobal = focus_target_global;
+
+            gAgent.endAnimationUpdateUI();
+            gAgent.setShowAvatar(TRUE);
+        }
+
+        if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK))
+        {
+            gAgentAvatarp->updateAttachmentVisibility(mCameraMode);
+        }
+    }
+    else 
+    {
+        camera_pos_global = camera_target_global;
+        mFocusGlobal = focus_target_global;
+        gAgent.setShowAvatar(TRUE);
+    }
+
+    // smoothing
+    if (TRUE)
+    {
+        LLVector3d agent_pos = gAgent.getPositionGlobal();
+        LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
+        // Sitting on what you're manipulating can cause camera jitter with smoothing. 
+        // This turns off smoothing while editing. -MG
+        bool in_build_mode = LLToolMgr::getInstance()->inBuildMode();
+        mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode;
+        
+        if (cameraThirdPerson() && !mCameraSmoothingStop)
+        {
+            const F32 SMOOTHING_HALF_LIFE = 0.02f;
+            
+            F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
+                    
+            if (!mFocusObject)  // we differentiate on avatar mode 
+            {
+                // for avatar-relative focus, we smooth in avatar space -
+                // the avatar moves too jerkily w/r/t global space to smooth there.
+
+                LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent;
+                if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE)  // only smooth over short distances please
+                {
+                    camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing);
+                    camera_pos_global = camera_pos_agent + agent_pos;
+                }
+            }
+            else
+            {
+                LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal;
+                if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
+                {
+                    camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing);
+                }
+            }
+        }
+                                 
+        mCameraSmoothingLastPositionGlobal = camera_pos_global;
+        mCameraSmoothingLastPositionAgent = camera_pos_agent;
+        mCameraSmoothingStop = false;
+    }
+
+    
+    mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE));
+
+//  LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL;
+
+    LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal);
+    
+    mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global);
+
+    // Move the camera
+
+    LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent);
+    //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent);
+    
+    // Change FOV
+    LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor));
+
+    // follow camera when in customize mode
+    if (cameraCustomizeAvatar())    
+    {
+        setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent);
+    }
+
+    // update the travel distance stat
+    // this isn't directly related to the camera
+    // but this seemed like the best place to do this
+    LLVector3d global_pos = gAgent.getPositionGlobal(); 
+    if (!gAgent.getLastPositionGlobal().isExactlyZero())
+    {
+        LLVector3d delta = global_pos - gAgent.getLastPositionGlobal();
+        gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec());
+    }
+    gAgent.setLastPositionGlobal(global_pos);
+    
+    if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook())
+    {
+        LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + 
+            LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + 
+            LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation();
+        LLVector3 diff = mCameraPositionAgent - head_pos;
+        diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation();
+
+        LLJoint* torso_joint = gAgentAvatarp->mTorsop;
+        LLJoint* chest_joint = gAgentAvatarp->mChestp;
+        LLVector3 torso_scale = torso_joint->getScale();
+        LLVector3 chest_scale = chest_joint->getScale();
+
+        // shorten avatar skeleton to avoid foot interpenetration
+        if (!gAgentAvatarp->mInAir)
+        {
+            LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation();
+            F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f);
+            F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f);
+            torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
+
+            LLJoint* neck_joint = gAgentAvatarp->mNeckp;
+            LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation();
+            scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f);
+            chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
+            diff.mV[VZ] = 0.f;
+        }
+
+        // SL-315
+        gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff);
+
+        gAgentAvatarp->mRoot->updateWorldMatrixChildren();
+
+        for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+             iter != gAgentAvatarp->mAttachmentPoints.end(); )
+        {
+            LLVOAvatar::attachment_map_t::iterator curiter = iter++;
+            LLViewerJointAttachment* attachment = curiter->second;
+            for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+                 attachment_iter != attachment->mAttachedObjects.end();
+                 ++attachment_iter)
+            {
+                LLViewerObject *attached_object = (*attachment_iter);
+                if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
+                {
+                    // clear any existing "early" movements of attachment
+                    attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE);
+                    gPipeline.updateMoveNormalAsync(attached_object->mDrawable);
+                    attached_object->updateText();
+                }
+            }
+        }
+
+        torso_joint->setScale(torso_scale);
+        chest_joint->setScale(chest_scale);
+    }
 }
 
 void LLAgentCamera::updateLastCamera()
 {
-	mLastCameraMode = mCameraMode;
+    mLastCameraMode = mCameraMode;
 }
 
 void LLAgentCamera::updateFocusOffset()
 {
-	validateFocusObject();
-	if (mFocusObject.notNull())
-	{
-		LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition());
-		mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos);
-	}
+    validateFocusObject();
+    if (mFocusObject.notNull())
+    {
+        LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition());
+        mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos);
+    }
 }
 
 void LLAgentCamera::validateFocusObject()
 {
-	if (mFocusObject.notNull() && 
-		mFocusObject->isDead())
-	{
-		mFocusObjectOffset.clearVec();
-		clearFocusObject();
-		mCameraFOVZoomFactor = 0.f;
-	}
+    if (mFocusObject.notNull() && 
+        mFocusObject->isDead())
+    {
+        mFocusObjectOffset.clearVec();
+        clearFocusObject();
+        mCameraFOVZoomFactor = 0.f;
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -1499,124 +1499,124 @@ void LLAgentCamera::validateFocusObject()
 //-----------------------------------------------------------------------------
 LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal()
 {
-	if (mFocusObject.notNull() && mFocusObject->isDead())
-	{
-		clearFocusObject();
-	}
-
-	if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
-	{
-		mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus());
-		return mFocusTargetGlobal;
-	}
-	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-	{
-		LLVector3d at_axis(1.0, 0.0, 0.0);
-		LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
-		if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-		{
-			LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot();
-			if (!root_object->flagCameraDecoupled())
-			{
-				agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
-			}
-		}
-		at_axis = at_axis * agent_rot;
-		mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis;
-		return mFocusTargetGlobal;
-	}
-	else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
-	{
-		if (mFocusOnAvatar)
-		{
-			LLVector3 focus_target = isAgentAvatarValid()
-				? gAgentAvatarp->mHeadp->getWorldPosition()
-				: gAgent.getPositionAgent();
-			LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
-			mFocusTargetGlobal = focus_target_global;
-		}
-		return mFocusTargetGlobal;
-	}
-	else if (!mFocusOnAvatar)
-	{
-		if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull())
-		{
-			LLDrawable* drawablep = mFocusObject->mDrawable;
-			
-			if (mTrackFocusObject &&
-				drawablep && 
-				drawablep->isActive())
-			{
-				if (!mFocusObject->isAvatar())
-				{
-					if (mFocusObject->isSelected())
-					{
-						gPipeline.updateMoveNormalAsync(drawablep);
-					}
-					else
-					{
-						if (drawablep->isState(LLDrawable::MOVE_UNDAMPED))
-						{
-							gPipeline.updateMoveNormalAsync(drawablep);
-						}
-						else
-						{
-							gPipeline.updateMoveDampedAsync(drawablep);
-						}
-					}
-				}
-			}
-			// if not tracking object, update offset based on new object position
-			else
-			{
-				updateFocusOffset();
-			}
-			LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset;
-			mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent));
-		}
-		return mFocusTargetGlobal;
-	}
-	else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull())
-	{
-		// sit camera
-		LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
-		LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
-
-		LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot);
-		return gAgent.getPosGlobalFromAgent(target_pos);
-	}
-	else
-	{
-		return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset();
-	}
+    if (mFocusObject.notNull() && mFocusObject->isDead())
+    {
+        clearFocusObject();
+    }
+
+    if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
+    {
+        mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus());
+        return mFocusTargetGlobal;
+    }
+    else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+    {
+        LLVector3d at_axis(1.0, 0.0, 0.0);
+        LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
+        if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+        {
+            LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot();
+            if (!root_object->flagCameraDecoupled())
+            {
+                agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
+            }
+        }
+        at_axis = at_axis * agent_rot;
+        mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis;
+        return mFocusTargetGlobal;
+    }
+    else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
+    {
+        if (mFocusOnAvatar)
+        {
+            LLVector3 focus_target = isAgentAvatarValid()
+                ? gAgentAvatarp->mHeadp->getWorldPosition()
+                : gAgent.getPositionAgent();
+            LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
+            mFocusTargetGlobal = focus_target_global;
+        }
+        return mFocusTargetGlobal;
+    }
+    else if (!mFocusOnAvatar)
+    {
+        if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull())
+        {
+            LLDrawable* drawablep = mFocusObject->mDrawable;
+            
+            if (mTrackFocusObject &&
+                drawablep && 
+                drawablep->isActive())
+            {
+                if (!mFocusObject->isAvatar())
+                {
+                    if (mFocusObject->isSelected())
+                    {
+                        gPipeline.updateMoveNormalAsync(drawablep);
+                    }
+                    else
+                    {
+                        if (drawablep->isState(LLDrawable::MOVE_UNDAMPED))
+                        {
+                            gPipeline.updateMoveNormalAsync(drawablep);
+                        }
+                        else
+                        {
+                            gPipeline.updateMoveDampedAsync(drawablep);
+                        }
+                    }
+                }
+            }
+            // if not tracking object, update offset based on new object position
+            else
+            {
+                updateFocusOffset();
+            }
+            LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset;
+            mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent));
+        }
+        return mFocusTargetGlobal;
+    }
+    else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull())
+    {
+        // sit camera
+        LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
+        LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
+
+        LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot);
+        return gAgent.getPosGlobalFromAgent(target_pos);
+    }
+    else
+    {
+        return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset();
+    }
 }
 
 LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()
 {
-	// ...offset from avatar
-	LLVector3d focus_offset;
-	LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
-	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-	{
-		agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
-	}
-
-	focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
-	return focus_offset * agent_rot;
+    // ...offset from avatar
+    LLVector3d focus_offset;
+    LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
+    if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+    {
+        agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
+    }
+
+    focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
+    return focus_offset * agent_rot;
 }
 
 void LLAgentCamera::setupSitCamera()
 {
-	// agent frame entering this function is in world coordinates
-	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-	{
-		LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-		// slam agent coordinate frame to proper parent local version
-		LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis();
-		at_axis.mV[VZ] = 0.f;
-		at_axis.normalize();
-		gAgent.resetAxes(at_axis * ~parent_rot);
-	}
+    // agent frame entering this function is in world coordinates
+    if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+    {
+        LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+        // slam agent coordinate frame to proper parent local version
+        LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis();
+        at_axis.mV[VZ] = 0.f;
+        at_axis.normalize();
+        gAgent.resetAxes(at_axis * ~parent_rot);
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -1624,7 +1624,7 @@ void LLAgentCamera::setupSitCamera()
 //-----------------------------------------------------------------------------
 const LLVector3 &LLAgentCamera::getCameraPositionAgent() const
 {
-	return LLViewerCamera::getInstance()->getOrigin();
+    return LLViewerCamera::getInstance()->getOrigin();
 }
 
 //-----------------------------------------------------------------------------
@@ -1632,39 +1632,39 @@ const LLVector3 &LLAgentCamera::getCameraPositionAgent() const
 //-----------------------------------------------------------------------------
 LLVector3d LLAgentCamera::getCameraPositionGlobal() const
 {
-	return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin());
+    return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin());
 }
 
 //-----------------------------------------------------------------------------
 // calcCameraFOVZoomFactor()
 //-----------------------------------------------------------------------------
-F32	LLAgentCamera::calcCameraFOVZoomFactor()
+F32 LLAgentCamera::calcCameraFOVZoomFactor()
 {
-	LLVector3 camera_offset_dir;
-	camera_offset_dir.setVec(mCameraFocusOffset);
-
-	if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-	{
-		return 0.f;
-	}
-	else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar)
-	{
-		// don't FOV zoom on mostly transparent objects
-		F32 obj_min_dist = 0.f;
-		calcCameraMinDistance(obj_min_dist);
-		F32 current_distance = llmax(0.001f, camera_offset_dir.magVec());
-
-		mFocusObjectDist = obj_min_dist - current_distance;
-
-		F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f);
-		return new_fov_zoom;
-	}
-	else // focusing on land or avatar
-	{
-		// keep old field of view until user changes focus explicitly
-		return mCameraFOVZoomFactor;
-		//return 0.f;
-	}
+    LLVector3 camera_offset_dir;
+    camera_offset_dir.setVec(mCameraFocusOffset);
+
+    if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+    {
+        return 0.f;
+    }
+    else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar)
+    {
+        // don't FOV zoom on mostly transparent objects
+        F32 obj_min_dist = 0.f;
+        calcCameraMinDistance(obj_min_dist);
+        F32 current_distance = llmax(0.001f, camera_offset_dir.magVec());
+
+        mFocusObjectDist = obj_min_dist - current_distance;
+
+        F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f);
+        return new_fov_zoom;
+    }
+    else // focusing on land or avatar
+    {
+        // keep old field of view until user changes focus explicitly
+        return mCameraFOVZoomFactor;
+        //return 0.f;
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -1672,268 +1672,268 @@ F32	LLAgentCamera::calcCameraFOVZoomFactor()
 //-----------------------------------------------------------------------------
 LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 {
-	// Compute base camera position and look-at points.
-	F32			camera_land_height;
-	LLVector3d	frame_center_global = !isAgentAvatarValid() ? 
-		gAgent.getPositionGlobal() :
-		gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition());
-	
-	BOOL		isConstrained = FALSE;
-	LLVector3d	head_offset;
-	head_offset.setVec(mThirdPersonHeadOffset);
-
-	LLVector3d camera_position_global;
-
-	if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
-	{
-		camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition());
-	}
-	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-	{
-		if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
-		{
-			LL_WARNS() << "Null avatar drawable!" << LL_ENDL;
-			return LLVector3d::zero;
-		}
-		head_offset.clearVec();
-		if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent())
-		{
-			gAgentAvatarp->updateHeadOffset();
-			head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
-			head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
-			head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
-			const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
-			camera_position_global = gAgent.getPosGlobalFromAgent
-								((gAgentAvatarp->getPosition()+
-								 LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
-		}
-		else
-		{
-			head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ];
-			if (gAgentAvatarp->isSitting())
-			{
-				head_offset.mdV[VZ] += 0.1;
-			}
-			camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global;
-			head_offset = head_offset * gAgentAvatarp->getRenderRotation();
-			camera_position_global = camera_position_global + head_offset;
-		}
-	}
-	else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar)
-	{
-		LLVector3 local_camera_offset;
-		F32 camera_distance = 0.f;
-
-		if (mSitCameraEnabled 
-			&& isAgentAvatarValid() 
-			&& gAgentAvatarp->isSitting() 
-			&& mSitCameraReferenceObject.notNull())
-		{
-			// sit camera
-			LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
-			LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
-
-			LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot);
-
-			camera_position_global = gAgent.getPosGlobalFromAgent(target_pos);
-		}
-		else
-		{
-			local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
-			
-			// are we sitting down?
-			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-			{
-				LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-				// slam agent coordinate frame to proper parent local version
-				LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot;
-				at_axis.mV[VZ] = 0.f;
-				at_axis.normalize();
-				gAgent.resetAxes(at_axis * ~parent_rot);
-
-				local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
-			}
-			else
-			{
-				local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
-			}
-
-			if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
-			{
-				LLVector3 plane_normal;
-				plane_normal.setVec(mCameraCollidePlane.mV);
-
-				F32 offset_dot_norm = local_camera_offset * plane_normal;
-				if (llabs(offset_dot_norm) < 0.001f)
-				{
-					offset_dot_norm = 0.001f;
-				}
-				
-				camera_distance = local_camera_offset.normalize();
-
-				F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal;
-				
-				// if agent is outside the colliding half-plane
-				if (pos_dot_norm > mCameraCollidePlane.mV[VW])
-				{
-					// check to see if camera is on the opposite side (inside) the half-plane
-					if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW])
-					{
-						// diminish offset by factor to push it back outside the half-plane
-						camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm;
-					}
-				}
-				else
-				{
-					if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW])
-					{
-						camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm;
-					}
-				}
-			}
-			else
-			{
-				camera_distance = local_camera_offset.normalize();
-			}
-
-			mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE);
-
-			if (mTargetCameraDistance != mCurrentCameraDistance)
-			{
-				F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE);
-
-				mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt);
-			}
-
-			// Make the camera distance current
-			local_camera_offset *= mCurrentCameraDistance;
-
-			// set the global camera position
-			LLVector3d camera_offset;
-			
-			camera_offset.setVec( local_camera_offset );
-			camera_position_global = frame_center_global + head_offset + camera_offset;
-
-			if (isAgentAvatarValid())
-			{
-				LLVector3d camera_lag_d;
-				F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE);
-				LLVector3 target_lag;
-				LLVector3 vel = gAgent.getVelocity();
-
-				// lag by appropriate amount for flying
-				F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32();
-				if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
-				{
-					LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
-					frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector());
-					frame_at_axis.normalize();
-
-					//transition smoothly in air mode, to avoid camera pop
-					F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME;
-					u = llclamp(u, 0.f, 1.f);
-
-					lag_interp *= u;
-
-					if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID())
-					{
-						// disable camera lag when using mouse-directed steering
-						target_lag.clearVec();
-					}
-					else
-					{
-						target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f;
-					}
-
-					mCameraLag = lerp(mCameraLag, target_lag, lag_interp);
-
-					F32 lag_dist = mCameraLag.magVec();
-					if (lag_dist > MAX_CAMERA_LAG)
-					{
-						mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist;
-					}
-
-					// clamp camera lag so that avatar is always in front
-					F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis;
-					if (dot < -(MIN_CAMERA_LAG * u))
-					{
-						mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis;
-					}
-				}
-				else
-				{
-					mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f));
-				}
-
-				camera_lag_d.setVec(mCameraLag);
-				camera_position_global = camera_position_global - camera_lag_d;
-			}
-		}
-	}
-	else
-	{
-		LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal();
-		// camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value
-		camera_position_global = focusPosGlobal + mCameraFocusOffset;
-	}
-
-	if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike())
-	{
-		LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
-		bool constrain = true;
-		if(regionp && regionp->canManageEstate())
-		{
-			constrain = false;
-		}
-		if(constrain)
-		{
-			F32 max_dist = (CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode) ? APPEARANCE_MAX_ZOOM : mDrawDistance;
-
-			LLVector3d camera_offset = camera_position_global - gAgent.getPositionGlobal();
-			F32 camera_distance = (F32)camera_offset.magVec();
-
-			if(camera_distance > max_dist)
-			{
-				camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset;
-				isConstrained = TRUE;
-			}
-		}
+    // Compute base camera position and look-at points.
+    F32         camera_land_height;
+    LLVector3d  frame_center_global = !isAgentAvatarValid() ? 
+        gAgent.getPositionGlobal() :
+        gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition());
+    
+    BOOL        isConstrained = FALSE;
+    LLVector3d  head_offset;
+    head_offset.setVec(mThirdPersonHeadOffset);
+
+    LLVector3d camera_position_global;
+
+    if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
+    {
+        camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition());
+    }
+    else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+    {
+        if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
+        {
+            LL_WARNS() << "Null avatar drawable!" << LL_ENDL;
+            return LLVector3d::zero;
+        }
+        head_offset.clearVec();
+        if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent())
+        {
+            gAgentAvatarp->updateHeadOffset();
+            head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
+            head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
+            head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
+            const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
+            camera_position_global = gAgent.getPosGlobalFromAgent
+                                ((gAgentAvatarp->getPosition()+
+                                 LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
+        }
+        else
+        {
+            head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ];
+            if (gAgentAvatarp->isSitting())
+            {
+                head_offset.mdV[VZ] += 0.1;
+            }
+            camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global;
+            head_offset = head_offset * gAgentAvatarp->getRenderRotation();
+            camera_position_global = camera_position_global + head_offset;
+        }
+    }
+    else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar)
+    {
+        LLVector3 local_camera_offset;
+        F32 camera_distance = 0.f;
+
+        if (mSitCameraEnabled 
+            && isAgentAvatarValid() 
+            && gAgentAvatarp->isSitting() 
+            && mSitCameraReferenceObject.notNull())
+        {
+            // sit camera
+            LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
+            LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
+
+            LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot);
+
+            camera_position_global = gAgent.getPosGlobalFromAgent(target_pos);
+        }
+        else
+        {
+            local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
+            
+            // are we sitting down?
+            if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+            {
+                LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+                // slam agent coordinate frame to proper parent local version
+                LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot;
+                at_axis.mV[VZ] = 0.f;
+                at_axis.normalize();
+                gAgent.resetAxes(at_axis * ~parent_rot);
+
+                local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
+            }
+            else
+            {
+                local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
+            }
+
+            if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
+            {
+                LLVector3 plane_normal;
+                plane_normal.setVec(mCameraCollidePlane.mV);
+
+                F32 offset_dot_norm = local_camera_offset * plane_normal;
+                if (llabs(offset_dot_norm) < 0.001f)
+                {
+                    offset_dot_norm = 0.001f;
+                }
+                
+                camera_distance = local_camera_offset.normalize();
+
+                F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal;
+                
+                // if agent is outside the colliding half-plane
+                if (pos_dot_norm > mCameraCollidePlane.mV[VW])
+                {
+                    // check to see if camera is on the opposite side (inside) the half-plane
+                    if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW])
+                    {
+                        // diminish offset by factor to push it back outside the half-plane
+                        camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm;
+                    }
+                }
+                else
+                {
+                    if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW])
+                    {
+                        camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm;
+                    }
+                }
+            }
+            else
+            {
+                camera_distance = local_camera_offset.normalize();
+            }
+
+            mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE);
+
+            if (mTargetCameraDistance != mCurrentCameraDistance)
+            {
+                F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE);
+
+                mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt);
+            }
+
+            // Make the camera distance current
+            local_camera_offset *= mCurrentCameraDistance;
+
+            // set the global camera position
+            LLVector3d camera_offset;
+            
+            camera_offset.setVec( local_camera_offset );
+            camera_position_global = frame_center_global + head_offset + camera_offset;
+
+            if (isAgentAvatarValid())
+            {
+                LLVector3d camera_lag_d;
+                F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE);
+                LLVector3 target_lag;
+                LLVector3 vel = gAgent.getVelocity();
+
+                // lag by appropriate amount for flying
+                F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32();
+                if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
+                {
+                    LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
+                    frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector());
+                    frame_at_axis.normalize();
+
+                    //transition smoothly in air mode, to avoid camera pop
+                    F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME;
+                    u = llclamp(u, 0.f, 1.f);
+
+                    lag_interp *= u;
+
+                    if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID())
+                    {
+                        // disable camera lag when using mouse-directed steering
+                        target_lag.clearVec();
+                    }
+                    else
+                    {
+                        target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f;
+                    }
+
+                    mCameraLag = lerp(mCameraLag, target_lag, lag_interp);
+
+                    F32 lag_dist = mCameraLag.magVec();
+                    if (lag_dist > MAX_CAMERA_LAG)
+                    {
+                        mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist;
+                    }
+
+                    // clamp camera lag so that avatar is always in front
+                    F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis;
+                    if (dot < -(MIN_CAMERA_LAG * u))
+                    {
+                        mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis;
+                    }
+                }
+                else
+                {
+                    mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f));
+                }
+
+                camera_lag_d.setVec(mCameraLag);
+                camera_position_global = camera_position_global - camera_lag_d;
+            }
+        }
+    }
+    else
+    {
+        LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal();
+        // camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value
+        camera_position_global = focusPosGlobal + mCameraFocusOffset;
+    }
+
+    if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike())
+    {
+        LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
+        bool constrain = true;
+        if(regionp && regionp->canManageEstate())
+        {
+            constrain = false;
+        }
+        if(constrain)
+        {
+            F32 max_dist = (CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode) ? APPEARANCE_MAX_ZOOM : mDrawDistance;
+
+            LLVector3d camera_offset = camera_position_global - gAgent.getPositionGlobal();
+            F32 camera_distance = (F32)camera_offset.magVec();
+
+            if(camera_distance > max_dist)
+            {
+                camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset;
+                isConstrained = TRUE;
+            }
+        }
 
 // JC - Could constrain camera based on parcel stuff here.
-//			LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
-//			
-//			if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global)))
-//			{
-//				camera_position_global = last_position_global;
+//          LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
+//          
+//          if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global)))
+//          {
+//              camera_position_global = last_position_global;
 //
-//				isConstrained = TRUE;
-//			}
-	}
+//              isConstrained = TRUE;
+//          }
+    }
 
-	// Don't let camera go underground
-	F32 camera_min_off_ground = getCameraMinOffGround();
+    // Don't let camera go underground
+    F32 camera_min_off_ground = getCameraMinOffGround();
 
-	camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global);
+    camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global);
 
-	if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground)
-	{
-		camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground;
-		isConstrained = TRUE;
-	}
+    if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground)
+    {
+        camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground;
+        isConstrained = TRUE;
+    }
 
 
-	if (hit_limit)
-	{
-		*hit_limit = isConstrained;
-	}
+    if (hit_limit)
+    {
+        *hit_limit = isConstrained;
+    }
 
-	return camera_position_global;
+    return camera_position_global;
 }
 
 
 LLVector3 LLAgentCamera::getCameraOffsetInitial()
 {
-	return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, "");
+    return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, "");
 }
 
 F32 LLAgentCamera::getCameraMaxZoomDistance()
@@ -1949,48 +1949,48 @@ F32 LLAgentCamera::getCameraMaxZoomDistance()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::handleScrollWheel(S32 clicks)
 {
-	if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar())
-	{
-		if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place
-		{
-			mFollowCam.zoom(clicks); 
-			if (mFollowCam.isZoomedToMinimumDistance())
-			{
-				changeCameraToMouselook(FALSE);
-			}
-		}
-	}
-	else
-	{
-		LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-		const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2);
-
-		// Block if camera is animating
-		if (mCameraAnimating)
-		{
-			return;
-		}
-
-		if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-		{
-			F32 zoom_factor = (F32)pow(0.8, -clicks);
-			cameraZoomIn(zoom_factor);
-		}
-		else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON))
-		{
-			F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec();
-			
-			F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
-			current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks);
-			
-			cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
-		}
-		else
-		{
-			F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec();
-			cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks)));
-		}
-	}
+    if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar())
+    {
+        if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place
+        {
+            mFollowCam.zoom(clicks); 
+            if (mFollowCam.isZoomedToMinimumDistance())
+            {
+                changeCameraToMouselook(FALSE);
+            }
+        }
+    }
+    else
+    {
+        LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+        const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2);
+
+        // Block if camera is animating
+        if (mCameraAnimating)
+        {
+            return;
+        }
+
+        if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+        {
+            F32 zoom_factor = (F32)pow(0.8, -clicks);
+            cameraZoomIn(zoom_factor);
+        }
+        else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON))
+        {
+            F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec();
+            
+            F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
+            current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks);
+            
+            cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
+        }
+        else
+        {
+            F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec();
+            cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks)));
+        }
+    }
 }
 
 
@@ -1999,21 +1999,21 @@ void LLAgentCamera::handleScrollWheel(S32 clicks)
 //-----------------------------------------------------------------------------
 F32 LLAgentCamera::getCameraMinOffGround()
 {
-	if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-	{
-		return 0.f;
-	}
-	else
-	{
-		if (gSavedSettings.getBOOL("DisableCameraConstraints"))
-		{
-			return -1000.f;
-		}
-		else
-		{
-			return 0.5f;
-		}
-	}
+    if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+    {
+        return 0.f;
+    }
+    else
+    {
+        if (gSavedSettings.getBOOL("DisableCameraConstraints"))
+        {
+            return -1000.f;
+        }
+        else
+        {
+            return 0.5f;
+        }
+    }
 }
 
 
@@ -2022,15 +2022,15 @@ F32 LLAgentCamera::getCameraMinOffGround()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::resetCamera()
 {
-	// Remove any pitch from the avatar
-	LLVector3 at = gAgent.getFrameAgent().getAtAxis();
-	at.mV[VZ] = 0.f;
-	at.normalize();
-	gAgent.resetAxes(at);
-	// have to explicitly clear field of view zoom now
-	mCameraFOVZoomFactor = 0.f;
-
-	updateCamera();
+    // Remove any pitch from the avatar
+    LLVector3 at = gAgent.getFrameAgent().getAtAxis();
+    at.mV[VZ] = 0.f;
+    at.normalize();
+    gAgent.resetAxes(at);
+    // have to explicitly clear field of view zoom now
+    mCameraFOVZoomFactor = 0.f;
+
+    updateCamera();
 }
 
 //-----------------------------------------------------------------------------
@@ -2038,58 +2038,58 @@ void LLAgentCamera::resetCamera()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 {
-	if (!gSavedSettings.getBOOL("EnableMouselook") 
-		|| LLViewerJoystick::getInstance()->getOverrideCamera())
-	{
-		return;
-	}
-	
-	// visibility changes at end of animation
-	gViewerWindow->getWindow()->resetBusyCount();
-
-	// Menus should not remain open on switching to mouselook...
-	LLMenuGL::sMenuContainer->hideMenus();
-	LLUI::clearPopups();
-
-	// unpause avatar animation
-	gAgent.unpauseAnimation();
-
-	LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
-
-	if (isAgentAvatarValid())
-	{
-		gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE);
-		gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT);
-	}
-
-	//gViewerWindow->stopGrab();
-	LLSelectMgr::getInstance()->deselectAll();
-	gViewerWindow->hideCursor();
-	gViewerWindow->moveCursorToCenter();
-
-	if (mCameraMode != CAMERA_MODE_MOUSELOOK)
-	{
-		gFocusMgr.setKeyboardFocus(NULL);
-		
-		updateLastCamera();
-		mCameraMode = CAMERA_MODE_MOUSELOOK;
-		const U32 old_flags = gAgent.getControlFlags();
-		gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK);
-		if (old_flags != gAgent.getControlFlags())
-		{
-			gAgent.setFlagsDirty();
-		}
-
-		if (animate)
-		{
-			startCameraAnimation();
-		}
-		else
-		{
-			mCameraAnimating = FALSE;
-			gAgent.endAnimationUpdateUI();
-		}
-	}
+    if (!gSavedSettings.getBOOL("EnableMouselook") 
+        || LLViewerJoystick::getInstance()->getOverrideCamera())
+    {
+        return;
+    }
+    
+    // visibility changes at end of animation
+    gViewerWindow->getWindow()->resetBusyCount();
+
+    // Menus should not remain open on switching to mouselook...
+    LLMenuGL::sMenuContainer->hideMenus();
+    LLUI::clearPopups();
+
+    // unpause avatar animation
+    gAgent.unpauseAnimation();
+
+    LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
+
+    if (isAgentAvatarValid())
+    {
+        gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE);
+        gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT);
+    }
+
+    //gViewerWindow->stopGrab();
+    LLSelectMgr::getInstance()->deselectAll();
+    gViewerWindow->hideCursor();
+    gViewerWindow->moveCursorToCenter();
+
+    if (mCameraMode != CAMERA_MODE_MOUSELOOK)
+    {
+        gFocusMgr.setKeyboardFocus(NULL);
+        
+        updateLastCamera();
+        mCameraMode = CAMERA_MODE_MOUSELOOK;
+        const U32 old_flags = gAgent.getControlFlags();
+        gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK);
+        if (old_flags != gAgent.getControlFlags())
+        {
+            gAgent.setFlagsDirty();
+        }
+
+        if (animate)
+        {
+            startCameraAnimation();
+        }
+        else
+        {
+            mCameraAnimating = FALSE;
+            gAgent.endAnimationUpdateUI();
+        }
+    }
 }
 
 
@@ -2098,24 +2098,24 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToDefault()
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
-	{
-		return;
-	}
-
-	if (LLFollowCamMgr::getActiveFollowCamParams())
-	{
-		changeCameraToFollow();
-	}
-	else
-	{
-		changeCameraToThirdPerson();
-	}
-	if (gSavedSettings.getBOOL("HideUIControls"))
-	{
-		gViewerWindow->setUIVisibility(false);
-		LLPanelStandStopFlying::getInstance()->setVisible(false);
-	}
+    if (LLViewerJoystick::getInstance()->getOverrideCamera())
+    {
+        return;
+    }
+
+    if (LLFollowCamMgr::getActiveFollowCamParams())
+    {
+        changeCameraToFollow();
+    }
+    else
+    {
+        changeCameraToThirdPerson();
+    }
+    if (gSavedSettings.getBOOL("HideUIControls"))
+    {
+        gViewerWindow->setUIVisibility(false);
+        LLPanelStandStopFlying::getInstance()->setVisible(false);
+    }
 }
 
 
@@ -2124,53 +2124,53 @@ void LLAgentCamera::changeCameraToDefault()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToFollow(BOOL animate)
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
-	{
-		return;
-	}
-
-	if(mCameraMode != CAMERA_MODE_FOLLOW)
-	{
-		if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-		{
-			animate = FALSE;
-		}
-		startCameraAnimation();
-
-		updateLastCamera();
-		mCameraMode = CAMERA_MODE_FOLLOW;
-
-		// bang-in the current focus, position, and up vector of the follow cam
-		mFollowCam.reset(mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis);
-		
-		if (gBasicToolset)
-		{
-			LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
-		}
-
-		if (isAgentAvatarValid())
-		{
-			// SL-315
-			gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
-			gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE );
-			gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT );
-		}
-
-		// unpause avatar animation
-		gAgent.unpauseAnimation();
-
-		gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
-
-		if (animate)
-		{
-			startCameraAnimation();
-		}
-		else
-		{
-			mCameraAnimating = FALSE;
-			gAgent.endAnimationUpdateUI();
-		}
-	}
+    if (LLViewerJoystick::getInstance()->getOverrideCamera())
+    {
+        return;
+    }
+
+    if(mCameraMode != CAMERA_MODE_FOLLOW)
+    {
+        if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+        {
+            animate = FALSE;
+        }
+        startCameraAnimation();
+
+        updateLastCamera();
+        mCameraMode = CAMERA_MODE_FOLLOW;
+
+        // bang-in the current focus, position, and up vector of the follow cam
+        mFollowCam.reset(mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis);
+        
+        if (gBasicToolset)
+        {
+            LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
+        }
+
+        if (isAgentAvatarValid())
+        {
+            // SL-315
+            gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
+            gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE );
+            gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT );
+        }
+
+        // unpause avatar animation
+        gAgent.unpauseAnimation();
+
+        gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+
+        if (animate)
+        {
+            startCameraAnimation();
+        }
+        else
+        {
+            mCameraAnimating = FALSE;
+            gAgent.endAnimationUpdateUI();
+        }
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -2178,77 +2178,77 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera())
-	{
-		return;
-	}
-
-	gViewerWindow->getWindow()->resetBusyCount();
-
-	mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
-
-	if (isAgentAvatarValid())
-	{
-		if (!gAgentAvatarp->isSitting())
-		{
-			// SL-315
-			gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
-		}
-		gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE);
-		gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
-	}
-
-	LLVector3 at_axis;
-
-	// unpause avatar animation
-	gAgent.unpauseAnimation();
-
-	if (mCameraMode != CAMERA_MODE_THIRD_PERSON)
-	{
-		if (gBasicToolset)
-		{
-			LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
-		}
-
-		mCameraLag.clearVec();
-		if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-		{
-			mCurrentCameraDistance = MIN_CAMERA_DISTANCE;
-			mTargetCameraDistance = MIN_CAMERA_DISTANCE;
-			animate = FALSE;
-		}
-		updateLastCamera();
-		mCameraMode = CAMERA_MODE_THIRD_PERSON;
-		gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
-	}
-
-	// Remove any pitch from the avatar
-	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-	{
-		LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-		at_axis = LLViewerCamera::getInstance()->getAtAxis();
-		at_axis.mV[VZ] = 0.f;
-		at_axis.normalize();
-		gAgent.resetAxes(at_axis * ~obj_rot);
-	}
-	else
-	{
-		at_axis = gAgent.getFrameAgent().getAtAxis();
-		at_axis.mV[VZ] = 0.f;
-		at_axis.normalize();
-		gAgent.resetAxes(at_axis);
-	}
-
-
-	if (animate)
-	{
-		startCameraAnimation();
-	}
-	else
-	{
-		mCameraAnimating = FALSE;
-		gAgent.endAnimationUpdateUI();
-	}
+    if (LLViewerJoystick::getInstance()->getOverrideCamera())
+    {
+        return;
+    }
+
+    gViewerWindow->getWindow()->resetBusyCount();
+
+    mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
+
+    if (isAgentAvatarValid())
+    {
+        if (!gAgentAvatarp->isSitting())
+        {
+            // SL-315
+            gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
+        }
+        gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE);
+        gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
+    }
+
+    LLVector3 at_axis;
+
+    // unpause avatar animation
+    gAgent.unpauseAnimation();
+
+    if (mCameraMode != CAMERA_MODE_THIRD_PERSON)
+    {
+        if (gBasicToolset)
+        {
+            LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
+        }
+
+        mCameraLag.clearVec();
+        if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+        {
+            mCurrentCameraDistance = MIN_CAMERA_DISTANCE;
+            mTargetCameraDistance = MIN_CAMERA_DISTANCE;
+            animate = FALSE;
+        }
+        updateLastCamera();
+        mCameraMode = CAMERA_MODE_THIRD_PERSON;
+        gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+    }
+
+    // Remove any pitch from the avatar
+    if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+    {
+        LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+        at_axis = LLViewerCamera::getInstance()->getAtAxis();
+        at_axis.mV[VZ] = 0.f;
+        at_axis.normalize();
+        gAgent.resetAxes(at_axis * ~obj_rot);
+    }
+    else
+    {
+        at_axis = gAgent.getFrameAgent().getAtAxis();
+        at_axis.mV[VZ] = 0.f;
+        at_axis.normalize();
+        gAgent.resetAxes(at_axis);
+    }
+
+
+    if (animate)
+    {
+        startCameraAnimation();
+    }
+    else
+    {
+        mCameraAnimating = FALSE;
+        gAgent.endAnimationUpdateUI();
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -2256,81 +2256,81 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToCustomizeAvatar()
 {
-	if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid())
-	{
-		return;
-	}
-
-	gAgent.standUp(); // force stand up
-	gViewerWindow->getWindow()->resetBusyCount();
-
-	if (gFaceEditToolset)
-	{
-		LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
-	}
-
-	startCameraAnimation();
-
-	if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR)
-	{
-		updateLastCamera();
-		mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR;
-		gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
-
-		gFocusMgr.setKeyboardFocus( NULL );
-		gFocusMgr.setMouseCapture( NULL );
-		if( gMorphView )
-		{
-			gMorphView->setVisible( TRUE );
-		}
-		// Remove any pitch or rotation from the avatar
-		LLVector3 at = gAgent.getAtAxis();
-		at.mV[VZ] = 0.f;
-		at.normalize();
-		gAgent.resetAxes(at);
-
-		gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START);
-		gAgent.setCustomAnim(TRUE);
-		gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE);
-		LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE);
-
-		if (turn_motion)
-		{
-			// delay camera animation long enough to play through turn animation
-			setAnimationDuration(turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP);
-		}
-	}
-
-	LLVector3 agent_at = gAgent.getAtAxis();
-	agent_at.mV[VZ] = 0.f;
-	agent_at.normalize();
-
-	// default focus point for customize avatar
-	LLVector3 focus_target = isAgentAvatarValid() 
-		? gAgentAvatarp->mHeadp->getWorldPosition()
-		: gAgent.getPositionAgent();
-
-	LLVector3d camera_offset(agent_at * -1.0);
-	// push camera up and out from avatar
-	camera_offset.mdV[VZ] = 0.1f; 
-	camera_offset *= CUSTOMIZE_AVATAR_CAMERA_DEFAULT_DIST;
-	LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
-	setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
-	setCameraPosAndFocusGlobal(focus_target_global + camera_offset, focus_target_global, gAgent.getID());
+    if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid())
+    {
+        return;
+    }
+
+    gAgent.standUp(); // force stand up
+    gViewerWindow->getWindow()->resetBusyCount();
+
+    if (gFaceEditToolset)
+    {
+        LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
+    }
+
+    startCameraAnimation();
+
+    if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR)
+    {
+        updateLastCamera();
+        mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR;
+        gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+
+        gFocusMgr.setKeyboardFocus( NULL );
+        gFocusMgr.setMouseCapture( NULL );
+        if( gMorphView )
+        {
+            gMorphView->setVisible( TRUE );
+        }
+        // Remove any pitch or rotation from the avatar
+        LLVector3 at = gAgent.getAtAxis();
+        at.mV[VZ] = 0.f;
+        at.normalize();
+        gAgent.resetAxes(at);
+
+        gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START);
+        gAgent.setCustomAnim(TRUE);
+        gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE);
+        LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE);
+
+        if (turn_motion)
+        {
+            // delay camera animation long enough to play through turn animation
+            setAnimationDuration(turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP);
+        }
+    }
+
+    LLVector3 agent_at = gAgent.getAtAxis();
+    agent_at.mV[VZ] = 0.f;
+    agent_at.normalize();
+
+    // default focus point for customize avatar
+    LLVector3 focus_target = isAgentAvatarValid() 
+        ? gAgentAvatarp->mHeadp->getWorldPosition()
+        : gAgent.getPositionAgent();
+
+    LLVector3d camera_offset(agent_at * -1.0);
+    // push camera up and out from avatar
+    camera_offset.mdV[VZ] = 0.1f; 
+    camera_offset *= CUSTOMIZE_AVATAR_CAMERA_DEFAULT_DIST;
+    LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
+    setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
+    setCameraPosAndFocusGlobal(focus_target_global + camera_offset, focus_target_global, gAgent.getID());
 }
 
 
 void LLAgentCamera::switchCameraPreset(ECameraPreset preset)
 {
-	//zoom is supposed to be reset for the front and group views
-	mCameraZoomFraction = 1.f;
+    //zoom is supposed to be reset for the front and group views
+    mCameraZoomFraction = 1.f;
 
-	//focusing on avatar in that case means following him on movements
-	mFocusOnAvatar = TRUE;
+    //focusing on avatar in that case means following him on movements
+    mFocusOnAvatar = TRUE;
 
-	mCameraPreset = preset;
+    mCameraPreset = preset;
 
-	gSavedSettings.setU32("CameraPreset", mCameraPreset);
+    gSavedSettings.setU32("CameraPreset", mCameraPreset);
 }
 
 
@@ -2340,16 +2340,16 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset)
 
 void LLAgentCamera::setAnimationDuration(F32 duration)
 { 
-	if (mCameraAnimating)
-	{
-		// do not cut any existing camera animation short
-		F32 animation_left = llmax(0.f, mAnimationDuration - mAnimationTimer.getElapsedTimeF32());
-		mAnimationDuration = llmax(duration, animation_left);
-	}
-	else
-	{
-		mAnimationDuration = duration; 
-	}
+    if (mCameraAnimating)
+    {
+        // do not cut any existing camera animation short
+        F32 animation_left = llmax(0.f, mAnimationDuration - mAnimationTimer.getElapsedTimeF32());
+        mAnimationDuration = llmax(duration, animation_left);
+    }
+    else
+    {
+        mAnimationDuration = duration; 
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -2357,11 +2357,11 @@ void LLAgentCamera::setAnimationDuration(F32 duration)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::startCameraAnimation()
 {
-	mAnimationCameraStartGlobal = getCameraPositionGlobal();
-	mAnimationFocusStartGlobal = mFocusGlobal;
-	setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
-	mAnimationTimer.reset();
-	mCameraAnimating = TRUE;
+    mAnimationCameraStartGlobal = getCameraPositionGlobal();
+    mAnimationFocusStartGlobal = mFocusGlobal;
+    setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
+    mAnimationTimer.reset();
+    mCameraAnimating = TRUE;
 }
 
 //-----------------------------------------------------------------------------
@@ -2369,23 +2369,23 @@ void LLAgentCamera::startCameraAnimation()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::stopCameraAnimation()
 {
-	mCameraAnimating = FALSE;
+    mCameraAnimating = FALSE;
 }
 
 void LLAgentCamera::clearFocusObject()
 {
-	if (mFocusObject.notNull())
-	{
-		startCameraAnimation();
+    if (mFocusObject.notNull())
+    {
+        startCameraAnimation();
 
-		setFocusObject(NULL);
-		mFocusObjectOffset.clearVec();
-	}
+        setFocusObject(NULL);
+        mFocusObjectOffset.clearVec();
+    }
 }
 
 void LLAgentCamera::setFocusObject(LLViewerObject* object)
 {
-	mFocusObject = object;
+    mFocusObject = object;
 }
 
 // Focus on a point, but try to keep camera position stable.
@@ -2394,104 +2394,104 @@ void LLAgentCamera::setFocusObject(LLViewerObject* object)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setFocusGlobal(const LLPickInfo& pick)
 {
-	LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
-
-	if (objectp)
-	{
-		// focus on object plus designated offset
-		// which may or may not be same as pick.mPosGlobal
-		setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID);
-	}
-	else
-	{
-		// focus directly on point where user clicked
-		setFocusGlobal(pick.mPosGlobal, pick.mObjectID);
-	}
+    LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
+
+    if (objectp)
+    {
+        // focus on object plus designated offset
+        // which may or may not be same as pick.mPosGlobal
+        setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID);
+    }
+    else
+    {
+        // focus directly on point where user clicked
+        setFocusGlobal(pick.mPosGlobal, pick.mObjectID);
+    }
 }
 
 
 void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
 {
-	setFocusObject(gObjectList.findObject(object_id));
-	LLVector3d old_focus = mFocusTargetGlobal;
-	LLViewerObject *focus_obj = mFocusObject;
-
-	// if focus has changed
-	if (old_focus != focus)
-	{
-		if (focus.isExactlyZero())
-		{
-			if (isAgentAvatarValid())
-			{
-				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
-			}
-			else
-			{
-				mFocusTargetGlobal = gAgent.getPositionGlobal();
-			}
-			mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal;
-			mCameraFocusOffset = mCameraFocusOffsetTarget;
-			setLookAt(LOOKAT_TARGET_CLEAR);
-		}
-		else
-		{
-			mFocusTargetGlobal = focus;
-			if (!focus_obj)
-			{
-				mCameraFOVZoomFactor = 0.f;
-			}
-
-			mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal;
-
-			startCameraAnimation();
-
-			if (focus_obj)
-			{
-				if (focus_obj->isAvatar())
-				{
-					setLookAt(LOOKAT_TARGET_FOCUS, focus_obj);
-				}
-				else
-				{
-					setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation());
-				}
-			}
-			else
-			{
-				setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
-			}
-		}
-	}
-	else // focus == mFocusTargetGlobal
-	{
-		if (focus.isExactlyZero())
-		{
-			if (isAgentAvatarValid())
-			{
-				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
-			}
-			else
-			{
-				mFocusTargetGlobal = gAgent.getPositionGlobal();
-			}
-		}
-		mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);;
-		mCameraFocusOffset = mCameraFocusOffsetTarget;
-	}
-
-	if (mFocusObject.notNull())
-	{
-		// for attachments, make offset relative to avatar, not the attachment
-		if (mFocusObject->isAttachment())
-		{
-			while (mFocusObject.notNull() && !mFocusObject->isAvatar())
-			{
-				mFocusObject = (LLViewerObject*) mFocusObject->getParent();
-			}
-			setFocusObject((LLViewerObject*)mFocusObject);
-		}
-		updateFocusOffset();
-	}
+    setFocusObject(gObjectList.findObject(object_id));
+    LLVector3d old_focus = mFocusTargetGlobal;
+    LLViewerObject *focus_obj = mFocusObject;
+
+    // if focus has changed
+    if (old_focus != focus)
+    {
+        if (focus.isExactlyZero())
+        {
+            if (isAgentAvatarValid())
+            {
+                mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
+            }
+            else
+            {
+                mFocusTargetGlobal = gAgent.getPositionGlobal();
+            }
+            mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal;
+            mCameraFocusOffset = mCameraFocusOffsetTarget;
+            setLookAt(LOOKAT_TARGET_CLEAR);
+        }
+        else
+        {
+            mFocusTargetGlobal = focus;
+            if (!focus_obj)
+            {
+                mCameraFOVZoomFactor = 0.f;
+            }
+
+            mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal;
+
+            startCameraAnimation();
+
+            if (focus_obj)
+            {
+                if (focus_obj->isAvatar())
+                {
+                    setLookAt(LOOKAT_TARGET_FOCUS, focus_obj);
+                }
+                else
+                {
+                    setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation());
+                }
+            }
+            else
+            {
+                setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+            }
+        }
+    }
+    else // focus == mFocusTargetGlobal
+    {
+        if (focus.isExactlyZero())
+        {
+            if (isAgentAvatarValid())
+            {
+                mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
+            }
+            else
+            {
+                mFocusTargetGlobal = gAgent.getPositionGlobal();
+            }
+        }
+        mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);;
+        mCameraFocusOffset = mCameraFocusOffsetTarget;
+    }
+
+    if (mFocusObject.notNull())
+    {
+        // for attachments, make offset relative to avatar, not the attachment
+        if (mFocusObject->isAttachment())
+        {
+            while (mFocusObject.notNull() && !mFocusObject->isAvatar())
+            {
+                mFocusObject = (LLViewerObject*) mFocusObject->getParent();
+            }
+            setFocusObject((LLViewerObject*)mFocusObject);
+        }
+        updateFocusOffset();
+    }
 }
 
 // Used for avatar customization
@@ -2500,48 +2500,48 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLVector3d& focus, const LLUUID &object_id)
 {
-	LLVector3d old_focus = mFocusTargetGlobal.isExactlyZero() ? focus : mFocusTargetGlobal;
-
-	F64 focus_delta_squared = (old_focus - focus).magVecSquared();
-	const F64 ANIM_EPSILON_SQUARED = 0.0001;
-	if (focus_delta_squared > ANIM_EPSILON_SQUARED)
-	{
-		startCameraAnimation();
-	}
-	
-	//LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) );
-	setFocusObject(gObjectList.findObject(object_id));
-	mFocusTargetGlobal = focus;
-	mCameraFocusOffsetTarget = camera_pos - focus;
-	mCameraFocusOffset = mCameraFocusOffsetTarget;
-
-	if (mFocusObject)
-	{
-		if (mFocusObject->isAvatar())
-		{
-			setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject);
-		}
-		else
-		{
-			setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation());
-		}
-	}
-	else
-	{
-		setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
-	}
-
-	if (mCameraAnimating)
-	{
-		const F64 ANIM_METERS_PER_SECOND = 10.0;
-		const F64 MIN_ANIM_SECONDS = 0.5;
-		const F64 MAX_ANIM_SECONDS = 10.0;
-		F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND );
-		anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS );
-		setAnimationDuration( (F32)anim_duration );
-	}
-
-	updateFocusOffset();
+    LLVector3d old_focus = mFocusTargetGlobal.isExactlyZero() ? focus : mFocusTargetGlobal;
+
+    F64 focus_delta_squared = (old_focus - focus).magVecSquared();
+    const F64 ANIM_EPSILON_SQUARED = 0.0001;
+    if (focus_delta_squared > ANIM_EPSILON_SQUARED)
+    {
+        startCameraAnimation();
+    }
+    
+    //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) );
+    setFocusObject(gObjectList.findObject(object_id));
+    mFocusTargetGlobal = focus;
+    mCameraFocusOffsetTarget = camera_pos - focus;
+    mCameraFocusOffset = mCameraFocusOffsetTarget;
+
+    if (mFocusObject)
+    {
+        if (mFocusObject->isAvatar())
+        {
+            setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject);
+        }
+        else
+        {
+            setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation());
+        }
+    }
+    else
+    {
+        setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+    }
+
+    if (mCameraAnimating)
+    {
+        const F64 ANIM_METERS_PER_SECOND = 10.0;
+        const F64 MIN_ANIM_SECONDS = 0.5;
+        const F64 MAX_ANIM_SECONDS = 10.0;
+        F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND );
+        anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS );
+        setAnimationDuration( (F32)anim_duration );
+    }
+
+    updateFocusOffset();
 }
 
 //-----------------------------------------------------------------------------
@@ -2549,27 +2549,27 @@ void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, con
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus)
 {
-	BOOL camera_enabled = !object_id.isNull();
-
-	if (camera_enabled)
-	{
-		LLViewerObject *reference_object = gObjectList.findObject(object_id);
-		if (reference_object)
-		{
-			//convert to root object relative?
-			mSitCameraPos = camera_pos;
-			mSitCameraFocus = camera_focus;
-			mSitCameraReferenceObject = reference_object;
-			mSitCameraEnabled = TRUE;
-		}
-	}
-	else
-	{
-		mSitCameraPos.clearVec();
-		mSitCameraFocus.clearVec();
-		mSitCameraReferenceObject = NULL;
-		mSitCameraEnabled = FALSE;
-	}
+    BOOL camera_enabled = !object_id.isNull();
+
+    if (camera_enabled)
+    {
+        LLViewerObject *reference_object = gObjectList.findObject(object_id);
+        if (reference_object)
+        {
+            //convert to root object relative?
+            mSitCameraPos = camera_pos;
+            mSitCameraFocus = camera_focus;
+            mSitCameraReferenceObject = reference_object;
+            mSitCameraEnabled = TRUE;
+        }
+    }
+    else
+    {
+        mSitCameraPos.clearVec();
+        mSitCameraFocus.clearVec();
+        mSitCameraReferenceObject = NULL;
+        mSitCameraEnabled = FALSE;
+    }
 }
 
 //-----------------------------------------------------------------------------
@@ -2577,80 +2577,80 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
 {
-	if (focus_on_avatar != mFocusOnAvatar)
-	{
-		if (animate)
-		{
-			startCameraAnimation();
-		}
-		else
-		{
-			stopCameraAnimation();
-		}
-	}
-	
-	//RN: when focused on the avatar, we're not "looking" at it
-	// looking implies intent while focusing on avatar means
-	// you're just walking around with a camera on you...eesh.
-	if (!mFocusOnAvatar && focus_on_avatar)
-	{
-		setFocusGlobal(LLVector3d::zero);
-		mCameraFOVZoomFactor = 0.f;
-		if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
-		{
-			LLVector3 at_axis;
-			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-			{
-				LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-				at_axis = LLViewerCamera::getInstance()->getAtAxis();
-				at_axis.mV[VZ] = 0.f;
-				at_axis.normalize();
-				gAgent.resetAxes(at_axis * ~obj_rot);
-			}
-			else
-			{
-				at_axis = LLViewerCamera::getInstance()->getAtAxis();
-				at_axis.mV[VZ] = 0.f;
-				at_axis.normalize();
-				gAgent.resetAxes(at_axis);
-			}
-		}
-	}
-	// unlocking camera from avatar
-	else if (mFocusOnAvatar && !focus_on_avatar)
-	{
-		// keep camera focus point consistent, even though it is now unlocked
-		setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
-		mAllowChangeToFollow = FALSE;
-	}
-	
-	mFocusOnAvatar = focus_on_avatar;
+    if (focus_on_avatar != mFocusOnAvatar)
+    {
+        if (animate)
+        {
+            startCameraAnimation();
+        }
+        else
+        {
+            stopCameraAnimation();
+        }
+    }
+    
+    //RN: when focused on the avatar, we're not "looking" at it
+    // looking implies intent while focusing on avatar means
+    // you're just walking around with a camera on you...eesh.
+    if (!mFocusOnAvatar && focus_on_avatar)
+    {
+        setFocusGlobal(LLVector3d::zero);
+        mCameraFOVZoomFactor = 0.f;
+        if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
+        {
+            LLVector3 at_axis;
+            if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+            {
+                LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+                at_axis = LLViewerCamera::getInstance()->getAtAxis();
+                at_axis.mV[VZ] = 0.f;
+                at_axis.normalize();
+                gAgent.resetAxes(at_axis * ~obj_rot);
+            }
+            else
+            {
+                at_axis = LLViewerCamera::getInstance()->getAtAxis();
+                at_axis.mV[VZ] = 0.f;
+                at_axis.normalize();
+                gAgent.resetAxes(at_axis);
+            }
+        }
+    }
+    // unlocking camera from avatar
+    else if (mFocusOnAvatar && !focus_on_avatar)
+    {
+        // keep camera focus point consistent, even though it is now unlocked
+        setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
+        mAllowChangeToFollow = FALSE;
+    }
+    
+    mFocusOnAvatar = focus_on_avatar;
 }
 
 
 BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
 {
-	if(object && object->isAttachment())
-	{
-		LLViewerObject* parent = object;
-		while(parent)
-		{
-			if (parent == gAgentAvatarp)
-			{
-				// looking at an attachment on ourselves, which we don't want to do
-				object = gAgentAvatarp;
-				position.clearVec();
-			}
-			parent = (LLViewerObject*)parent->getParent();
-		}
-	}
-	if(!mLookAt || mLookAt->isDead())
-	{
-		mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
-		mLookAt->setSourceObject(gAgentAvatarp);
-	}
-
-	return mLookAt->setLookAt(target_type, object, position);
+    if(object && object->isAttachment())
+    {
+        LLViewerObject* parent = object;
+        while(parent)
+        {
+            if (parent == gAgentAvatarp)
+            {
+                // looking at an attachment on ourselves, which we don't want to do
+                object = gAgentAvatarp;
+                position.clearVec();
+            }
+            parent = (LLViewerObject*)parent->getParent();
+        }
+    }
+    if(!mLookAt || mLookAt->isDead())
+    {
+        mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
+        mLookAt->setSourceObject(gAgentAvatarp);
+    }
+
+    return mLookAt->setLookAt(target_type, object, position);
 }
 
 //-----------------------------------------------------------------------------
@@ -2658,157 +2658,157 @@ BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, L
 //-----------------------------------------------------------------------------
 void LLAgentCamera::lookAtLastChat()
 {
-	// Block if camera is animating or not in normal third person camera mode
-	if (mCameraAnimating || !cameraThirdPerson())
-	{
-		return;
-	}
-
-	LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter());
-	if (!chatter)
-	{
-		return;
-	}
-
-	LLVector3 delta_pos;
-	if (chatter->isAvatar())
-	{
-		LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
-		if (isAgentAvatarValid() && chatter_av->mHeadp)
-		{
-			delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition();
-		}
-		else
-		{
-			delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent();
-		}
-		delta_pos.normalize();
-
-		gAgent.setControlFlags(AGENT_CONTROL_STOP);
-
-		changeCameraToThirdPerson();
-
-		LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
-		LLVector3 left = delta_pos % LLVector3::z_axis;
-		left.normalize();
-		LLVector3 up = left % delta_pos;
-		up.normalize();
-		new_camera_pos -= delta_pos * 0.4f;
-		new_camera_pos += left * 0.3f;
-		new_camera_pos += up * 0.2f;
-
-		setFocusOnAvatar(FALSE, FALSE);
-
-		if (chatter_av->mHeadp)
-		{
-			setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter());
-			mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition());
-		}
-		else
-		{
-			setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
-			mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
-		}
-	}
-	else
-	{
-		delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent();
-		delta_pos.normalize();
-
-		gAgent.setControlFlags(AGENT_CONTROL_STOP);
-
-		changeCameraToThirdPerson();
-
-		LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
-		LLVector3 left = delta_pos % LLVector3::z_axis;
-		left.normalize();
-		LLVector3 up = left % delta_pos;
-		up.normalize();
-		new_camera_pos -= delta_pos * 0.4f;
-		new_camera_pos += left * 0.3f;
-		new_camera_pos += up * 0.2f;
-
-		setFocusOnAvatar(FALSE, FALSE);
-
-		setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
-		mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
-	}
+    // Block if camera is animating or not in normal third person camera mode
+    if (mCameraAnimating || !cameraThirdPerson())
+    {
+        return;
+    }
+
+    LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter());
+    if (!chatter)
+    {
+        return;
+    }
+
+    LLVector3 delta_pos;
+    if (chatter->isAvatar())
+    {
+        LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
+        if (isAgentAvatarValid() && chatter_av->mHeadp)
+        {
+            delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition();
+        }
+        else
+        {
+            delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent();
+        }
+        delta_pos.normalize();
+
+        gAgent.setControlFlags(AGENT_CONTROL_STOP);
+
+        changeCameraToThirdPerson();
+
+        LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
+        LLVector3 left = delta_pos % LLVector3::z_axis;
+        left.normalize();
+        LLVector3 up = left % delta_pos;
+        up.normalize();
+        new_camera_pos -= delta_pos * 0.4f;
+        new_camera_pos += left * 0.3f;
+        new_camera_pos += up * 0.2f;
+
+        setFocusOnAvatar(FALSE, FALSE);
+
+        if (chatter_av->mHeadp)
+        {
+            setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter());
+            mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition());
+        }
+        else
+        {
+            setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
+            mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
+        }
+    }
+    else
+    {
+        delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent();
+        delta_pos.normalize();
+
+        gAgent.setControlFlags(AGENT_CONTROL_STOP);
+
+        changeCameraToThirdPerson();
+
+        LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
+        LLVector3 left = delta_pos % LLVector3::z_axis;
+        left.normalize();
+        LLVector3 up = left % delta_pos;
+        up.normalize();
+        new_camera_pos -= delta_pos * 0.4f;
+        new_camera_pos += left * 0.3f;
+        new_camera_pos += up * 0.2f;
+
+        setFocusOnAvatar(FALSE, FALSE);
+
+        setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
+        mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
+    }
 }
 
 bool LLAgentCamera::isfollowCamLocked()
 {
-	return mFollowCam.getPositionLocked();
+    return mFollowCam.getPositionLocked();
 }
 
 BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position)
 {
-	// disallow pointing at attachments and avatars
-	if (object && (object->isAttachment() || object->isAvatar()))
-	{
-		return FALSE;
-	}
-	if (!mPointAt || mPointAt->isDead())
-	{
-		mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
-		mPointAt->setSourceObject(gAgentAvatarp);
-	}
-	return mPointAt->setPointAt(target_type, object, position);
+    // disallow pointing at attachments and avatars
+    if (object && (object->isAttachment() || object->isAvatar()))
+    {
+        return FALSE;
+    }
+    if (!mPointAt || mPointAt->isDead())
+    {
+        mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
+        mPointAt->setSourceObject(gAgentAvatarp);
+    }
+    return mPointAt->setPointAt(target_type, object, position);
 }
 
 ELookAtType LLAgentCamera::getLookAtType()
 {
-	if (mLookAt) 
-	{
-		return mLookAt->getLookAtType();
-	}
-	return LOOKAT_TARGET_NONE;
+    if (mLookAt) 
+    {
+        return mLookAt->getLookAtType();
+    }
+    return LOOKAT_TARGET_NONE;
 }
 
 EPointAtType LLAgentCamera::getPointAtType()
 { 
-	if (mPointAt) 
-	{
-		return mPointAt->getPointAtType();
-	}
-	return POINTAT_TARGET_NONE;
+    if (mPointAt) 
+    {
+        return mPointAt->getPointAtType();
+    }
+    return POINTAT_TARGET_NONE;
 }
 
 void LLAgentCamera::clearGeneralKeys()
 {
-	mAtKey 				= 0;
-	mWalkKey 			= 0;
-	mLeftKey 			= 0;
-	mUpKey 				= 0;
-	mYawKey 			= 0.f;
-	mPitchKey 			= 0.f;
+    mAtKey              = 0;
+    mWalkKey            = 0;
+    mLeftKey            = 0;
+    mUpKey              = 0;
+    mYawKey             = 0.f;
+    mPitchKey           = 0.f;
 }
 
 void LLAgentCamera::clearOrbitKeys()
 {
-	mOrbitLeftKey		= 0.f;
-	mOrbitRightKey		= 0.f;
-	mOrbitUpKey			= 0.f;
-	mOrbitDownKey		= 0.f;
-	mOrbitInKey			= 0.f;
-	mOrbitOutKey		= 0.f;
+    mOrbitLeftKey       = 0.f;
+    mOrbitRightKey      = 0.f;
+    mOrbitUpKey         = 0.f;
+    mOrbitDownKey       = 0.f;
+    mOrbitInKey         = 0.f;
+    mOrbitOutKey        = 0.f;
 }
 
 void LLAgentCamera::clearPanKeys()
 {
-	mPanRightKey		= 0.f;
-	mPanLeftKey			= 0.f;
-	mPanUpKey			= 0.f;
-	mPanDownKey			= 0.f;
-	mPanInKey			= 0.f;
-	mPanOutKey			= 0.f;
+    mPanRightKey        = 0.f;
+    mPanLeftKey         = 0.f;
+    mPanUpKey           = 0.f;
+    mPanDownKey         = 0.f;
+    mPanInKey           = 0.f;
+    mPanOutKey          = 0.f;
 }
 
 // static
 S32 LLAgentCamera::directionToKey(S32 direction)
 {
-	if (direction > 0) return 1;
-	if (direction < 0) return -1;
-	return 0;
+    if (direction > 0) return 1;
+    if (direction < 0) return -1;
+    return 0;
 }
 
 
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 4575c1501a..27a9891030 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -27,9 +27,9 @@
 #ifndef LL_LLAGENTCAMERA_H
 #define LL_LLAGENTCAMERA_H
 
-#include "llfollowcam.h" 			// Ventrella
-#include "llhudeffectlookat.h" 		// EPointAtType
-#include "llhudeffectpointat.h" 	// ELookAtType
+#include "llfollowcam.h"            // Ventrella
+#include "llhudeffectlookat.h"      // EPointAtType
+#include "llhudeffectpointat.h"     // ELookAtType
 
 class LLPickInfo;
 class LLVOAvatarSelf;
@@ -40,26 +40,26 @@ class LLControlVariable;
 //--------------------------------------------------------------------
 enum ECameraMode
 {
-	CAMERA_MODE_THIRD_PERSON,
-	CAMERA_MODE_MOUSELOOK,
-	CAMERA_MODE_CUSTOMIZE_AVATAR,
-	CAMERA_MODE_FOLLOW
+    CAMERA_MODE_THIRD_PERSON,
+    CAMERA_MODE_MOUSELOOK,
+    CAMERA_MODE_CUSTOMIZE_AVATAR,
+    CAMERA_MODE_FOLLOW
 };
 
 /** Camera Presets for CAMERA_MODE_THIRD_PERSON */
 enum ECameraPreset 
 {
-	/** Default preset, what the Third Person Mode actually was */
-	CAMERA_PRESET_REAR_VIEW,
-	
-	/** "Looking at the Avatar from the front" */
-	CAMERA_PRESET_FRONT_VIEW, 
+    /** Default preset, what the Third Person Mode actually was */
+    CAMERA_PRESET_REAR_VIEW,
+    
+    /** "Looking at the Avatar from the front" */
+    CAMERA_PRESET_FRONT_VIEW, 
 
-	/** "Above and to the left, over the shoulder, pulled back a little on the zoom" */
-	CAMERA_PRESET_GROUP_VIEW,
+    /** "Above and to the left, over the shoulder, pulled back a little on the zoom" */
+    CAMERA_PRESET_GROUP_VIEW,
 
-	/** Current view when a preset is saved */
-	CAMERA_PRESET_CUSTOM0
+    /** Current view when a preset is saved */
+    CAMERA_PRESET_CUSTOM0
 };
 
 //------------------------------------------------------------------------
@@ -67,243 +67,243 @@ enum ECameraPreset
 //------------------------------------------------------------------------
 class LLAgentCamera
 {
-	LOG_CLASS(LLAgentCamera);
+    LOG_CLASS(LLAgentCamera);
 
 public:
-	//--------------------------------------------------------------------
-	// Constructors / Destructors
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Constructors / Destructors
+    //--------------------------------------------------------------------
 public:
-	LLAgentCamera();
-	virtual 		~LLAgentCamera();
-	void			init();
-	void			cleanup();
-	void		    setAvatarObject(LLVOAvatarSelf* avatar);
-	bool			isInitialized() { return mInitialized; }
+    LLAgentCamera();
+    virtual         ~LLAgentCamera();
+    void            init();
+    void            cleanup();
+    void            setAvatarObject(LLVOAvatarSelf* avatar);
+    bool            isInitialized() { return mInitialized; }
 private:
-	bool			mInitialized;
+    bool            mInitialized;
 
 
-	//--------------------------------------------------------------------
-	// Mode
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Mode
+    //--------------------------------------------------------------------
 public:
-	void			changeCameraToDefault();
-	void			changeCameraToMouselook(BOOL animate = TRUE);
-	void			changeCameraToThirdPerson(BOOL animate = TRUE);
-	void			changeCameraToCustomizeAvatar(); // Trigger transition animation
-	void			changeCameraToFollow(BOOL animate = TRUE); 	// Ventrella
-	BOOL			cameraThirdPerson() const		{ return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
-	BOOL			cameraMouselook() const			{ return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
-	BOOL			cameraCustomizeAvatar() const	{ return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
-	BOOL			cameraFollow() const			{ return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
-	ECameraMode		getCameraMode() const 			{ return mCameraMode; }
-	ECameraMode		getLastCameraMode() const 		{ return mLastCameraMode; }
-	void			updateCamera();					// Call once per frame to update camera location/orientation
-	void			resetCamera(); 					// Slam camera into its default position
-	void			updateLastCamera();				// Set last camera to current camera
+    void            changeCameraToDefault();
+    void            changeCameraToMouselook(BOOL animate = TRUE);
+    void            changeCameraToThirdPerson(BOOL animate = TRUE);
+    void            changeCameraToCustomizeAvatar(); // Trigger transition animation
+    void            changeCameraToFollow(BOOL animate = TRUE);  // Ventrella
+    BOOL            cameraThirdPerson() const       { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
+    BOOL            cameraMouselook() const         { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
+    BOOL            cameraCustomizeAvatar() const   { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
+    BOOL            cameraFollow() const            { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
+    ECameraMode     getCameraMode() const           { return mCameraMode; }
+    ECameraMode     getLastCameraMode() const       { return mLastCameraMode; }
+    void            updateCamera();                 // Call once per frame to update camera location/orientation
+    void            resetCamera();                  // Slam camera into its default position
+    void            updateLastCamera();             // Set last camera to current camera
 
 private:
-	ECameraMode		mCameraMode;					// Target mode after transition animation is done
-	ECameraMode		mLastCameraMode;
+    ECameraMode     mCameraMode;                    // Target mode after transition animation is done
+    ECameraMode     mLastCameraMode;
 
-	//--------------------------------------------------------------------
-	// Preset
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Preset
+    //--------------------------------------------------------------------
 public:
-	void switchCameraPreset(ECameraPreset preset);
+    void switchCameraPreset(ECameraPreset preset);
 private:
-	/** Determines default camera offset depending on the current camera preset */
-	LLVector3 getCameraOffsetInitial();
-	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
-	F32 getCameraMaxZoomDistance();
+    /** Determines default camera offset depending on the current camera preset */
+    LLVector3 getCameraOffsetInitial();
+    /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
+    F32 getCameraMaxZoomDistance();
 
-	/** Camera preset in Third Person Mode */
-	ECameraPreset mCameraPreset; 
+    /** Camera preset in Third Person Mode */
+    ECameraPreset mCameraPreset; 
 
-	/** Initial camera offsets */
-	std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial;
+    /** Initial camera offsets */
+    std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial;
 
-	/** Initial focus offsets */
-	std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial;
+    /** Initial focus offsets */
+    std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial;
 
-	//--------------------------------------------------------------------
-	// Position
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Position
+    //--------------------------------------------------------------------
 public:
-	LLVector3d		getCameraPositionGlobal() const;
-	const LLVector3 &getCameraPositionAgent() const;
-	LLVector3d		calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
-	F32				getCameraMinOffGround(); 		// Minimum height off ground for this mode, meters
-	void			setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; }
-	BOOL			calcCameraMinDistance(F32 &obj_min_distance);
-	F32				getCurrentCameraBuildOffset() 	{ return (F32)mCameraFocusOffset.length(); }
-	void			clearCameraLag() { mCameraLag.clearVec(); }
+    LLVector3d      getCameraPositionGlobal() const;
+    const LLVector3 &getCameraPositionAgent() const;
+    LLVector3d      calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
+    F32             getCameraMinOffGround();        // Minimum height off ground for this mode, meters
+    void            setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; }
+    BOOL            calcCameraMinDistance(F32 &obj_min_distance);
+    F32             getCurrentCameraBuildOffset()   { return (F32)mCameraFocusOffset.length(); }
+    void            clearCameraLag() { mCameraLag.clearVec(); }
 private:
-	F32				mCurrentCameraDistance;	 		// Current camera offset from avatar
-	F32				mTargetCameraDistance;			// Target camera offset from avatar
-	F32				mCameraFOVZoomFactor;			// Amount of fov zoom applied to camera when zeroing in on an object
-	F32				mCameraCurrentFOVZoomFactor;	// Interpolated fov zoom
-	F32				mCameraFOVDefault;				// Default field of view that is basis for FOV zoom effect
-	LLVector4		mCameraCollidePlane;			// Colliding plane for camera
-	F32				mCameraZoomFraction;			// Mousewheel driven fraction of zoom
-	LLVector3		mCameraPositionAgent;			// Camera position in agent coordinates
-	LLVector3		mCameraVirtualPositionAgent;	// Camera virtual position (target) before performing FOV zoom
-	LLVector3d      mCameraSmoothingLastPositionGlobal;    
-	LLVector3d      mCameraSmoothingLastPositionAgent;
-	bool            mCameraSmoothingStop;
-	LLVector3		mCameraLag;						// Third person camera lag
-	LLVector3		mCameraUpVector;				// Camera's up direction in world coordinates (determines the 'roll' of the view)
-
-	//--------------------------------------------------------------------
-	// Follow
-	//--------------------------------------------------------------------
+    F32             mCurrentCameraDistance;         // Current camera offset from avatar
+    F32             mTargetCameraDistance;          // Target camera offset from avatar
+    F32             mCameraFOVZoomFactor;           // Amount of fov zoom applied to camera when zeroing in on an object
+    F32             mCameraCurrentFOVZoomFactor;    // Interpolated fov zoom
+    F32             mCameraFOVDefault;              // Default field of view that is basis for FOV zoom effect
+    LLVector4       mCameraCollidePlane;            // Colliding plane for camera
+    F32             mCameraZoomFraction;            // Mousewheel driven fraction of zoom
+    LLVector3       mCameraPositionAgent;           // Camera position in agent coordinates
+    LLVector3       mCameraVirtualPositionAgent;    // Camera virtual position (target) before performing FOV zoom
+    LLVector3d      mCameraSmoothingLastPositionGlobal;    
+    LLVector3d      mCameraSmoothingLastPositionAgent;
+    bool            mCameraSmoothingStop;
+    LLVector3       mCameraLag;                     // Third person camera lag
+    LLVector3       mCameraUpVector;                // Camera's up direction in world coordinates (determines the 'roll' of the view)
+
+    //--------------------------------------------------------------------
+    // Follow
+    //--------------------------------------------------------------------
 public:
-	void			setUsingFollowCam(bool using_follow_cam);
-	bool 			isfollowCamLocked();
+    void            setUsingFollowCam(bool using_follow_cam);
+    bool            isfollowCamLocked();
 private:
-	LLFollowCam 	mFollowCam; 			// Ventrella
+    LLFollowCam     mFollowCam;             // Ventrella
 
-	//--------------------------------------------------------------------
-	// Sit
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Sit
+    //--------------------------------------------------------------------
 public:
-	void			setupSitCamera();
-	BOOL			sitCameraEnabled() 		{ return mSitCameraEnabled; }
-	void			setSitCamera(const LLUUID &object_id, 
-								 const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
+    void            setupSitCamera();
+    BOOL            sitCameraEnabled()      { return mSitCameraEnabled; }
+    void            setSitCamera(const LLUUID &object_id, 
+                                 const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
 private:
-	LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting
-	BOOL			mSitCameraEnabled;		// Use provided camera information when sitting?
-	LLVector3		mSitCameraPos;			// Root relative camera pos when sitting
-	LLVector3		mSitCameraFocus;		// Root relative camera target when sitting
-
-	//--------------------------------------------------------------------
-	// Animation
-	//--------------------------------------------------------------------
+    LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting
+    BOOL            mSitCameraEnabled;      // Use provided camera information when sitting?
+    LLVector3       mSitCameraPos;          // Root relative camera pos when sitting
+    LLVector3       mSitCameraFocus;        // Root relative camera target when sitting
+
+    //--------------------------------------------------------------------
+    // Animation
+    //--------------------------------------------------------------------
 public:
-	void			setCameraAnimating(BOOL b)			{ mCameraAnimating = b; }
-	BOOL			getCameraAnimating()				{ return mCameraAnimating; }
-	void			setAnimationDuration(F32 seconds);
-	void			startCameraAnimation();
-	void			stopCameraAnimation();
+    void            setCameraAnimating(BOOL b)          { mCameraAnimating = b; }
+    BOOL            getCameraAnimating()                { return mCameraAnimating; }
+    void            setAnimationDuration(F32 seconds);
+    void            startCameraAnimation();
+    void            stopCameraAnimation();
 private:
-	LLFrameTimer	mAnimationTimer; 	// Seconds that transition animation has been active
-	F32				mAnimationDuration;	// In seconds
-	BOOL			mCameraAnimating;					// Camera is transitioning from one mode to another
-	LLVector3d		mAnimationCameraStartGlobal;		// Camera start position, global coords
-	LLVector3d		mAnimationFocusStartGlobal;			// Camera focus point, global coords
-
-	//--------------------------------------------------------------------
-	// Focus
-	//--------------------------------------------------------------------
+    LLFrameTimer    mAnimationTimer;    // Seconds that transition animation has been active
+    F32             mAnimationDuration; // In seconds
+    BOOL            mCameraAnimating;                   // Camera is transitioning from one mode to another
+    LLVector3d      mAnimationCameraStartGlobal;        // Camera start position, global coords
+    LLVector3d      mAnimationFocusStartGlobal;         // Camera focus point, global coords
+
+    //--------------------------------------------------------------------
+    // Focus
+    //--------------------------------------------------------------------
 public:
-	LLVector3d		calcFocusPositionTargetGlobal();
-	LLVector3		calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y);
-	BOOL			getFocusOnAvatar() const		{ return mFocusOnAvatar; }
-	LLPointer<LLViewerObject>&	getFocusObject() 	{ return mFocusObject; }
-	F32				getFocusObjectDist() const		{ return mFocusObjectDist; }
-	void			updateFocusOffset();
-	void			validateFocusObject();
-	void			setFocusGlobal(const LLPickInfo& pick);
-	void			setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
-	void			setFocusOnAvatar(BOOL focus, BOOL animate);
-	void			setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
-	void			clearFocusObject();
-	void			setFocusObject(LLViewerObject* object);
-	void			setAllowChangeToFollow(BOOL focus) 	{ mAllowChangeToFollow = focus; }
-	void			setObjectTracking(BOOL track) 	{ mTrackFocusObject = track; }
-	const LLVector3d &getFocusGlobal() const		{ return mFocusGlobal; }
-	const LLVector3d &getFocusTargetGlobal() const	{ return mFocusTargetGlobal; }
+    LLVector3d      calcFocusPositionTargetGlobal();
+    LLVector3       calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y);
+    BOOL            getFocusOnAvatar() const        { return mFocusOnAvatar; }
+    LLPointer<LLViewerObject>&  getFocusObject()    { return mFocusObject; }
+    F32             getFocusObjectDist() const      { return mFocusObjectDist; }
+    void            updateFocusOffset();
+    void            validateFocusObject();
+    void            setFocusGlobal(const LLPickInfo& pick);
+    void            setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
+    void            setFocusOnAvatar(BOOL focus, BOOL animate);
+    void            setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
+    void            clearFocusObject();
+    void            setFocusObject(LLViewerObject* object);
+    void            setAllowChangeToFollow(BOOL focus)  { mAllowChangeToFollow = focus; }
+    void            setObjectTracking(BOOL track)   { mTrackFocusObject = track; }
+    const LLVector3d &getFocusGlobal() const        { return mFocusGlobal; }
+    const LLVector3d &getFocusTargetGlobal() const  { return mFocusTargetGlobal; }
 private:
-	LLVector3d		mCameraFocusOffset;				// Offset from focus point in build mode
-	LLVector3d		mCameraFocusOffsetTarget;		// Target towards which we are lerping the camera's focus offset
-	BOOL			mFocusOnAvatar;
-	BOOL			mAllowChangeToFollow;
-	LLVector3d		mFocusGlobal;
-	LLVector3d		mFocusTargetGlobal;
-	LLPointer<LLViewerObject> mFocusObject;
-	F32				mFocusObjectDist;
-	LLVector3		mFocusObjectOffset;
-	F32				mFocusDotRadius; 				// Meters
-	BOOL			mTrackFocusObject;
-	
-	//--------------------------------------------------------------------
-	// Lookat / Pointat
-	//--------------------------------------------------------------------
+    LLVector3d      mCameraFocusOffset;             // Offset from focus point in build mode
+    LLVector3d      mCameraFocusOffsetTarget;       // Target towards which we are lerping the camera's focus offset
+    BOOL            mFocusOnAvatar;
+    BOOL            mAllowChangeToFollow;
+    LLVector3d      mFocusGlobal;
+    LLVector3d      mFocusTargetGlobal;
+    LLPointer<LLViewerObject> mFocusObject;
+    F32             mFocusObjectDist;
+    LLVector3       mFocusObjectOffset;
+    F32             mFocusDotRadius;                // Meters
+    BOOL            mTrackFocusObject;
+    
+    //--------------------------------------------------------------------
+    // Lookat / Pointat
+    //--------------------------------------------------------------------
 public:
-	void			updateLookAt(const S32 mouse_x, const S32 mouse_y);
-	BOOL			setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
-	ELookAtType		getLookAtType();
-	void			lookAtLastChat();
-	void 			slamLookAt(const LLVector3 &look_at); // Set the physics data
-	BOOL			setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
-	EPointAtType	getPointAtType();
+    void            updateLookAt(const S32 mouse_x, const S32 mouse_y);
+    BOOL            setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
+    ELookAtType     getLookAtType();
+    void            lookAtLastChat();
+    void            slamLookAt(const LLVector3 &look_at); // Set the physics data
+    BOOL            setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
+    EPointAtType    getPointAtType();
 public:
-	LLPointer<LLHUDEffectLookAt> mLookAt;
-	LLPointer<LLHUDEffectPointAt> mPointAt;
+    LLPointer<LLHUDEffectLookAt> mLookAt;
+    LLPointer<LLHUDEffectPointAt> mPointAt;
 
-	//--------------------------------------------------------------------
-	// Third person
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Third person
+    //--------------------------------------------------------------------
 public:
-	LLVector3d		calcThirdPersonFocusOffset();
-	void			setThirdPersonHeadOffset(LLVector3 offset) 	{ mThirdPersonHeadOffset = offset; }	
+    LLVector3d      calcThirdPersonFocusOffset();
+    void            setThirdPersonHeadOffset(LLVector3 offset)  { mThirdPersonHeadOffset = offset; }    
 private:
-	LLVector3		mThirdPersonHeadOffset;						// Head offset for third person camera position
+    LLVector3       mThirdPersonHeadOffset;                     // Head offset for third person camera position
 
-	//--------------------------------------------------------------------
-	// Orbit
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Orbit
+    //--------------------------------------------------------------------
 public:
-	void			cameraOrbitAround(const F32 radians);	// Rotate camera CCW radians about build focus point
-	void			cameraOrbitOver(const F32 radians);		// Rotate camera forward radians over build focus point
-	void			cameraOrbitIn(const F32 meters);		// Move camera in toward build focus point
+    void            cameraOrbitAround(const F32 radians);   // Rotate camera CCW radians about build focus point
+    void            cameraOrbitOver(const F32 radians);     // Rotate camera forward radians over build focus point
+    void            cameraOrbitIn(const F32 meters);        // Move camera in toward build focus point
 
-	//--------------------------------------------------------------------
-	// Zoom
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Zoom
+    //--------------------------------------------------------------------
 public:
-	void			handleScrollWheel(S32 clicks); 			// Mousewheel driven zoom
-	void			cameraZoomIn(const F32 factor);			// Zoom in by fraction of current distance
-	F32				getCameraZoomFraction();				// Get camera zoom as fraction of minimum and maximum zoom
-	void			setCameraZoomFraction(F32 fraction);	// Set camera zoom as fraction of minimum and maximum zoom
-	F32				calcCameraFOVZoomFactor();
-
-	//--------------------------------------------------------------------
-	// Pan
-	//--------------------------------------------------------------------
+    void            handleScrollWheel(S32 clicks);          // Mousewheel driven zoom
+    void            cameraZoomIn(const F32 factor);         // Zoom in by fraction of current distance
+    F32             getCameraZoomFraction();                // Get camera zoom as fraction of minimum and maximum zoom
+    void            setCameraZoomFraction(F32 fraction);    // Set camera zoom as fraction of minimum and maximum zoom
+    F32             calcCameraFOVZoomFactor();
+
+    //--------------------------------------------------------------------
+    // Pan
+    //--------------------------------------------------------------------
 public:
-	void			cameraPanIn(const F32 meters);
-	void			cameraPanLeft(const F32 meters);
-	void			cameraPanUp(const F32 meters);
-	
-	//--------------------------------------------------------------------
-	// View
-	//--------------------------------------------------------------------
+    void            cameraPanIn(const F32 meters);
+    void            cameraPanLeft(const F32 meters);
+    void            cameraPanUp(const F32 meters);
+    
+    //--------------------------------------------------------------------
+    // View
+    //--------------------------------------------------------------------
 public:
-	// Called whenever the agent moves.  Puts camera back in default position, deselects items, etc.
-	void			resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE);
-	// Called on camera movement.  Unlocks camera from the default position behind the avatar.
-	void			unlockView();
+    // Called whenever the agent moves.  Puts camera back in default position, deselects items, etc.
+    void            resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE);
+    // Called on camera movement.  Unlocks camera from the default position behind the avatar.
+    void            unlockView();
 public:
-	F32				mDrawDistance;
+    F32             mDrawDistance;
 
-	//--------------------------------------------------------------------
-	// Mouselook
-	//--------------------------------------------------------------------
+    //--------------------------------------------------------------------
+    // Mouselook
+    //--------------------------------------------------------------------
 public:
-	BOOL			getForceMouselook() const 			{ return mForceMouselook; }
-	void			setForceMouselook(BOOL mouselook) 	{ mForceMouselook = mouselook; }
+    BOOL            getForceMouselook() const           { return mForceMouselook; }
+    void            setForceMouselook(BOOL mouselook)   { mForceMouselook = mouselook; }
 private:
-	BOOL			mForceMouselook;
-	
-	//--------------------------------------------------------------------
-	// HUD
-	//--------------------------------------------------------------------
+    BOOL            mForceMouselook;
+    
+    //--------------------------------------------------------------------
+    // HUD
+    //--------------------------------------------------------------------
 public:
-	F32				mHUDTargetZoom;	// Target zoom level for HUD objects (used when editing)
-	F32				mHUDCurZoom; 	// Current animated zoom level for HUD objects
+    F32             mHUDTargetZoom; // Target zoom level for HUD objects (used when editing)
+    F32             mHUDCurZoom;    // Current animated zoom level for HUD objects
 
 
 /********************************************************************************
@@ -312,84 +312,84 @@ public:
  **/
 
 public:
-	S32				getAtKey() const		{ return mAtKey; }
-	S32				getWalkKey() const		{ return mWalkKey; }
-	S32				getLeftKey() const		{ return mLeftKey; }
-	S32				getUpKey() const		{ return mUpKey; }
-	F32				getYawKey() const		{ return mYawKey; }
-	F32				getPitchKey() const		{ return mPitchKey; }
-
-	void			setAtKey(S32 mag)		{ mAtKey = mag; }
-	void			setWalkKey(S32 mag)		{ mWalkKey = mag; }
-	void			setLeftKey(S32 mag)		{ mLeftKey = mag; }
-	void			setUpKey(S32 mag)		{ mUpKey = mag; }
-	void			setYawKey(F32 mag)		{ mYawKey = mag; }
-	void			setPitchKey(F32 mag)	{ mPitchKey = mag; }
-
-	void			clearGeneralKeys();
-	static S32		directionToKey(S32 direction); // Changes direction to -1/0/1
+    S32             getAtKey() const        { return mAtKey; }
+    S32             getWalkKey() const      { return mWalkKey; }
+    S32             getLeftKey() const      { return mLeftKey; }
+    S32             getUpKey() const        { return mUpKey; }
+    F32             getYawKey() const       { return mYawKey; }
+    F32             getPitchKey() const     { return mPitchKey; }
+
+    void            setAtKey(S32 mag)       { mAtKey = mag; }
+    void            setWalkKey(S32 mag)     { mWalkKey = mag; }
+    void            setLeftKey(S32 mag)     { mLeftKey = mag; }
+    void            setUpKey(S32 mag)       { mUpKey = mag; }
+    void            setYawKey(F32 mag)      { mYawKey = mag; }
+    void            setPitchKey(F32 mag)    { mPitchKey = mag; }
+
+    void            clearGeneralKeys();
+    static S32      directionToKey(S32 direction); // Changes direction to -1/0/1
 
 private:
-	S32 			mAtKey;				// Either 1, 0, or -1. Indicates that movement key is pressed
-	S32				mWalkKey; 			// Like AtKey, but causes less forward thrust
-	S32 			mLeftKey;
-	S32				mUpKey;
-	F32				mYawKey;
-	F32				mPitchKey;
-
-	//--------------------------------------------------------------------
-	// Orbit
-	//--------------------------------------------------------------------
+    S32             mAtKey;             // Either 1, 0, or -1. Indicates that movement key is pressed
+    S32             mWalkKey;           // Like AtKey, but causes less forward thrust
+    S32             mLeftKey;
+    S32             mUpKey;
+    F32             mYawKey;
+    F32             mPitchKey;
+
+    //--------------------------------------------------------------------
+    // Orbit
+    //--------------------------------------------------------------------
 public:
-	F32				getOrbitLeftKey() const		{ return mOrbitLeftKey; }
-	F32				getOrbitRightKey() const	{ return mOrbitRightKey; }
-	F32				getOrbitUpKey() const		{ return mOrbitUpKey; }
-	F32				getOrbitDownKey() const		{ return mOrbitDownKey; }
-	F32				getOrbitInKey() const		{ return mOrbitInKey; }
-	F32				getOrbitOutKey() const		{ return mOrbitOutKey; }
-
-	void			setOrbitLeftKey(F32 mag)	{ mOrbitLeftKey = mag; }
-	void			setOrbitRightKey(F32 mag)	{ mOrbitRightKey = mag; }
-	void			setOrbitUpKey(F32 mag)		{ mOrbitUpKey = mag; }
-	void			setOrbitDownKey(F32 mag)	{ mOrbitDownKey = mag; }
-	void			setOrbitInKey(F32 mag)		{ mOrbitInKey = mag; }
-	void			setOrbitOutKey(F32 mag)		{ mOrbitOutKey = mag; }
-
-	void			clearOrbitKeys();
+    F32             getOrbitLeftKey() const     { return mOrbitLeftKey; }
+    F32             getOrbitRightKey() const    { return mOrbitRightKey; }
+    F32             getOrbitUpKey() const       { return mOrbitUpKey; }
+    F32             getOrbitDownKey() const     { return mOrbitDownKey; }
+    F32             getOrbitInKey() const       { return mOrbitInKey; }
+    F32             getOrbitOutKey() const      { return mOrbitOutKey; }
+
+    void            setOrbitLeftKey(F32 mag)    { mOrbitLeftKey = mag; }
+    void            setOrbitRightKey(F32 mag)   { mOrbitRightKey = mag; }
+    void            setOrbitUpKey(F32 mag)      { mOrbitUpKey = mag; }
+    void            setOrbitDownKey(F32 mag)    { mOrbitDownKey = mag; }
+    void            setOrbitInKey(F32 mag)      { mOrbitInKey = mag; }
+    void            setOrbitOutKey(F32 mag)     { mOrbitOutKey = mag; }
+
+    void            clearOrbitKeys();
 private:
-	F32				mOrbitLeftKey;
-	F32				mOrbitRightKey;
-	F32				mOrbitUpKey;
-	F32				mOrbitDownKey;
-	F32				mOrbitInKey;
-	F32				mOrbitOutKey;
-
-	//--------------------------------------------------------------------
-	// Pan
-	//--------------------------------------------------------------------
+    F32             mOrbitLeftKey;
+    F32             mOrbitRightKey;
+    F32             mOrbitUpKey;
+    F32             mOrbitDownKey;
+    F32             mOrbitInKey;
+    F32             mOrbitOutKey;
+
+    //--------------------------------------------------------------------
+    // Pan
+    //--------------------------------------------------------------------
 public:
-	F32				getPanLeftKey() const		{ return mPanLeftKey; }
-	F32				getPanRightKey() const	{ return mPanRightKey; }
-	F32				getPanUpKey() const		{ return mPanUpKey; }
-	F32				getPanDownKey() const		{ return mPanDownKey; }
-	F32				getPanInKey() const		{ return mPanInKey; }
-	F32				getPanOutKey() const		{ return mPanOutKey; }
-
-	void			setPanLeftKey(F32 mag)		{ mPanLeftKey = mag; }
-	void			setPanRightKey(F32 mag)		{ mPanRightKey = mag; }
-	void			setPanUpKey(F32 mag)		{ mPanUpKey = mag; }
-	void			setPanDownKey(F32 mag)		{ mPanDownKey = mag; }
-	void			setPanInKey(F32 mag)		{ mPanInKey = mag; }
-	void			setPanOutKey(F32 mag)		{ mPanOutKey = mag; }
-
-	void			clearPanKeys();
+    F32             getPanLeftKey() const       { return mPanLeftKey; }
+    F32             getPanRightKey() const  { return mPanRightKey; }
+    F32             getPanUpKey() const     { return mPanUpKey; }
+    F32             getPanDownKey() const       { return mPanDownKey; }
+    F32             getPanInKey() const     { return mPanInKey; }
+    F32             getPanOutKey() const        { return mPanOutKey; }
+
+    void            setPanLeftKey(F32 mag)      { mPanLeftKey = mag; }
+    void            setPanRightKey(F32 mag)     { mPanRightKey = mag; }
+    void            setPanUpKey(F32 mag)        { mPanUpKey = mag; }
+    void            setPanDownKey(F32 mag)      { mPanDownKey = mag; }
+    void            setPanInKey(F32 mag)        { mPanInKey = mag; }
+    void            setPanOutKey(F32 mag)       { mPanOutKey = mag; }
+
+    void            clearPanKeys();
 private:
-	F32				mPanUpKey;						
-	F32				mPanDownKey;					
-	F32				mPanLeftKey;					
-	F32				mPanRightKey;					
-	F32				mPanInKey;
-	F32				mPanOutKey;
+    F32             mPanUpKey;                      
+    F32             mPanDownKey;                    
+    F32             mPanLeftKey;                    
+    F32             mPanRightKey;                   
+    F32             mPanInKey;
+    F32             mPanOutKey;
 
 /**                    Keys
  **                                                                            **
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index df06ad31e6..9848a1af0b 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -34,7 +34,7 @@
 #include "m3math.h"
 #include "llrender.h"
 
-#include "llagent.h"		// for gAgent for getRegion for getWaterHeight
+#include "llagent.h"        // for gAgent for getRegion for getWaterHeight
 #include "llcubemap.h"
 #include "lldrawable.h"
 #include "llface.h"
@@ -64,26 +64,26 @@ F32 LLDrawPoolWater::sWaterFogEnd = 0.f;
 LLVector3 LLDrawPoolWater::sLightDir;
 
 LLDrawPoolWater::LLDrawPoolWater() :
-	LLFacePool(POOL_WATER)
+    LLFacePool(POOL_WATER)
 {
-	mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
-	gGL.getTexUnit(0)->bind(mHBTex[0]) ;
-	mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP);
+    mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+    gGL.getTexUnit(0)->bind(mHBTex[0]) ;
+    mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP);
 
-	mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
-	gGL.getTexUnit(0)->bind(mHBTex[1]);
-	mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
+    mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+    gGL.getTexUnit(0)->bind(mHBTex[1]);
+    mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
 
 
-	mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE);
-	llassert(mWaterImagep);
-	mWaterImagep->setNoDelete();
-	mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
-	llassert(mOpaqueWaterImagep);
-	mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
-	mWaterNormp->setNoDelete();
+    mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE);
+    llassert(mWaterImagep);
+    mWaterImagep->setNoDelete();
+    mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
+    llassert(mOpaqueWaterImagep);
+    mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
+    mWaterNormp->setNoDelete();
 
-	restoreGL();
+    restoreGL();
 }
 
 LLDrawPoolWater::~LLDrawPoolWater()
@@ -93,48 +93,48 @@ LLDrawPoolWater::~LLDrawPoolWater()
 //static
 void LLDrawPoolWater::restoreGL()
 {
-	
+    
 }
 
 LLDrawPool *LLDrawPoolWater::instancePool()
 {
-	LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL;
-	return NULL;
+    LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL;
+    return NULL;
 }
 
 
 void LLDrawPoolWater::prerender()
 {
-	mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ?
-		LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0;
+    mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ?
+        LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0;
 
-	// got rid of modulation by light color since it got a little too
-	// green at sunset and sl-57047 (underwater turns black at 8:00)
-	sWaterFogColor = LLWaterParamManager::instance().getFogColor();
-	sWaterFogColor.mV[3] = 0;
+    // got rid of modulation by light color since it got a little too
+    // green at sunset and sl-57047 (underwater turns black at 8:00)
+    sWaterFogColor = LLWaterParamManager::instance().getFogColor();
+    sWaterFogColor.mV[3] = 0;
 
 }
 
 S32 LLDrawPoolWater::getNumPasses()
 {
-	if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f)
-	{
-		return 1;
-	}
+    if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f)
+    {
+        return 1;
+    }
 
-	return 0;
+    return 0;
 }
 
 void LLDrawPoolWater::beginPostDeferredPass(S32 pass)
 {
-	beginRenderPass(pass);
-	deferred_render = TRUE;
+    beginRenderPass(pass);
+    deferred_render = TRUE;
 }
 
 void LLDrawPoolWater::endPostDeferredPass(S32 pass)
 {
-	endRenderPass(pass);
-	deferred_render = FALSE;
+    endRenderPass(pass);
+    deferred_render = FALSE;
 }
 
 //===============================
@@ -142,591 +142,591 @@ void LLDrawPoolWater::endPostDeferredPass(S32 pass)
 //===============================
 void LLDrawPoolWater::renderDeferred(S32 pass)
 {
-	LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
-	deferred_render = TRUE;
-	shade();
-	deferred_render = FALSE;
+    LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
+    deferred_render = TRUE;
+    shade();
+    deferred_render = FALSE;
 }
 
 //=========================================
 
 void LLDrawPoolWater::render(S32 pass)
 {
-	LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
-	if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
-	{
-		return;
-	}
-
-	//do a quick 'n dirty depth sort
-	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-			 iter != mDrawFace.end(); iter++)
-	{
-		LLFace* facep = *iter;
-		facep->mDistance = -facep->mCenterLocal.mV[2];
-	}
-
-	std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
-
-	// See if we are rendering water as opaque or not
-	if (!gSavedSettings.getBOOL("RenderTransparentWater"))
-	{
-		// render water for low end hardware
-		renderOpaqueLegacyWater();
-		return;
-	}
-
-	LLGLEnable blend(GL_BLEND);
-
-	if ((mVertexShaderLevel > 0) && !sSkipScreenCopy)
-	{
-		shade();
-		return;
-	}
-
-	LLVOSky *voskyp = gSky.mVOSkyp;
-
-	stop_glerror();
-
-	if (!gGLManager.mHasMultitexture)
-	{
-		// Ack!  No multitexture!  Bail!
-		return;
-	}
-
-	LLFace* refl_face = voskyp->getReflFace();
-
-	gPipeline.disableLights();
-	
-	LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
-
-	LLGLDisable cullFace(GL_CULL_FACE);
-	
-	// Set up second pass first
-	mWaterImagep->addTextureStats(1024.f*1024.f);
-	gGL.getTexUnit(1)->activate();
-	gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
-	gGL.getTexUnit(1)->bind(mWaterImagep) ;
-
-	LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
-	F32 up_dot = camera_up * LLVector3::z_axis;
-
-	LLColor4 water_color;
-	if (LLViewerCamera::getInstance()->cameraUnderWater())
-	{
-		water_color.setVec(1.f, 1.f, 1.f, 0.4f);
-	}
-	else
-	{
-		water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
-	}
-
-	gGL.diffuseColor4fv(water_color.mV);
-
-	// Automatically generate texture coords for detail map
-	glEnable(GL_TEXTURE_GEN_S); //texture unit 1
-	glEnable(GL_TEXTURE_GEN_T); //texture unit 1
-	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-
-	// Slowly move over time.
-	F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f);
-	F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f};
-	F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f};
-	glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
-	glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
-
-	gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
-	gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA);
-
-	gGL.getTexUnit(0)->activate();
-	
-	glClearStencil(1);
-	glClear(GL_STENCIL_BUFFER_BIT);
-	LLGLEnable gls_stencil(GL_STENCIL_TEST);
-	glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP);
-	glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF);
-
-	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-		 iter != mDrawFace.end(); iter++)
-	{
-		LLFace *face = *iter;
-		if (voskyp->isReflFace(face))
-		{
-			continue;
-		}
-		gGL.getTexUnit(0)->bind(face->getTexture());
-		face->renderIndexed();
-	}
-
-	// Now, disable texture coord generation on texture state 1
-	gGL.getTexUnit(1)->activate();
-	gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
-	gGL.getTexUnit(1)->disable();
-	glDisable(GL_TEXTURE_GEN_S); //texture unit 1
-	glDisable(GL_TEXTURE_GEN_T); //texture unit 1
-
-	// Disable texture coordinate and color arrays
-	gGL.getTexUnit(0)->activate();
-	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
-	stop_glerror();
-	
-	if (gSky.mVOSkyp->getCubeMap())
-	{
-		gSky.mVOSkyp->getCubeMap()->enable(0);
-		gSky.mVOSkyp->getCubeMap()->bind();
-
-		gGL.matrixMode(LLRender::MM_TEXTURE);
-		gGL.loadIdentity();
-		LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
-		LLMatrix4 camera_rot(camera_mat.getMat3());
-		camera_rot.invert();
-
-		gGL.loadMatrix((F32 *)camera_rot.mMatrix);
-
-		gGL.matrixMode(LLRender::MM_MODELVIEW);
-		LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f,  0.5f*up_dot);
-
-		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
-
-		for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-			 iter != mDrawFace.end(); iter++)
-		{
-			LLFace *face = *iter;
-			if (voskyp->isReflFace(face))
-			{
-				//refl_face = face;
-				continue;
-			}
-
-			if (face->getGeomCount() > 0)
-			{					
-				face->renderIndexed();
-			}
-		}
-
-		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
-
-		gSky.mVOSkyp->getCubeMap()->disable();
-		
-		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-		gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
-		gGL.matrixMode(LLRender::MM_TEXTURE);
-		gGL.loadIdentity();
-		gGL.matrixMode(LLRender::MM_MODELVIEW);
-		
-	}
-
-	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+    LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
+    if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
+    {
+        return;
+    }
+
+    //do a quick 'n dirty depth sort
+    for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+             iter != mDrawFace.end(); iter++)
+    {
+        LLFace* facep = *iter;
+        facep->mDistance = -facep->mCenterLocal.mV[2];
+    }
+
+    std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
+
+    // See if we are rendering water as opaque or not
+    if (!gSavedSettings.getBOOL("RenderTransparentWater"))
+    {
+        // render water for low end hardware
+        renderOpaqueLegacyWater();
+        return;
+    }
+
+    LLGLEnable blend(GL_BLEND);
+
+    if ((mVertexShaderLevel > 0) && !sSkipScreenCopy)
+    {
+        shade();
+        return;
+    }
+
+    LLVOSky *voskyp = gSky.mVOSkyp;
+
+    stop_glerror();
+
+    if (!gGLManager.mHasMultitexture)
+    {
+        // Ack!  No multitexture!  Bail!
+        return;
+    }
+
+    LLFace* refl_face = voskyp->getReflFace();
+
+    gPipeline.disableLights();
+    
+    LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
+
+    LLGLDisable cullFace(GL_CULL_FACE);
+    
+    // Set up second pass first
+    mWaterImagep->addTextureStats(1024.f*1024.f);
+    gGL.getTexUnit(1)->activate();
+    gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
+    gGL.getTexUnit(1)->bind(mWaterImagep) ;
+
+    LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
+    F32 up_dot = camera_up * LLVector3::z_axis;
+
+    LLColor4 water_color;
+    if (LLViewerCamera::getInstance()->cameraUnderWater())
+    {
+        water_color.setVec(1.f, 1.f, 1.f, 0.4f);
+    }
+    else
+    {
+        water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
+    }
+
+    gGL.diffuseColor4fv(water_color.mV);
+
+    // Automatically generate texture coords for detail map
+    glEnable(GL_TEXTURE_GEN_S); //texture unit 1
+    glEnable(GL_TEXTURE_GEN_T); //texture unit 1
+    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+
+    // Slowly move over time.
+    F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f);
+    F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f};
+    F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f};
+    glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
+    glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
+
+    gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
+    gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA);
+
+    gGL.getTexUnit(0)->activate();
+    
+    glClearStencil(1);
+    glClear(GL_STENCIL_BUFFER_BIT);
+    LLGLEnable gls_stencil(GL_STENCIL_TEST);
+    glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP);
+    glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF);
+
+    for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+         iter != mDrawFace.end(); iter++)
+    {
+        LLFace *face = *iter;
+        if (voskyp->isReflFace(face))
+        {
+            continue;
+        }
+        gGL.getTexUnit(0)->bind(face->getTexture());
+        face->renderIndexed();
+    }
+
+    // Now, disable texture coord generation on texture state 1
+    gGL.getTexUnit(1)->activate();
+    gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+    gGL.getTexUnit(1)->disable();
+    glDisable(GL_TEXTURE_GEN_S); //texture unit 1
+    glDisable(GL_TEXTURE_GEN_T); //texture unit 1
+
+    // Disable texture coordinate and color arrays
+    gGL.getTexUnit(0)->activate();
+    gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+    stop_glerror();
+    
+    if (gSky.mVOSkyp->getCubeMap())
+    {
+        gSky.mVOSkyp->getCubeMap()->enable(0);
+        gSky.mVOSkyp->getCubeMap()->bind();
+
+        gGL.matrixMode(LLRender::MM_TEXTURE);
+        gGL.loadIdentity();
+        LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
+        LLMatrix4 camera_rot(camera_mat.getMat3());
+        camera_rot.invert();
+
+        gGL.loadMatrix((F32 *)camera_rot.mMatrix);
+
+        gGL.matrixMode(LLRender::MM_MODELVIEW);
+        LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f,  0.5f*up_dot);
+
+        gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+
+        for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+             iter != mDrawFace.end(); iter++)
+        {
+            LLFace *face = *iter;
+            if (voskyp->isReflFace(face))
+            {
+                //refl_face = face;
+                continue;
+            }
+
+            if (face->getGeomCount() > 0)
+            {                   
+                face->renderIndexed();
+            }
+        }
+
+        gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+
+        gSky.mVOSkyp->getCubeMap()->disable();
+        
+        gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+        gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+        gGL.matrixMode(LLRender::MM_TEXTURE);
+        gGL.loadIdentity();
+        gGL.matrixMode(LLRender::MM_MODELVIEW);
+        
+    }
+
+    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
 
     if (refl_face)
-	{
-		glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF);
-		renderReflection(refl_face);
-	}
+    {
+        glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF);
+        renderReflection(refl_face);
+    }
 
-	gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+    gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
 }
 
 // for low end hardware
 void LLDrawPoolWater::renderOpaqueLegacyWater()
 {
-	LLVOSky *voskyp = gSky.mVOSkyp;
-
-	LLGLSLShader* shader = NULL;
-	if (LLGLSLShader::sNoFixedFunction)
-	{
-		if (LLPipeline::sUnderWaterRender)
-		{
-			shader = &gObjectSimpleNonIndexedTexGenWaterProgram;
-		}
-		else
-		{
-			shader = &gObjectSimpleNonIndexedTexGenProgram;
-		}
-
-		shader->bind();
-	}
-
-	stop_glerror();
-
-	// Depth sorting and write to depth buffer
-	// since this is opaque, we should see nothing
-	// behind the water.  No blending because
-	// of no transparency.  And no face culling so
-	// that the underside of the water is also opaque.
-	LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
-	LLGLDisable no_cull(GL_CULL_FACE);
-	LLGLDisable no_blend(GL_BLEND);
-
-	gPipeline.disableLights();
-
-	mOpaqueWaterImagep->addTextureStats(1024.f*1024.f);
-
-	// Activate the texture binding and bind one
-	// texture since all images will have the same texture
-	gGL.getTexUnit(0)->activate();
-	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
-	gGL.getTexUnit(0)->bind(mOpaqueWaterImagep);
-
-	// Automatically generate texture coords for water texture
-	if (!shader)
-	{
-		glEnable(GL_TEXTURE_GEN_S); //texture unit 0
-		glEnable(GL_TEXTURE_GEN_T); //texture unit 0
-		glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-		glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-	}
-
-	// Use the fact that we know all water faces are the same size
-	// to save some computation
-
-	// Slowly move texture coordinates over time so the watter appears
-	// to be moving.
-	F32 movement_period_secs = 50.f;
-
-	F32 offset = fmod(gFrameTimeSeconds, movement_period_secs);
-
-	if (movement_period_secs != 0)
-	{
-	 	offset /= movement_period_secs;
-	}
-	else
-	{
-		offset = 0;
-	}
-
-	F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset };
-	F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset };
-
-	if (!shader)
-	{
-		glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
-		glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
-	}
-	else
-	{
-		shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0);
-		shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1);
-	}
-
-	gGL.diffuseColor3f(1.f, 1.f, 1.f);
-
-	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-		 iter != mDrawFace.end(); iter++)
-	{
-		LLFace *face = *iter;
-		if (voskyp->isReflFace(face))
-		{
-			continue;
-		}
-
-		face->renderIndexed();
-	}
-
-	stop_glerror();
-
-	if (!shader)
-	{
-		// Reset the settings back to expected values
-		glDisable(GL_TEXTURE_GEN_S); //texture unit 0
-		glDisable(GL_TEXTURE_GEN_T); //texture unit 0
-	}
-
-	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-	gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+    LLVOSky *voskyp = gSky.mVOSkyp;
+
+    LLGLSLShader* shader = NULL;
+    if (LLGLSLShader::sNoFixedFunction)
+    {
+        if (LLPipeline::sUnderWaterRender)
+        {
+            shader = &gObjectSimpleNonIndexedTexGenWaterProgram;
+        }
+        else
+        {
+            shader = &gObjectSimpleNonIndexedTexGenProgram;
+        }
+
+        shader->bind();
+    }
+
+    stop_glerror();
+
+    // Depth sorting and write to depth buffer
+    // since this is opaque, we should see nothing
+    // behind the water.  No blending because
+    // of no transparency.  And no face culling so
+    // that the underside of the water is also opaque.
+    LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
+    LLGLDisable no_cull(GL_CULL_FACE);
+    LLGLDisable no_blend(GL_BLEND);
+
+    gPipeline.disableLights();
+
+    mOpaqueWaterImagep->addTextureStats(1024.f*1024.f);
+
+    // Activate the texture binding and bind one
+    // texture since all images will have the same texture
+    gGL.getTexUnit(0)->activate();
+    gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+    gGL.getTexUnit(0)->bind(mOpaqueWaterImagep);
+
+    // Automatically generate texture coords for water texture
+    if (!shader)
+    {
+        glEnable(GL_TEXTURE_GEN_S); //texture unit 0
+        glEnable(GL_TEXTURE_GEN_T); //texture unit 0
+        glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+        glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+    }
+
+    // Use the fact that we know all water faces are the same size
+    // to save some computation
+
+    // Slowly move texture coordinates over time so the watter appears
+    // to be moving.
+    F32 movement_period_secs = 50.f;
+
+    F32 offset = fmod(gFrameTimeSeconds, movement_period_secs);
+
+    if (movement_period_secs != 0)
+    {
+        offset /= movement_period_secs;
+    }
+    else
+    {
+        offset = 0;
+    }
+
+    F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset };
+    F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset };
+
+    if (!shader)
+    {
+        glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
+        glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
+    }
+    else
+    {
+        shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0);
+        shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1);
+    }
+
+    gGL.diffuseColor3f(1.f, 1.f, 1.f);
+
+    for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+         iter != mDrawFace.end(); iter++)
+    {
+        LLFace *face = *iter;
+        if (voskyp->isReflFace(face))
+        {
+            continue;
+        }
+
+        face->renderIndexed();
+    }
+
+    stop_glerror();
+
+    if (!shader)
+    {
+        // Reset the settings back to expected values
+        glDisable(GL_TEXTURE_GEN_S); //texture unit 0
+        glDisable(GL_TEXTURE_GEN_T); //texture unit 0
+    }
+
+    gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+    gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
 }
 
 
 void LLDrawPoolWater::renderReflection(LLFace* face)
 {
-	LLVOSky *voskyp = gSky.mVOSkyp;
-
-	if (!voskyp)
-	{
-		return;
-	}
-
-	if (!face->getGeomCount())
-	{
-		return;
-	}
-	
-	S8 dr = voskyp->getDrawRefl();
-	if (dr < 0)
-	{
-		return;
-	}
-
-	LLGLSNoFog noFog;
-
-	gGL.getTexUnit(0)->bind(mHBTex[dr]);
-
-	LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV));
-	face->renderIndexed();
+    LLVOSky *voskyp = gSky.mVOSkyp;
+
+    if (!voskyp)
+    {
+        return;
+    }
+
+    if (!face->getGeomCount())
+    {
+        return;
+    }
+    
+    S8 dr = voskyp->getDrawRefl();
+    if (dr < 0)
+    {
+        return;
+    }
+
+    LLGLSNoFog noFog;
+
+    gGL.getTexUnit(0)->bind(mHBTex[dr]);
+
+    LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV));
+    face->renderIndexed();
 }
 
 void LLDrawPoolWater::shade()
 {
-	if (!deferred_render)
-	{
-		gGL.setColorMask(true, true);
-	}
-
-	LLVOSky *voskyp = gSky.mVOSkyp;
-
-	if(voskyp == NULL) 
-	{
-		return;
-	}
-
-	LLGLDisable blend(GL_BLEND);
-
-	LLColor3 light_diffuse(0,0,0);
-	F32 light_exp = 0.0f;
-	LLVector3 light_dir;
-	LLColor3 light_color;
-
-	if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) 	 
-    { 	 
-        light_dir  = gSky.getSunDirection(); 	 
-        light_dir.normVec(); 	
-		light_color = gSky.getSunDiffuseColor();
-		if(gSky.mVOSkyp) {
-	        light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); 	 
-			light_diffuse.normVec(); 	 
-		}
-        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	 
-        light_diffuse *= light_exp + 0.25f; 	 
-    } 	 
-    else  	 
-    { 	 
-        light_dir       = gSky.getMoonDirection(); 	 
-        light_dir.normVec(); 	 
-		light_color = gSky.getMoonDiffuseColor();
-        light_diffuse   = gSky.mVOSkyp->getMoon().getColorCached(); 	 
-        light_diffuse.normVec(); 	 
-        light_diffuse *= 0.5f; 	 
-        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	 
-    }
-
-	light_exp *= light_exp;
-	light_exp *= light_exp;
-	light_exp *= light_exp;
-	light_exp *= light_exp;
-	light_exp *= 256.f;
-	light_exp = light_exp > 32.f ? light_exp : 32.f;
-
-	LLGLSLShader* shader;
-
-	F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight();
-	
-	if (eyedepth < 0.f && LLPipeline::sWaterReflections)
-	{
-	if (deferred_render)
-	{
-			shader = &gDeferredUnderWaterProgram;
-	}
-		else
-	{
-		shader = &gUnderWaterProgram;
-	}
-	}
-	else if (deferred_render)
-	{
-		shader = &gDeferredWaterProgram;
-	}
-	else
-	{
-		shader = &gWaterProgram;
-	}
-
-	if (deferred_render)
-	{
-		gPipeline.bindDeferredShader(*shader);
-	}
-	else
-	{
-		shader->bind();
-	}
-
-	sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f;
-	
-	S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
-		
-	if (reftex > -1)
-	{
-		gGL.getTexUnit(reftex)->activate();
-		gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
-		gGL.getTexUnit(0)->activate();
-	}	
-
-	//bind normal map
-	S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
-
-	LLWaterParamManager * param_mgr = &LLWaterParamManager::instance();
-
-	// change mWaterNormp if needed
-	if (mWaterNormp->getID() != param_mgr->getNormalMapID())
-	{
-		mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID());
-	}
-
-	mWaterNormp->addTextureStats(1024.f*1024.f);
-	gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ;
-	if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
-	{
-		mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
-	}
-	else 
-	{
-		mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT);
-	}
-	
-	S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);	
-		
-	if (screentex > -1)
-	{
-		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
-		shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, 
-			param_mgr->getFogDensity());
-		gPipeline.mWaterDis.bindTexture(0, screentex);
-	}
-	
-	stop_glerror();
-	
-	gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);	
-
-	if (mVertexShaderLevel == 1)
-	{
-		sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
-		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
-	}
-
-	F32 screenRes[] = 
-	{
-		1.f/gGLViewport[2],
-		1.f/gGLViewport[3]
-	};
-	shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
-	stop_glerror();
-	
-	S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
-	stop_glerror();
-	
-	light_dir.normVec();
-	sLightDir = light_dir;
-	
-	light_diffuse *= 6.f;
-
-	//shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);
-	shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);
-	shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);
-	shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
-	shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
-	shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
-	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
-	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
-	shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
-
-	shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV);
-	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale());
-	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset());
-	shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier());
-
-	F32 sunAngle = llmax(0.f, light_dir.mV[2]);
-	F32 scaledAngle = 1.f - sunAngle;
-
-	shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
-	shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
-	shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle);
-
-	LLColor4 water_color;
-	LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
-	F32 up_dot = camera_up * LLVector3::z_axis;
-	if (LLViewerCamera::getInstance()->cameraUnderWater())
-	{
-		water_color.setVec(1.f, 1.f, 1.f, 0.4f);
-		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
-	}
-	else
-	{
-		water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
-		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
-	}
-
-	if (water_color.mV[3] > 0.9f)
-	{
-		water_color.mV[3] = 0.9f;
-	}
-
-	{
-		LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0);
-		LLGLDisable cullface(GL_CULL_FACE);
-		for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-			iter != mDrawFace.end(); iter++)
-		{
-			LLFace *face = *iter;
-
-			if (voskyp->isReflFace(face))
-			{
-				continue;
-			}
-
-			LLVOWater* water = (LLVOWater*) face->getViewerObject();
-			gGL.getTexUnit(diffTex)->bind(face->getTexture());
-
-			sNeedsReflectionUpdate = TRUE;
-			
-			if (water->getUseTexture() || !water->getIsEdgePatch())
-			{
-				sNeedsDistortionUpdate = TRUE;
-				face->renderIndexed();
-			}
-			else if (gGLManager.mHasDepthClamp || deferred_render)
-			{
-				face->renderIndexed();
-			}
-			else
-			{
-				LLGLSquashToFarClip far_clip(glh_get_current_projection());
-				face->renderIndexed();
-			}
-		}
-	}
-	
-	shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
-	shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);	
-	shader->disableTexture(LLShaderMgr::BUMP_MAP);
-	shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
-	shader->disableTexture(LLShaderMgr::WATER_REFTEX);
-	shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
-
-	if (deferred_render)
-	{
-		gPipeline.unbindDeferredShader(*shader);
-	}
-	else
-	{
-		shader->unbind();
-	}
-
-	gGL.getTexUnit(0)->activate();
-	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
-	if (!deferred_render)
-	{
-		gGL.setColorMask(true, false);
-	}
+    if (!deferred_render)
+    {
+        gGL.setColorMask(true, true);
+    }
+
+    LLVOSky *voskyp = gSky.mVOSkyp;
+
+    if(voskyp == NULL) 
+    {
+        return;
+    }
+
+    LLGLDisable blend(GL_BLEND);
+
+    LLColor3 light_diffuse(0,0,0);
+    F32 light_exp = 0.0f;
+    LLVector3 light_dir;
+    LLColor3 light_color;
+
+    if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS)   
+    {    
+        light_dir  = gSky.getSunDirection();     
+        light_dir.normVec();    
+        light_color = gSky.getSunDiffuseColor();
+        if(gSky.mVOSkyp) {
+            light_diffuse = gSky.mVOSkyp->getSun().getColorCached();     
+            light_diffuse.normVec();     
+        }
+        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0);      
+        light_diffuse *= light_exp + 0.25f;      
+    }    
+    else     
+    {    
+        light_dir       = gSky.getMoonDirection();   
+        light_dir.normVec();     
+        light_color = gSky.getMoonDiffuseColor();
+        light_diffuse   = gSky.mVOSkyp->getMoon().getColorCached();      
+        light_diffuse.normVec();     
+        light_diffuse *= 0.5f;   
+        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0);      
+    }
+
+    light_exp *= light_exp;
+    light_exp *= light_exp;
+    light_exp *= light_exp;
+    light_exp *= light_exp;
+    light_exp *= 256.f;
+    light_exp = light_exp > 32.f ? light_exp : 32.f;
+
+    LLGLSLShader* shader;
+
+    F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight();
+    
+    if (eyedepth < 0.f && LLPipeline::sWaterReflections)
+    {
+    if (deferred_render)
+    {
+            shader = &gDeferredUnderWaterProgram;
+    }
+        else
+    {
+        shader = &gUnderWaterProgram;
+    }
+    }
+    else if (deferred_render)
+    {
+        shader = &gDeferredWaterProgram;
+    }
+    else
+    {
+        shader = &gWaterProgram;
+    }
+
+    if (deferred_render)
+    {
+        gPipeline.bindDeferredShader(*shader);
+    }
+    else
+    {
+        shader->bind();
+    }
+
+    sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f;
+    
+    S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
+        
+    if (reftex > -1)
+    {
+        gGL.getTexUnit(reftex)->activate();
+        gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
+        gGL.getTexUnit(0)->activate();
+    }   
+
+    //bind normal map
+    S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
+
+    LLWaterParamManager * param_mgr = &LLWaterParamManager::instance();
+
+    // change mWaterNormp if needed
+    if (mWaterNormp->getID() != param_mgr->getNormalMapID())
+    {
+        mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID());
+    }
+
+    mWaterNormp->addTextureStats(1024.f*1024.f);
+    gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ;
+    if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
+    {
+        mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
+    }
+    else 
+    {
+        mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT);
+    }
+    
+    S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);    
+        
+    if (screentex > -1)
+    {
+        shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
+        shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, 
+            param_mgr->getFogDensity());
+        gPipeline.mWaterDis.bindTexture(0, screentex);
+    }
+    
+    stop_glerror();
+    
+    gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);  
+
+    if (mVertexShaderLevel == 1)
+    {
+        sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
+        shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
+    }
+
+    F32 screenRes[] = 
+    {
+        1.f/gGLViewport[2],
+        1.f/gGLViewport[3]
+    };
+    shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
+    stop_glerror();
+    
+    S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
+    stop_glerror();
+    
+    light_dir.normVec();
+    sLightDir = light_dir;
+    
+    light_diffuse *= 6.f;
+
+    //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);
+    shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);
+    shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);
+    shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
+    shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
+    shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
+    shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
+    shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
+    shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
+
+    shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV);
+    shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale());
+    shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset());
+    shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier());
+
+    F32 sunAngle = llmax(0.f, light_dir.mV[2]);
+    F32 scaledAngle = 1.f - sunAngle;
+
+    shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
+    shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
+    shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle);
+
+    LLColor4 water_color;
+    LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
+    F32 up_dot = camera_up * LLVector3::z_axis;
+    if (LLViewerCamera::getInstance()->cameraUnderWater())
+    {
+        water_color.setVec(1.f, 1.f, 1.f, 0.4f);
+        shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
+    }
+    else
+    {
+        water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
+        shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
+    }
+
+    if (water_color.mV[3] > 0.9f)
+    {
+        water_color.mV[3] = 0.9f;
+    }
+
+    {
+        LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0);
+        LLGLDisable cullface(GL_CULL_FACE);
+        for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+            iter != mDrawFace.end(); iter++)
+        {
+            LLFace *face = *iter;
+
+            if (voskyp->isReflFace(face))
+            {
+                continue;
+            }
+
+            LLVOWater* water = (LLVOWater*) face->getViewerObject();
+            gGL.getTexUnit(diffTex)->bind(face->getTexture());
+
+            sNeedsReflectionUpdate = TRUE;
+            
+            if (water->getUseTexture() || !water->getIsEdgePatch())
+            {
+                sNeedsDistortionUpdate = TRUE;
+                face->renderIndexed();
+            }
+            else if (gGLManager.mHasDepthClamp || deferred_render)
+            {
+                face->renderIndexed();
+            }
+            else
+            {
+                LLGLSquashToFarClip far_clip(glh_get_current_projection());
+                face->renderIndexed();
+            }
+        }
+    }
+    
+    shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
+    shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);   
+    shader->disableTexture(LLShaderMgr::BUMP_MAP);
+    shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
+    shader->disableTexture(LLShaderMgr::WATER_REFTEX);
+    shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
+
+    if (deferred_render)
+    {
+        gPipeline.unbindDeferredShader(*shader);
+    }
+    else
+    {
+        shader->unbind();
+    }
+
+    gGL.getTexUnit(0)->activate();
+    gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+    if (!deferred_render)
+    {
+        gGL.setColorMask(true, false);
+    }
 
 }
 
 LLViewerTexture *LLDrawPoolWater::getDebugTexture()
 {
-	return LLViewerFetchedTexture::sSmokeImagep;
+    return LLViewerFetchedTexture::sSmokeImagep;
 }
 
 LLColor3 LLDrawPoolWater::getDebugColor() const
 {
-	return LLColor3(0.f, 1.f, 1.f);
+    return LLColor3(0.f, 1.f, 1.f);
 }
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index c12ccb386e..2582715dd9 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -46,7 +46,7 @@
 
 static LLDefaultChildRegistry::Register<LLPanelCameraItem> r("panel_camera_item");
 
-const F32 NUDGE_TIME = 0.25f;		// in seconds
+const F32 NUDGE_TIME = 0.25f;       // in seconds
 const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed
 
 // constants
@@ -61,94 +61,94 @@ bool LLFloaterCamera::sAppearanceEditing = false;
 
 // Zoom the camera in and out
 class LLPanelCameraZoom
-:	public LLPanel
+:   public LLPanel
 {
-	LOG_CLASS(LLPanelCameraZoom);
+    LOG_CLASS(LLPanelCameraZoom);
 public:
-	LLPanelCameraZoom();
+    LLPanelCameraZoom();
 
-	/* virtual */ BOOL	postBuild();
-	/* virtual */ void	draw();
+    /* virtual */ BOOL  postBuild();
+    /* virtual */ void  draw();
 
 protected:
-	void	onZoomPlusHeldDown();
-	void	onZoomMinusHeldDown();
-	void	onSliderValueChanged();
-	void	onCameraTrack();
-	void	onCameraRotate();
-	F32		getOrbitRate(F32 time);
+    void    onZoomPlusHeldDown();
+    void    onZoomMinusHeldDown();
+    void    onSliderValueChanged();
+    void    onCameraTrack();
+    void    onCameraRotate();
+    F32     getOrbitRate(F32 time);
 
 private:
-	LLButton*	mPlusBtn;
-	LLButton*	mMinusBtn;
-	LLSlider*	mSlider;
+    LLButton*   mPlusBtn;
+    LLButton*   mMinusBtn;
+    LLSlider*   mSlider;
 };
 
 LLPanelCameraItem::Params::Params()
-:	icon_over("icon_over"),
-	icon_selected("icon_selected"),
-	picture("picture"),
-	text("text"),
-	selected_picture("selected_picture"),
-	mousedown_callback("mousedown_callback")
+:   icon_over("icon_over"),
+    icon_selected("icon_selected"),
+    picture("picture"),
+    text("text"),
+    selected_picture("selected_picture"),
+    mousedown_callback("mousedown_callback")
 {
 }
 
 LLPanelCameraItem::LLPanelCameraItem(const LLPanelCameraItem::Params& p)
-:	LLPanel(p)
+:   LLPanel(p)
 {
-	LLIconCtrl::Params icon_params = p.picture;
-	mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-	addChild(mPicture);
+    LLIconCtrl::Params icon_params = p.picture;
+    mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+    addChild(mPicture);
 
-	icon_params = p.icon_over;
-	mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-	addChild(mIconOver);
+    icon_params = p.icon_over;
+    mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+    addChild(mIconOver);
 
-	icon_params = p.icon_selected;
-	mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-	addChild(mIconSelected);
+    icon_params = p.icon_selected;
+    mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+    addChild(mIconSelected);
 
-	icon_params = p.selected_picture;
-	mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-	addChild(mPictureSelected);
+    icon_params = p.selected_picture;
+    mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+    addChild(mPictureSelected);
 
-	LLTextBox::Params text_params = p.text;
-	mText = LLUICtrlFactory::create<LLTextBox>(text_params);
-	addChild(mText);
+    LLTextBox::Params text_params = p.text;
+    mText = LLUICtrlFactory::create<LLTextBox>(text_params);
+    addChild(mText);
 
-	if (p.mousedown_callback.isProvided())
-	{
-		setCommitCallback(initCommitCallback(p.mousedown_callback));
-	}
+    if (p.mousedown_callback.isProvided())
+    {
+        setCommitCallback(initCommitCallback(p.mousedown_callback));
+    }
 }
 
 void set_view_visible(LLView* parent, const std::string& name, bool visible)
 {
-	parent->getChildView(name)->setVisible(visible);
+    parent->getChildView(name)->setVisible(visible);
 }
 
 BOOL LLPanelCameraItem::postBuild()
 {
-	setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true));
-	setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false));
-	setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
-	setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
-	return TRUE;
+    setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true));
+    setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false));
+    setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
+    setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
+    return TRUE;
 }
 
 void LLPanelCameraItem::onAnyMouseClick()
 {
-	if (mCommitSignal) (*mCommitSignal)(this, LLSD());
+    if (mCommitSignal) (*mCommitSignal)(this, LLSD());
 }
 
 void LLPanelCameraItem::setValue(const LLSD& value)
 {
-	if (!value.isMap()) return;;
-	if (!value.has("selected")) return;
-	getChildView("selected_icon")->setVisible( value["selected"]);
-	getChildView("picture")->setVisible( !value["selected"]);
-	getChildView("selected_picture")->setVisible( value["selected"]);
+    if (!value.isMap()) return;;
+    if (!value.has("selected")) return;
+    getChildView("selected_icon")->setVisible( value["selected"]);
+    getChildView("picture")->setVisible( !value["selected"]);
+    getChildView("selected_picture")->setVisible( value["selected"]);
 }
 
 static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel");
@@ -158,85 +158,85 @@ static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel
 //-------------------------------------------------------------------------------
 
 LLPanelCameraZoom::LLPanelCameraZoom()
-:	mPlusBtn( NULL ),
-	mMinusBtn( NULL ),
-	mSlider( NULL )
+:   mPlusBtn( NULL ),
+    mMinusBtn( NULL ),
+    mSlider( NULL )
 {
-	mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this));
-	mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this));
-	mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this));
-	mCommitCallbackRegistrar.add("Camera.track", boost::bind(&LLPanelCameraZoom::onCameraTrack, this));
-	mCommitCallbackRegistrar.add("Camera.rotate", boost::bind(&LLPanelCameraZoom::onCameraRotate, this));
+    mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this));
+    mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this));
+    mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this));
+    mCommitCallbackRegistrar.add("Camera.track", boost::bind(&LLPanelCameraZoom::onCameraTrack, this));
+    mCommitCallbackRegistrar.add("Camera.rotate", boost::bind(&LLPanelCameraZoom::onCameraRotate, this));
 }
 
 BOOL LLPanelCameraZoom::postBuild()
 {
-	mPlusBtn  = getChild <LLButton> ("zoom_plus_btn");
-	mMinusBtn = getChild <LLButton> ("zoom_minus_btn");
-	mSlider   = getChild <LLSlider> ("zoom_slider");
-	return LLPanel::postBuild();
+    mPlusBtn  = getChild <LLButton> ("zoom_plus_btn");
+    mMinusBtn = getChild <LLButton> ("zoom_minus_btn");
+    mSlider   = getChild <LLSlider> ("zoom_slider");
+    return LLPanel::postBuild();
 }
 
 void LLPanelCameraZoom::draw()
 {
-	mSlider->setValue(gAgentCamera.getCameraZoomFraction());
-	LLPanel::draw();
+    mSlider->setValue(gAgentCamera.getCameraZoomFraction());
+    LLPanel::draw();
 }
 
 void LLPanelCameraZoom::onZoomPlusHeldDown()
 {
-	F32 val = mSlider->getValueF32();
-	F32 inc = mSlider->getIncrement();
-	mSlider->setValue(val - inc);
-	F32 time = mPlusBtn->getHeldDownTime();
-	gAgentCamera.unlockView();
-	gAgentCamera.setOrbitInKey(getOrbitRate(time));
+    F32 val = mSlider->getValueF32();
+    F32 inc = mSlider->getIncrement();
+    mSlider->setValue(val - inc);
+    F32 time = mPlusBtn->getHeldDownTime();
+    gAgentCamera.unlockView();
+    gAgentCamera.setOrbitInKey(getOrbitRate(time));
 }
 
 void LLPanelCameraZoom::onZoomMinusHeldDown()
 {
-	F32 val = mSlider->getValueF32();
-	F32 inc = mSlider->getIncrement();
-	mSlider->setValue(val + inc);
-	F32 time = mMinusBtn->getHeldDownTime();
-	gAgentCamera.unlockView();
-	gAgentCamera.setOrbitOutKey(getOrbitRate(time));
+    F32 val = mSlider->getValueF32();
+    F32 inc = mSlider->getIncrement();
+    mSlider->setValue(val + inc);
+    F32 time = mMinusBtn->getHeldDownTime();
+    gAgentCamera.unlockView();
+    gAgentCamera.setOrbitOutKey(getOrbitRate(time));
 }
 
 void LLPanelCameraZoom::onCameraTrack()
 {
-	// EXP-202 when camera panning activated, remove the hint
-	LLFirstUse::viewPopup( false );
+    // EXP-202 when camera panning activated, remove the hint
+    LLFirstUse::viewPopup( false );
 }
 
 void LLPanelCameraZoom::onCameraRotate()
 {
-	// EXP-202 when camera rotation activated, remove the hint
-	LLFirstUse::viewPopup( false );
+    // EXP-202 when camera rotation activated, remove the hint
+    LLFirstUse::viewPopup( false );
 }
 
 F32 LLPanelCameraZoom::getOrbitRate(F32 time)
 {
-	if( time < NUDGE_TIME )
-	{
-		F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME;
-		return rate;
-	}
-	else
-	{
-		return 1;
-	}
+    if( time < NUDGE_TIME )
+    {
+        F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME;
+        return rate;
+    }
+    else
+    {
+        return 1;
+    }
 }
 
 void  LLPanelCameraZoom::onSliderValueChanged()
 {
-	F32 zoom_level = mSlider->getValueF32();
-	gAgentCamera.setCameraZoomFraction(zoom_level);
+    F32 zoom_level = mSlider->getValueF32();
+    gAgentCamera.setCameraZoomFraction(zoom_level);
 }
 
 void activate_camera_tool()
 {
-	LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
+    LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
 };
 
 //
@@ -245,375 +245,375 @@ void activate_camera_tool()
 
 /*static*/ bool LLFloaterCamera::inFreeCameraMode()
 {
-	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-	if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
-	{
-		return true;
-	}
-	return false;
+    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+    if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
+    {
+        return true;
+    }
+    return false;
 }
 
 void LLFloaterCamera::resetCameraMode()
 {
-	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-	if (!floater_camera) return;
-	floater_camera->switchMode(CAMERA_CTRL_MODE_PAN);
+    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+    if (!floater_camera) return;
+    floater_camera->switchMode(CAMERA_CTRL_MODE_PAN);
 }
 
 void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
 {
-	sAppearanceEditing = editing;
-	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-	if (!floater_camera) return;
-	floater_camera->handleAvatarEditingAppearance(editing);
+    sAppearanceEditing = editing;
+    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+    if (!floater_camera) return;
+    floater_camera->handleAvatarEditingAppearance(editing);
 }
 
 void LLFloaterCamera::handleAvatarEditingAppearance(bool editing)
 {
-	//camera presets (rear, front, etc.)
-	getChildView("preset_views_list")->setEnabled(!editing);
-	getChildView("presets_btn")->setEnabled(!editing);
+    //camera presets (rear, front, etc.)
+    getChildView("preset_views_list")->setEnabled(!editing);
+    getChildView("presets_btn")->setEnabled(!editing);
 
-	//camera modes (object view, mouselook view)
-	getChildView("camera_modes_list")->setEnabled(!editing);
-	getChildView("avatarview_btn")->setEnabled(!editing);
+    //camera modes (object view, mouselook view)
+    getChildView("camera_modes_list")->setEnabled(!editing);
+    getChildView("avatarview_btn")->setEnabled(!editing);
 }
 
 void LLFloaterCamera::update()
 {
-	ECameraControlMode mode = determineMode();
-	if (mode != mCurrMode) setMode(mode);
+    ECameraControlMode mode = determineMode();
+    if (mode != mCurrMode) setMode(mode);
 }
 
 
 void LLFloaterCamera::toPrevMode()
 {
-	switchMode(mPrevMode);
+    switchMode(mPrevMode);
 }
 
 /*static*/ void LLFloaterCamera::onLeavingMouseLook()
 {
-	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-	if (floater_camera)
-	{
-		floater_camera->updateItemsSelection();
-		if(floater_camera->inFreeCameraMode())
-		{
-			activate_camera_tool();
-		}
-	}
+    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+    if (floater_camera)
+    {
+        floater_camera->updateItemsSelection();
+        if(floater_camera->inFreeCameraMode())
+        {
+            activate_camera_tool();
+        }
+    }
 }
 
 LLFloaterCamera* LLFloaterCamera::findInstance()
 {
-	return LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
+    return LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
 }
 
 void LLFloaterCamera::onOpen(const LLSD& key)
 {
-	LLFirstUse::viewPopup();
+    LLFirstUse::viewPopup();
 
-	mZoom->onOpen(key);
+    mZoom->onOpen(key);
 
-	// Returns to previous mode, see EXT-2727(View tool should remember state).
-	// In case floater was just hidden and it isn't reset the mode
-	// just update state to current one. Else go to previous.
-	if ( !mClosed )
-		updateState();
-	else
-		toPrevMode();
-	mClosed = FALSE;
+    // Returns to previous mode, see EXT-2727(View tool should remember state).
+    // In case floater was just hidden and it isn't reset the mode
+    // just update state to current one. Else go to previous.
+    if ( !mClosed )
+        updateState();
+    else
+        toPrevMode();
+    mClosed = FALSE;
 }
 
 void LLFloaterCamera::onClose(bool app_quitting)
 {
-	//We don't care of camera mode if app is quitting
-	if(app_quitting)
-		return;
-	// It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so 
-	// to avoid seeing an empty floater when reopening the control.
-	if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA)
-		mCurrMode = CAMERA_CTRL_MODE_PAN;
-	// When mCurrMode is in CAMERA_CTRL_MODE_PAN
-	// switchMode won't modify mPrevMode, so force it here.
-	// It is needed to correctly return to previous mode on open, see EXT-2727.
-	if (mCurrMode == CAMERA_CTRL_MODE_PAN)
-		mPrevMode = CAMERA_CTRL_MODE_PAN;
+    //We don't care of camera mode if app is quitting
+    if(app_quitting)
+        return;
+    // It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so 
+    // to avoid seeing an empty floater when reopening the control.
+    if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA)
+        mCurrMode = CAMERA_CTRL_MODE_PAN;
+    // When mCurrMode is in CAMERA_CTRL_MODE_PAN
+    // switchMode won't modify mPrevMode, so force it here.
+    // It is needed to correctly return to previous mode on open, see EXT-2727.
+    if (mCurrMode == CAMERA_CTRL_MODE_PAN)
+        mPrevMode = CAMERA_CTRL_MODE_PAN;
 
-	switchMode(CAMERA_CTRL_MODE_PAN);
-	mClosed = TRUE;
+    switchMode(CAMERA_CTRL_MODE_PAN);
+    mClosed = TRUE;
 
-	gAgent.setMovementLocked(FALSE);
+    gAgent.setMovementLocked(FALSE);
 }
 
 LLFloaterCamera::LLFloaterCamera(const LLSD& val)
-:	LLFloater(val),
-	mClosed(FALSE),
-	mCurrMode(CAMERA_CTRL_MODE_PAN),
-	mPrevMode(CAMERA_CTRL_MODE_PAN)
+:   LLFloater(val),
+    mClosed(FALSE),
+    mCurrMode(CAMERA_CTRL_MODE_PAN),
+    mPrevMode(CAMERA_CTRL_MODE_PAN)
 {
-	LLHints::registerHintTarget("view_popup", getHandle());
-	mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
-	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2));
+    LLHints::registerHintTarget("view_popup", getHandle());
+    mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
+    mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2));
 }
 
 // virtual
 BOOL LLFloaterCamera::postBuild()
 {
-	updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730)
+    updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730)
 
-	mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
-	mZoom = findChild<LLPanelCameraZoom>(ZOOM);
-	mTrack = getChild<LLJoystickCameraTrack>(PAN);
+    mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
+    mZoom = findChild<LLPanelCameraZoom>(ZOOM);
+    mTrack = getChild<LLJoystickCameraTrack>(PAN);
 
-	assignButton2Mode(CAMERA_CTRL_MODE_MODES,			"avatarview_btn");
-	assignButton2Mode(CAMERA_CTRL_MODE_PAN,				"pan_btn");
-	assignButton2Mode(CAMERA_CTRL_MODE_PRESETS,		"presets_btn");
+    assignButton2Mode(CAMERA_CTRL_MODE_MODES,           "avatarview_btn");
+    assignButton2Mode(CAMERA_CTRL_MODE_PAN,             "pan_btn");
+    assignButton2Mode(CAMERA_CTRL_MODE_PRESETS,     "presets_btn");
 
-	update();
+    update();
 
-	// ensure that appearance mode is handled while building. See EXT-7796.
-	handleAvatarEditingAppearance(sAppearanceEditing);
+    // ensure that appearance mode is handled while building. See EXT-7796.
+    handleAvatarEditingAppearance(sAppearanceEditing);
 
-	return LLFloater::postBuild();
+    return LLFloater::postBuild();
 }
 
-F32	LLFloaterCamera::getCurrentTransparency()
+F32 LLFloaterCamera::getCurrentTransparency()
 {
 
-	static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity");
-	static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency");
-	return llmin(camera_opacity(), active_floater_transparency());
+    static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity");
+    static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency");
+    return llmin(camera_opacity(), active_floater_transparency());
 
 }
 
 void LLFloaterCamera::onViewButtonClick(const LLSD& user_data)
 {
-	// bring up the prefs floater
-	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
-	if (prefsfloater)
-	{
-		// grab the 'view' panel from the preferences floater and
-		// bring it the front!
-		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
-		if (tabcontainer && graphicspanel)
-		{
-			tabcontainer->selectTabPanel(graphicspanel);
-		}
-	}
+    // bring up the prefs floater
+    LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
+    if (prefsfloater)
+    {
+        // grab the 'view' panel from the preferences floater and
+        // bring it the front!
+        LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+        LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
+        if (tabcontainer && graphicspanel)
+        {
+            tabcontainer->selectTabPanel(graphicspanel);
+        }
+    }
 }
 
 
 void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel)
 {
-	// copying child list and then iterating over a copy, because list itself
-	// is changed in process
-	const child_list_t child_list = *panel->getChildList();
-	child_list_t::const_reverse_iterator iter = child_list.rbegin();
-	child_list_t::const_reverse_iterator end = child_list.rend();
-	for ( ; iter != end; ++iter)
-	{
-		LLView* view = *iter;
-		LLPanel* item = dynamic_cast<LLPanel*>(view);
-		if (panel)
-			list->addItem(item);
-	}
+    // copying child list and then iterating over a copy, because list itself
+    // is changed in process
+    const child_list_t child_list = *panel->getChildList();
+    child_list_t::const_reverse_iterator iter = child_list.rbegin();
+    child_list_t::const_reverse_iterator end = child_list.rend();
+    for ( ; iter != end; ++iter)
+    {
+        LLView* view = *iter;
+        LLPanel* item = dynamic_cast<LLPanel*>(view);
+        if (panel)
+            list->addItem(item);
+    }
 
 }
 
 ECameraControlMode LLFloaterCamera::determineMode()
 {
-	if (sAppearanceEditing)
-	{
-		// this is the only enabled camera mode while editing agent appearance.
-		return CAMERA_CTRL_MODE_PAN;
-	}
+    if (sAppearanceEditing)
+    {
+        // this is the only enabled camera mode while editing agent appearance.
+        return CAMERA_CTRL_MODE_PAN;
+    }
 
-	LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool();
-	if (curr_tool == LLToolCamera::getInstance())
-	{
-		return CAMERA_CTRL_MODE_FREE_CAMERA;
-	} 
+    LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool();
+    if (curr_tool == LLToolCamera::getInstance())
+    {
+        return CAMERA_CTRL_MODE_FREE_CAMERA;
+    } 
 
-	if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
-	{
-		return CAMERA_CTRL_MODE_PRESETS;
-	}
+    if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+    {
+        return CAMERA_CTRL_MODE_PRESETS;
+    }
 
-	return CAMERA_CTRL_MODE_PAN;
+    return CAMERA_CTRL_MODE_PAN;
 }
 
 
 void clear_camera_tool()
 {
-	LLToolMgr* tool_mgr = LLToolMgr::getInstance();
-	if (tool_mgr->usingTransientTool() && 
-		tool_mgr->getCurrentTool() == LLToolCamera::getInstance())
-	{
-		tool_mgr->clearTransientTool();
-	}
+    LLToolMgr* tool_mgr = LLToolMgr::getInstance();
+    if (tool_mgr->usingTransientTool() && 
+        tool_mgr->getCurrentTool() == LLToolCamera::getInstance())
+    {
+        tool_mgr->clearTransientTool();
+    }
 }
 
 
 void LLFloaterCamera::setMode(ECameraControlMode mode)
 {
-	if (mode != mCurrMode)
-	{
-		mPrevMode = mCurrMode;
-		mCurrMode = mode;
-	}
-	
-	updateState();
+    if (mode != mCurrMode)
+    {
+        mPrevMode = mCurrMode;
+        mCurrMode = mode;
+    }
+    
+    updateState();
 }
 
 void LLFloaterCamera::switchMode(ECameraControlMode mode)
 {
-	setMode(mode);
+    setMode(mode);
 
-	switch (mode)
-	{
-	case CAMERA_CTRL_MODE_MODES:
-		if(sFreeCamera)
-		{
-			switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-		}
-		break;
+    switch (mode)
+    {
+    case CAMERA_CTRL_MODE_MODES:
+        if(sFreeCamera)
+        {
+            switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+        }
+        break;
 
-	case CAMERA_CTRL_MODE_PAN:
-		sFreeCamera = false;
-		clear_camera_tool();
-		break;
+    case CAMERA_CTRL_MODE_PAN:
+        sFreeCamera = false;
+        clear_camera_tool();
+        break;
 
-	case CAMERA_CTRL_MODE_FREE_CAMERA:
-		sFreeCamera = true;
-		activate_camera_tool();
-		break;
+    case CAMERA_CTRL_MODE_FREE_CAMERA:
+        sFreeCamera = true;
+        activate_camera_tool();
+        break;
 
-	case CAMERA_CTRL_MODE_PRESETS:
-		if(sFreeCamera)
-		{
-			switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-		}
-		break;
+    case CAMERA_CTRL_MODE_PRESETS:
+        if(sFreeCamera)
+        {
+            switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+        }
+        break;
 
-	default:
-		//normally we won't occur here
-		llassert_always(FALSE);
-	}
+    default:
+        //normally we won't occur here
+        llassert_always(FALSE);
+    }
 }
 
 
 void LLFloaterCamera::onClickBtn(ECameraControlMode mode)
 {
-	// check for a click on active button
-	if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE);
-	
-	switchMode(mode);
+    // check for a click on active button
+    if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE);
+    
+    switchMode(mode);
 
 }
 
 void LLFloaterCamera::assignButton2Mode(ECameraControlMode mode, const std::string& button_name)
 {
-	LLButton* button = getChild<LLButton>(button_name);
-	
-	button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode));
-	mMode2Button[mode] = button;
+    LLButton* button = getChild<LLButton>(button_name);
+    
+    button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode));
+    mMode2Button[mode] = button;
 }
 
 void LLFloaterCamera::updateState()
 {
-	getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode);
-	
-	bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
-																	&& CAMERA_CTRL_MODE_PRESETS == mPrevMode);
-	getChildView(PRESETS)->setVisible(show_presets);
-	
-	bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
-																	&& CAMERA_CTRL_MODE_MODES == mPrevMode);
-	getChildView("camera_modes_list")->setVisible( show_camera_modes);
+    getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode);
+    
+    bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
+                                                                    && CAMERA_CTRL_MODE_PRESETS == mPrevMode);
+    getChildView(PRESETS)->setVisible(show_presets);
+    
+    bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
+                                                                    && CAMERA_CTRL_MODE_MODES == mPrevMode);
+    getChildView("camera_modes_list")->setVisible( show_camera_modes);
 
-	updateItemsSelection();
+    updateItemsSelection();
 
-	if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode)
-	{
-		return;
-	}
+    if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode)
+    {
+        return;
+    }
 
-	//updating buttons
-	std::map<ECameraControlMode, LLButton*>::const_iterator iter = mMode2Button.begin();
-	for (; iter != mMode2Button.end(); ++iter)
-	{
-		iter->second->setToggleState(iter->first == mCurrMode);
-	}
+    //updating buttons
+    std::map<ECameraControlMode, LLButton*>::const_iterator iter = mMode2Button.begin();
+    for (; iter != mMode2Button.end(); ++iter)
+    {
+        iter->second->setToggleState(iter->first == mCurrMode);
+    }
 }
 
 void LLFloaterCamera::updateItemsSelection()
 {
-	ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
-	LLSD argument;
-	argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW;
-	getChild<LLPanelCameraItem>("rear_view")->setValue(argument);
-	argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW;
-	getChild<LLPanelCameraItem>("group_view")->setValue(argument);
-	argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW;
-	getChild<LLPanelCameraItem>("front_view")->setValue(argument);
-	argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK;
-	getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument);
-	argument["selected"] = mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA;
-	getChild<LLPanelCameraItem>("object_view")->setValue(argument);
+    ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
+    LLSD argument;
+    argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW;
+    getChild<LLPanelCameraItem>("rear_view")->setValue(argument);
+    argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW;
+    getChild<LLPanelCameraItem>("group_view")->setValue(argument);
+    argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW;
+    getChild<LLPanelCameraItem>("front_view")->setValue(argument);
+    argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK;
+    getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument);
+    argument["selected"] = mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA;
+    getChild<LLPanelCameraItem>("object_view")->setValue(argument);
 }
 
 void LLFloaterCamera::onClickCameraItem(const LLSD& param)
 {
-	std::string name = param.asString();
-
-	if ("mouselook_view" == name)
-	{
-		gAgentCamera.changeCameraToMouselook();
-	}
-	else if ("object_view" == name)
-	{
-		LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
-		if (camera_floater)
-		camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-	}
-	else
-	{
-		switchToPreset(name);
-	}
-
-	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
-	if (camera_floater)
-	{
-		camera_floater->updateItemsSelection();
-		camera_floater->fromFreeToPresets();
-	}
+    std::string name = param.asString();
+
+    if ("mouselook_view" == name)
+    {
+        gAgentCamera.changeCameraToMouselook();
+    }
+    else if ("object_view" == name)
+    {
+        LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
+        if (camera_floater)
+        camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+    }
+    else
+    {
+        switchToPreset(name);
+    }
+
+    LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
+    if (camera_floater)
+    {
+        camera_floater->updateItemsSelection();
+        camera_floater->fromFreeToPresets();
+    }
 }
 
 /*static*/
 void LLFloaterCamera::switchToPreset(const std::string& name)
 {
-	sFreeCamera = false;
-	clear_camera_tool();
-	if ("rear_view" == name)
-	{
-		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
-	}
-	else if ("group_view" == name)
-	{
-		gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
-	}
-	else if ("front_view" == name)
-	{
-		gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
-	}
+    sFreeCamera = false;
+    clear_camera_tool();
+    if ("rear_view" == name)
+    {
+        gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+    }
+    else if ("group_view" == name)
+    {
+        gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
+    }
+    else if ("front_view" == name)
+    {
+        gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
+    }
 }
 
 void LLFloaterCamera::fromFreeToPresets()
 {
-	if (!sFreeCamera && mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && mPrevMode == CAMERA_CTRL_MODE_PRESETS)
-	{
-		switchMode(CAMERA_CTRL_MODE_PRESETS);
-	}
+    if (!sFreeCamera && mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && mPrevMode == CAMERA_CTRL_MODE_PRESETS)
+    {
+        switchMode(CAMERA_CTRL_MODE_PRESETS);
+    }
 }
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 481e9aec1b..1b24b143bf 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -39,95 +39,95 @@ class LLPanelCameraZoom;
 
 enum ECameraControlMode
 {
-	CAMERA_CTRL_MODE_MODES,
-	CAMERA_CTRL_MODE_PAN,
-	CAMERA_CTRL_MODE_FREE_CAMERA,
-	CAMERA_CTRL_MODE_PRESETS
+    CAMERA_CTRL_MODE_MODES,
+    CAMERA_CTRL_MODE_PAN,
+    CAMERA_CTRL_MODE_FREE_CAMERA,
+    CAMERA_CTRL_MODE_PRESETS
 };
 
 class LLFloaterCamera : public LLFloater
 {
-	friend class LLFloaterReg;
-	
+    friend class LLFloaterReg;
+    
 public:
 
-	/* whether in free camera mode */
-	static bool inFreeCameraMode();
-	/* callback for camera items selection changing */
-	static void onClickCameraItem(const LLSD& param);
+    /* whether in free camera mode */
+    static bool inFreeCameraMode();
+    /* callback for camera items selection changing */
+    static void onClickCameraItem(const LLSD& param);
 
-	static void onLeavingMouseLook();
+    static void onLeavingMouseLook();
 
-	/** resets current camera mode to orbit mode */
-	static void resetCameraMode();
+    /** resets current camera mode to orbit mode */
+    static void resetCameraMode();
 
-	/** Called when Avatar is entered/exited editing appearance mode */
-	static void onAvatarEditingAppearance(bool editing);
+    /** Called when Avatar is entered/exited editing appearance mode */
+    static void onAvatarEditingAppearance(bool editing);
 
-	/* determines actual mode and updates ui */
-	void update();
+    /* determines actual mode and updates ui */
+    void update();
 
-	/*switch to one of the camera presets (front, rear, side)*/
-	static void switchToPreset(const std::string& name);
+    /*switch to one of the camera presets (front, rear, side)*/
+    static void switchToPreset(const std::string& name);
 
-	/* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and
-	   are not in free camera mode*/
-	void fromFreeToPresets();
+    /* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and
+       are not in free camera mode*/
+    void fromFreeToPresets();
 
-	virtual void onOpen(const LLSD& key);
-	virtual void onClose(bool app_quitting);
+    virtual void onOpen(const LLSD& key);
+    virtual void onClose(bool app_quitting);
 
-	LLJoystickCameraRotate* mRotate;
-	LLPanelCameraZoom*	mZoom;
-	LLJoystickCameraTrack*	mTrack;
+    LLJoystickCameraRotate* mRotate;
+    LLPanelCameraZoom*  mZoom;
+    LLJoystickCameraTrack*  mTrack;
 
 private:
 
-	LLFloaterCamera(const LLSD& val);
-	~LLFloaterCamera() {};
+    LLFloaterCamera(const LLSD& val);
+    ~LLFloaterCamera() {};
 
-	/* return instance if it exists - created by LLFloaterReg */
-	static LLFloaterCamera* findInstance();
+    /* return instance if it exists - created by LLFloaterReg */
+    static LLFloaterCamera* findInstance();
 
-	/*virtual*/ BOOL postBuild();
+    /*virtual*/ BOOL postBuild();
 
-	F32 getCurrentTransparency();
+    F32 getCurrentTransparency();
 
-	void onViewButtonClick(const LLSD& user_data);
+    void onViewButtonClick(const LLSD& user_data);
 
-	ECameraControlMode determineMode();
+    ECameraControlMode determineMode();
 
-	/* resets to the previous mode */
-	void toPrevMode();
+    /* resets to the previous mode */
+    void toPrevMode();
 
-	/* sets a new mode and performs related actions */
-	void switchMode(ECameraControlMode mode);
+    /* sets a new mode and performs related actions */
+    void switchMode(ECameraControlMode mode);
 
-	/* sets a new mode preserving previous one and updates ui*/
-	void setMode(ECameraControlMode mode);
+    /* sets a new mode preserving previous one and updates ui*/
+    void setMode(ECameraControlMode mode);
 
-	/* updates the state (UI) according to the current mode */
-	void updateState();
+    /* updates the state (UI) according to the current mode */
+    void updateState();
 
-	/* update camera modes items selection and camera preset items selection according to the currently selected preset */
-	void updateItemsSelection();
+    /* update camera modes items selection and camera preset items selection according to the currently selected preset */
+    void updateItemsSelection();
 
-	void onClickBtn(ECameraControlMode mode);
-	void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
-	
-	// fills flatlist with items from given panel
-	void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
+    void onClickBtn(ECameraControlMode mode);
+    void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
+    
+    // fills flatlist with items from given panel
+    void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
 
-	void handleAvatarEditingAppearance(bool editing);
+    void handleAvatarEditingAppearance(bool editing);
 
-	// set to true when free camera mode is selected in modes list
-	// remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
-	static bool sFreeCamera;
-	static bool sAppearanceEditing;
-	BOOL mClosed;
-	ECameraControlMode mPrevMode;
-	ECameraControlMode mCurrMode;
-	std::map<ECameraControlMode, LLButton*> mMode2Button;
+    // set to true when free camera mode is selected in modes list
+    // remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
+    static bool sFreeCamera;
+    static bool sAppearanceEditing;
+    BOOL mClosed;
+    ECameraControlMode mPrevMode;
+    ECameraControlMode mCurrMode;
+    std::map<ECameraControlMode, LLButton*> mMode2Button;
 };
 
 /**
@@ -138,33 +138,33 @@ private:
  * it's items are used inside of flatlist.
  */
 class LLPanelCameraItem 
-	: public LLPanel
+    : public LLPanel
 {
 public:
-	struct Params :	public LLInitParam::Block<Params, LLPanel::Params>
-	{
-		Optional<LLIconCtrl::Params> icon_over;
-		Optional<LLIconCtrl::Params> icon_selected;
-		Optional<LLIconCtrl::Params> picture;
-		Optional<LLIconCtrl::Params> selected_picture;
-
-		Optional<LLTextBox::Params> text;
-		Optional<CommitCallbackParam> mousedown_callback;
-		Params();
-	};
-	/*virtual*/ BOOL postBuild();
-	/** setting on/off background icon to indicate selected state */
-	/*virtual*/ void setValue(const LLSD& value);
-	// sends commit signal
-	void onAnyMouseClick();
+    struct Params : public LLInitParam::Block<Params, LLPanel::Params>
+    {
+        Optional<LLIconCtrl::Params> icon_over;
+        Optional<LLIconCtrl::Params> icon_selected;
+        Optional<LLIconCtrl::Params> picture;
+        Optional<LLIconCtrl::Params> selected_picture;
+
+        Optional<LLTextBox::Params> text;
+        Optional<CommitCallbackParam> mousedown_callback;
+        Params();
+    };
+    /*virtual*/ BOOL postBuild();
+    /** setting on/off background icon to indicate selected state */
+    /*virtual*/ void setValue(const LLSD& value);
+    // sends commit signal
+    void onAnyMouseClick();
 protected:
-	friend class LLUICtrlFactory;
-	LLPanelCameraItem(const Params&);
-	LLIconCtrl* mIconOver;
-	LLIconCtrl* mIconSelected;
-	LLIconCtrl* mPicture;
-	LLIconCtrl* mPictureSelected;
-	LLTextBox* mText;
+    friend class LLUICtrlFactory;
+    LLPanelCameraItem(const Params&);
+    LLIconCtrl* mIconOver;
+    LLIconCtrl* mIconSelected;
+    LLIconCtrl* mPicture;
+    LLIconCtrl* mPictureSelected;
+    LLTextBox* mText;
 };
 
 #endif
diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp
index bd62849b42..dd8117f95f 100644
--- a/indra/newview/llfloaterdeleteprefpreset.cpp
+++ b/indra/newview/llfloaterdeleteprefpreset.cpp
@@ -37,65 +37,65 @@
 #include "llfloaterreg.h"
 
 LLFloaterDeletePrefPreset::LLFloaterDeletePrefPreset(const LLSD &key)
-:	LLFloater(key)
+:   LLFloater(key)
 {
 }
 
 // virtual
 BOOL LLFloaterDeletePrefPreset::postBuild()
 {
-	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-	if (preferences)
-	{
-		preferences->addDependentFloater(this);
-	}
-	getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this));
-	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this));
-	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this));
-
-	return TRUE;
+    LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+    if (preferences)
+    {
+        preferences->addDependentFloater(this);
+    }
+    getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this));
+    getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this));
+    LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this));
+
+    return TRUE;
 }
 
 void LLFloaterDeletePrefPreset::onOpen(const LLSD& key)
 {
-	mSubdirectory = key.asString();
-	std::string floater_title = getString(std::string("title_") + mSubdirectory);
-	setTitle(floater_title);
+    mSubdirectory = key.asString();
+    std::string floater_title = getString(std::string("title_") + mSubdirectory);
+    setTitle(floater_title);
 
-	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-	EDefaultOptions option = DEFAULT_HIDE;
-	bool action;
-	action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+    EDefaultOptions option = DEFAULT_HIDE;
+    bool action;
+    action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 
-	LLButton* delete_btn = getChild<LLButton>("delete");
-	delete_btn->setEnabled(action);
+    LLButton* delete_btn = getChild<LLButton>("delete");
+    delete_btn->setEnabled(action);
 }
 
 void LLFloaterDeletePrefPreset::onBtnDelete()
 {
-	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-	std::string name = combo->getSimple();
+    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+    std::string name = combo->getSimple();
 
-	if (!LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name))
-	{
-		LLSD args;
-		args["NAME"] = name;
-		LLNotificationsUtil::add("PresetNotDeleted", args);
-	}
+    if (!LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name))
+    {
+        LLSD args;
+        args["NAME"] = name;
+        LLNotificationsUtil::add("PresetNotDeleted", args);
+    }
 
-	closeFloater();
+    closeFloater();
 }
 
 void LLFloaterDeletePrefPreset::onPresetsListChange()
 {
-	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
 
-	EDefaultOptions option = DEFAULT_HIDE;
+    EDefaultOptions option = DEFAULT_HIDE;
 
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterDeletePrefPreset::onBtnCancel()
 {
-	closeFloater();
+    closeFloater();
 }
diff --git a/indra/newview/llfloaterloadprefpreset.cpp b/indra/newview/llfloaterloadprefpreset.cpp
index fa17a9d40e..0584bf7e09 100644
--- a/indra/newview/llfloaterloadprefpreset.cpp
+++ b/indra/newview/llfloaterloadprefpreset.cpp
@@ -36,57 +36,57 @@
 #include "llviewercontrol.h"
 
 LLFloaterLoadPrefPreset::LLFloaterLoadPrefPreset(const LLSD &key)
-:	LLFloater(key)
+:   LLFloater(key)
 {
 }
 
 // virtual
 BOOL LLFloaterLoadPrefPreset::postBuild()
 {
-	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-	if (preferences)
-	{
-		preferences->addDependentFloater(this);
-	}
-	getChild<LLButton>("ok")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnOk, this));
-	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnCancel, this));
-	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterLoadPrefPreset::onPresetsListChange, this));
-
-	return TRUE;
+    LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+    if (preferences)
+    {
+        preferences->addDependentFloater(this);
+    }
+    getChild<LLButton>("ok")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnOk, this));
+    getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnCancel, this));
+    LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterLoadPrefPreset::onPresetsListChange, this));
+
+    return TRUE;
 }
 
 void LLFloaterLoadPrefPreset::onOpen(const LLSD& key)
 {
-	mSubdirectory = key.asString();
-	std::string floater_title = getString(std::string("title_") + mSubdirectory);
+    mSubdirectory = key.asString();
+    std::string floater_title = getString(std::string("title_") + mSubdirectory);
 
-	setTitle(floater_title);
+    setTitle(floater_title);
 
-	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
 
-	EDefaultOptions option = DEFAULT_TOP;
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+    EDefaultOptions option = DEFAULT_TOP;
+    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterLoadPrefPreset::onPresetsListChange()
 {
-	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
 
-	EDefaultOptions option = DEFAULT_TOP;
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+    EDefaultOptions option = DEFAULT_TOP;
+    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterLoadPrefPreset::onBtnCancel()
 {
-	closeFloater();
+    closeFloater();
 }
 
 void LLFloaterLoadPrefPreset::onBtnOk()
 {
-	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-	std::string name = combo->getSimple();
+    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+    std::string name = combo->getSimple();
 
-	LLPresetsManager::getInstance()->loadPreset(mSubdirectory, name);
+    LLPresetsManager::getInstance()->loadPreset(mSubdirectory, name);
 
-	closeFloater();
+    closeFloater();
 }
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 6b4e4ceeac..ee85a46405 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -139,35 +139,35 @@ static const F32 ARC_LIMIT_MAP_SCALE = (MAX_ARC_LOG - MIN_ARC_LOG) / (MAX_INDIRE
 class LLVoiceSetKeyDialog : public LLModalDialog
 {
 public:
-	LLVoiceSetKeyDialog(const LLSD& key);
-	~LLVoiceSetKeyDialog();
-	
-	/*virtual*/ BOOL postBuild();
-	
-	void setParent(LLFloaterPreference* parent) { mParent = parent; }
-	
-	BOOL handleKeyHere(KEY key, MASK mask);
-	static void onCancel(void* user_data);
-		
+    LLVoiceSetKeyDialog(const LLSD& key);
+    ~LLVoiceSetKeyDialog();
+    
+    /*virtual*/ BOOL postBuild();
+    
+    void setParent(LLFloaterPreference* parent) { mParent = parent; }
+    
+    BOOL handleKeyHere(KEY key, MASK mask);
+    static void onCancel(void* user_data);
+        
 private:
-	LLFloaterPreference* mParent;
+    LLFloaterPreference* mParent;
 };
 
 LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
   : LLModalDialog(key),
-	mParent(NULL)
+    mParent(NULL)
 {
 }
 
 //virtual
 BOOL LLVoiceSetKeyDialog::postBuild()
 {
-	childSetAction("Cancel", onCancel, this);
-	getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
-	
-	gFocusMgr.setKeystrokesOnly(TRUE);
-	
-	return TRUE;
+    childSetAction("Cancel", onCancel, this);
+    getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
+    
+    gFocusMgr.setKeystrokesOnly(TRUE);
+    
+    return TRUE;
 }
 
 LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
@@ -176,25 +176,25 @@ LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
 
 BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
 {
-	BOOL result = TRUE;
-	
-	if (key == 'Q' && mask == MASK_CONTROL)
-	{
-		result = FALSE;
-	}
-	else if (mParent)
-	{
-		mParent->setKey(key);
-	}
-	closeFloater();
-	return result;
+    BOOL result = TRUE;
+    
+    if (key == 'Q' && mask == MASK_CONTROL)
+    {
+        result = FALSE;
+    }
+    else if (mParent)
+    {
+        mParent->setKey(key);
+    }
+    closeFloater();
+    return result;
 }
 
 //static
 void LLVoiceSetKeyDialog::onCancel(void* user_data)
 {
-	LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
-	self->closeFloater();
+    LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
+    self->closeFloater();
 }
 
 
@@ -204,8 +204,8 @@ void LLVoiceSetKeyDialog::onCancel(void* user_data)
 // if creating/destroying these is too slow, we'll need to create
 // a static member and update all our static callbacks
 
-void handleNameTagOptionChanged(const LLSD& newvalue);	
-void handleDisplayNamesOptionChanged(const LLSD& newvalue);	
+void handleNameTagOptionChanged(const LLSD& newvalue);  
+void handleDisplayNamesOptionChanged(const LLSD& newvalue); 
 bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response);
 bool callback_clear_cache(const LLSD& notification, const LLSD& response);
 
@@ -216,110 +216,110 @@ void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator);
 
 bool callback_clear_cache(const LLSD& notification, const LLSD& response)
 {
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if ( option == 0 ) // YES
-	{
-		// flag client texture cache for clearing next time the client runs
-		gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
-		LLNotificationsUtil::add("CacheWillClear");
-	}
+    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+    if ( option == 0 ) // YES
+    {
+        // flag client texture cache for clearing next time the client runs
+        gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
+        LLNotificationsUtil::add("CacheWillClear");
+    }
 
-	return false;
+    return false;
 }
 
 bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response)
 {
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if ( option == 0 ) // YES
-	{
-		// clean web
-		LLViewerMedia::clearAllCaches();
-		LLViewerMedia::clearAllCookies();
-		
-		// clean nav bar history
-		LLNavigationBar::getInstance()->clearHistoryCache();
-		
-		// flag client texture cache for clearing next time the client runs
-		gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
-		LLNotificationsUtil::add("CacheWillClear");
-
-		LLSearchHistory::getInstance()->clearHistory();
-		LLSearchHistory::getInstance()->save();
-		LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
-		search_ctrl->clearHistory();
-
-		LLTeleportHistoryStorage::getInstance()->purgeItems();
-		LLTeleportHistoryStorage::getInstance()->save();
-	}
-	
-	return false;
+    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+    if ( option == 0 ) // YES
+    {
+        // clean web
+        LLViewerMedia::clearAllCaches();
+        LLViewerMedia::clearAllCookies();
+        
+        // clean nav bar history
+        LLNavigationBar::getInstance()->clearHistoryCache();
+        
+        // flag client texture cache for clearing next time the client runs
+        gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
+        LLNotificationsUtil::add("CacheWillClear");
+
+        LLSearchHistory::getInstance()->clearHistory();
+        LLSearchHistory::getInstance()->save();
+        LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
+        search_ctrl->clearHistory();
+
+        LLTeleportHistoryStorage::getInstance()->purgeItems();
+        LLTeleportHistoryStorage::getInstance()->save();
+    }
+    
+    return false;
 }
 
 void handleNameTagOptionChanged(const LLSD& newvalue)
 {
-	LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
-	LLVOAvatar::invalidateNameTags();
+    LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
+    LLVOAvatar::invalidateNameTags();
 }
 
 void handleDisplayNamesOptionChanged(const LLSD& newvalue)
 {
-	LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean());
-	LLVOAvatar::invalidateNameTags();
+    LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean());
+    LLVOAvatar::invalidateNameTags();
 }
 
 void handleAppearanceCameraMovementChanged(const LLSD& newvalue)
 {
-	if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
-	{
-		gAgentCamera.changeCameraToDefault();
-		gAgentCamera.resetView();
-	}
+    if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
+    {
+        gAgentCamera.changeCameraToDefault();
+        gAgentCamera.resetView();
+    }
 }
 
 /*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
 {
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if (0 == option && floater )
-	{
-		if ( floater )
-		{
-			floater->setAllIgnored();
-		//	LLFirstUse::disableFirstUse();
-			floater->buildPopupLists();
-		}
-	}
-	return false;
+    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+    if (0 == option && floater )
+    {
+        if ( floater )
+        {
+            floater->setAllIgnored();
+        //  LLFirstUse::disableFirstUse();
+            floater->buildPopupLists();
+        }
+    }
+    return false;
 }
 
 bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
 {
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if ( 0 == option && floater )
-	{
-		if ( floater )
-		{
-			floater->resetAllIgnored();
-			//LLFirstUse::resetFirstUse();
-			floater->buildPopupLists();
-		}
-	}
-	return false;
+    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+    if ( 0 == option && floater )
+    {
+        if ( floater )
+        {
+            floater->resetAllIgnored();
+            //LLFirstUse::resetFirstUse();
+            floater->buildPopupLists();
+        }
+    }
+    return false;
 }
 */
 
 void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
 {
-	numerator = 0;
-	denominator = 0;
-	for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
-	{
-		if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
-		{
-			numerator = ll_round(decimal_val * test_denominator);
-			denominator = ll_round(test_denominator);
-			break;
-		}
-	}
+    numerator = 0;
+    denominator = 0;
+    for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
+    {
+        if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
+        {
+            numerator = ll_round(decimal_val * test_denominator);
+            denominator = ll_round(test_denominator);
+            break;
+        }
+    }
 }
 // static
 std::string LLFloaterPreference::sSkin = "";
@@ -327,1537 +327,1537 @@ std::string LLFloaterPreference::sSkin = "";
 // LLFloaterPreference
 
 LLFloaterPreference::LLFloaterPreference(const LLSD& key)
-	: LLFloater(key),
-	mGotPersonalInfo(false),
-	mOriginalIMViaEmail(false),
-	mLanguageChanged(false),
-	mAvatarDataInitialized(false),
-	mClickActionDirty(false)
-{
-	LLConversationLog::instance().addObserver(this);
-
-	//Build Floater is now Called from 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
-	
-	static bool registered_dialog = false;
-	if (!registered_dialog)
-	{
-		LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
-		registered_dialog = true;
-	}
-	
-	mCommitCallbackRegistrar.add("Pref.Cancel",				boost::bind(&LLFloaterPreference::onBtnCancel, this, _2));
-	mCommitCallbackRegistrar.add("Pref.OK",					boost::bind(&LLFloaterPreference::onBtnOK, this, _2));
-	
-	mCommitCallbackRegistrar.add("Pref.ClearCache",				boost::bind(&LLFloaterPreference::onClickClearCache, this));
-	mCommitCallbackRegistrar.add("Pref.WebClearCache",			boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
-	mCommitCallbackRegistrar.add("Pref.SetCache",				boost::bind(&LLFloaterPreference::onClickSetCache, this));
-	mCommitCallbackRegistrar.add("Pref.ResetCache",				boost::bind(&LLFloaterPreference::onClickResetCache, this));
-	mCommitCallbackRegistrar.add("Pref.ClickSkin",				boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2));
-	mCommitCallbackRegistrar.add("Pref.SelectSkin",				boost::bind(&LLFloaterPreference::onSelectSkin, this));
-	mCommitCallbackRegistrar.add("Pref.VoiceSetKey",			boost::bind(&LLFloaterPreference::onClickSetKey, this));
-	mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse",	boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
-	mCommitCallbackRegistrar.add("Pref.SetSounds",				boost::bind(&LLFloaterPreference::onClickSetSounds, this));
-	mCommitCallbackRegistrar.add("Pref.ClickEnablePopup",		boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
-	mCommitCallbackRegistrar.add("Pref.ClickDisablePopup",		boost::bind(&LLFloaterPreference::onClickDisablePopup, this));	
-	mCommitCallbackRegistrar.add("Pref.LogPath",				boost::bind(&LLFloaterPreference::onClickLogPath, this));
-	mCommitCallbackRegistrar.add("Pref.RenderExceptions",       boost::bind(&LLFloaterPreference::onClickRenderExceptions, this));
-	mCommitCallbackRegistrar.add("Pref.HardwareDefaults",		boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
-	mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable",	boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this));
-	mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",	boost::bind(&LLFloaterPreference::updateMaxComplexity, this));
-	mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",		boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
-	mCommitCallbackRegistrar.add("Pref.WindowedMod",			boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
-	mCommitCallbackRegistrar.add("Pref.UpdateSliderText",		boost::bind(&LLFloaterPreference::refreshUI,this));
-	mCommitCallbackRegistrar.add("Pref.QualityPerformance",		boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
-	mCommitCallbackRegistrar.add("Pref.applyUIColor",			boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
-	mCommitCallbackRegistrar.add("Pref.getUIColor",				boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
-	mCommitCallbackRegistrar.add("Pref.MaturitySettings",		boost::bind(&LLFloaterPreference::onChangeMaturity, this));
-	mCommitCallbackRegistrar.add("Pref.BlockList",				boost::bind(&LLFloaterPreference::onClickBlockList, this));
-	mCommitCallbackRegistrar.add("Pref.Proxy",					boost::bind(&LLFloaterPreference::onClickProxySettings, this));
-	mCommitCallbackRegistrar.add("Pref.TranslationSettings",	boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
-	mCommitCallbackRegistrar.add("Pref.AutoReplace",            boost::bind(&LLFloaterPreference::onClickAutoReplace, this));
-	mCommitCallbackRegistrar.add("Pref.PermsDefault",           boost::bind(&LLFloaterPreference::onClickPermsDefault, this));
-	mCommitCallbackRegistrar.add("Pref.SpellChecker",           boost::bind(&LLFloaterPreference::onClickSpellChecker, this));
-	mCommitCallbackRegistrar.add("Pref.Advanced",				boost::bind(&LLFloaterPreference::onClickAdvanced, this));
-
-	sSkin = gSavedSettings.getString("SkinCurrent");
-
-	mCommitCallbackRegistrar.add("Pref.ClickActionChange",		boost::bind(&LLFloaterPreference::onClickActionChange, this));
-
-	gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));	
-	gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));	
-	gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged,  _2));
-
-	gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged,  _2));
-
-	LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
-
-	mCommitCallbackRegistrar.add("Pref.ClearLog",				boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance()));
-	mCommitCallbackRegistrar.add("Pref.DeleteTranscripts",      boost::bind(&LLFloaterPreference::onDeleteTranscripts, this));
+    : LLFloater(key),
+    mGotPersonalInfo(false),
+    mOriginalIMViaEmail(false),
+    mLanguageChanged(false),
+    mAvatarDataInitialized(false),
+    mClickActionDirty(false)
+{
+    LLConversationLog::instance().addObserver(this);
+
+    //Build Floater is now Called from  LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
+    
+    static bool registered_dialog = false;
+    if (!registered_dialog)
+    {
+        LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
+        registered_dialog = true;
+    }
+    
+    mCommitCallbackRegistrar.add("Pref.Cancel",             boost::bind(&LLFloaterPreference::onBtnCancel, this, _2));
+    mCommitCallbackRegistrar.add("Pref.OK",                 boost::bind(&LLFloaterPreference::onBtnOK, this, _2));
+    
+    mCommitCallbackRegistrar.add("Pref.ClearCache",             boost::bind(&LLFloaterPreference::onClickClearCache, this));
+    mCommitCallbackRegistrar.add("Pref.WebClearCache",          boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
+    mCommitCallbackRegistrar.add("Pref.SetCache",               boost::bind(&LLFloaterPreference::onClickSetCache, this));
+    mCommitCallbackRegistrar.add("Pref.ResetCache",             boost::bind(&LLFloaterPreference::onClickResetCache, this));
+    mCommitCallbackRegistrar.add("Pref.ClickSkin",              boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2));
+    mCommitCallbackRegistrar.add("Pref.SelectSkin",             boost::bind(&LLFloaterPreference::onSelectSkin, this));
+    mCommitCallbackRegistrar.add("Pref.VoiceSetKey",            boost::bind(&LLFloaterPreference::onClickSetKey, this));
+    mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse",    boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
+    mCommitCallbackRegistrar.add("Pref.SetSounds",              boost::bind(&LLFloaterPreference::onClickSetSounds, this));
+    mCommitCallbackRegistrar.add("Pref.ClickEnablePopup",       boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
+    mCommitCallbackRegistrar.add("Pref.ClickDisablePopup",      boost::bind(&LLFloaterPreference::onClickDisablePopup, this));  
+    mCommitCallbackRegistrar.add("Pref.LogPath",                boost::bind(&LLFloaterPreference::onClickLogPath, this));
+    mCommitCallbackRegistrar.add("Pref.RenderExceptions",       boost::bind(&LLFloaterPreference::onClickRenderExceptions, this));
+    mCommitCallbackRegistrar.add("Pref.HardwareDefaults",       boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
+    mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable",  boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this));
+    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",    boost::bind(&LLFloaterPreference::updateMaxComplexity, this));
+    mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",     boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
+    mCommitCallbackRegistrar.add("Pref.WindowedMod",            boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
+    mCommitCallbackRegistrar.add("Pref.UpdateSliderText",       boost::bind(&LLFloaterPreference::refreshUI,this));
+    mCommitCallbackRegistrar.add("Pref.QualityPerformance",     boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
+    mCommitCallbackRegistrar.add("Pref.applyUIColor",           boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
+    mCommitCallbackRegistrar.add("Pref.getUIColor",             boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
+    mCommitCallbackRegistrar.add("Pref.MaturitySettings",       boost::bind(&LLFloaterPreference::onChangeMaturity, this));
+    mCommitCallbackRegistrar.add("Pref.BlockList",              boost::bind(&LLFloaterPreference::onClickBlockList, this));
+    mCommitCallbackRegistrar.add("Pref.Proxy",                  boost::bind(&LLFloaterPreference::onClickProxySettings, this));
+    mCommitCallbackRegistrar.add("Pref.TranslationSettings",    boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
+    mCommitCallbackRegistrar.add("Pref.AutoReplace",            boost::bind(&LLFloaterPreference::onClickAutoReplace, this));
+    mCommitCallbackRegistrar.add("Pref.PermsDefault",           boost::bind(&LLFloaterPreference::onClickPermsDefault, this));
+    mCommitCallbackRegistrar.add("Pref.SpellChecker",           boost::bind(&LLFloaterPreference::onClickSpellChecker, this));
+    mCommitCallbackRegistrar.add("Pref.Advanced",               boost::bind(&LLFloaterPreference::onClickAdvanced, this));
+
+    sSkin = gSavedSettings.getString("SkinCurrent");
+
+    mCommitCallbackRegistrar.add("Pref.ClickActionChange",      boost::bind(&LLFloaterPreference::onClickActionChange, this));
+
+    gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));   
+    gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2)); 
+    gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged,  _2));
+
+    gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged,  _2));
+
+    LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
+
+    mCommitCallbackRegistrar.add("Pref.ClearLog",               boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance()));
+    mCommitCallbackRegistrar.add("Pref.DeleteTranscripts",      boost::bind(&LLFloaterPreference::onDeleteTranscripts, this));
 }
 
 void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type )
 {
-	if ( APT_PROPERTIES == type )
-	{
-		const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData );
-		if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null))
-		{
-			storeAvatarProperties( pAvatarData );
-			processProfileProperties( pAvatarData );
-		}
-	}	
+    if ( APT_PROPERTIES == type )
+    {
+        const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData );
+        if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null))
+        {
+            storeAvatarProperties( pAvatarData );
+            processProfileProperties( pAvatarData );
+        }
+    }   
 }
 
 void LLFloaterPreference::storeAvatarProperties( const LLAvatarData* pAvatarData )
 {
-	if (LLStartUp::getStartupState() == STATE_STARTED)
-	{
-		mAvatarProperties.avatar_id		= pAvatarData->avatar_id;
-		mAvatarProperties.image_id		= pAvatarData->image_id;
-		mAvatarProperties.fl_image_id   = pAvatarData->fl_image_id;
-		mAvatarProperties.about_text	= pAvatarData->about_text;
-		mAvatarProperties.fl_about_text = pAvatarData->fl_about_text;
-		mAvatarProperties.profile_url   = pAvatarData->profile_url;
-		mAvatarProperties.flags		    = pAvatarData->flags;
-		mAvatarProperties.allow_publish	= pAvatarData->flags & AVATAR_ALLOW_PUBLISH;
-
-		mAvatarDataInitialized = true;
-	}
+    if (LLStartUp::getStartupState() == STATE_STARTED)
+    {
+        mAvatarProperties.avatar_id     = pAvatarData->avatar_id;
+        mAvatarProperties.image_id      = pAvatarData->image_id;
+        mAvatarProperties.fl_image_id   = pAvatarData->fl_image_id;
+        mAvatarProperties.about_text    = pAvatarData->about_text;
+        mAvatarProperties.fl_about_text = pAvatarData->fl_about_text;
+        mAvatarProperties.profile_url   = pAvatarData->profile_url;
+        mAvatarProperties.flags         = pAvatarData->flags;
+        mAvatarProperties.allow_publish = pAvatarData->flags & AVATAR_ALLOW_PUBLISH;
+
+        mAvatarDataInitialized = true;
+    }
 }
 
 void LLFloaterPreference::processProfileProperties(const LLAvatarData* pAvatarData )
 {
-	getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) );	
+    getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) );  
 }
 
 void LLFloaterPreference::saveAvatarProperties( void )
 {
-	const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue();
+    const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue();
 
-	if (allowPublish)
-	{
-		mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH;
-	}
+    if (allowPublish)
+    {
+        mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH;
+    }
 
-	//
-	// NOTE: We really don't want to send the avatar properties unless we absolutely
-	//       need to so we can avoid the accidental profile reset bug, so, if we're
-	//       logged in, the avatar data has been initialized and we have a state change
-	//       for the "allow publish" flag, then set the flag to its new value and send
-	//       the properties update.
-	//
-	// NOTE: The only reason we can not remove this update altogether is because of the
-	//       "allow publish" flag, the last remaining profile setting in the viewer
-	//       that doesn't exist in the web profile.
-	//
-	if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish))
-	{
-		mAvatarProperties.allow_publish = allowPublish;
+    //
+    // NOTE: We really don't want to send the avatar properties unless we absolutely
+    //       need to so we can avoid the accidental profile reset bug, so, if we're
+    //       logged in, the avatar data has been initialized and we have a state change
+    //       for the "allow publish" flag, then set the flag to its new value and send
+    //       the properties update.
+    //
+    // NOTE: The only reason we can not remove this update altogether is because of the
+    //       "allow publish" flag, the last remaining profile setting in the viewer
+    //       that doesn't exist in the web profile.
+    //
+    if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish))
+    {
+        mAvatarProperties.allow_publish = allowPublish;
 
-		LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties );
-	}
+        LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties );
+    }
 }
 
 BOOL LLFloaterPreference::postBuild()
 {
-	gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
+    gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
 
-	gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged));
+    gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged));
 
-	gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2));
+    gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2));
 
-	gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this));
+    gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this));
 
-	gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this));
-	gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this));
-	gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this));
-	gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this));
+    gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this));
+    gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this));
+    gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this));
+    gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this));
 
-	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-	if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
-		tabcontainer->selectFirstTab();
+    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+    if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
+        tabcontainer->selectFirstTab();
 
-	getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227)
-	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
-	setCacheLocation(cache_location);
+    getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227)
+    std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
+    setCacheLocation(cache_location);
 
-	getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable
+    getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable
 
-	getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this));
+    getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this));
 
-	getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions"));
-	getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions"));
-	getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions"));
-	getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions"));
-	getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions"));
-	getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions"));
+    getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions"));
+    getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions"));
+    getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions"));
+    getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions"));
+    getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions"));
+    getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions"));
 
-	// if floater is opened before login set default localized do not disturb message
-	if (LLStartUp::getStartupState() < STATE_STARTED)
-	{
-		gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
-	}
+    // if floater is opened before login set default localized do not disturb message
+    if (LLStartUp::getStartupState() < STATE_STARTED)
+    {
+        gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
+    }
 
-	// set 'enable' property for 'Clear log...' button
-	changed();
+    // set 'enable' property for 'Clear log...' button
+    changed();
 
-	LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
+    LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
 
-	LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
-	fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
-	fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
+    LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
+    fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
+    fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
 
 
-	return TRUE;
+    return TRUE;
 }
 
 void LLFloaterPreference::updateDeleteTranscriptsButton()
 {
-	std::vector<std::string> list_of_transcriptions_file_names;
-	LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names);
-	getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0);
+    std::vector<std::string> list_of_transcriptions_file_names;
+    LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names);
+    getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0);
 }
 
 void LLFloaterPreference::onDoNotDisturbResponseChanged()
 {
-	// set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise
-	bool response_changed_flag =
-			LLTrans::getString("DoNotDisturbModeResponseDefault")
-					!= getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString();
+    // set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise
+    bool response_changed_flag =
+            LLTrans::getString("DoNotDisturbModeResponseDefault")
+                    != getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString();
 
-	gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag );
+    gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag );
 }
 
 LLFloaterPreference::~LLFloaterPreference()
 {
-	LLConversationLog::instance().removeObserver(this);
+    LLConversationLog::instance().removeObserver(this);
 }
 
 void LLFloaterPreference::draw()
 {
-	BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
-	gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
-	
-	has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
-	gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
-	
-	LLFloater::draw();
+    BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
+    gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
+    
+    has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
+    gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
+    
+    LLFloater::draw();
 }
 
 void LLFloaterPreference::saveSettings()
 {
-	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-	child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-	child_list_t::const_iterator end = tabcontainer->getChildList()->end();
-	for ( ; iter != end; ++iter)
-	{
-		LLView* view = *iter;
-		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-		if (panel)
-			panel->saveSettings();
-	}
-}	
+    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+    child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+    child_list_t::const_iterator end = tabcontainer->getChildList()->end();
+    for ( ; iter != end; ++iter)
+    {
+        LLView* view = *iter;
+        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+        if (panel)
+            panel->saveSettings();
+    }
+}   
 
 void LLFloaterPreference::apply()
 {
-	LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
-	
-	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-	if (sSkin != gSavedSettings.getString("SkinCurrent"))
-	{
-		LLNotificationsUtil::add("ChangeSkin");
-		refreshSkin(this);
-	}
-	// Call apply() on all panels that derive from LLPanelPreference
-	for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-		 iter != tabcontainer->getChildList()->end(); ++iter)
-	{
-		LLView* view = *iter;
-		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-		if (panel)
-			panel->apply();
-	}
-	
-	gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
-
-	LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
-	fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
-	fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
-	
-	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
-	setCacheLocation(cache_location);
-	
-	LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
-	
-	if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE))
-	{
-		bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
-		std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
-		int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
-		LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
-	}
-	
-	if (mGotPersonalInfo)
-	{ 
-		bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
-		bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();		
-	
-		if ((new_im_via_email != mOriginalIMViaEmail)
-			||(new_hide_online != mOriginalHideOnlineStatus))
-		{
-			// This hack is because we are representing several different 	 
-			// possible strings with a single checkbox. Since most users 	 
-			// can only select between 2 values, we represent it as a 	 
-			// checkbox. This breaks down a little bit for liaisons, but 	 
-			// works out in the end. 	 
-			if (new_hide_online != mOriginalHideOnlineStatus)
-			{
-				if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
-				else mDirectoryVisibility = VISIBILITY_DEFAULT;
-			 //Update showonline value, otherwise multiple applys won't work
-				mOriginalHideOnlineStatus = new_hide_online;
-			}
-			gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
-		}
-	}
-
-	saveAvatarProperties();
-
-	if (mClickActionDirty)
-	{
-		updateClickActionSettings();
-		mClickActionDirty = false;
-	}
+    LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
+    
+    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+    if (sSkin != gSavedSettings.getString("SkinCurrent"))
+    {
+        LLNotificationsUtil::add("ChangeSkin");
+        refreshSkin(this);
+    }
+    // Call apply() on all panels that derive from LLPanelPreference
+    for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+         iter != tabcontainer->getChildList()->end(); ++iter)
+    {
+        LLView* view = *iter;
+        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+        if (panel)
+            panel->apply();
+    }
+    
+    gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
+
+    LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
+    fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
+    fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
+    
+    std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
+    setCacheLocation(cache_location);
+    
+    LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
+    
+    if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE))
+    {
+        bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
+        std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
+        int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
+        LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
+    }
+    
+    if (mGotPersonalInfo)
+    { 
+        bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
+        bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();     
+    
+        if ((new_im_via_email != mOriginalIMViaEmail)
+            ||(new_hide_online != mOriginalHideOnlineStatus))
+        {
+            // This hack is because we are representing several different    
+            // possible strings with a single checkbox. Since most users     
+            // can only select between 2 values, we represent it as a    
+            // checkbox. This breaks down a little bit for liaisons, but     
+            // works out in the end.     
+            if (new_hide_online != mOriginalHideOnlineStatus)
+            {
+                if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
+                else mDirectoryVisibility = VISIBILITY_DEFAULT;
+             //Update showonline value, otherwise multiple applys won't work
+                mOriginalHideOnlineStatus = new_hide_online;
+            }
+            gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
+        }
+    }
+
+    saveAvatarProperties();
+
+    if (mClickActionDirty)
+    {
+        updateClickActionSettings();
+        mClickActionDirty = false;
+    }
 }
 
 void LLFloaterPreference::cancel()
 {
-	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-	// Call cancel() on all panels that derive from LLPanelPreference
-	for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-		iter != tabcontainer->getChildList()->end(); ++iter)
-	{
-		LLView* view = *iter;
-		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-		if (panel)
-			panel->cancel();
-	}
-	// hide joystick pref floater
-	LLFloaterReg::hideInstance("pref_joystick");
-
-	// hide translation settings floater
-	LLFloaterReg::hideInstance("prefs_translation");
-	
-	// hide autoreplace settings floater
-	LLFloaterReg::hideInstance("prefs_autoreplace");
-	
-	// hide spellchecker settings folder
-	LLFloaterReg::hideInstance("prefs_spellchecker");
-
-	// hide advanced graphics floater
-	LLFloaterReg::hideInstance("prefs_graphics_advanced");
-	
-	// reverts any changes to current skin
-	gSavedSettings.setString("SkinCurrent", sSkin);
-
-	if (mClickActionDirty)
-	{
-		updateClickActionControls();
-		mClickActionDirty = false;
-	}
-
-	LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy");
-	if (advanced_proxy_settings)
-	{
-		advanced_proxy_settings->cancel();
-	}
-	//Need to reload the navmesh if the pathing console is up
-	LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
-	if ( !pathfindingConsoleHandle.isDead() )
-	{
-		LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
-		pPathfindingConsole->onRegionBoundaryCross();
-	}
-
-	if (!mSavedGraphicsPreset.empty())
-	{
-		gSavedSettings.setString("PresetGraphicActive", mSavedGraphicsPreset);
-		LLPresetsManager::getInstance()->triggerChangeSignal();
-	}
+    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+    // Call cancel() on all panels that derive from LLPanelPreference
+    for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+        iter != tabcontainer->getChildList()->end(); ++iter)
+    {
+        LLView* view = *iter;
+        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+        if (panel)
+            panel->cancel();
+    }
+    // hide joystick pref floater
+    LLFloaterReg::hideInstance("pref_joystick");
+
+    // hide translation settings floater
+    LLFloaterReg::hideInstance("prefs_translation");
+    
+    // hide autoreplace settings floater
+    LLFloaterReg::hideInstance("prefs_autoreplace");
+    
+    // hide spellchecker settings folder
+    LLFloaterReg::hideInstance("prefs_spellchecker");
+
+    // hide advanced graphics floater
+    LLFloaterReg::hideInstance("prefs_graphics_advanced");
+    
+    // reverts any changes to current skin
+    gSavedSettings.setString("SkinCurrent", sSkin);
+
+    if (mClickActionDirty)
+    {
+        updateClickActionControls();
+        mClickActionDirty = false;
+    }
+
+    LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy");
+    if (advanced_proxy_settings)
+    {
+        advanced_proxy_settings->cancel();
+    }
+    //Need to reload the navmesh if the pathing console is up
+    LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
+    if ( !pathfindingConsoleHandle.isDead() )
+    {
+        LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
+        pPathfindingConsole->onRegionBoundaryCross();
+    }
+
+    if (!mSavedGraphicsPreset.empty())
+    {
+        gSavedSettings.setString("PresetGraphicActive", mSavedGraphicsPreset);
+        LLPresetsManager::getInstance()->triggerChangeSignal();
+    }
 }
 
 void LLFloaterPreference::onOpen(const LLSD& key)
 {
 
-	// this variable and if that follows it are used to properly handle do not disturb mode response message
-	static bool initialized = FALSE;
-	// if user is logged in and we haven't initialized do not disturb mode response yet, do it
-	if (!initialized && LLStartUp::getStartupState() == STATE_STARTED)
-	{
-		// Special approach is used for do not disturb response localization, because "DoNotDisturbModeResponse" is
-		// in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized.
-		// To keep track of whether do not disturb response is default or changed by user additional setting DoNotDisturbResponseChanged
-		// was added into per account settings.
-
-		// initialization should happen once,so setting variable to TRUE
-		initialized = TRUE;
-		// this connection is needed to properly set "DoNotDisturbResponseChanged" setting when user makes changes in
-		// do not disturb response message.
-		gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onDoNotDisturbResponseChanged, this));
-	}
-	gAgent.sendAgentUserInfoRequest();
-
-	/////////////////////////// From LLPanelGeneral //////////////////////////
-	// if we have no agent, we can't let them choose anything
-	// if we have an agent, then we only let them choose if they have a choice
-	bool can_choose_maturity =
-		gAgent.getID().notNull() &&
-		(gAgent.isMature() || gAgent.isGodlike());
-	
-	LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox");
-	LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() );
-	if (can_choose_maturity)
-	{		
-		// if they're not adult or a god, they shouldn't see the adult selection, so delete it
-		if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery())
-		{
-			// we're going to remove the adult entry from the combo
-			LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox");
-			if (maturity_list)
-			{
-				maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT));
-			}
-		}
-		getChildView("maturity_desired_combobox")->setEnabled( true);
-		getChildView("maturity_desired_textbox")->setVisible( false);
-	}
-	else
-	{
-		getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel());
-		getChildView("maturity_desired_combobox")->setEnabled( false);
-	}
-
-	// Forget previous language changes.
-	mLanguageChanged = false;
-
-	// Display selected maturity icons.
-	onChangeMaturity();
-
-	onChangeModelFolder();
-	onChangeTextureFolder();
-	onChangeSoundFolder();
-	onChangeAnimationFolder();
-
-	// Load (double-)click to walk/teleport settings.
-	updateClickActionControls();
-	
-	// Enabled/disabled popups, might have been changed by user actions
-	// while preferences floater was closed.
-	buildPopupLists();
-
-
-	//get the options that were checked
-	onNotificationsChange("FriendIMOptions");
-	onNotificationsChange("NonFriendIMOptions");
-	onNotificationsChange("ConferenceIMOptions");
-	onNotificationsChange("GroupChatOptions");
-	onNotificationsChange("NearbyChatOptions");
-	onNotificationsChange("ObjectIMOptions");
-
-	LLPanelLogin::setAlwaysRefresh(true);
-	refresh();
-	
-	// Make sure the current state of prefs are saved away when
-	// when the floater is opened.  That will make cancel do its
-	// job
-	saveSettings();
-
-	// Make sure there is a default preference file
-	LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA);
-	LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC);
-
-	bool started = (LLStartUp::getStartupState() == STATE_STARTED);
-
-	LLButton* load_btn = findChild<LLButton>("PrefLoadButton");
-	LLButton* save_btn = findChild<LLButton>("PrefSaveButton");
-	LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton");
-	LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton");
-
-	if (load_btn && save_btn && delete_btn && exceptions_btn)
-	{
-		load_btn->setEnabled(started);
-		save_btn->setEnabled(started);
-		delete_btn->setEnabled(started);
-		exceptions_btn->setEnabled(started);
-	}
-
-	LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
-	LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton");
-	LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton");
-
-	if (load_camera_btn && save_camera_btn && delete_camera_btn)
-	{
-		load_camera_btn->setEnabled(started);
-		save_camera_btn->setEnabled(started);
-		delete_camera_btn->setEnabled(started);
-	}
+    // this variable and if that follows it are used to properly handle do not disturb mode response message
+    static bool initialized = FALSE;
+    // if user is logged in and we haven't initialized do not disturb mode response yet, do it
+    if (!initialized && LLStartUp::getStartupState() == STATE_STARTED)
+    {
+        // Special approach is used for do not disturb response localization, because "DoNotDisturbModeResponse" is
+        // in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized.
+        // To keep track of whether do not disturb response is default or changed by user additional setting DoNotDisturbResponseChanged
+        // was added into per account settings.
+
+        // initialization should happen once,so setting variable to TRUE
+        initialized = TRUE;
+        // this connection is needed to properly set "DoNotDisturbResponseChanged" setting when user makes changes in
+        // do not disturb response message.
+        gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onDoNotDisturbResponseChanged, this));
+    }
+    gAgent.sendAgentUserInfoRequest();
+
+    /////////////////////////// From LLPanelGeneral //////////////////////////
+    // if we have no agent, we can't let them choose anything
+    // if we have an agent, then we only let them choose if they have a choice
+    bool can_choose_maturity =
+        gAgent.getID().notNull() &&
+        (gAgent.isMature() || gAgent.isGodlike());
+    
+    LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox");
+    LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() );
+    if (can_choose_maturity)
+    {       
+        // if they're not adult or a god, they shouldn't see the adult selection, so delete it
+        if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery())
+        {
+            // we're going to remove the adult entry from the combo
+            LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox");
+            if (maturity_list)
+            {
+                maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT));
+            }
+        }
+        getChildView("maturity_desired_combobox")->setEnabled( true);
+        getChildView("maturity_desired_textbox")->setVisible( false);
+    }
+    else
+    {
+        getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel());
+        getChildView("maturity_desired_combobox")->setEnabled( false);
+    }
+
+    // Forget previous language changes.
+    mLanguageChanged = false;
+
+    // Display selected maturity icons.
+    onChangeMaturity();
+
+    onChangeModelFolder();
+    onChangeTextureFolder();
+    onChangeSoundFolder();
+    onChangeAnimationFolder();
+
+    // Load (double-)click to walk/teleport settings.
+    updateClickActionControls();
+    
+    // Enabled/disabled popups, might have been changed by user actions
+    // while preferences floater was closed.
+    buildPopupLists();
+
+
+    //get the options that were checked
+    onNotificationsChange("FriendIMOptions");
+    onNotificationsChange("NonFriendIMOptions");
+    onNotificationsChange("ConferenceIMOptions");
+    onNotificationsChange("GroupChatOptions");
+    onNotificationsChange("NearbyChatOptions");
+    onNotificationsChange("ObjectIMOptions");
+
+    LLPanelLogin::setAlwaysRefresh(true);
+    refresh();
+    
+    // Make sure the current state of prefs are saved away when
+    // when the floater is opened.  That will make cancel do its
+    // job
+    saveSettings();
+
+    // Make sure there is a default preference file
+    LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA);
+    LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC);
+
+    bool started = (LLStartUp::getStartupState() == STATE_STARTED);
+
+    LLButton* load_btn = findChild<LLButton>("PrefLoadButton");
+    LLButton* save_btn = findChild<LLButton>("PrefSaveButton");
+    LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton");
+    LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton");
+
+    if (load_btn && save_btn && delete_btn && exceptions_btn)
+    {
+        load_btn->setEnabled(started);
+        save_btn->setEnabled(started);
+        delete_btn->setEnabled(started);
+        exceptions_btn->setEnabled(started);
+    }
+
+    LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
+    LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton");
+    LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton");
+
+    if (load_camera_btn && save_camera_btn && delete_camera_btn)
+    {
+        load_camera_btn->setEnabled(started);
+        save_camera_btn->setEnabled(started);
+        delete_camera_btn->setEnabled(started);
+    }
 }
 
 void LLFloaterPreference::onVertexShaderEnable()
 {
-	refreshEnabledGraphics();
+    refreshEnabledGraphics();
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable()
 {
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance)
-	{
-		instance->refresh();
-	}
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance)
+    {
+        instance->refresh();
+    }
 
-	refreshEnabledGraphics();
+    refreshEnabledGraphics();
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledGraphics()
 {
-	refreshEnabledState();
+    refreshEnabledState();
 }
 
 void LLFloaterPreference::onAvatarImpostorsEnable()
 {
-	refreshEnabledGraphics();
+    refreshEnabledGraphics();
 }
 
 //static
 void LLFloaterPreference::initDoNotDisturbResponse()
-	{
-		if (!gSavedPerAccountSettings.getBOOL("DoNotDisturbResponseChanged"))
-		{
-			//LLTrans::getString("DoNotDisturbModeResponseDefault") is used here for localization (EXT-5885)
-			gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
-		}
-	}
+    {
+        if (!gSavedPerAccountSettings.getBOOL("DoNotDisturbResponseChanged"))
+        {
+            //LLTrans::getString("DoNotDisturbModeResponseDefault") is used here for localization (EXT-5885)
+            gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
+        }
+    }
 
 //static 
 void LLFloaterPreference::updateShowFavoritesCheckbox(bool val)
 {
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance)
-	{
-		instance->getChild<LLUICtrl>("favorites_on_login_check")->setValue(val);
-	}	
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance)
+    {
+        instance->getChild<LLUICtrl>("favorites_on_login_check")->setValue(val);
+    }   
 }
 
 void LLFloaterPreference::setHardwareDefaults()
 {
-	std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-	if (!preset_graphic_active.empty())
-	{
-		saveGraphicsPreset(preset_graphic_active);
-		saveSettings(); // save here to be able to return to the previous preset by Cancel
-	}
+    std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+    if (!preset_graphic_active.empty())
+    {
+        saveGraphicsPreset(preset_graphic_active);
+        saveSettings(); // save here to be able to return to the previous preset by Cancel
+    }
 
-	LLFeatureManager::getInstance()->applyRecommendedSettings();
+    LLFeatureManager::getInstance()->applyRecommendedSettings();
 
-	// reset indirects before refresh because we may have changed what they control
-	LLAvatarComplexityControls::setIndirectControls(); 
+    // reset indirects before refresh because we may have changed what they control
+    LLAvatarComplexityControls::setIndirectControls(); 
 
-	refreshEnabledGraphics();
-	gSavedSettings.setString("PresetGraphicActive", "");
-	LLPresetsManager::getInstance()->triggerChangeSignal();
+    refreshEnabledGraphics();
+    gSavedSettings.setString("PresetGraphicActive", "");
+    LLPresetsManager::getInstance()->triggerChangeSignal();
 
-	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-	child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-	child_list_t::const_iterator end = tabcontainer->getChildList()->end();
-	for ( ; iter != end; ++iter)
-	{
-		LLView* view = *iter;
-		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-		if (panel)
-		{
-			panel->setHardwareDefaults();
-		}
-	}
+    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+    child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+    child_list_t::const_iterator end = tabcontainer->getChildList()->end();
+    for ( ; iter != end; ++iter)
+    {
+        LLView* view = *iter;
+        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+        if (panel)
+        {
+            panel->setHardwareDefaults();
+        }
+    }
 }
 
 void LLFloaterPreference::getControlNames(std::vector<std::string>& names)
 {
-	LLView* view = findChild<LLView>("display");
-	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-	if (view && advanced)
-	{
-		std::list<LLView*> stack;
-		stack.push_back(view);
-		stack.push_back(advanced);
-		while(!stack.empty())
-		{
-			// Process view on top of the stack
-			LLView* curview = stack.front();
-			stack.pop_front();
-
-			LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-			if (ctrl)
-			{
-				LLControlVariable* control = ctrl->getControlVariable();
-				if (control)
-				{
-					std::string control_name = control->getName();
-					if (std::find(names.begin(), names.end(), control_name) == names.end())
-					{
-						names.push_back(control_name);
-					}
-				}
-			}
-
-			for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-				iter != curview->getChildList()->end(); ++iter)
-			{
-				stack.push_back(*iter);
-			}
-		}
-	}
+    LLView* view = findChild<LLView>("display");
+    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+    if (view && advanced)
+    {
+        std::list<LLView*> stack;
+        stack.push_back(view);
+        stack.push_back(advanced);
+        while(!stack.empty())
+        {
+            // Process view on top of the stack
+            LLView* curview = stack.front();
+            stack.pop_front();
+
+            LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+            if (ctrl)
+            {
+                LLControlVariable* control = ctrl->getControlVariable();
+                if (control)
+                {
+                    std::string control_name = control->getName();
+                    if (std::find(names.begin(), names.end(), control_name) == names.end())
+                    {
+                        names.push_back(control_name);
+                    }
+                }
+            }
+
+            for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+                iter != curview->getChildList()->end(); ++iter)
+            {
+                stack.push_back(*iter);
+            }
+        }
+    }
 }
 
 //virtual
 void LLFloaterPreference::onClose(bool app_quitting)
 {
-	gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
-	LLPanelLogin::setAlwaysRefresh(false);
-	if (!app_quitting)
-	{
-		cancel();
-	}
+    gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
+    LLPanelLogin::setAlwaysRefresh(false);
+    if (!app_quitting)
+    {
+        cancel();
+    }
 }
 
 // static 
 void LLFloaterPreference::onBtnOK(const LLSD& userdata)
 {
-	// commit any outstanding text entry
-	if (hasFocus())
-	{
-		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-		if (cur_focus && cur_focus->acceptsTextInput())
-		{
-			cur_focus->onCommit();
-		}
-	}
-
-	if (canClose())
-	{
-		saveSettings();
-		apply();
-		
-		if (userdata.asString() == "closeadvanced")
-		{
-			LLFloaterReg::hideInstance("prefs_graphics_advanced");
-		}
-		else
-		{
-			closeFloater(false);
-		}
-
-		//Conversation transcript and log path changed so reload conversations based on new location
-		if(mPriorInstantMessageLogPath.length())
-		{
-			if(moveTranscriptsAndLog())
-			{
-				//When floaters are empty but have a chat history files, reload chat history into them
-				LLFloaterIMSessionTab::reloadEmptyFloaters();
-			}
-			//Couldn't move files so restore the old path and show a notification
-			else
-			{
-				gSavedPerAccountSettings.setString("InstantMessageLogPath", mPriorInstantMessageLogPath);
-				LLNotificationsUtil::add("PreferenceChatPathChanged");
-			}
-			mPriorInstantMessageLogPath.clear();
-		}
-
-		LLUIColorTable::instance().saveUserSettings();
-		gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
-		
-		//Only save once logged in and loaded per account settings
-		if(mGotPersonalInfo)
-		{
-			gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
-	}
-	}
-	else
-	{
-		// Show beep, pop up dialog, etc.
-		LL_INFOS() << "Can't close preferences!" << LL_ENDL;
-	}
-
-	LLPanelLogin::updateLocationSelectorsVisibility();	
-	//Need to reload the navmesh if the pathing console is up
-	LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
-	if ( !pathfindingConsoleHandle.isDead() )
-	{
-		LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
-		pPathfindingConsole->onRegionBoundaryCross();
-	}
+    // commit any outstanding text entry
+    if (hasFocus())
+    {
+        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+        if (cur_focus && cur_focus->acceptsTextInput())
+        {
+            cur_focus->onCommit();
+        }
+    }
+
+    if (canClose())
+    {
+        saveSettings();
+        apply();
+        
+        if (userdata.asString() == "closeadvanced")
+        {
+            LLFloaterReg::hideInstance("prefs_graphics_advanced");
+        }
+        else
+        {
+            closeFloater(false);
+        }
+
+        //Conversation transcript and log path changed so reload conversations based on new location
+        if(mPriorInstantMessageLogPath.length())
+        {
+            if(moveTranscriptsAndLog())
+            {
+                //When floaters are empty but have a chat history files, reload chat history into them
+                LLFloaterIMSessionTab::reloadEmptyFloaters();
+            }
+            //Couldn't move files so restore the old path and show a notification
+            else
+            {
+                gSavedPerAccountSettings.setString("InstantMessageLogPath", mPriorInstantMessageLogPath);
+                LLNotificationsUtil::add("PreferenceChatPathChanged");
+            }
+            mPriorInstantMessageLogPath.clear();
+        }
+
+        LLUIColorTable::instance().saveUserSettings();
+        gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
+        
+        //Only save once logged in and loaded per account settings
+        if(mGotPersonalInfo)
+        {
+            gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
+    }
+    }
+    else
+    {
+        // Show beep, pop up dialog, etc.
+        LL_INFOS() << "Can't close preferences!" << LL_ENDL;
+    }
+
+    LLPanelLogin::updateLocationSelectorsVisibility();  
+    //Need to reload the navmesh if the pathing console is up
+    LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
+    if ( !pathfindingConsoleHandle.isDead() )
+    {
+        LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
+        pPathfindingConsole->onRegionBoundaryCross();
+    }
 }
 
 // static 
 void LLFloaterPreference::onBtnCancel(const LLSD& userdata)
 {
-	if (hasFocus())
-	{
-		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-		if (cur_focus && cur_focus->acceptsTextInput())
-		{
-			cur_focus->onCommit();
-		}
-		refresh();
-	}
-	cancel();
-
-	if (userdata.asString() == "closeadvanced")
-	{
-		LLFloaterReg::hideInstance("prefs_graphics_advanced");
-	}
-	else
-	{
-		closeFloater();
-	}
+    if (hasFocus())
+    {
+        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+        if (cur_focus && cur_focus->acceptsTextInput())
+        {
+            cur_focus->onCommit();
+        }
+        refresh();
+    }
+    cancel();
+
+    if (userdata.asString() == "closeadvanced")
+    {
+        LLFloaterReg::hideInstance("prefs_graphics_advanced");
+    }
+    else
+    {
+        closeFloater();
+    }
 }
 
 // static 
 void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email)
 {
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance)
-	{
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance)
+    {
         instance->setPersonalInfo(visibility, im_via_email, is_verified_email);
-	}
+    }
 }
 
 void LLFloaterPreference::refreshEnabledGraphics()
 {
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance)
-	{
-		instance->refresh();
-	}
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance)
+    {
+        instance->refresh();
+    }
 
-	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-	if (advanced)
-	{
-		advanced->refresh();
-	}
+    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+    if (advanced)
+    {
+        advanced->refresh();
+    }
 }
 
 void LLFloaterPreference::onClickClearCache()
 {
-	LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache);
+    LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache);
 }
 
 void LLFloaterPreference::onClickBrowserClearCache()
 {
-	LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache);
+    LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache);
 }
 
 // Called when user changes language via the combobox.
 void LLFloaterPreference::onLanguageChange()
 {
-	// Let the user know that the change will only take effect after restart.
-	// Do it only once so that we're not too irritating.
-	if (!mLanguageChanged)
-	{
-		LLNotificationsUtil::add("ChangeLanguage");
-		mLanguageChanged = true;
-	}
+    // Let the user know that the change will only take effect after restart.
+    // Do it only once so that we're not too irritating.
+    if (!mLanguageChanged)
+    {
+        LLNotificationsUtil::add("ChangeLanguage");
+        mLanguageChanged = true;
+    }
 }
 
 void LLFloaterPreference::onNotificationsChange(const std::string& OptionName)
 {
-	mNotificationOptions[OptionName] = getChild<LLComboBox>(OptionName)->getSelectedItemLabel();
+    mNotificationOptions[OptionName] = getChild<LLComboBox>(OptionName)->getSelectedItemLabel();
 
-	bool show_notifications_alert = true;
-	for (notifications_map::iterator it_notification = mNotificationOptions.begin(); it_notification != mNotificationOptions.end(); it_notification++)
-	{
-		if(it_notification->second != "No action")
-		{
-			show_notifications_alert = false;
-			break;
-		}
-	}
+    bool show_notifications_alert = true;
+    for (notifications_map::iterator it_notification = mNotificationOptions.begin(); it_notification != mNotificationOptions.end(); it_notification++)
+    {
+        if(it_notification->second != "No action")
+        {
+            show_notifications_alert = false;
+            break;
+        }
+    }
 
-	getChild<LLTextBox>("notifications_alert")->setVisible(show_notifications_alert);
+    getChild<LLTextBox>("notifications_alert")->setVisible(show_notifications_alert);
 }
 
 void LLFloaterPreference::onNameTagOpacityChange(const LLSD& newvalue)
 {
-	LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background");
-	if (color_swatch)
-	{
-		LLColor4 new_color = color_swatch->get();
-		color_swatch->set( new_color.setAlpha(newvalue.asReal()) );
-	}
+    LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background");
+    if (color_swatch)
+    {
+        LLColor4 new_color = color_swatch->get();
+        color_swatch->set( new_color.setAlpha(newvalue.asReal()) );
+    }
 }
 
 void LLFloaterPreference::onClickSetCache()
 {
-	std::string cur_name(gSavedSettings.getString("CacheLocation"));
-//	std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name));
-	
-	std::string proposed_name(cur_name);
+    std::string cur_name(gSavedSettings.getString("CacheLocation"));
+//  std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name));
+    
+    std::string proposed_name(cur_name);
 
-	(new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeCachePath, this, _1, _2), proposed_name))->getFile();
+    (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeCachePath, this, _1, _2), proposed_name))->getFile();
 }
 
 void LLFloaterPreference::changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name)
 {
-	std::string dir_name = filenames[0];
-	if (!dir_name.empty() && dir_name != proposed_name)
-	{
-		std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name));
-		LLNotificationsUtil::add("CacheWillBeMoved");
-		gSavedSettings.setString("NewCacheLocation", dir_name);
-		gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder);
-	}
-	else
-	{
-		std::string cache_location = gDirUtilp->getCacheDir();
-		gSavedSettings.setString("CacheLocation", cache_location);
-		std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
-		gSavedSettings.setString("CacheLocationTopFolder", top_folder);
-	}
+    std::string dir_name = filenames[0];
+    if (!dir_name.empty() && dir_name != proposed_name)
+    {
+        std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name));
+        LLNotificationsUtil::add("CacheWillBeMoved");
+        gSavedSettings.setString("NewCacheLocation", dir_name);
+        gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder);
+    }
+    else
+    {
+        std::string cache_location = gDirUtilp->getCacheDir();
+        gSavedSettings.setString("CacheLocation", cache_location);
+        std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
+        gSavedSettings.setString("CacheLocationTopFolder", top_folder);
+    }
 }
 
 void LLFloaterPreference::onClickResetCache()
 {
-	if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true))
-	{
-		// The cache location was already the default.
-		return;
-	}
-	gSavedSettings.setString("NewCacheLocation", "");
-	gSavedSettings.setString("NewCacheLocationTopFolder", "");
-	LLNotificationsUtil::add("CacheWillBeMoved");
-	std::string cache_location = gDirUtilp->getCacheDir(false);
-	gSavedSettings.setString("CacheLocation", cache_location);
-	std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
-	gSavedSettings.setString("CacheLocationTopFolder", top_folder);
+    if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true))
+    {
+        // The cache location was already the default.
+        return;
+    }
+    gSavedSettings.setString("NewCacheLocation", "");
+    gSavedSettings.setString("NewCacheLocationTopFolder", "");
+    LLNotificationsUtil::add("CacheWillBeMoved");
+    std::string cache_location = gDirUtilp->getCacheDir(false);
+    gSavedSettings.setString("CacheLocation", cache_location);
+    std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
+    gSavedSettings.setString("CacheLocationTopFolder", top_folder);
 }
 
 void LLFloaterPreference::onClickSkin(LLUICtrl* ctrl, const LLSD& userdata)
 {
-	gSavedSettings.setString("SkinCurrent", userdata.asString());
-	ctrl->setValue(userdata.asString());
+    gSavedSettings.setString("SkinCurrent", userdata.asString());
+    ctrl->setValue(userdata.asString());
 }
 
 void LLFloaterPreference::onSelectSkin()
 {
-	std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString();
-	gSavedSettings.setString("SkinCurrent", skin_selection);
+    std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString();
+    gSavedSettings.setString("SkinCurrent", skin_selection);
 }
 
 void LLFloaterPreference::refreshSkin(void* data)
 {
-	LLPanel*self = (LLPanel*)data;
-	sSkin = gSavedSettings.getString("SkinCurrent");
-	self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin);
+    LLPanel*self = (LLPanel*)data;
+    sSkin = gSavedSettings.getString("SkinCurrent");
+    self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin);
 }
 
 void LLFloaterPreference::buildPopupLists()
 {
-	LLScrollListCtrl& disabled_popups =
-		getChildRef<LLScrollListCtrl>("disabled_popups");
-	LLScrollListCtrl& enabled_popups =
-		getChildRef<LLScrollListCtrl>("enabled_popups");
-	
-	disabled_popups.deleteAllItems();
-	enabled_popups.deleteAllItems();
-	
-	for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
-		 iter != LLNotifications::instance().templatesEnd();
-		 ++iter)
-	{
-		LLNotificationTemplatePtr templatep = iter->second;
-		LLNotificationFormPtr formp = templatep->mForm;
-		
-		LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType();
-		if (ignore == LLNotificationForm::IGNORE_NO)
-			continue;
-		
-		LLSD row;
-		row["columns"][0]["value"] = formp->getIgnoreMessage();
-		row["columns"][0]["font"] = "SANSSERIF_SMALL";
-		row["columns"][0]["width"] = 400;
-		
-		LLScrollListItem* item = NULL;
-		
-		bool show_popup = !formp->getIgnored();
-		if (!show_popup)
-		{
-			if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
-			{
-				LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
-				if (!last_response.isUndefined())
-				{
-					for (LLSD::map_const_iterator it = last_response.beginMap();
-						 it != last_response.endMap();
-						 ++it)
-					{
-						if (it->second.asBoolean())
-						{
-							row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString();
-							break;
-						}
-					}
-				}
-				row["columns"][1]["font"] = "SANSSERIF_SMALL";
-				row["columns"][1]["width"] = 360;
-			}
-			item = disabled_popups.addElement(row);
-		}
-		else
-		{
-			item = enabled_popups.addElement(row);
-		}
-		
-		if (item)
-		{
-			item->setUserdata((void*)&iter->first);
-		}
-	}
+    LLScrollListCtrl& disabled_popups =
+        getChildRef<LLScrollListCtrl>("disabled_popups");
+    LLScrollListCtrl& enabled_popups =
+        getChildRef<LLScrollListCtrl>("enabled_popups");
+    
+    disabled_popups.deleteAllItems();
+    enabled_popups.deleteAllItems();
+    
+    for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
+         iter != LLNotifications::instance().templatesEnd();
+         ++iter)
+    {
+        LLNotificationTemplatePtr templatep = iter->second;
+        LLNotificationFormPtr formp = templatep->mForm;
+        
+        LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType();
+        if (ignore == LLNotificationForm::IGNORE_NO)
+            continue;
+        
+        LLSD row;
+        row["columns"][0]["value"] = formp->getIgnoreMessage();
+        row["columns"][0]["font"] = "SANSSERIF_SMALL";
+        row["columns"][0]["width"] = 400;
+        
+        LLScrollListItem* item = NULL;
+        
+        bool show_popup = !formp->getIgnored();
+        if (!show_popup)
+        {
+            if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
+            {
+                LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
+                if (!last_response.isUndefined())
+                {
+                    for (LLSD::map_const_iterator it = last_response.beginMap();
+                         it != last_response.endMap();
+                         ++it)
+                    {
+                        if (it->second.asBoolean())
+                        {
+                            row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString();
+                            break;
+                        }
+                    }
+                }
+                row["columns"][1]["font"] = "SANSSERIF_SMALL";
+                row["columns"][1]["width"] = 360;
+            }
+            item = disabled_popups.addElement(row);
+        }
+        else
+        {
+            item = enabled_popups.addElement(row);
+        }
+        
+        if (item)
+        {
+            item->setUserdata((void*)&iter->first);
+        }
+    }
 }
 
 void LLFloaterPreference::refreshEnabledState()
 {
-	LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+    LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
+    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
 
-	// if vertex shaders off, disable all shader related products
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") ||
-		!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
-	{
-		ctrl_wind_light->setEnabled(FALSE);
-		ctrl_wind_light->setValue(FALSE);
-	}
-	else
-	{
-		ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable"));
-	}
+    // if vertex shaders off, disable all shader related products
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") ||
+        !LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
+    {
+        ctrl_wind_light->setEnabled(FALSE);
+        ctrl_wind_light->setValue(FALSE);
+    }
+    else
+    {
+        ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable"));
+    }
 
-	//Deferred/SSAO/Shadows
-	BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump");
-	BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable");
-	BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-						bumpshiny &&
-						shaders && 
-						gGLManager.mHasFramebufferObject &&
-						gSavedSettings.getBOOL("RenderAvatarVP") &&
-						(ctrl_wind_light->get()) ? TRUE : FALSE;
+    //Deferred/SSAO/Shadows
+    BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump");
+    BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable");
+    BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+                        bumpshiny &&
+                        shaders && 
+                        gGLManager.mHasFramebufferObject &&
+                        gSavedSettings.getBOOL("RenderAvatarVP") &&
+                        (ctrl_wind_light->get()) ? TRUE : FALSE;
 
-	ctrl_deferred->setEnabled(enabled);
+    ctrl_deferred->setEnabled(enabled);
 
-	// Cannot have floater active until caps have been received
-	getChild<LLButton>("default_creation_permissions")->setEnabled(LLStartUp::getStartupState() < STATE_STARTED ? false : true);
+    // Cannot have floater active until caps have been received
+    getChild<LLButton>("default_creation_permissions")->setEnabled(LLStartUp::getStartupState() < STATE_STARTED ? false : true);
 
-	getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess());
+    getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess());
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState()
 {
-	LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
-	LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
-
-	// Reflections
-	BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") 
-		&& gGLManager.mHasCubeMap
-		&& LLCubeMap::sUseCubeMaps;
-	ctrl_reflections->setEnabled(reflections);
-	reflections_text->setEnabled(reflections);
-	
-	// Bump & Shiny	
-	LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny");
-	bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
-	bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE);
+    LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
+    LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
+
+    // Reflections
+    BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") 
+        && gGLManager.mHasCubeMap
+        && LLCubeMap::sUseCubeMaps;
+    ctrl_reflections->setEnabled(reflections);
+    reflections_text->setEnabled(reflections);
+    
+    // Bump & Shiny 
+    LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny");
+    bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
+    bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE);
+    
+    // Avatar Mode
+    // Enable Avatar Shaders
+    LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
+    // Avatar Render Mode
+    LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
     
-	// Avatar Mode
-	// Enable Avatar Shaders
-	LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
-	// Avatar Render Mode
-	LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
-	
-	bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP");
-	if (LLViewerShaderMgr::sInitialized)
-	{
-		S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
-		avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE;
-	}
-
-	ctrl_avatar_vp->setEnabled(avatar_vp_enabled);
-	
-	if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || 
-		gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
-	{
-		ctrl_avatar_cloth->setEnabled(FALSE);
-	} 
-	else
-	{
-		ctrl_avatar_cloth->setEnabled(TRUE);
-	}
-	
-	// Vertex Shaders
-	// Global Shader Enable
-	LLCheckBoxCtrl* ctrl_shader_enable   = getChild<LLCheckBoxCtrl>("BasicShaders");
-	LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail");   // can be linked with control var
-	LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText");
-
-	ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"));
-	
-	BOOL shaders = ctrl_shader_enable->get();
-	if (shaders)
-	{
-		terrain_detail->setEnabled(FALSE);
-		terrain_text->setEnabled(FALSE);
-	}
-	else
-	{
-		terrain_detail->setEnabled(TRUE);
-		terrain_text->setEnabled(TRUE);
-	}
-	
-	// WindLight
-	LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-	LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
-	LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
-
-	// *HACK just checks to see if we can use shaders... 
-	// maybe some cards that use shaders, but don't support windlight
-	ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
-
-	sky->setEnabled(ctrl_wind_light->get() && shaders);
-	sky_text->setEnabled(ctrl_wind_light->get() && shaders);
-
-	//Deferred/SSAO/Shadows
-	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
-	
-	BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-						((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) &&
-						shaders && 
-						gGLManager.mHasFramebufferObject &&
-						gSavedSettings.getBOOL("RenderAvatarVP") &&
-						(ctrl_wind_light->get()) ? TRUE : FALSE;
-
-	ctrl_deferred->setEnabled(enabled);
-
-	LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
-	LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
-	LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
-	LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText");
-
-	// note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it
-	enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
-	
-	ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred"));
-
-	ctrl_ssao->setEnabled(enabled);
-	ctrl_dof->setEnabled(enabled);
-
-	enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
-
-	ctrl_shadow->setEnabled(enabled);
-	shadow_text->setEnabled(enabled);
-
-	// Hardware settings
-	F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
-	S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
-	S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier);
-	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value());
-	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value());
-
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
-		!gGLManager.mHasVertexBufferObject)
-	{
-		getChildView("vbo")->setEnabled(FALSE);
-	}
-
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") ||
-		!gGLManager.mHasVertexBufferObject)
-	{
-		getChildView("texture compression")->setEnabled(FALSE);
-	}
-
-	// if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
-	LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma");
-	gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
-	getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
-	getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
-	getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"));
-
-	// now turn off any features that are unavailable
-	disableUnavailableSettings();
+    bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP");
+    if (LLViewerShaderMgr::sInitialized)
+    {
+        S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
+        avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE;
+    }
+
+    ctrl_avatar_vp->setEnabled(avatar_vp_enabled);
+    
+    if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || 
+        gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
+    {
+        ctrl_avatar_cloth->setEnabled(FALSE);
+    } 
+    else
+    {
+        ctrl_avatar_cloth->setEnabled(TRUE);
+    }
+    
+    // Vertex Shaders
+    // Global Shader Enable
+    LLCheckBoxCtrl* ctrl_shader_enable   = getChild<LLCheckBoxCtrl>("BasicShaders");
+    LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail");   // can be linked with control var
+    LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText");
+
+    ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"));
+    
+    BOOL shaders = ctrl_shader_enable->get();
+    if (shaders)
+    {
+        terrain_detail->setEnabled(FALSE);
+        terrain_text->setEnabled(FALSE);
+    }
+    else
+    {
+        terrain_detail->setEnabled(TRUE);
+        terrain_text->setEnabled(TRUE);
+    }
+    
+    // WindLight
+    LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
+    LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
+    LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
+
+    // *HACK just checks to see if we can use shaders... 
+    // maybe some cards that use shaders, but don't support windlight
+    ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
+
+    sky->setEnabled(ctrl_wind_light->get() && shaders);
+    sky_text->setEnabled(ctrl_wind_light->get() && shaders);
+
+    //Deferred/SSAO/Shadows
+    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+    
+    BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+                        ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) &&
+                        shaders && 
+                        gGLManager.mHasFramebufferObject &&
+                        gSavedSettings.getBOOL("RenderAvatarVP") &&
+                        (ctrl_wind_light->get()) ? TRUE : FALSE;
+
+    ctrl_deferred->setEnabled(enabled);
+
+    LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
+    LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
+    LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
+    LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText");
+
+    // note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it
+    enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
+    
+    ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred"));
+
+    ctrl_ssao->setEnabled(enabled);
+    ctrl_dof->setEnabled(enabled);
+
+    enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
+
+    ctrl_shadow->setEnabled(enabled);
+    shadow_text->setEnabled(enabled);
+
+    // Hardware settings
+    F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
+    S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
+    S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier);
+    getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value());
+    getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value());
+
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
+        !gGLManager.mHasVertexBufferObject)
+    {
+        getChildView("vbo")->setEnabled(FALSE);
+    }
+
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") ||
+        !gGLManager.mHasVertexBufferObject)
+    {
+        getChildView("texture compression")->setEnabled(FALSE);
+    }
+
+    // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
+    LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma");
+    gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
+    getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
+    getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
+    getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"));
+
+    // now turn off any features that are unavailable
+    disableUnavailableSettings();
 }
 
 // static
 void LLAvatarComplexityControls::setIndirectControls()
 {
-	/*
-	 * We have controls that have an indirect relationship between the control
-	 * values and adjacent text and the underlying setting they influence.
-	 * In each case, the control and its associated setting are named Indirect<something>
-	 * This method interrogates the controlled setting and establishes the
-	 * appropriate value for the indirect control. It must be called whenever the
-	 * underlying setting may have changed other than through the indirect control,
-	 * such as when the 'Reset all to recommended settings' button is used...
-	 */
-	setIndirectMaxNonImpostors();
-	setIndirectMaxArc();
+    /*
+     * We have controls that have an indirect relationship between the control
+     * values and adjacent text and the underlying setting they influence.
+     * In each case, the control and its associated setting are named Indirect<something>
+     * This method interrogates the controlled setting and establishes the
+     * appropriate value for the indirect control. It must be called whenever the
+     * underlying setting may have changed other than through the indirect control,
+     * such as when the 'Reset all to recommended settings' button is used...
+     */
+    setIndirectMaxNonImpostors();
+    setIndirectMaxArc();
 }
 
 // static
 void LLAvatarComplexityControls::setIndirectMaxNonImpostors()
 {
-	U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors");
-	// for this one, we just need to make zero, which means off, the max value of the slider
-	U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors;
-	gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors);
+    U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors");
+    // for this one, we just need to make zero, which means off, the max value of the slider
+    U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors;
+    gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors);
 }
 
 void LLAvatarComplexityControls::setIndirectMaxArc()
 {
-	U32 max_arc = gSavedSettings.getU32("RenderAvatarMaxComplexity");
-	U32 indirect_max_arc;
-	if (0 == max_arc)
-	{
-		// the off position is all the way to the right, so set to control max
-		indirect_max_arc = INDIRECT_MAX_ARC_OFF;
-	}
-	else
-	{
-		// This is the inverse of the calculation in updateMaxComplexity
-		indirect_max_arc = (U32)ll_round(((log(F32(max_arc)) - MIN_ARC_LOG) / ARC_LIMIT_MAP_SCALE)) + MIN_INDIRECT_ARC_LIMIT;
-	}
-	gSavedSettings.setU32("IndirectMaxComplexity", indirect_max_arc);
+    U32 max_arc = gSavedSettings.getU32("RenderAvatarMaxComplexity");
+    U32 indirect_max_arc;
+    if (0 == max_arc)
+    {
+        // the off position is all the way to the right, so set to control max
+        indirect_max_arc = INDIRECT_MAX_ARC_OFF;
+    }
+    else
+    {
+        // This is the inverse of the calculation in updateMaxComplexity
+        indirect_max_arc = (U32)ll_round(((log(F32(max_arc)) - MIN_ARC_LOG) / ARC_LIMIT_MAP_SCALE)) + MIN_INDIRECT_ARC_LIMIT;
+    }
+    gSavedSettings.setU32("IndirectMaxComplexity", indirect_max_arc);
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings()
-{	
-	LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
-	LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
-	LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
-	LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
-	LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
-	LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
-	LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
-	LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText");
-	LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
-	LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
-	LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
-	LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
-
-	// if vertex shaders off, disable all shader related products
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
-	{
-		ctrl_shader_enable->setEnabled(FALSE);
-		ctrl_shader_enable->setValue(FALSE);
-		
-		ctrl_wind_light->setEnabled(FALSE);
-		ctrl_wind_light->setValue(FALSE);
-
-		sky->setEnabled(FALSE);
-		sky_text->setEnabled(FALSE);
-
-		ctrl_reflections->setEnabled(FALSE);
-		ctrl_reflections->setValue(0);
-		reflections_text->setEnabled(FALSE);
-		
-		ctrl_avatar_vp->setEnabled(FALSE);
-		ctrl_avatar_vp->setValue(FALSE);
-		
-		ctrl_avatar_cloth->setEnabled(FALSE);
-		ctrl_avatar_cloth->setValue(FALSE);
-
-		ctrl_shadows->setEnabled(FALSE);
-		ctrl_shadows->setValue(0);
-		shadows_text->setEnabled(FALSE);
-		
-		ctrl_ssao->setEnabled(FALSE);
-		ctrl_ssao->setValue(FALSE);
-
-		ctrl_dof->setEnabled(FALSE);
-		ctrl_dof->setValue(FALSE);
-
-		ctrl_deferred->setEnabled(FALSE);
-		ctrl_deferred->setValue(FALSE);
-	}
-	
-	// disabled windlight
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
-	{
-		ctrl_wind_light->setEnabled(FALSE);
-		ctrl_wind_light->setValue(FALSE);
-
-		sky->setEnabled(FALSE);
-		sky_text->setEnabled(FALSE);
-
-		//deferred needs windlight, disable deferred
-		ctrl_shadows->setEnabled(FALSE);
-		ctrl_shadows->setValue(0);
-		shadows_text->setEnabled(FALSE);
-		
-		ctrl_ssao->setEnabled(FALSE);
-		ctrl_ssao->setValue(FALSE);
-
-		ctrl_dof->setEnabled(FALSE);
-		ctrl_dof->setValue(FALSE);
-
-		ctrl_deferred->setEnabled(FALSE);
-		ctrl_deferred->setValue(FALSE);
-	}
-
-	// disabled deferred
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") ||
-		!gGLManager.mHasFramebufferObject)
-	{
-		ctrl_shadows->setEnabled(FALSE);
-		ctrl_shadows->setValue(0);
-		shadows_text->setEnabled(FALSE);
-		
-		ctrl_ssao->setEnabled(FALSE);
-		ctrl_ssao->setValue(FALSE);
-
-		ctrl_dof->setEnabled(FALSE);
-		ctrl_dof->setValue(FALSE);
-
-		ctrl_deferred->setEnabled(FALSE);
-		ctrl_deferred->setValue(FALSE);
-	}
-	
-	// disabled deferred SSAO
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
-	{
-		ctrl_ssao->setEnabled(FALSE);
-		ctrl_ssao->setValue(FALSE);
-	}
-	
-	// disabled deferred shadows
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
-	{
-		ctrl_shadows->setEnabled(FALSE);
-		ctrl_shadows->setValue(0);
-		shadows_text->setEnabled(FALSE);
-	}
-
-	// disabled reflections
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
-	{
-		ctrl_reflections->setEnabled(FALSE);
-		ctrl_reflections->setValue(FALSE);
-		reflections_text->setEnabled(FALSE);
-	}
-	
-	// disabled av
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
-	{
-		ctrl_avatar_vp->setEnabled(FALSE);
-		ctrl_avatar_vp->setValue(FALSE);
-		
-		ctrl_avatar_cloth->setEnabled(FALSE);
-		ctrl_avatar_cloth->setValue(FALSE);
-
-		//deferred needs AvatarVP, disable deferred
-		ctrl_shadows->setEnabled(FALSE);
-		ctrl_shadows->setValue(0);
-		shadows_text->setEnabled(FALSE);
-		
-		ctrl_ssao->setEnabled(FALSE);
-		ctrl_ssao->setValue(FALSE);
-
-		ctrl_dof->setEnabled(FALSE);
-		ctrl_dof->setValue(FALSE);
-
-		ctrl_deferred->setEnabled(FALSE);
-		ctrl_deferred->setValue(FALSE);
-	}
-
-	// disabled cloth
-	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
-	{
-		ctrl_avatar_cloth->setEnabled(FALSE);
-		ctrl_avatar_cloth->setValue(FALSE);
-	}
+{   
+    LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
+    LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
+    LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
+    LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
+    LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
+    LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
+    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+    LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
+    LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText");
+    LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
+    LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
+    LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
+    LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
+
+    // if vertex shaders off, disable all shader related products
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
+    {
+        ctrl_shader_enable->setEnabled(FALSE);
+        ctrl_shader_enable->setValue(FALSE);
+        
+        ctrl_wind_light->setEnabled(FALSE);
+        ctrl_wind_light->setValue(FALSE);
+
+        sky->setEnabled(FALSE);
+        sky_text->setEnabled(FALSE);
+
+        ctrl_reflections->setEnabled(FALSE);
+        ctrl_reflections->setValue(0);
+        reflections_text->setEnabled(FALSE);
+        
+        ctrl_avatar_vp->setEnabled(FALSE);
+        ctrl_avatar_vp->setValue(FALSE);
+        
+        ctrl_avatar_cloth->setEnabled(FALSE);
+        ctrl_avatar_cloth->setValue(FALSE);
+
+        ctrl_shadows->setEnabled(FALSE);
+        ctrl_shadows->setValue(0);
+        shadows_text->setEnabled(FALSE);
+        
+        ctrl_ssao->setEnabled(FALSE);
+        ctrl_ssao->setValue(FALSE);
+
+        ctrl_dof->setEnabled(FALSE);
+        ctrl_dof->setValue(FALSE);
+
+        ctrl_deferred->setEnabled(FALSE);
+        ctrl_deferred->setValue(FALSE);
+    }
+    
+    // disabled windlight
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
+    {
+        ctrl_wind_light->setEnabled(FALSE);
+        ctrl_wind_light->setValue(FALSE);
+
+        sky->setEnabled(FALSE);
+        sky_text->setEnabled(FALSE);
+
+        //deferred needs windlight, disable deferred
+        ctrl_shadows->setEnabled(FALSE);
+        ctrl_shadows->setValue(0);
+        shadows_text->setEnabled(FALSE);
+        
+        ctrl_ssao->setEnabled(FALSE);
+        ctrl_ssao->setValue(FALSE);
+
+        ctrl_dof->setEnabled(FALSE);
+        ctrl_dof->setValue(FALSE);
+
+        ctrl_deferred->setEnabled(FALSE);
+        ctrl_deferred->setValue(FALSE);
+    }
+
+    // disabled deferred
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") ||
+        !gGLManager.mHasFramebufferObject)
+    {
+        ctrl_shadows->setEnabled(FALSE);
+        ctrl_shadows->setValue(0);
+        shadows_text->setEnabled(FALSE);
+        
+        ctrl_ssao->setEnabled(FALSE);
+        ctrl_ssao->setValue(FALSE);
+
+        ctrl_dof->setEnabled(FALSE);
+        ctrl_dof->setValue(FALSE);
+
+        ctrl_deferred->setEnabled(FALSE);
+        ctrl_deferred->setValue(FALSE);
+    }
+    
+    // disabled deferred SSAO
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
+    {
+        ctrl_ssao->setEnabled(FALSE);
+        ctrl_ssao->setValue(FALSE);
+    }
+    
+    // disabled deferred shadows
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
+    {
+        ctrl_shadows->setEnabled(FALSE);
+        ctrl_shadows->setValue(0);
+        shadows_text->setEnabled(FALSE);
+    }
+
+    // disabled reflections
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
+    {
+        ctrl_reflections->setEnabled(FALSE);
+        ctrl_reflections->setValue(FALSE);
+        reflections_text->setEnabled(FALSE);
+    }
+    
+    // disabled av
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
+    {
+        ctrl_avatar_vp->setEnabled(FALSE);
+        ctrl_avatar_vp->setValue(FALSE);
+        
+        ctrl_avatar_cloth->setEnabled(FALSE);
+        ctrl_avatar_cloth->setValue(FALSE);
+
+        //deferred needs AvatarVP, disable deferred
+        ctrl_shadows->setEnabled(FALSE);
+        ctrl_shadows->setValue(0);
+        shadows_text->setEnabled(FALSE);
+        
+        ctrl_ssao->setEnabled(FALSE);
+        ctrl_ssao->setValue(FALSE);
+
+        ctrl_dof->setEnabled(FALSE);
+        ctrl_dof->setValue(FALSE);
+
+        ctrl_deferred->setEnabled(FALSE);
+        ctrl_deferred->setValue(FALSE);
+    }
+
+    // disabled cloth
+    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
+    {
+        ctrl_avatar_cloth->setEnabled(FALSE);
+        ctrl_avatar_cloth->setValue(FALSE);
+    }
 }
 
 void LLFloaterPreference::refresh()
 {
-	LLPanel::refresh();
+    LLPanel::refresh();
     LLAvatarComplexityControls::setText(
         gSavedSettings.getU32("RenderAvatarMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText", true));
-	refreshEnabledState();
-	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-	if (advanced)
-	{
-		advanced->refresh();
-	}
+    refreshEnabledState();
+    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+    if (advanced)
+    {
+        advanced->refresh();
+    }
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::refresh()
 {
-	getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer)  gSavedSettings.getU32("RenderFSAASamples"));
-
-	// sliders and their text boxes
-	//	mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
-	// slider text boxes
-	updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail",		true), getChild<LLTextBox>("ObjectMeshDetailText",		true));
-	updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail",	true), getChild<LLTextBox>("FlexibleMeshDetailText",	true));
-	updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail",		true), getChild<LLTextBox>("TreeMeshDetailText",		true));
-	updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail",		true), getChild<LLTextBox>("AvatarMeshDetailText",		true));
-	updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail",	true), getChild<LLTextBox>("AvatarPhysicsDetailText",		true));
-	updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail",	true), getChild<LLTextBox>("TerrainMeshDetailText",		true));
-	updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess",	true), getChild<LLTextBox>("PostProcessText",			true));
-	updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail",		true), getChild<LLTextBox>("SkyMeshDetailText",			true));
-	updateSliderText(getChild<LLSliderCtrl>("TerrainDetail",		true), getChild<LLTextBox>("TerrainDetailText",			true));	
+    getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer)  gSavedSettings.getU32("RenderFSAASamples"));
+
+    // sliders and their text boxes
+    //  mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
+    // slider text boxes
+    updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail",     true), getChild<LLTextBox>("ObjectMeshDetailText",      true));
+    updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail",   true), getChild<LLTextBox>("FlexibleMeshDetailText",    true));
+    updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail",       true), getChild<LLTextBox>("TreeMeshDetailText",        true));
+    updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail",     true), getChild<LLTextBox>("AvatarMeshDetailText",      true));
+    updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail",  true), getChild<LLTextBox>("AvatarPhysicsDetailText",       true));
+    updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail",    true), getChild<LLTextBox>("TerrainMeshDetailText",     true));
+    updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess",    true), getChild<LLTextBox>("PostProcessText",           true));
+    updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail",        true), getChild<LLTextBox>("SkyMeshDetailText",         true));
+    updateSliderText(getChild<LLSliderCtrl>("TerrainDetail",        true), getChild<LLTextBox>("TerrainDetailText",         true)); 
     LLAvatarComplexityControls::setIndirectControls();
-	setMaxNonImpostorsText(
+    setMaxNonImpostorsText(
         gSavedSettings.getU32("RenderAvatarMaxNonImpostors"),
         getChild<LLTextBox>("IndirectMaxNonImpostorsText", true));
     LLAvatarComplexityControls::setText(
         gSavedSettings.getU32("RenderAvatarMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText", true));
-	refreshEnabledState();
+    refreshEnabledState();
 }
 
 void LLFloaterPreference::onCommitWindowedMode()
 {
-	refresh();
+    refresh();
 }
 
 void LLFloaterPreference::onChangeQuality(const LLSD& data)
 {
-	U32 level = (U32)(data.asReal());
-	LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
-	refreshEnabledGraphics();
-	refresh();
+    U32 level = (U32)(data.asReal());
+    LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
+    refreshEnabledGraphics();
+    refresh();
 }
 
 void LLFloaterPreference::onClickSetKey()
 {
-	LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
-	if (dialog)
-	{
-		dialog->setParent(this);
-	}
+    LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
+    if (dialog)
+    {
+        dialog->setParent(this);
+    }
 }
 
 void LLFloaterPreference::setKey(KEY key)
 {
-	getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key));
-	// update the control right away since we no longer wait for apply
-	getChild<LLUICtrl>("modifier_combo")->onCommit();
+    getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key));
+    // update the control right away since we no longer wait for apply
+    getChild<LLUICtrl>("modifier_combo")->onCommit();
 }
 
 void LLFloaterPreference::onClickSetMiddleMouse()
 {
-	LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo");
+    LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo");
 
-	// update the control right away since we no longer wait for apply
-	p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV);
+    // update the control right away since we no longer wait for apply
+    p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV);
 
-	//push2talk button "middle mouse" control value is in English, need to localize it for presentation
-	LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent());
-	if (advanced_preferences)
-	{
-		p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse"));
-	}
+    //push2talk button "middle mouse" control value is in English, need to localize it for presentation
+    LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent());
+    if (advanced_preferences)
+    {
+        p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse"));
+    }
 }
 
 void LLFloaterPreference::onClickSetSounds()
 {
-	// Disable Enable gesture sounds checkbox if the master sound is disabled 
-	// or if sound effects are disabled.
-	getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds"));
+    // Disable Enable gesture sounds checkbox if the master sound is disabled 
+    // or if sound effects are disabled.
+    getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds"));
 }
 
 /*
 void LLFloaterPreference::onClickSkipDialogs()
 {
-	LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this));
+    LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this));
 }
 
 void LLFloaterPreference::onClickResetDialogs()
 {
-	LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this));
+    LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this));
 }
  */
 
 void LLFloaterPreference::onClickEnablePopup()
-{	
-	LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups");
-	
-	std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected();
-	std::vector<LLScrollListItem*>::iterator itor;
-	for (itor = items.begin(); itor != items.end(); ++itor)
-	{
-		LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
-		//gSavedSettings.setWarning(templatep->mName, TRUE);
-		std::string notification_name = templatep->mName;
-		LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
-	}
-	
-	buildPopupLists();
+{   
+    LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups");
+    
+    std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected();
+    std::vector<LLScrollListItem*>::iterator itor;
+    for (itor = items.begin(); itor != items.end(); ++itor)
+    {
+        LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
+        //gSavedSettings.setWarning(templatep->mName, TRUE);
+        std::string notification_name = templatep->mName;
+        LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
+    }
+    
+    buildPopupLists();
 }
 
 void LLFloaterPreference::onClickDisablePopup()
-{	
-	LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups");
-	
-	std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected();
-	std::vector<LLScrollListItem*>::iterator itor;
-	for (itor = items.begin(); itor != items.end(); ++itor)
-	{
-		LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
-		templatep->mForm->setIgnored(true);
-	}
-	
-	buildPopupLists();
+{   
+    LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups");
+    
+    std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected();
+    std::vector<LLScrollListItem*>::iterator itor;
+    for (itor = items.begin(); itor != items.end(); ++itor)
+    {
+        LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
+        templatep->mForm->setIgnored(true);
+    }
+    
+    buildPopupLists();
 }
 
 void LLFloaterPreference::resetAllIgnored()
 {
-	for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
-		 iter != LLNotifications::instance().templatesEnd();
-		 ++iter)
-	{
-		if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
-		{
-			iter->second->mForm->setIgnored(false);
-		}
-	}
+    for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
+         iter != LLNotifications::instance().templatesEnd();
+         ++iter)
+    {
+        if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
+        {
+            iter->second->mForm->setIgnored(false);
+        }
+    }
 }
 
 void LLFloaterPreference::setAllIgnored()
 {
-	for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
-		 iter != LLNotifications::instance().templatesEnd();
-		 ++iter)
-	{
-		if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
-		{
-			iter->second->mForm->setIgnored(true);
-		}
-	}
+    for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
+         iter != LLNotifications::instance().templatesEnd();
+         ++iter)
+    {
+        if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
+        {
+            iter->second->mForm->setIgnored(true);
+        }
+    }
 }
 
 void LLFloaterPreference::onClickLogPath()
 {
-	std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath"));	 
-	mPriorInstantMessageLogPath.clear();
-	
+    std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath"));  
+    mPriorInstantMessageLogPath.clear();
+    
 
-	(new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeLogPath, this, _1, _2), proposed_name))->getFile();
+    (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeLogPath, this, _1, _2), proposed_name))->getFile();
 }
 
 void LLFloaterPreference::changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name)
 {
-	//Path changed
-	if (proposed_name != filenames[0])
-	{
-		gSavedPerAccountSettings.setString("InstantMessageLogPath", filenames[0]);
-		mPriorInstantMessageLogPath = proposed_name;
+    //Path changed
+    if (proposed_name != filenames[0])
+    {
+        gSavedPerAccountSettings.setString("InstantMessageLogPath", filenames[0]);
+        mPriorInstantMessageLogPath = proposed_name;
 
-		// enable/disable 'Delete transcripts button
-		updateDeleteTranscriptsButton();
-	}
+        // enable/disable 'Delete transcripts button
+        updateDeleteTranscriptsButton();
+    }
 }
 
 bool LLFloaterPreference::moveTranscriptsAndLog()
 {
-	std::string instantMessageLogPath(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
-	std::string chatLogPath = gDirUtilp->add(instantMessageLogPath, gDirUtilp->getUserName());
-
-	bool madeDirectory = false;
-
-	//Does the directory really exist, if not then make it
-	if(!LLFile::isdir(chatLogPath))
-	{
-		//mkdir success is defined as zero
-		if(LLFile::mkdir(chatLogPath) != 0)
-		{
-			return false;
-		}
-		madeDirectory = true;
-	}
-	
-	std::string originalConversationLogDir = LLConversationLog::instance().getFileName();
-	std::string targetConversationLogDir = gDirUtilp->add(chatLogPath, "conversation.log");
-	//Try to move the conversation log
-	if(!LLConversationLog::instance().moveLog(originalConversationLogDir, targetConversationLogDir))
-	{
-		//Couldn't move the log and created a new directory so remove the new directory
-		if(madeDirectory)
-		{
-			LLFile::rmdir(chatLogPath);
-		}
-		return false;
-	}
-
-	//Attempt to move transcripts
-	std::vector<std::string> listOfTranscripts;
-	std::vector<std::string> listOfFilesMoved;
-
-	LLLogChat::getListOfTranscriptFiles(listOfTranscripts);
-
-	if(!LLLogChat::moveTranscripts(gDirUtilp->getChatLogsDir(), 
-									instantMessageLogPath, 
-									listOfTranscripts,
-									listOfFilesMoved))
-	{
-		//Couldn't move all the transcripts so restore those that moved back to their old location
-		LLLogChat::moveTranscripts(instantMessageLogPath, 
-			gDirUtilp->getChatLogsDir(), 
-			listOfFilesMoved);
-
-		//Move the conversation log back
-		LLConversationLog::instance().moveLog(targetConversationLogDir, originalConversationLogDir);
-
-		if(madeDirectory)
-		{
-			LLFile::rmdir(chatLogPath);
-		}
-
-		return false;
-	}
-
-	gDirUtilp->setChatLogsDir(instantMessageLogPath);
-	gDirUtilp->updatePerAccountChatLogsDir();
-
-	return true;
+    std::string instantMessageLogPath(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
+    std::string chatLogPath = gDirUtilp->add(instantMessageLogPath, gDirUtilp->getUserName());
+
+    bool madeDirectory = false;
+
+    //Does the directory really exist, if not then make it
+    if(!LLFile::isdir(chatLogPath))
+    {
+        //mkdir success is defined as zero
+        if(LLFile::mkdir(chatLogPath) != 0)
+        {
+            return false;
+        }
+        madeDirectory = true;
+    }
+    
+    std::string originalConversationLogDir = LLConversationLog::instance().getFileName();
+    std::string targetConversationLogDir = gDirUtilp->add(chatLogPath, "conversation.log");
+    //Try to move the conversation log
+    if(!LLConversationLog::instance().moveLog(originalConversationLogDir, targetConversationLogDir))
+    {
+        //Couldn't move the log and created a new directory so remove the new directory
+        if(madeDirectory)
+        {
+            LLFile::rmdir(chatLogPath);
+        }
+        return false;
+    }
+
+    //Attempt to move transcripts
+    std::vector<std::string> listOfTranscripts;
+    std::vector<std::string> listOfFilesMoved;
+
+    LLLogChat::getListOfTranscriptFiles(listOfTranscripts);
+
+    if(!LLLogChat::moveTranscripts(gDirUtilp->getChatLogsDir(), 
+                                    instantMessageLogPath, 
+                                    listOfTranscripts,
+                                    listOfFilesMoved))
+    {
+        //Couldn't move all the transcripts so restore those that moved back to their old location
+        LLLogChat::moveTranscripts(instantMessageLogPath, 
+            gDirUtilp->getChatLogsDir(), 
+            listOfFilesMoved);
+
+        //Move the conversation log back
+        LLConversationLog::instance().moveLog(targetConversationLogDir, originalConversationLogDir);
+
+        if(madeDirectory)
+        {
+            LLFile::rmdir(chatLogPath);
+        }
+
+        return false;
+    }
+
+    gDirUtilp->setChatLogsDir(instantMessageLogPath);
+    gDirUtilp->updatePerAccountChatLogsDir();
+
+    return true;
 }
 
 void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email)
 {
-	mGotPersonalInfo = true;
-	mOriginalIMViaEmail = im_via_email;
-	mDirectoryVisibility = visibility;
-	
-	if (visibility == VISIBILITY_DEFAULT)
-	{
-		mOriginalHideOnlineStatus = false;
-		getChildView("online_visibility")->setEnabled(TRUE); 	 
-	}
-	else if (visibility == VISIBILITY_HIDDEN)
-	{
-		mOriginalHideOnlineStatus = true;
-		getChildView("online_visibility")->setEnabled(TRUE); 	 
-	}
-	else
-	{
-		mOriginalHideOnlineStatus = true;
-	}
-	
-	getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE);
-	getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
-	getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); 	 
-	getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
-	getChildView("send_im_to_email")->setEnabled(is_verified_email);
+    mGotPersonalInfo = true;
+    mOriginalIMViaEmail = im_via_email;
+    mDirectoryVisibility = visibility;
+    
+    if (visibility == VISIBILITY_DEFAULT)
+    {
+        mOriginalHideOnlineStatus = false;
+        getChildView("online_visibility")->setEnabled(TRUE);     
+    }
+    else if (visibility == VISIBILITY_HIDDEN)
+    {
+        mOriginalHideOnlineStatus = true;
+        getChildView("online_visibility")->setEnabled(TRUE);     
+    }
+    else
+    {
+        mOriginalHideOnlineStatus = true;
+    }
+    
+    getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE);
+    getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
+    getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus);    
+    getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
+    getChildView("send_im_to_email")->setEnabled(is_verified_email);
 
     std::string tooltip;
     if (!is_verified_email)
@@ -1867,115 +1867,115 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im
 
     // *TODO: Show or hide verify email text here based on is_verified_email
     getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email);
-	getChildView("favorites_on_login_check")->setEnabled(TRUE);
-	getChildView("log_path_button")->setEnabled(TRUE);
-	getChildView("chat_font_size")->setEnabled(TRUE);
-	getChildView("conversation_log_combo")->setEnabled(TRUE);
+    getChildView("favorites_on_login_check")->setEnabled(TRUE);
+    getChildView("log_path_button")->setEnabled(TRUE);
+    getChildView("chat_font_size")->setEnabled(TRUE);
+    getChildView("conversation_log_combo")->setEnabled(TRUE);
 }
 
 
 void LLFloaterPreference::refreshUI()
 {
-	refresh();
+    refresh();
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box)
 {
-	if (text_box == NULL || ctrl== NULL)
-		return;
-
-	// get range and points when text should change
-	F32 value = (F32)ctrl->getValue().asReal();
-	F32 min = ctrl->getMinValue();
-	F32 max = ctrl->getMaxValue();
-	F32 range = max - min;
-	llassert(range > 0);
-	F32 midPoint = min + range / 3.0f;
-	F32 highPoint = min + (2.0f * range / 3.0f);
-
-	// choose the right text
-	if (value < midPoint)
-	{
-		text_box->setText(LLTrans::getString("GraphicsQualityLow"));
-	} 
-	else if (value < highPoint)
-	{
-		text_box->setText(LLTrans::getString("GraphicsQualityMid"));
-	}
-	else
-	{
-		text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
-	}
+    if (text_box == NULL || ctrl== NULL)
+        return;
+
+    // get range and points when text should change
+    F32 value = (F32)ctrl->getValue().asReal();
+    F32 min = ctrl->getMinValue();
+    F32 max = ctrl->getMaxValue();
+    F32 range = max - min;
+    llassert(range > 0);
+    F32 midPoint = min + range / 3.0f;
+    F32 highPoint = min + (2.0f * range / 3.0f);
+
+    // choose the right text
+    if (value < midPoint)
+    {
+        text_box->setText(LLTrans::getString("GraphicsQualityLow"));
+    } 
+    else if (value < highPoint)
+    {
+        text_box->setText(LLTrans::getString("GraphicsQualityMid"));
+    }
+    else
+    {
+        text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
+    }
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors()
 {
-	// Called when the IndirectMaxNonImpostors control changes
-	// Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors
-	LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true);
-	U32 value = ctrl->getValue().asInteger();
+    // Called when the IndirectMaxNonImpostors control changes
+    // Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors
+    LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true);
+    U32 value = ctrl->getValue().asInteger();
 
-	if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value)
-	{
-		value=0;
-	}
-	gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value);
-	LLVOAvatar::updateImpostorRendering(value); // make it effective immediately
-	setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText"));
+    if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value)
+    {
+        value=0;
+    }
+    gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value);
+    LLVOAvatar::updateImpostorRendering(value); // make it effective immediately
+    setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText"));
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::setMaxNonImpostorsText(U32 value, LLTextBox* text_box)
 {
-	if (0 == value)
-	{
-		text_box->setText(LLTrans::getString("no_limit"));
-	}
-	else
-	{
-		text_box->setText(llformat("%d", value));
-	}
+    if (0 == value)
+    {
+        text_box->setText(LLTrans::getString("no_limit"));
+    }
+    else
+    {
+        text_box->setText(llformat("%d", value));
+    }
 }
 
 void LLAvatarComplexityControls::updateMax(LLSliderCtrl* slider, LLTextBox* value_label)
 {
-	// Called when the IndirectMaxComplexity control changes
-	// Responsible for fixing the slider label (IndirectMaxComplexityText) and setting RenderAvatarMaxComplexity
-	U32 indirect_value = slider->getValue().asInteger();
-	U32 max_arc;
-	
-	if (INDIRECT_MAX_ARC_OFF == indirect_value)
-	{
-		// The 'off' position is when the slider is all the way to the right, 
-		// which is a value of INDIRECT_MAX_ARC_OFF,
-		// so it is necessary to set max_arc to 0 disable muted avatars.
-		max_arc = 0;
-	}
-	else
-	{
-		// if this is changed, the inverse calculation in setIndirectMaxArc
-		// must be changed to match
-		max_arc = (U32)ll_round(exp(MIN_ARC_LOG + (ARC_LIMIT_MAP_SCALE * (indirect_value - MIN_INDIRECT_ARC_LIMIT))));
-	}
-
-	gSavedSettings.setU32("RenderAvatarMaxComplexity", (U32)max_arc);
-	setText(max_arc, value_label);
+    // Called when the IndirectMaxComplexity control changes
+    // Responsible for fixing the slider label (IndirectMaxComplexityText) and setting RenderAvatarMaxComplexity
+    U32 indirect_value = slider->getValue().asInteger();
+    U32 max_arc;
+    
+    if (INDIRECT_MAX_ARC_OFF == indirect_value)
+    {
+        // The 'off' position is when the slider is all the way to the right, 
+        // which is a value of INDIRECT_MAX_ARC_OFF,
+        // so it is necessary to set max_arc to 0 disable muted avatars.
+        max_arc = 0;
+    }
+    else
+    {
+        // if this is changed, the inverse calculation in setIndirectMaxArc
+        // must be changed to match
+        max_arc = (U32)ll_round(exp(MIN_ARC_LOG + (ARC_LIMIT_MAP_SCALE * (indirect_value - MIN_INDIRECT_ARC_LIMIT))));
+    }
+
+    gSavedSettings.setU32("RenderAvatarMaxComplexity", (U32)max_arc);
+    setText(max_arc, value_label);
 }
 
 void LLAvatarComplexityControls::setText(U32 value, LLTextBox* text_box)
 {
-	if (0 == value)
-	{
-		text_box->setText(LLTrans::getString("no_limit"));
-	}
-	else
-	{
-		text_box->setText(llformat("%d", value));
-	}
+    if (0 == value)
+    {
+        text_box->setText(LLTrans::getString("no_limit"));
+    }
+    else
+    {
+        text_box->setText(llformat("%d", value));
+    }
 }
 
 void LLFloaterPreference::updateMaxComplexity()
 {
-	// Called when the IndirectMaxComplexity control changes
+    // Called when the IndirectMaxComplexity control changes
     LLAvatarComplexityControls::updateMax(
         getChild<LLSliderCtrl>("IndirectMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText"));
@@ -1983,7 +1983,7 @@ void LLFloaterPreference::updateMaxComplexity()
 
 void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity()
 {
-	// Called when the IndirectMaxComplexity control changes
+    // Called when the IndirectMaxComplexity control changes
     LLAvatarComplexityControls::updateMax(
         getChild<LLSliderCtrl>("IndirectMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText"));
@@ -1991,16 +1991,16 @@ void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity()
 
 void LLFloaterPreference::onChangeMaturity()
 {
-	U8 sim_access = gSavedSettings.getU32("PreferredMaturity");
+    U8 sim_access = gSavedSettings.getU32("PreferredMaturity");
 
-	getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG
-															|| sim_access == SIM_ACCESS_MATURE
-															|| sim_access == SIM_ACCESS_ADULT);
+    getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG
+                                                            || sim_access == SIM_ACCESS_MATURE
+                                                            || sim_access == SIM_ACCESS_ADULT);
 
-	getChild<LLIconCtrl>("rating_icon_moderate")->setVisible(sim_access == SIM_ACCESS_MATURE
-															|| sim_access == SIM_ACCESS_ADULT);
+    getChild<LLIconCtrl>("rating_icon_moderate")->setVisible(sim_access == SIM_ACCESS_MATURE
+                                                            || sim_access == SIM_ACCESS_ADULT);
 
-	getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT);
+    getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT);
 }
 
 std::string get_category_path(LLUUID cat_id)
@@ -2064,23 +2064,23 @@ void LLFloaterPreference::onChangeAnimationFolder()
 // but the UI for this will still be enabled
 void LLFloaterPreference::onClickBlockList()
 {
-	LLFloaterSidePanelContainer::showPanel("people", "panel_people",
-		LLSD().with("people_panel_tab_name", "blocked_panel"));
+    LLFloaterSidePanelContainer::showPanel("people", "panel_people",
+        LLSD().with("people_panel_tab_name", "blocked_panel"));
 }
 
 void LLFloaterPreference::onClickProxySettings()
 {
-	LLFloaterReg::showInstance("prefs_proxy");
+    LLFloaterReg::showInstance("prefs_proxy");
 }
 
 void LLFloaterPreference::onClickTranslationSettings()
 {
-	LLFloaterReg::showInstance("prefs_translation");
+    LLFloaterReg::showInstance("prefs_translation");
 }
 
 void LLFloaterPreference::onClickAutoReplace()
 {
-	LLFloaterReg::showInstance("prefs_autoreplace");
+    LLFloaterReg::showInstance("prefs_autoreplace");
 }
 
 void LLFloaterPreference::onClickSpellChecker()
@@ -2095,141 +2095,141 @@ void LLFloaterPreference::onClickRenderExceptions()
 
 void LLFloaterPreference::onClickAdvanced()
 {
-	LLFloaterReg::showInstance("prefs_graphics_advanced");
+    LLFloaterReg::showInstance("prefs_graphics_advanced");
 
-	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-	for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-		 iter != tabcontainer->getChildList()->end(); ++iter)
-	{
-		LLView* view = *iter;
-		LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view);
-		if (panel)
-		{
-			panel->resetDirtyChilds();
-		}
-	}
+    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+    for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+         iter != tabcontainer->getChildList()->end(); ++iter)
+    {
+        LLView* view = *iter;
+        LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view);
+        if (panel)
+        {
+            panel->resetDirtyChilds();
+        }
+    }
 }
 
 void LLFloaterPreference::onClickActionChange()
 {
-	mClickActionDirty = true;
+    mClickActionDirty = true;
 }
 
 void LLFloaterPreference::onClickPermsDefault()
 {
-	LLFloaterReg::showInstance("perms_default");
+    LLFloaterReg::showInstance("perms_default");
 }
 
 void LLFloaterPreference::onDeleteTranscripts()
 {
-	LLSD args;
-	args["FOLDER"] = gDirUtilp->getUserName();
+    LLSD args;
+    args["FOLDER"] = gDirUtilp->getUserName();
 
-	LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2));
+    LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2));
 }
 
 void LLFloaterPreference::onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response)
 {
-	if (0 == LLNotificationsUtil::getSelectedOption(notification, response))
-	{
-		LLLogChat::deleteTranscripts();
-		updateDeleteTranscriptsButton();
-	}
+    if (0 == LLNotificationsUtil::getSelectedOption(notification, response))
+    {
+        LLLogChat::deleteTranscripts();
+        updateDeleteTranscriptsButton();
+    }
 }
 
 void LLFloaterPreference::onLogChatHistorySaved()
 {
-	LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts");
+    LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts");
 
-	if (!delete_transcripts_buttonp->getEnabled())
-	{
-		delete_transcripts_buttonp->setEnabled(true);
-	}
+    if (!delete_transcripts_buttonp->getEnabled())
+    {
+        delete_transcripts_buttonp->setEnabled(true);
+    }
 }
 
 void LLFloaterPreference::updateClickActionSettings()
 {
-	const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger();
-	const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger();
+    const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger();
+    const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger();
 
-	gSavedSettings.setBOOL("ClickToWalk",			single_clk_action == 1);
-	gSavedSettings.setBOOL("DoubleClickAutoPilot",	double_clk_action == 1);
-	gSavedSettings.setBOOL("DoubleClickTeleport",	double_clk_action == 2);
+    gSavedSettings.setBOOL("ClickToWalk",           single_clk_action == 1);
+    gSavedSettings.setBOOL("DoubleClickAutoPilot",  double_clk_action == 1);
+    gSavedSettings.setBOOL("DoubleClickTeleport",   double_clk_action == 2);
 }
 
 void LLFloaterPreference::updateClickActionControls()
 {
-	const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk");
-	const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot");
-	const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport");
+    const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk");
+    const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot");
+    const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport");
 
-	getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk);
-	getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk);
+    getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk);
+    getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk);
 }
 
 void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param)
 {
-	LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue()));
+    LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue()));
 }
 
 void LLFloaterPreference::getUIColor(LLUICtrl* ctrl, const LLSD& param)
 {
-	LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl;
-	color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString()));
+    LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl;
+    color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString()));
 }
 
 void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location)
 {
-	LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location");
-	cache_location_editor->setValue(location);
-	cache_location_editor->setToolTip(location);
+    LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location");
+    cache_location_editor->setValue(location);
+    cache_location_editor->setToolTip(location);
 }
 
 void LLFloaterPreference::selectPanel(const LLSD& name)
 {
-	LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");
-	LLPanel * panel = tab_containerp->getPanelByName(name);
-	if (NULL != panel)
-	{
-		tab_containerp->selectTabPanel(panel);
-	}
+    LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");
+    LLPanel * panel = tab_containerp->getPanelByName(name);
+    if (NULL != panel)
+    {
+        tab_containerp->selectTabPanel(panel);
+    }
 }
 
 void LLFloaterPreference::selectPrivacyPanel()
 {
-	selectPanel("im");
+    selectPanel("im");
 }
 
 void LLFloaterPreference::selectChatPanel()
 {
-	selectPanel("chat");
+    selectPanel("chat");
 }
 
 void LLFloaterPreference::changed()
 {
-	getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0);
+    getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0);
 
-	// set 'enable' property for 'Delete transcripts...' button
-	updateDeleteTranscriptsButton();
+    // set 'enable' property for 'Delete transcripts...' button
+    updateDeleteTranscriptsButton();
 
 }
 
 void LLFloaterPreference::saveCameraPreset(std::string& preset)
 {
-	mSavedCameraPreset = preset;
+    mSavedCameraPreset = preset;
 }
 
 void LLFloaterPreference::saveGraphicsPreset(std::string& preset)
 {
-	mSavedGraphicsPreset = preset;
+    mSavedGraphicsPreset = preset;
 }
 
 //------------------------------Updater---------------------------------------
 
 static bool handleBandwidthChanged(const LLSD& newvalue)
 {
-	gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
-	return true;
+    gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
+    return true;
 }
 
 class LLPanelPreference::Updater : public LLEventTimer
@@ -2237,37 +2237,37 @@ class LLPanelPreference::Updater : public LLEventTimer
 
 public:
 
-	typedef boost::function<bool(const LLSD&)> callback_t;
+    typedef boost::function<bool(const LLSD&)> callback_t;
 
-	Updater(callback_t cb, F32 period)
-	:LLEventTimer(period),
-	 mCallback(cb)
-	{
-		mEventTimer.stop();
-	}
+    Updater(callback_t cb, F32 period)
+    :LLEventTimer(period),
+     mCallback(cb)
+    {
+        mEventTimer.stop();
+    }
 
-	virtual ~Updater(){}
+    virtual ~Updater(){}
 
-	void update(const LLSD& new_value)
-	{
-		mNewValue = new_value;
-		mEventTimer.start();
-	}
+    void update(const LLSD& new_value)
+    {
+        mNewValue = new_value;
+        mEventTimer.start();
+    }
 
 protected:
 
-	BOOL tick()
-	{
-		mCallback(mNewValue);
-		mEventTimer.stop();
+    BOOL tick()
+    {
+        mCallback(mNewValue);
+        mEventTimer.stop();
 
-		return FALSE;
-	}
+        return FALSE;
+    }
 
 private:
 
-	LLSD mNewValue;
-	callback_t mCallback;
+    LLSD mNewValue;
+    callback_t mCallback;
 };
 //----------------------------------------------------------------------------
 static LLPanelInjector<LLPanelPreference> t_places("panel_preference");
@@ -2275,169 +2275,169 @@ LLPanelPreference::LLPanelPreference()
 : LLPanel(),
   mBandWidthUpdater(NULL)
 {
-	mCommitCallbackRegistrar.add("Pref.setControlFalse",	boost::bind(&LLPanelPreference::setControlFalse,this, _2));
-	mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox",	boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1));
-	mCommitCallbackRegistrar.add("Pref.PrefDelete",	boost::bind(&LLPanelPreference::deletePreset, this, _2));
-	mCommitCallbackRegistrar.add("Pref.PrefSave",	boost::bind(&LLPanelPreference::savePreset, this, _2));
-	mCommitCallbackRegistrar.add("Pref.PrefLoad",	boost::bind(&LLPanelPreference::loadPreset, this, _2));
+    mCommitCallbackRegistrar.add("Pref.setControlFalse",    boost::bind(&LLPanelPreference::setControlFalse,this, _2));
+    mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox",    boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1));
+    mCommitCallbackRegistrar.add("Pref.PrefDelete", boost::bind(&LLPanelPreference::deletePreset, this, _2));
+    mCommitCallbackRegistrar.add("Pref.PrefSave",   boost::bind(&LLPanelPreference::savePreset, this, _2));
+    mCommitCallbackRegistrar.add("Pref.PrefLoad",   boost::bind(&LLPanelPreference::loadPreset, this, _2));
 }
 
 //virtual
 BOOL LLPanelPreference::postBuild()
 {
-	////////////////////// PanelGeneral ///////////////////
-	if (hasChild("display_names_check", TRUE))
-	{
-		BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI");
-		LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check");
-		ctrl_display_name->setEnabled(use_people_api);
-		if (!use_people_api)
-		{
-			ctrl_display_name->setValue(FALSE);
-		}
-	}
-
-	////////////////////// PanelVoice ///////////////////
-	if (hasChild("voice_unavailable", TRUE))
-	{
-		BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
-		getChildView("voice_unavailable")->setVisible( voice_disabled);
-		getChildView("enable_voice_check")->setVisible( !voice_disabled);
-	}
-	
-	//////////////////////PanelSkins ///////////////////
-	
-	if (hasChild("skin_selection", TRUE))
-	{
-		LLFloaterPreference::refreshSkin(this);
-
-		// if skin is set to a skin that no longer exists (silver) set back to default
-		if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0)
-		{
-			gSavedSettings.setString("SkinCurrent", "default");
-			LLFloaterPreference::refreshSkin(this);
-		}
-
-	}
-
-	//////////////////////PanelPrivacy ///////////////////
-	if (hasChild("media_enabled", TRUE))
-	{
-		bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
-		
-		getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
-		getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
-	}
-	if (hasChild("music_enabled", TRUE))
-	{
-		getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
-	}
-	if (hasChild("voice_call_friends_only_check", TRUE))
-	{
-		getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
-	}
-	if (hasChild("allow_multiple_viewer_check", TRUE))
-	{
-		getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2));
-	}
-	if (hasChild("favorites_on_login_check", TRUE))
-	{
-		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
-		bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
-		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
-	}
-	if (hasChild("mute_chb_label", TRUE))
-	{
-		getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false);
-		getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized));
-	}
-
-	//////////////////////PanelAdvanced ///////////////////
-	if (hasChild("modifier_combo", TRUE))
-	{
-		//localizing if push2talk button is set to middle mouse
-		if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString())
-		{
-			getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse"));
-		}
-	}
-
-	//////////////////////PanelSetup ///////////////////
-	if (hasChild("max_bandwidth"), TRUE)
-	{
-		mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT);
-		gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2));
-	}
+    ////////////////////// PanelGeneral ///////////////////
+    if (hasChild("display_names_check", TRUE))
+    {
+        BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI");
+        LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check");
+        ctrl_display_name->setEnabled(use_people_api);
+        if (!use_people_api)
+        {
+            ctrl_display_name->setValue(FALSE);
+        }
+    }
+
+    ////////////////////// PanelVoice ///////////////////
+    if (hasChild("voice_unavailable", TRUE))
+    {
+        BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
+        getChildView("voice_unavailable")->setVisible( voice_disabled);
+        getChildView("enable_voice_check")->setVisible( !voice_disabled);
+    }
+    
+    //////////////////////PanelSkins ///////////////////
+    
+    if (hasChild("skin_selection", TRUE))
+    {
+        LLFloaterPreference::refreshSkin(this);
+
+        // if skin is set to a skin that no longer exists (silver) set back to default
+        if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0)
+        {
+            gSavedSettings.setString("SkinCurrent", "default");
+            LLFloaterPreference::refreshSkin(this);
+        }
+
+    }
+
+    //////////////////////PanelPrivacy ///////////////////
+    if (hasChild("media_enabled", TRUE))
+    {
+        bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
+        
+        getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
+        getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
+    }
+    if (hasChild("music_enabled", TRUE))
+    {
+        getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
+    }
+    if (hasChild("voice_call_friends_only_check", TRUE))
+    {
+        getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
+    }
+    if (hasChild("allow_multiple_viewer_check", TRUE))
+    {
+        getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2));
+    }
+    if (hasChild("favorites_on_login_check", TRUE))
+    {
+        getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
+        bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
+        getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
+    }
+    if (hasChild("mute_chb_label", TRUE))
+    {
+        getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false);
+        getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized));
+    }
+
+    //////////////////////PanelAdvanced ///////////////////
+    if (hasChild("modifier_combo", TRUE))
+    {
+        //localizing if push2talk button is set to middle mouse
+        if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString())
+        {
+            getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse"));
+        }
+    }
+
+    //////////////////////PanelSetup ///////////////////
+    if (hasChild("max_bandwidth"), TRUE)
+    {
+        mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT);
+        gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2));
+    }
 
 #ifdef EXTERNAL_TOS
-	LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior");
-	if (ext_browser_settings)
-	{
-		// turn off ability to set external/internal browser
-		ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true);
-		ext_browser_settings->setEnabled(false);
-	}
+    LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior");
+    if (ext_browser_settings)
+    {
+        // turn off ability to set external/internal browser
+        ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true);
+        ext_browser_settings->setEnabled(false);
+    }
 #endif
 
-	apply();
-	return true;
+    apply();
+    return true;
 }
 
 LLPanelPreference::~LLPanelPreference()
 {
-	if (mBandWidthUpdater)
-	{
-		delete mBandWidthUpdater;
-	}
+    if (mBandWidthUpdater)
+    {
+        delete mBandWidthUpdater;
+    }
 }
 void LLPanelPreference::apply()
 {
-	// no-op
+    // no-op
 }
 
 void LLPanelPreference::saveSettings()
 {
-	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-
-	// Save the value of all controls in the hierarchy
-	mSavedValues.clear();
-	std::list<LLView*> view_stack;
-	view_stack.push_back(this);
-	if (advanced)
-	{
-		view_stack.push_back(advanced);
-	}
-	while(!view_stack.empty())
-	{
-		// Process view on top of the stack
-		LLView* curview = view_stack.front();
-		view_stack.pop_front();
-
-		LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
-		if (color_swatch)
-		{
-			mSavedColors[color_swatch->getName()] = color_swatch->get();
-		}
-		else
-		{
-			LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-			if (ctrl)
-			{
-				LLControlVariable* control = ctrl->getControlVariable();
-				if (control)
-				{
-					mSavedValues[control] = control->getValue();
-				}
-			}
-		}
-			
-		// Push children onto the end of the work stack
-		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-			 iter != curview->getChildList()->end(); ++iter)
-		{
-			view_stack.push_back(*iter);
-		}
-	}	
+    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+
+    // Save the value of all controls in the hierarchy
+    mSavedValues.clear();
+    std::list<LLView*> view_stack;
+    view_stack.push_back(this);
+    if (advanced)
+    {
+        view_stack.push_back(advanced);
+    }
+    while(!view_stack.empty())
+    {
+        // Process view on top of the stack
+        LLView* curview = view_stack.front();
+        view_stack.pop_front();
+
+        LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
+        if (color_swatch)
+        {
+            mSavedColors[color_swatch->getName()] = color_swatch->get();
+        }
+        else
+        {
+            LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+            if (ctrl)
+            {
+                LLControlVariable* control = ctrl->getControlVariable();
+                if (control)
+                {
+                    mSavedValues[control] = control->getValue();
+                }
+            }
+        }
+            
+        // Push children onto the end of the work stack
+        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+             iter != curview->getChildList()->end(); ++iter)
+        {
+            view_stack.push_back(*iter);
+        }
+    }   
 }
 
 void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLSD& value)
@@ -2450,104 +2450,104 @@ void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLS
 
 void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& value)
 {
-	if (checkbox && checkbox->getValue())
-	{
-		LLNotificationsUtil::add("FriendsAndGroupsOnly");
-	}
+    if (checkbox && checkbox->getValue())
+    {
+        LLNotificationsUtil::add("FriendsAndGroupsOnly");
+    }
 }
 
 void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value)
 {
-	if (checkbox)
-	{
-		LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
-		if(checkbox->getValue())
-		{
-			LLNotificationsUtil::add("FavoritesOnLogin");
-		}
-	}
+    if (checkbox)
+    {
+        LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
+        if(checkbox->getValue())
+        {
+            LLNotificationsUtil::add("FavoritesOnLogin");
+        }
+    }
 }
 
 void LLPanelPreference::toggleMuteWhenMinimized()
 {
-	std::string mute("MuteWhenMinimized");
-	gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute));
+    std::string mute("MuteWhenMinimized");
+    gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute));
 }
 
 void LLPanelPreference::cancel()
 {
-	for (control_values_map_t::iterator iter =  mSavedValues.begin();
-		 iter !=  mSavedValues.end(); ++iter)
-	{
-		LLControlVariable* control = iter->first;
-		LLSD ctrl_value = iter->second;
+    for (control_values_map_t::iterator iter =  mSavedValues.begin();
+         iter !=  mSavedValues.end(); ++iter)
+    {
+        LLControlVariable* control = iter->first;
+        LLSD ctrl_value = iter->second;
 
-		if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == ""))
-		{
-			continue;
-		}
+        if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == ""))
+        {
+            continue;
+        }
 
-		control->set(ctrl_value);
-	}
+        control->set(ctrl_value);
+    }
 
-	for (string_color_map_t::iterator iter = mSavedColors.begin();
-		 iter != mSavedColors.end(); ++iter)
-	{
-		LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
-		if (color_swatch)
-		{
-			color_swatch->set(iter->second);
-			color_swatch->onCommit();
-		}
-	}
+    for (string_color_map_t::iterator iter = mSavedColors.begin();
+         iter != mSavedColors.end(); ++iter)
+    {
+        LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
+        if (color_swatch)
+        {
+            color_swatch->set(iter->second);
+            color_swatch->onCommit();
+        }
+    }
 }
 
 void LLPanelPreference::setControlFalse(const LLSD& user_data)
 {
-	std::string control_name = user_data.asString();
-	LLControlVariable* control = findControl(control_name);
-	
-	if (control)
-		control->set(LLSD(FALSE));
+    std::string control_name = user_data.asString();
+    LLControlVariable* control = findControl(control_name);
+    
+    if (control)
+        control->set(LLSD(FALSE));
 }
 
 void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
 {
-	std::string name = ctrl->getName();
+    std::string name = ctrl->getName();
 
-	// Disable "Allow Media to auto play" only when both
-	// "Streaming Music" and "Media" are unchecked. STORM-513.
-	if ((name == "enable_music") || (name == "enable_media"))
-	{
-		bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
-		bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
+    // Disable "Allow Media to auto play" only when both
+    // "Streaming Music" and "Media" are unchecked. STORM-513.
+    if ((name == "enable_music") || (name == "enable_media"))
+    {
+        bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
+        bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
 
-		getChild<LLCheckBoxCtrl>("media_auto_play_btn")->setEnabled(music_enabled || media_enabled);
-	}
+        getChild<LLCheckBoxCtrl>("media_auto_play_btn")->setEnabled(music_enabled || media_enabled);
+    }
 }
 
 void LLPanelPreference::deletePreset(const LLSD& user_data)
 {
-	std::string subdirectory = user_data.asString();
-	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
-	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
-	LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
+    std::string subdirectory = user_data.asString();
+    LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
+    LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
+    LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::savePreset(const LLSD& user_data)
 {
-	std::string subdirectory = user_data.asString();
-	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
-	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
-	LLFloaterReg::showInstance("save_pref_preset", subdirectory);
+    std::string subdirectory = user_data.asString();
+    LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
+    LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
+    LLFloaterReg::showInstance("save_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::loadPreset(const LLSD& user_data)
 {
-	std::string subdirectory = user_data.asString();
-	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
-	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
-	LLFloaterReg::showInstance("load_pref_preset", subdirectory);
+    std::string subdirectory = user_data.asString();
+    LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
+    LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
+    LLFloaterReg::showInstance("load_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::setHardwareDefaults()
@@ -2557,39 +2557,39 @@ void LLPanelPreference::setHardwareDefaults()
 class LLPanelPreferencePrivacy : public LLPanelPreference
 {
 public:
-	LLPanelPreferencePrivacy()
-	{
-		mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly");
-		mAccountIndependentSettings.push_back("AutoDisengageMic");
-	}
-
-	/*virtual*/ void saveSettings()
-	{
-		LLPanelPreference::saveSettings();
-
-		// Don't save (=erase from the saved values map) per-account privacy settings
-		// if we're not logged in, otherwise they will be reset to defaults on log off.
-		if (LLStartUp::getStartupState() != STATE_STARTED)
-		{
-			// Erase only common settings, assuming there are no color settings on Privacy page.
-			for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); )
-			{
-				const std::string setting = it->first->getName();
-				if (find(mAccountIndependentSettings.begin(),
-					mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end())
-				{
-					mSavedValues.erase(it++);
-				}
-				else
-				{
-					++it;
-				}
-			}
-		}
-	}
+    LLPanelPreferencePrivacy()
+    {
+        mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly");
+        mAccountIndependentSettings.push_back("AutoDisengageMic");
+    }
+
+    /*virtual*/ void saveSettings()
+    {
+        LLPanelPreference::saveSettings();
+
+        // Don't save (=erase from the saved values map) per-account privacy settings
+        // if we're not logged in, otherwise they will be reset to defaults on log off.
+        if (LLStartUp::getStartupState() != STATE_STARTED)
+        {
+            // Erase only common settings, assuming there are no color settings on Privacy page.
+            for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); )
+            {
+                const std::string setting = it->first->getName();
+                if (find(mAccountIndependentSettings.begin(),
+                    mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end())
+                {
+                    mSavedValues.erase(it++);
+                }
+                else
+                {
+                    ++it;
+                }
+            }
+        }
+    }
 
 private:
-	std::list<std::string> mAccountIndependentSettings;
+    std::list<std::string> mAccountIndependentSettings;
 };
 
 static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
@@ -2598,253 +2598,253 @@ static LLPanelInjector<LLPanelPreferenceView> t_pref_view("panel_preference_view
 
 BOOL LLPanelPreferenceView::postBuild()
 {
-	setPresetText();
+    setPresetText();
 
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this));
-		presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok
-	}
+    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+    if (presetsMgr)
+    {
+        presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this));
+        presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok
+    }
 
-	return LLPanelPreference::postBuild();
+    return LLPanelPreference::postBuild();
 }
 
 void LLPanelPreferenceView::onPresetsListChangeCamera()
 {
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		presetsMgr->setCameraDirty(false);
-	}
+    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+    if (presetsMgr)
+    {
+        presetsMgr->setCameraDirty(false);
+    }
 
-	setPresetText();
+    setPresetText();
 
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance && !gSavedSettings.getString("PresetCameraActive").empty())
-	{
-		instance->saveSettings(); //make cancel work correctly after changing the preset
-	}
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance && !gSavedSettings.getString("PresetCameraActive").empty())
+    {
+        instance->saveSettings(); //make cancel work correctly after changing the preset
+    }
 }
 
 void LLPanelPreferenceView::draw()
 {
-	setPresetText();
-	LLPanelPreference::draw();
+    setPresetText();
+    LLPanelPreference::draw();
 }
 
 void LLPanelPreferenceView::setPresetText()
 {
-	LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text");
-
-	std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive");
-
-	if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText())
-	{
-		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-		if (instance)
-		{
-			instance->saveCameraPreset(preset_camera_active);
-		}
-	}
-
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
-		{
-			preset_camera_active.clear();
-		}
-	}
-
-	if (!preset_camera_active.empty())
-	{
-		if (preset_camera_active == PRESETS_DEFAULT)
-		{
-			preset_camera_active = LLTrans::getString(PRESETS_DEFAULT);
-		}
-		preset_text->setText(preset_camera_active);
-	}
-	else
-	{
-		preset_text->setText(LLTrans::getString("none_paren_cap"));
-	}
+    LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text");
+
+    std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive");
+
+    if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText())
+    {
+        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+        if (instance)
+        {
+            instance->saveCameraPreset(preset_camera_active);
+        }
+    }
+
+    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+    if (presetsMgr)
+    {
+        if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
+        {
+            preset_camera_active.clear();
+        }
+    }
+
+    if (!preset_camera_active.empty())
+    {
+        if (preset_camera_active == PRESETS_DEFAULT)
+        {
+            preset_camera_active = LLTrans::getString(PRESETS_DEFAULT);
+        }
+        preset_text->setText(preset_camera_active);
+    }
+    else
+    {
+        preset_text->setText(LLTrans::getString("none_paren_cap"));
+    }
 }
 
 BOOL LLPanelPreferenceGraphics::postBuild()
 {
-	LLFloaterReg::showInstance("prefs_graphics_advanced");
-	LLFloaterReg::hideInstance("prefs_graphics_advanced");
+    LLFloaterReg::showInstance("prefs_graphics_advanced");
+    LLFloaterReg::hideInstance("prefs_graphics_advanced");
 
-	resetDirtyChilds();
-	setPresetText();
+    resetDirtyChilds();
+    setPresetText();
 
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
     presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this));
     presetsMgr->createMissingDefault(PRESETS_GRAPHIC); // a no-op after the first time, but that's ok
     
-	return LLPanelPreference::postBuild();
+    return LLPanelPreference::postBuild();
 }
 
 void LLPanelPreferenceGraphics::draw()
 {
-	setPresetText();
-	LLPanelPreference::draw();
+    setPresetText();
+    LLPanelPreference::draw();
 }
 
 void LLPanelPreferenceGraphics::onPresetsListChange()
 {
-	resetDirtyChilds();
-	setPresetText();
+    resetDirtyChilds();
+    setPresetText();
 
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance && !gSavedSettings.getString("PresetGraphicActive").empty())
-	{
-		instance->saveSettings(); //make cancel work correctly after changing the preset
-	}
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance && !gSavedSettings.getString("PresetGraphicActive").empty())
+    {
+        instance->saveSettings(); //make cancel work correctly after changing the preset
+    }
 }
 
 void LLPanelPreferenceGraphics::setPresetText()
 {
-	LLTextBox* preset_text = getChild<LLTextBox>("preset_text");
-
-	std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-
-	if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText())
-	{
-		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-		if (instance)
-		{
-			instance->saveGraphicsPreset(preset_graphic_active);
-		}
-	}
-
-	if (hasDirtyChilds() && !preset_graphic_active.empty())
-	{
-		gSavedSettings.setString("PresetGraphicActive", "");
-		preset_graphic_active.clear();
-		// This doesn't seem to cause an infinite recursion.  This trigger is needed to cause the pulldown
-		// panel to update.
-		LLPresetsManager::getInstance()->triggerChangeSignal();
-	}
-
-	if (!preset_graphic_active.empty())
-	{
-		if (preset_graphic_active == PRESETS_DEFAULT)
-		{
-			preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT);
-		}
-		preset_text->setText(preset_graphic_active);
-	}
-	else
-	{
-		preset_text->setText(LLTrans::getString("none_paren_cap"));
-	}
-
-	preset_text->resetDirty();
+    LLTextBox* preset_text = getChild<LLTextBox>("preset_text");
+
+    std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+
+    if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText())
+    {
+        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+        if (instance)
+        {
+            instance->saveGraphicsPreset(preset_graphic_active);
+        }
+    }
+
+    if (hasDirtyChilds() && !preset_graphic_active.empty())
+    {
+        gSavedSettings.setString("PresetGraphicActive", "");
+        preset_graphic_active.clear();
+        // This doesn't seem to cause an infinite recursion.  This trigger is needed to cause the pulldown
+        // panel to update.
+        LLPresetsManager::getInstance()->triggerChangeSignal();
+    }
+
+    if (!preset_graphic_active.empty())
+    {
+        if (preset_graphic_active == PRESETS_DEFAULT)
+        {
+            preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT);
+        }
+        preset_text->setText(preset_graphic_active);
+    }
+    else
+    {
+        preset_text->setText(LLTrans::getString("none_paren_cap"));
+    }
+
+    preset_text->resetDirty();
 }
 
 bool LLPanelPreferenceGraphics::hasDirtyChilds()
 {
-	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-	std::list<LLView*> view_stack;
-	view_stack.push_back(this);
-	if (advanced)
-	{
-		view_stack.push_back(advanced);
-	}
-	while(!view_stack.empty())
-	{
-		// Process view on top of the stack
-		LLView* curview = view_stack.front();
-		view_stack.pop_front();
-
-		LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-		if (ctrl)
-		{
-			if (ctrl->isDirty())
-			{
-				LLControlVariable* control = ctrl->getControlVariable();
-				if (control)
-				{
-					std::string control_name = control->getName();
-					if (!control_name.empty())
-					{
-						return true;
-					}
-				}
-			}
-		}
-		// Push children onto the end of the work stack
-		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-			 iter != curview->getChildList()->end(); ++iter)
-		{
-			view_stack.push_back(*iter);
-		}
-	}
-
-	return false;
+    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+    std::list<LLView*> view_stack;
+    view_stack.push_back(this);
+    if (advanced)
+    {
+        view_stack.push_back(advanced);
+    }
+    while(!view_stack.empty())
+    {
+        // Process view on top of the stack
+        LLView* curview = view_stack.front();
+        view_stack.pop_front();
+
+        LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+        if (ctrl)
+        {
+            if (ctrl->isDirty())
+            {
+                LLControlVariable* control = ctrl->getControlVariable();
+                if (control)
+                {
+                    std::string control_name = control->getName();
+                    if (!control_name.empty())
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+        // Push children onto the end of the work stack
+        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+             iter != curview->getChildList()->end(); ++iter)
+        {
+            view_stack.push_back(*iter);
+        }
+    }
+
+    return false;
 }
 
 void LLPanelPreferenceGraphics::resetDirtyChilds()
 {
-	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-	std::list<LLView*> view_stack;
-	view_stack.push_back(this);
-	if (advanced)
-	{
-		view_stack.push_back(advanced);
-	}
-	while(!view_stack.empty())
-	{
-		// Process view on top of the stack
-		LLView* curview = view_stack.front();
-		view_stack.pop_front();
-
-		LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-		if (ctrl)
-		{
-			ctrl->resetDirty();
-		}
-		// Push children onto the end of the work stack
-		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-			 iter != curview->getChildList()->end(); ++iter)
-		{
-			view_stack.push_back(*iter);
-		}
-	}	
+    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+    std::list<LLView*> view_stack;
+    view_stack.push_back(this);
+    if (advanced)
+    {
+        view_stack.push_back(advanced);
+    }
+    while(!view_stack.empty())
+    {
+        // Process view on top of the stack
+        LLView* curview = view_stack.front();
+        view_stack.pop_front();
+
+        LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+        if (ctrl)
+        {
+            ctrl->resetDirty();
+        }
+        // Push children onto the end of the work stack
+        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+             iter != curview->getChildList()->end(); ++iter)
+        {
+            view_stack.push_back(*iter);
+        }
+    }   
 }
 
 void LLPanelPreferenceGraphics::cancel()
 {
-	LLPanelPreference::cancel();
+    LLPanelPreference::cancel();
 }
 void LLPanelPreferenceGraphics::saveSettings()
 {
-	resetDirtyChilds();
-	std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-	if (preset_graphic_active.empty())
-	{
-		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-		if (instance)
-		{
-			//don't restore previous preset after closing Preferences
-			instance->saveGraphicsPreset(preset_graphic_active);
-		}
-	}
-	LLPanelPreference::saveSettings();
+    resetDirtyChilds();
+    std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+    if (preset_graphic_active.empty())
+    {
+        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+        if (instance)
+        {
+            //don't restore previous preset after closing Preferences
+            instance->saveGraphicsPreset(preset_graphic_active);
+        }
+    }
+    LLPanelPreference::saveSettings();
 }
 void LLPanelPreferenceGraphics::setHardwareDefaults()
 {
-	resetDirtyChilds();
+    resetDirtyChilds();
 }
 
 LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key)
-	: LLFloater(key)
+    : LLFloater(key)
 {
-	mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",		boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this));
-	mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this));
-	mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",   boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this));
+    mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",     boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this));
+    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this));
+    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",   boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this));
 }
 
 LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced()
@@ -2852,12 +2852,12 @@ LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced()
 }
 
 LLFloaterPreferenceProxy::LLFloaterPreferenceProxy(const LLSD& key)
-	: LLFloater(key),
-	  mSocksSettingsDirty(false)
+    : LLFloater(key),
+      mSocksSettingsDirty(false)
 {
-	mCommitCallbackRegistrar.add("Proxy.OK",                boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this));
-	mCommitCallbackRegistrar.add("Proxy.Cancel",            boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this));
-	mCommitCallbackRegistrar.add("Proxy.Change",            boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this));
+    mCommitCallbackRegistrar.add("Proxy.OK",                boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this));
+    mCommitCallbackRegistrar.add("Proxy.Cancel",            boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this));
+    mCommitCallbackRegistrar.add("Proxy.Change",            boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this));
 }
 
 BOOL LLFloaterPreferenceGraphicsAdvanced::postBuild()
@@ -2884,11 +2884,11 @@ void LLFloaterPreferenceGraphicsAdvanced::onOpen(const LLSD& key)
 
 void LLFloaterPreferenceGraphicsAdvanced::onClickCloseBtn(bool app_quitting)
 {
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance)
-	{
-		instance->cancel();
-	}
+    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+    if (instance)
+    {
+        instance->cancel();
+    }
 }
 
 LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy()
@@ -2897,182 +2897,182 @@ LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy()
 
 BOOL LLFloaterPreferenceProxy::postBuild()
 {
-	LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
-	if (!socksAuth)
-	{
-		return FALSE;
-	}
-	if (socksAuth->getSelectedValue().asString() == "None")
-	{
-		getChild<LLLineEditor>("socks5_username")->setEnabled(false);
-		getChild<LLLineEditor>("socks5_password")->setEnabled(false);
-	}
-	else
-	{
-		// Populate the SOCKS 5 credential fields with protected values.
-		LLPointer<LLCredential> socks_cred = gSecAPIHandler->loadCredential("SOCKS5");
-		getChild<LLLineEditor>("socks5_username")->setValue(socks_cred->getIdentifier()["username"].asString());
-		getChild<LLLineEditor>("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString());
-	}
-
-	return TRUE;
+    LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+    if (!socksAuth)
+    {
+        return FALSE;
+    }
+    if (socksAuth->getSelectedValue().asString() == "None")
+    {
+        getChild<LLLineEditor>("socks5_username")->setEnabled(false);
+        getChild<LLLineEditor>("socks5_password")->setEnabled(false);
+    }
+    else
+    {
+        // Populate the SOCKS 5 credential fields with protected values.
+        LLPointer<LLCredential> socks_cred = gSecAPIHandler->loadCredential("SOCKS5");
+        getChild<LLLineEditor>("socks5_username")->setValue(socks_cred->getIdentifier()["username"].asString());
+        getChild<LLLineEditor>("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString());
+    }
+
+    return TRUE;
 }
 
 void LLFloaterPreferenceProxy::onOpen(const LLSD& key)
 {
-	saveSettings();
+    saveSettings();
 }
 
 void LLFloaterPreferenceProxy::onClose(bool app_quitting)
 {
-	if(app_quitting)
-	{
-		cancel();
-	}
+    if(app_quitting)
+    {
+        cancel();
+    }
 
-	if (mSocksSettingsDirty)
-	{
+    if (mSocksSettingsDirty)
+    {
 
-		// If the user plays with the Socks proxy settings after login, it's only fair we let them know
-		// it will not be updated until next restart.
-		if (LLStartUp::getStartupState()>STATE_LOGIN_WAIT)
-		{
-			LLNotifications::instance().add("ChangeProxySettings", LLSD(), LLSD());
-			mSocksSettingsDirty = false; // we have notified the user now be quiet again
-		}
-	}
+        // If the user plays with the Socks proxy settings after login, it's only fair we let them know
+        // it will not be updated until next restart.
+        if (LLStartUp::getStartupState()>STATE_LOGIN_WAIT)
+        {
+            LLNotifications::instance().add("ChangeProxySettings", LLSD(), LLSD());
+            mSocksSettingsDirty = false; // we have notified the user now be quiet again
+        }
+    }
 }
 
 void LLFloaterPreferenceProxy::saveSettings()
 {
-	// Save the value of all controls in the hierarchy
-	mSavedValues.clear();
-	std::list<LLView*> view_stack;
-	view_stack.push_back(this);
-	while(!view_stack.empty())
-	{
-		// Process view on top of the stack
-		LLView* curview = view_stack.front();
-		view_stack.pop_front();
-
-		LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-		if (ctrl)
-		{
-			LLControlVariable* control = ctrl->getControlVariable();
-			if (control)
-			{
-				mSavedValues[control] = control->getValue();
-			}
-		}
-
-		// Push children onto the end of the work stack
-		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-				iter != curview->getChildList()->end(); ++iter)
-		{
-			view_stack.push_back(*iter);
-		}
-	}
+    // Save the value of all controls in the hierarchy
+    mSavedValues.clear();
+    std::list<LLView*> view_stack;
+    view_stack.push_back(this);
+    while(!view_stack.empty())
+    {
+        // Process view on top of the stack
+        LLView* curview = view_stack.front();
+        view_stack.pop_front();
+
+        LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+        if (ctrl)
+        {
+            LLControlVariable* control = ctrl->getControlVariable();
+            if (control)
+            {
+                mSavedValues[control] = control->getValue();
+            }
+        }
+
+        // Push children onto the end of the work stack
+        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+                iter != curview->getChildList()->end(); ++iter)
+        {
+            view_stack.push_back(*iter);
+        }
+    }
 }
 
 void LLFloaterPreferenceProxy::onBtnOk()
 {
-	// commit any outstanding text entry
-	if (hasFocus())
-	{
-		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-		if (cur_focus && cur_focus->acceptsTextInput())
-		{
-			cur_focus->onCommit();
-		}
-	}
-
-	// Save SOCKS proxy credentials securely if password auth is enabled
-	LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
-	if (socksAuth->getSelectedValue().asString() == "UserPass")
-	{
-		LLSD socks_id = LLSD::emptyMap();
-		socks_id["type"] = "SOCKS5";
-		socks_id["username"] = getChild<LLLineEditor>("socks5_username")->getValue().asString();
-
-		LLSD socks_authenticator = LLSD::emptyMap();
-		socks_authenticator["type"] = "SOCKS5";
-		socks_authenticator["creds"] = getChild<LLLineEditor>("socks5_password")->getValue().asString();
-
-		// Using "SOCKS5" as the "grid" argument since the same proxy
-		// settings will be used for all grids and because there is no
-		// way to specify the type of credential.
-		LLPointer<LLCredential> socks_cred = gSecAPIHandler->createCredential("SOCKS5", socks_id, socks_authenticator);
-		gSecAPIHandler->saveCredential(socks_cred, true);
-	}
-	else
-	{
-		// Clear SOCKS5 credentials since they are no longer needed.
-		LLPointer<LLCredential> socks_cred = new LLCredential("SOCKS5");
-		gSecAPIHandler->deleteCredential(socks_cred);
-	}
-
-	closeFloater(false);
+    // commit any outstanding text entry
+    if (hasFocus())
+    {
+        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+        if (cur_focus && cur_focus->acceptsTextInput())
+        {
+            cur_focus->onCommit();
+        }
+    }
+
+    // Save SOCKS proxy credentials securely if password auth is enabled
+    LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+    if (socksAuth->getSelectedValue().asString() == "UserPass")
+    {
+        LLSD socks_id = LLSD::emptyMap();
+        socks_id["type"] = "SOCKS5";
+        socks_id["username"] = getChild<LLLineEditor>("socks5_username")->getValue().asString();
+
+        LLSD socks_authenticator = LLSD::emptyMap();
+        socks_authenticator["type"] = "SOCKS5";
+        socks_authenticator["creds"] = getChild<LLLineEditor>("socks5_password")->getValue().asString();
+
+        // Using "SOCKS5" as the "grid" argument since the same proxy
+        // settings will be used for all grids and because there is no
+        // way to specify the type of credential.
+        LLPointer<LLCredential> socks_cred = gSecAPIHandler->createCredential("SOCKS5", socks_id, socks_authenticator);
+        gSecAPIHandler->saveCredential(socks_cred, true);
+    }
+    else
+    {
+        // Clear SOCKS5 credentials since they are no longer needed.
+        LLPointer<LLCredential> socks_cred = new LLCredential("SOCKS5");
+        gSecAPIHandler->deleteCredential(socks_cred);
+    }
+
+    closeFloater(false);
 }
 
 void LLFloaterPreferenceProxy::onBtnCancel()
 {
-	if (hasFocus())
-	{
-		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-		if (cur_focus && cur_focus->acceptsTextInput())
-		{
-			cur_focus->onCommit();
-		}
-		refresh();
-	}
+    if (hasFocus())
+    {
+        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+        if (cur_focus && cur_focus->acceptsTextInput())
+        {
+            cur_focus->onCommit();
+        }
+        refresh();
+    }
 
-	cancel();
+    cancel();
 }
 
 void LLFloaterPreferenceProxy::onClickCloseBtn(bool app_quitting)
 {
-	cancel();
+    cancel();
 }
 
 void LLFloaterPreferenceProxy::cancel()
 {
 
-	for (control_values_map_t::iterator iter =  mSavedValues.begin();
-			iter !=  mSavedValues.end(); ++iter)
-	{
-		LLControlVariable* control = iter->first;
-		LLSD ctrl_value = iter->second;
-		control->set(ctrl_value);
-	}
-	mSocksSettingsDirty = false;
-	closeFloater();
+    for (control_values_map_t::iterator iter =  mSavedValues.begin();
+            iter !=  mSavedValues.end(); ++iter)
+    {
+        LLControlVariable* control = iter->first;
+        LLSD ctrl_value = iter->second;
+        control->set(ctrl_value);
+    }
+    mSocksSettingsDirty = false;
+    closeFloater();
 }
 
 void LLFloaterPreferenceProxy::onChangeSocksSettings() 
 {
-	mSocksSettingsDirty = true;
-
-	LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
-	if (socksAuth->getSelectedValue().asString() == "None")
-	{
-		getChild<LLLineEditor>("socks5_username")->setEnabled(false);
-		getChild<LLLineEditor>("socks5_password")->setEnabled(false);
-	}
-	else
-	{
-		getChild<LLLineEditor>("socks5_username")->setEnabled(true);
-		getChild<LLLineEditor>("socks5_password")->setEnabled(true);
-	}
-
-	// Check for invalid states for the other HTTP proxy radio
-	LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_type");
-	if ((otherHttpProxy->getSelectedValue().asString() == "Socks" &&
-			getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||(
-					otherHttpProxy->getSelectedValue().asString() == "Web" &&
-					getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) )
-	{
-		otherHttpProxy->selectFirstItem();
-	}
+    mSocksSettingsDirty = true;
+
+    LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+    if (socksAuth->getSelectedValue().asString() == "None")
+    {
+        getChild<LLLineEditor>("socks5_username")->setEnabled(false);
+        getChild<LLLineEditor>("socks5_password")->setEnabled(false);
+    }
+    else
+    {
+        getChild<LLLineEditor>("socks5_username")->setEnabled(true);
+        getChild<LLLineEditor>("socks5_password")->setEnabled(true);
+    }
+
+    // Check for invalid states for the other HTTP proxy radio
+    LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_type");
+    if ((otherHttpProxy->getSelectedValue().asString() == "Socks" &&
+            getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||(
+                    otherHttpProxy->getSelectedValue().asString() == "Web" &&
+                    getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) )
+    {
+        otherHttpProxy->selectFirstItem();
+    }
 
 }
 
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index da96e68f5e..0d383c1da0 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -50,308 +50,308 @@ class LLTextBox;
 typedef std::map<std::string, std::string> notifications_map;
 
 typedef enum
-	{
-		GS_LOW_GRAPHICS,
-		GS_MID_GRAPHICS,
-		GS_HIGH_GRAPHICS,
-		GS_ULTRA_GRAPHICS
-		
-	} EGraphicsSettings;
+    {
+        GS_LOW_GRAPHICS,
+        GS_MID_GRAPHICS,
+        GS_HIGH_GRAPHICS,
+        GS_ULTRA_GRAPHICS
+        
+    } EGraphicsSettings;
 
 // Floater to control preferences (display, audio, bandwidth, general.
 class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver, public LLConversationLogObserver
 {
 public: 
-	LLFloaterPreference(const LLSD& key);
-	~LLFloaterPreference();
-
-	void apply();
-	void cancel();
-	/*virtual*/ void draw();
-	/*virtual*/ BOOL postBuild();
-	/*virtual*/ void onOpen(const LLSD& key);
-	/*virtual*/	void onClose(bool app_quitting);
-	/*virtual*/ void changed();
-	/*virtual*/ void changed(const LLUUID& session_id, U32 mask) {};
-
-	// static data update, called from message handler
-	static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
-
-	// refresh all the graphics preferences menus
-	static void refreshEnabledGraphics();
-	
-	// translate user's do not disturb response message according to current locale if message is default, otherwise do nothing
-	static void initDoNotDisturbResponse();
-
-	// update Show Favorites checkbox
-	static void updateShowFavoritesCheckbox(bool val);
-
-	void processProperties( void* pData, EAvatarProcessorType type );
-	void processProfileProperties(const LLAvatarData* pAvatarData );
-	void storeAvatarProperties( const LLAvatarData* pAvatarData );
-	void saveAvatarProperties( void );
-	void selectPrivacyPanel();
-	void selectChatPanel();
-	void getControlNames(std::vector<std::string>& names);
-
-protected:	
-	void		onBtnOK(const LLSD& userdata);
-	void		onBtnCancel(const LLSD& userdata);
-
-	void		onClickClearCache();			// Clear viewer texture cache, vfs, and VO cache on next startup
-	void		onClickBrowserClearCache();		// Clear web history and caches as well as viewer caches above
-	void		onLanguageChange();
-	void		onNotificationsChange(const std::string& OptionName);
-	void		onNameTagOpacityChange(const LLSD& newvalue);
-
-	// set value of "DoNotDisturbResponseChanged" in account settings depending on whether do not disturb response
-	// string differs from default after user changes.
-	void onDoNotDisturbResponseChanged();
-	// if the custom settings box is clicked
-	void onChangeCustom();
-	void updateMeterText(LLUICtrl* ctrl);
-	// callback for defaults
-	void setHardwareDefaults();
-	void setRecommended();
-	// callback for when client turns on shaders
-	void onVertexShaderEnable();
-	// callback for when client turns on impostors
-	void onAvatarImpostorsEnable();
-
-	// callback for commit in the "Single click on land" and "Double click on land" comboboxes.
-	void onClickActionChange();
-	// updates click/double-click action settings depending on controls values
-	void updateClickActionSettings();
-	// updates click/double-click action controls depending on values from settings.xml
-	void updateClickActionControls();
+    LLFloaterPreference(const LLSD& key);
+    ~LLFloaterPreference();
+
+    void apply();
+    void cancel();
+    /*virtual*/ void draw();
+    /*virtual*/ BOOL postBuild();
+    /*virtual*/ void onOpen(const LLSD& key);
+    /*virtual*/ void onClose(bool app_quitting);
+    /*virtual*/ void changed();
+    /*virtual*/ void changed(const LLUUID& session_id, U32 mask) {};
+
+    // static data update, called from message handler
+    static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
+
+    // refresh all the graphics preferences menus
+    static void refreshEnabledGraphics();
+    
+    // translate user's do not disturb response message according to current locale if message is default, otherwise do nothing
+    static void initDoNotDisturbResponse();
+
+    // update Show Favorites checkbox
+    static void updateShowFavoritesCheckbox(bool val);
+
+    void processProperties( void* pData, EAvatarProcessorType type );
+    void processProfileProperties(const LLAvatarData* pAvatarData );
+    void storeAvatarProperties( const LLAvatarData* pAvatarData );
+    void saveAvatarProperties( void );
+    void selectPrivacyPanel();
+    void selectChatPanel();
+    void getControlNames(std::vector<std::string>& names);
+
+protected:  
+    void        onBtnOK(const LLSD& userdata);
+    void        onBtnCancel(const LLSD& userdata);
+
+    void        onClickClearCache();            // Clear viewer texture cache, vfs, and VO cache on next startup
+    void        onClickBrowserClearCache();     // Clear web history and caches as well as viewer caches above
+    void        onLanguageChange();
+    void        onNotificationsChange(const std::string& OptionName);
+    void        onNameTagOpacityChange(const LLSD& newvalue);
+
+    // set value of "DoNotDisturbResponseChanged" in account settings depending on whether do not disturb response
+    // string differs from default after user changes.
+    void onDoNotDisturbResponseChanged();
+    // if the custom settings box is clicked
+    void onChangeCustom();
+    void updateMeterText(LLUICtrl* ctrl);
+    // callback for defaults
+    void setHardwareDefaults();
+    void setRecommended();
+    // callback for when client turns on shaders
+    void onVertexShaderEnable();
+    // callback for when client turns on impostors
+    void onAvatarImpostorsEnable();
+
+    // callback for commit in the "Single click on land" and "Double click on land" comboboxes.
+    void onClickActionChange();
+    // updates click/double-click action settings depending on controls values
+    void updateClickActionSettings();
+    // updates click/double-click action controls depending on values from settings.xml
+    void updateClickActionControls();
 
 public:
-	// This function squirrels away the current values of the controls so that
-	// cancel() can restore them.	
-	void saveSettings();
-
-	void setCacheLocation(const LLStringExplicit& location);
-
-	void onClickSetCache();
-	void changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name);
-	void onClickResetCache();
-	void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata);
-	void onSelectSkin();
-	void onClickSetKey();
-	void setKey(KEY key);
-	void onClickSetMiddleMouse();
-	void onClickSetSounds();
-	void onClickEnablePopup();
-	void onClickDisablePopup();	
-	void resetAllIgnored();
-	void setAllIgnored();
-	void onClickLogPath();
-	void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name);
-	bool moveTranscriptsAndLog();
-	void enableHistory();
-	void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
-	void refreshEnabledState();
-	void onCommitWindowedMode();
-	void refresh();	// Refresh enable/disable
-	// if the quality radio buttons are changed
-	void onChangeQuality(const LLSD& data);
-	
-	void refreshUI();
-
-	void onCommitParcelMediaAutoPlayEnable();
-	void onCommitMediaEnabled();
-	void onCommitMusicEnabled();
-	void applyResolution();
-	void onChangeMaturity();
-	void onChangeModelFolder();
-	void onChangeTextureFolder();
-	void onChangeSoundFolder();
-	void onChangeAnimationFolder();
-	void onClickBlockList();
-	void onClickProxySettings();
-	void onClickTranslationSettings();
-	void onClickPermsDefault();
-	void onClickAutoReplace();
-	void onClickSpellChecker();
-	void onClickRenderExceptions();
-	void onClickAdvanced();
-	void applyUIColor(LLUICtrl* ctrl, const LLSD& param);
-	void getUIColor(LLUICtrl* ctrl, const LLSD& param);
-	void onLogChatHistorySaved();	
-	void buildPopupLists();
-	static void refreshSkin(void* data);
-	void selectPanel(const LLSD& name);
-	void saveCameraPreset(std::string& preset);
-	void saveGraphicsPreset(std::string& preset);
+    // This function squirrels away the current values of the controls so that
+    // cancel() can restore them.   
+    void saveSettings();
+
+    void setCacheLocation(const LLStringExplicit& location);
+
+    void onClickSetCache();
+    void changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name);
+    void onClickResetCache();
+    void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata);
+    void onSelectSkin();
+    void onClickSetKey();
+    void setKey(KEY key);
+    void onClickSetMiddleMouse();
+    void onClickSetSounds();
+    void onClickEnablePopup();
+    void onClickDisablePopup(); 
+    void resetAllIgnored();
+    void setAllIgnored();
+    void onClickLogPath();
+    void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name);
+    bool moveTranscriptsAndLog();
+    void enableHistory();
+    void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
+    void refreshEnabledState();
+    void onCommitWindowedMode();
+    void refresh(); // Refresh enable/disable
+    // if the quality radio buttons are changed
+    void onChangeQuality(const LLSD& data);
+    
+    void refreshUI();
+
+    void onCommitParcelMediaAutoPlayEnable();
+    void onCommitMediaEnabled();
+    void onCommitMusicEnabled();
+    void applyResolution();
+    void onChangeMaturity();
+    void onChangeModelFolder();
+    void onChangeTextureFolder();
+    void onChangeSoundFolder();
+    void onChangeAnimationFolder();
+    void onClickBlockList();
+    void onClickProxySettings();
+    void onClickTranslationSettings();
+    void onClickPermsDefault();
+    void onClickAutoReplace();
+    void onClickSpellChecker();
+    void onClickRenderExceptions();
+    void onClickAdvanced();
+    void applyUIColor(LLUICtrl* ctrl, const LLSD& param);
+    void getUIColor(LLUICtrl* ctrl, const LLSD& param);
+    void onLogChatHistorySaved();   
+    void buildPopupLists();
+    static void refreshSkin(void* data);
+    void selectPanel(const LLSD& name);
+    void saveCameraPreset(std::string& preset);
+    void saveGraphicsPreset(std::string& preset);
 
 private:
 
-	void onDeleteTranscripts();
-	void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response);
-	void updateDeleteTranscriptsButton();
-	void updateMaxComplexity();
-
-	static std::string sSkin;
-	notifications_map mNotificationOptions;
-	bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user.
-	bool mGotPersonalInfo;
-	bool mOriginalIMViaEmail;
-	bool mLanguageChanged;
-	bool mAvatarDataInitialized;
-	std::string mPriorInstantMessageLogPath;
-	
-	bool mOriginalHideOnlineStatus;
-	std::string mDirectoryVisibility;
-	
-	LLAvatarData mAvatarProperties;
-	std::string mSavedCameraPreset;
-	std::string mSavedGraphicsPreset;
-	LOG_CLASS(LLFloaterPreference);
+    void onDeleteTranscripts();
+    void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response);
+    void updateDeleteTranscriptsButton();
+    void updateMaxComplexity();
+
+    static std::string sSkin;
+    notifications_map mNotificationOptions;
+    bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user.
+    bool mGotPersonalInfo;
+    bool mOriginalIMViaEmail;
+    bool mLanguageChanged;
+    bool mAvatarDataInitialized;
+    std::string mPriorInstantMessageLogPath;
+    
+    bool mOriginalHideOnlineStatus;
+    std::string mDirectoryVisibility;
+    
+    LLAvatarData mAvatarProperties;
+    std::string mSavedCameraPreset;
+    std::string mSavedGraphicsPreset;
+    LOG_CLASS(LLFloaterPreference);
 };
 
 class LLPanelPreference : public LLPanel
 {
 public:
-	LLPanelPreference();
-	/*virtual*/ BOOL postBuild();
-	
-	virtual ~LLPanelPreference();
+    LLPanelPreference();
+    /*virtual*/ BOOL postBuild();
+    
+    virtual ~LLPanelPreference();
 
-	virtual void apply();
-	virtual void cancel();
-	void setControlFalse(const LLSD& user_data);
-	virtual void setHardwareDefaults();
+    virtual void apply();
+    virtual void cancel();
+    void setControlFalse(const LLSD& user_data);
+    virtual void setHardwareDefaults();
 
-	// Disables "Allow Media to auto play" check box only when both
-	// "Streaming Music" and "Media" are unchecked. Otherwise enables it.
-	void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl);
+    // Disables "Allow Media to auto play" check box only when both
+    // "Streaming Music" and "Media" are unchecked. Otherwise enables it.
+    void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl);
 
-	// This function squirrels away the current values of the controls so that
-	// cancel() can restore them.
-	virtual void saveSettings();
+    // This function squirrels away the current values of the controls so that
+    // cancel() can restore them.
+    virtual void saveSettings();
 
-	void deletePreset(const LLSD& user_data);
-	void savePreset(const LLSD& user_data);
-	void loadPreset(const LLSD& user_data);
+    void deletePreset(const LLSD& user_data);
+    void savePreset(const LLSD& user_data);
+    void loadPreset(const LLSD& user_data);
 
-	class Updater;
+    class Updater;
 
 protected:
-	typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
-	control_values_map_t mSavedValues;
+    typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
+    control_values_map_t mSavedValues;
 
 private:
-	//for "Only friends and groups can call or IM me"
-	static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&);
+    //for "Only friends and groups can call or IM me"
+    static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&);
     //for  "Allow Multiple Viewers"
     static void showMultipleViewersWarning(LLUICtrl*, const LLSD&);
-	//for "Show my Favorite Landmarks at Login"
-	static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value);
+    //for "Show my Favorite Landmarks at Login"
+    static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value);
 
-	static void toggleMuteWhenMinimized();
-	typedef std::map<std::string, LLColor4> string_color_map_t;
-	string_color_map_t mSavedColors;
+    static void toggleMuteWhenMinimized();
+    typedef std::map<std::string, LLColor4> string_color_map_t;
+    string_color_map_t mSavedColors;
 
-	Updater* mBandWidthUpdater;
-	LOG_CLASS(LLPanelPreference);
+    Updater* mBandWidthUpdater;
+    LOG_CLASS(LLPanelPreference);
 };
 
 class LLPanelPreferenceView : public LLPanelPreference
 {
 public:
-	BOOL postBuild();
-	void draw();
-	void setPresetText();
+    BOOL postBuild();
+    void draw();
+    void setPresetText();
 
 private:
-	void onPresetsListChangeCamera();
-	LOG_CLASS(LLPanelPreferenceView);
+    void onPresetsListChangeCamera();
+    LOG_CLASS(LLPanelPreferenceView);
 };
 
 class LLPanelPreferenceGraphics : public LLPanelPreference
 {
 public:
-	BOOL postBuild();
-	void draw();
-	void cancel();
-	void saveSettings();
-	void resetDirtyChilds();
-	void setHardwareDefaults();
-	void setPresetText();
+    BOOL postBuild();
+    void draw();
+    void cancel();
+    void saveSettings();
+    void resetDirtyChilds();
+    void setHardwareDefaults();
+    void setPresetText();
 
-	static const std::string getPresetsPath();
+    static const std::string getPresetsPath();
 
 protected:
-	bool hasDirtyChilds();
+    bool hasDirtyChilds();
 
 private:
-	void onPresetsListChange();
-	LOG_CLASS(LLPanelPreferenceGraphics);
+    void onPresetsListChange();
+    LOG_CLASS(LLPanelPreferenceGraphics);
 };
 
 class LLFloaterPreferenceGraphicsAdvanced : public LLFloater
 {
   public: 
-	LLFloaterPreferenceGraphicsAdvanced(const LLSD& key);
-	~LLFloaterPreferenceGraphicsAdvanced();
-	/*virtual*/ BOOL postBuild();
-	void onOpen(const LLSD& key);
-	void onClickCloseBtn(bool app_quitting);
-	void disableUnavailableSettings();
-	void refreshEnabledGraphics();
-	void refreshEnabledState();
-	void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box);
-	void updateMaxNonImpostors();
-	void setMaxNonImpostorsText(U32 value, LLTextBox* text_box);
-	void updateMaxComplexity();
-	void setMaxComplexityText(U32 value, LLTextBox* text_box);
-	static void setIndirectControls();
-	static void setIndirectMaxNonImpostors();
-	static void setIndirectMaxArc();
-	void refresh();
-	// callback for when client turns on shaders
-	void onVertexShaderEnable();
-	LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced);
+    LLFloaterPreferenceGraphicsAdvanced(const LLSD& key);
+    ~LLFloaterPreferenceGraphicsAdvanced();
+    /*virtual*/ BOOL postBuild();
+    void onOpen(const LLSD& key);
+    void onClickCloseBtn(bool app_quitting);
+    void disableUnavailableSettings();
+    void refreshEnabledGraphics();
+    void refreshEnabledState();
+    void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box);
+    void updateMaxNonImpostors();
+    void setMaxNonImpostorsText(U32 value, LLTextBox* text_box);
+    void updateMaxComplexity();
+    void setMaxComplexityText(U32 value, LLTextBox* text_box);
+    static void setIndirectControls();
+    static void setIndirectMaxNonImpostors();
+    static void setIndirectMaxArc();
+    void refresh();
+    // callback for when client turns on shaders
+    void onVertexShaderEnable();
+    LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced);
 };
 
 class LLAvatarComplexityControls
 {
   public: 
-	static void updateMax(LLSliderCtrl* slider, LLTextBox* value_label);
-	static void setText(U32 value, LLTextBox* text_box);
-	static void setIndirectControls();
-	static void setIndirectMaxNonImpostors();
-	static void setIndirectMaxArc();
-	LOG_CLASS(LLAvatarComplexityControls);
+    static void updateMax(LLSliderCtrl* slider, LLTextBox* value_label);
+    static void setText(U32 value, LLTextBox* text_box);
+    static void setIndirectControls();
+    static void setIndirectMaxNonImpostors();
+    static void setIndirectMaxArc();
+    LOG_CLASS(LLAvatarComplexityControls);
 };
 
 class LLFloaterPreferenceProxy : public LLFloater
 {
 public: 
-	LLFloaterPreferenceProxy(const LLSD& key);
-	~LLFloaterPreferenceProxy();
+    LLFloaterPreferenceProxy(const LLSD& key);
+    ~LLFloaterPreferenceProxy();
 
-	/// show off our menu
-	static void show();
-	void cancel();
-	
+    /// show off our menu
+    static void show();
+    void cancel();
+    
 protected:
-	BOOL postBuild();
-	void onOpen(const LLSD& key);
-	void onClose(bool app_quitting);
-	void saveSettings();
-	void onBtnOk();
-	void onBtnCancel();
-	void onClickCloseBtn(bool app_quitting = false);
+    BOOL postBuild();
+    void onOpen(const LLSD& key);
+    void onClose(bool app_quitting);
+    void saveSettings();
+    void onBtnOk();
+    void onBtnCancel();
+    void onClickCloseBtn(bool app_quitting = false);
 
-	void onChangeSocksSettings();
+    void onChangeSocksSettings();
 
 private:
-	
-	bool mSocksSettingsDirty;
-	typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
-	control_values_map_t mSavedValues;
-	LOG_CLASS(LLFloaterPreferenceProxy);
+    
+    bool mSocksSettingsDirty;
+    typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
+    control_values_map_t mSavedValues;
+    LOG_CLASS(LLFloaterPreferenceProxy);
 };
 
 
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
index 791ff79d87..e740a3a9cf 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -34,11 +34,11 @@
 
 
 LLFloaterPreferenceViewAdvanced::LLFloaterPreferenceViewAdvanced(const LLSD& key) 
-:	LLFloater(key)
+:   LLFloater(key)
 {
-	mCommitCallbackRegistrar.add("Cancel",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this));
-	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
-	mCommitCallbackRegistrar.add("Ok",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this));
+    mCommitCallbackRegistrar.add("Cancel",  boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this));
+    mCommitCallbackRegistrar.add("CommitSettings",  boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
+    mCommitCallbackRegistrar.add("Ok",  boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this));
 
 }
 
@@ -47,66 +47,66 @@ LLFloaterPreferenceViewAdvanced::~LLFloaterPreferenceViewAdvanced()
 
 void LLFloaterPreferenceViewAdvanced::onClickOk()
 {
-	closeFloater();
+    closeFloater();
 }
 
 void LLFloaterPreferenceViewAdvanced::onClickCancel()
 {
-	gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
-	gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
+    gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
+    gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
 
-	updateCameraControl(mCameraSaved);
-	updateFocusControl(mFocusSaved);
+    updateCameraControl(mCameraSaved);
+    updateFocusControl(mFocusSaved);
 }
 
 BOOL LLFloaterPreferenceViewAdvanced::postBuild()
 {
-	mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
-	mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
+    mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
+    mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
 
-	updateCameraControl(mCameraSaved);
-	updateFocusControl(mFocusSaved);
+    updateCameraControl(mCameraSaved);
+    updateFocusControl(mFocusSaved);
 
-	return TRUE;
+    return TRUE;
 }
 
 void LLFloaterPreferenceViewAdvanced::updateCameraControl(const LLVector3& vector)
 {
-	getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
-	getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]);
-	getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]);
+    getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
+    getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]);
+    getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]);
 }
 
 void LLFloaterPreferenceViewAdvanced::updateFocusControl(const LLVector3d& vector3d)
 {
-	getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]);
-	getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]);
-	getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]);
+    getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]);
+    getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]);
+    getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]);
 }
 
  void LLFloaterPreferenceViewAdvanced::draw()
 {
-	static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView");
-	static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView");
+    static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView");
+    static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView");
 
-	updateCameraControl(camera);
-	updateFocusControl(focus);
+    updateCameraControl(camera);
+    updateFocusControl(focus);
 
-	LLFloater::draw();
+    LLFloater::draw();
 }
 
 void LLFloaterPreferenceViewAdvanced::onCommitSettings()
 {
-	LLVector3 vector;
-	LLVector3d vector3d;
-
-	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
-	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
-	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
-	gSavedSettings.setVector3("CameraOffsetRearView", vector);
-
-	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
-	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
-	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
-	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
+    LLVector3 vector;
+    LLVector3d vector3d;
+
+    vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
+    vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
+    vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
+    gSavedSettings.setVector3("CameraOffsetRearView", vector);
+
+    vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
+    vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
+    vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
+    gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
 }
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h
index 8f4b594605..9113949273 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.h
+++ b/indra/newview/llfloaterpreferenceviewadvanced.h
@@ -31,27 +31,27 @@
 #include "llfloater.h"
 
 class LLFloaterPreferenceViewAdvanced
-:	public LLFloater
+:   public LLFloater
 {
-	friend class LLFloaterReg;
+    friend class LLFloaterReg;
 
 public:
-	LLFloaterPreferenceViewAdvanced(const LLSD& key);
-	virtual BOOL postBuild();
-	virtual void draw();
+    LLFloaterPreferenceViewAdvanced(const LLSD& key);
+    virtual BOOL postBuild();
+    virtual void draw();
 
-	void onCommitSettings();
-	void onClickCancel();
-	void onClickOk();
-	void updateCameraControl(const LLVector3& vector);
-	void updateFocusControl(const LLVector3d& vector3d);
+    void onCommitSettings();
+    void onClickCancel();
+    void onClickOk();
+    void updateCameraControl(const LLVector3& vector);
+    void updateFocusControl(const LLVector3d& vector3d);
 
 private:
-	virtual ~LLFloaterPreferenceViewAdvanced();
+    virtual ~LLFloaterPreferenceViewAdvanced();
 
-	LLVector3	mCameraSaved;
-	LLVector3d	mFocusSaved;
-	
+    LLVector3   mCameraSaved;
+    LLVector3d  mFocusSaved;
+    
 };
 
 #endif //LLFLOATERPREFERENCEVIEWADVANCED_H
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index bae7602566..149451c8c4 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -37,78 +37,78 @@
 #include "lltrans.h"
 
 LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key)
-:	LLFloater(key)
+:   LLFloater(key)
 {
 }
 
 // virtual
 BOOL LLFloaterSavePrefPreset::postBuild()
 {
-	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-	if (preferences)
-	{
-		preferences->addDependentFloater(this);
-	}
-	getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
-	getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
-	getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
-	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
-
-	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
-
-	mSaveButton = getChild<LLButton>("save");
-	mPresetCombo = getChild<LLComboBox>("preset_combo");
-
-	return TRUE;
+    LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+    if (preferences)
+    {
+        preferences->addDependentFloater(this);
+    }
+    getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
+    getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
+    getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
+    getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
+
+    LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
+
+    mSaveButton = getChild<LLButton>("save");
+    mPresetCombo = getChild<LLComboBox>("preset_combo");
+
+    return TRUE;
 }
 
 void LLFloaterSavePrefPreset::onPresetNameEdited()
 {
-	// Disable saving a preset having empty name.
-	std::string name = mPresetCombo->getSimple();
+    // Disable saving a preset having empty name.
+    std::string name = mPresetCombo->getSimple();
 
-	mSaveButton->setEnabled(!name.empty());
+    mSaveButton->setEnabled(!name.empty());
 }
 
 void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 {
-	mSubdirectory = key.asString();
+    mSubdirectory = key.asString();
 
-	std::string floater_title = getString(std::string("title_") + mSubdirectory);
+    std::string floater_title = getString(std::string("title_") + mSubdirectory);
 
-	setTitle(floater_title);
+    setTitle(floater_title);
 
-	EDefaultOptions option = DEFAULT_HIDE;
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
+    EDefaultOptions option = DEFAULT_HIDE;
+    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 
-	onPresetNameEdited();
+    onPresetNameEdited();
 }
 
 void LLFloaterSavePrefPreset::onBtnSave()
 {
-	std::string name = mPresetCombo->getSimple();
-
-	if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
-	{
-		LLNotificationsUtil::add("DefaultPresetNotSaved");
-	}
-	else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
-	{
-		LLSD args;
-		args["NAME"] = name;
-		LLNotificationsUtil::add("PresetNotSaved", args);
-	}
-
-	closeFloater();
+    std::string name = mPresetCombo->getSimple();
+
+    if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
+    {
+        LLNotificationsUtil::add("DefaultPresetNotSaved");
+    }
+    else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
+    {
+        LLSD args;
+        args["NAME"] = name;
+        LLNotificationsUtil::add("PresetNotSaved", args);
+    }
+
+    closeFloater();
 }
 
 void LLFloaterSavePrefPreset::onPresetsListChange()
 {
-	EDefaultOptions option = DEFAULT_HIDE;
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
+    EDefaultOptions option = DEFAULT_HIDE;
+    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 }
 
 void LLFloaterSavePrefPreset::onBtnCancel()
 {
-	closeFloater();
+    closeFloater();
 }
diff --git a/indra/newview/llnavigationbar.h b/indra/newview/llnavigationbar.h
index a44c6dd699..a9d0f1a82e 100755
--- a/indra/newview/llnavigationbar.h
+++ b/indra/newview/llnavigationbar.h
@@ -47,113 +47,113 @@ class LLSearchComboBox;
 
 class LLPullButton: public LLButton
 {
-	LOG_CLASS(LLPullButton);
+    LOG_CLASS(LLPullButton);
 
 public:
-	struct Params: public LLInitParam::Block<Params, LLButton::Params>
-	{
-		Optional<std::string> direction; // left, right, down, up
+    struct Params: public LLInitParam::Block<Params, LLButton::Params>
+    {
+        Optional<std::string> direction; // left, right, down, up
 
-		Params() 
-		:	direction("direction", "down")
-		{
-		}
-	};
-	
-	/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+        Params() 
+        :   direction("direction", "down")
+        {
+        }
+    };
+    
+    /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
 
-	/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
 
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+    /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
 
-	boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
+    boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
 
 protected:
-	friend class LLUICtrlFactory;
-	// convert string name into direction vector
-	void setDirectionFromName(const std::string& name);
-	LLPullButton(const LLPullButton::Params& params);
-
-	commit_signal_t mClickDraggingSignal;
-	LLVector2 mLastMouseDown;
-	LLVector2 mDraggingDirection;
+    friend class LLUICtrlFactory;
+    // convert string name into direction vector
+    void setDirectionFromName(const std::string& name);
+    LLPullButton(const LLPullButton::Params& params);
+
+    commit_signal_t mClickDraggingSignal;
+    LLVector2 mLastMouseDown;
+    LLVector2 mDraggingDirection;
 };
 
 /**
  * Web browser-like navigation bar.
  */ 
 class LLNavigationBar
-	:	public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar>
+    :   public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar>
 {
-	LLSINGLETON(LLNavigationBar);
-	virtual ~LLNavigationBar();
-	LOG_CLASS(LLNavigationBar);
-	friend class LLDestroyClass<LLNavigationBar>;
+    LLSINGLETON(LLNavigationBar);
+    virtual ~LLNavigationBar();
+    LOG_CLASS(LLNavigationBar);
+    friend class LLDestroyClass<LLNavigationBar>;
 
 public:
-	
-	/*virtual*/ void	draw();
-	/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL	postBuild();
-	/*virtual*/ void	setVisible(BOOL visible);
-
-	void handleLoginComplete();
-	void clearHistoryCache();
-
-	int getDefNavBarHeight();
-	int getDefFavBarHeight();
-	
+    
+    /*virtual*/ void    draw();
+    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL    postBuild();
+    /*virtual*/ void    setVisible(BOOL visible);
+
+    void handleLoginComplete();
+    void clearHistoryCache();
+
+    int getDefNavBarHeight();
+    int getDefFavBarHeight();
+    
 private:
-	// the distance between navigation panel and favorites panel in pixels
-	const static S32 FAVBAR_TOP_PADDING = 10;
-
-	void rebuildTeleportHistoryMenu();
-	void showTeleportHistoryMenu(LLUICtrl* btn_ctrl);
-	void invokeSearch(std::string search_text);
-	void resizeLayoutPanel();
-	// callbacks
-	void onTeleportHistoryMenuItemClicked(const LLSD& userdata);
-	void onTeleportHistoryChanged();
-	void onBackButtonClicked();
-	void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param);
-	void onNavigationButtonHeldUp(LLButton* nav_button);
-	void onForwardButtonClicked();
-	void onHomeButtonClicked();
-	void onLocationSelection();
-	void onLocationPrearrange(const LLSD& data);
-	void onTeleportFinished(const LLVector3d& global_agent_pos);
-	void onTeleportFailed();
-	void onNavbarResized();
-	void onRegionNameResponse(
-			std::string typed_location,
-			std::string region_name,
-			LLVector3 local_coords,
-			U64 region_handle, const std::string& url,
-			const LLUUID& snapshot_id, bool teleport);
-
-	static void destroyClass()
-	{
-		if (LLNavigationBar::instanceExists())
-		{
-			LLNavigationBar::getInstance()->setEnabled(FALSE);
-		}
-	}
-
-	S32							mNavPanWidth;
-	LLMenuGL*					mTeleportHistoryMenu;
-	LLPullButton*				mBtnBack;
-	LLPullButton*				mBtnForward;
-	LLButton*					mBtnHome;
-	LLLocationInputCtrl*		mCmbLocation;
-	LLRect						mDefaultNbRect;
-	LLRect						mDefaultFpRect;
-	LLLayoutPanel* 				mNavigationPanel;
-	LLLayoutPanel* 				mFavoritePanel;
-	boost::signals2::connection	mTeleportFailedConnection;
-	boost::signals2::connection	mTeleportFinishConnection;
-	boost::signals2::connection	mHistoryMenuConnection;
-	// if true, save location to location history when teleport finishes
-	bool						mSaveToLocationHistory;
+    // the distance between navigation panel and favorites panel in pixels
+    const static S32 FAVBAR_TOP_PADDING = 10;
+
+    void rebuildTeleportHistoryMenu();
+    void showTeleportHistoryMenu(LLUICtrl* btn_ctrl);
+    void invokeSearch(std::string search_text);
+    void resizeLayoutPanel();
+    // callbacks
+    void onTeleportHistoryMenuItemClicked(const LLSD& userdata);
+    void onTeleportHistoryChanged();
+    void onBackButtonClicked();
+    void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param);
+    void onNavigationButtonHeldUp(LLButton* nav_button);
+    void onForwardButtonClicked();
+    void onHomeButtonClicked();
+    void onLocationSelection();
+    void onLocationPrearrange(const LLSD& data);
+    void onTeleportFinished(const LLVector3d& global_agent_pos);
+    void onTeleportFailed();
+    void onNavbarResized();
+    void onRegionNameResponse(
+            std::string typed_location,
+            std::string region_name,
+            LLVector3 local_coords,
+            U64 region_handle, const std::string& url,
+            const LLUUID& snapshot_id, bool teleport);
+
+    static void destroyClass()
+    {
+        if (LLNavigationBar::instanceExists())
+        {
+            LLNavigationBar::getInstance()->setEnabled(FALSE);
+        }
+    }
+
+    S32                         mNavPanWidth;
+    LLMenuGL*                   mTeleportHistoryMenu;
+    LLPullButton*               mBtnBack;
+    LLPullButton*               mBtnForward;
+    LLButton*                   mBtnHome;
+    LLLocationInputCtrl*        mCmbLocation;
+    LLRect                      mDefaultNbRect;
+    LLRect                      mDefaultFpRect;
+    LLLayoutPanel*              mNavigationPanel;
+    LLLayoutPanel*              mFavoritePanel;
+    boost::signals2::connection mTeleportFailedConnection;
+    boost::signals2::connection mTeleportFinishConnection;
+    boost::signals2::connection mHistoryMenuConnection;
+    // if true, save location to location history when teleport finishes
+    bool                        mSaveToLocationHistory;
 };
 
 #endif
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index 7612c428d9..7cdb91388a 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -50,85 +50,85 @@
 // Default constructor
 LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown()
 {
-	mHoverTimer.stop();
+    mHoverTimer.stop();
 
-	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
-	mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
+    mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
+    mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
 
-	buildFromFile( "panel_presets_camera_pulldown.xml");
+    buildFromFile( "panel_presets_camera_pulldown.xml");
 }
 
 BOOL LLPanelPresetsCameraPulldown::postBuild()
 {
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		// Make sure there is a default preference file
-		presetsMgr->createMissingDefault(PRESETS_CAMERA);
+    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+    if (presetsMgr)
+    {
+        // Make sure there is a default preference file
+        presetsMgr->createMissingDefault(PRESETS_CAMERA);
 
-		presetsMgr->startWatching(PRESETS_CAMERA);
+        presetsMgr->startWatching(PRESETS_CAMERA);
 
-		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
-	}
+        presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
+    }
 
-	populatePanel();
+    populatePanel();
 
-	return LLPanel::postBuild();
+    return LLPanel::postBuild();
 }
 
 void LLPanelPresetsCameraPulldown::populatePanel()
 {
-	std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
-	LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
+    std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
+    LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
 
-	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
+    LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
 
-	if (scroll && mPresetNames.begin() != mPresetNames.end())
-	{
-		scroll->clearRows();
+    if (scroll && mPresetNames.begin() != mPresetNames.end())
+    {
+        scroll->clearRows();
 
-		std::string active_preset = gSavedSettings.getString("PresetCameraActive");
-		if (active_preset == PRESETS_DEFAULT)
-		{
-			active_preset = LLTrans::getString(PRESETS_DEFAULT);
-		}
+        std::string active_preset = gSavedSettings.getString("PresetCameraActive");
+        if (active_preset == PRESETS_DEFAULT)
+        {
+            active_preset = LLTrans::getString(PRESETS_DEFAULT);
+        }
 
-		for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it)
-		{
-			const std::string& name = *it;
+        for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it)
+        {
+            const std::string& name = *it;
             LL_DEBUGS() << "adding '" << name << "'" << LL_ENDL;
             
-			LLSD row;
-			row["columns"][0]["column"] = "preset_name";
-			row["columns"][0]["value"] = name;
-
-			bool is_selected_preset = false;
-			if (name == active_preset)
-			{
-				row["columns"][1]["column"] = "icon";
-				row["columns"][1]["type"] = "icon";
-				row["columns"][1]["value"] = "Check_Mark";
-
-				is_selected_preset = true;
-			}
-
-			LLScrollListItem* new_item = scroll->addElement(row);
-			new_item->setSelected(is_selected_preset);
-		}
-	}
+            LLSD row;
+            row["columns"][0]["column"] = "preset_name";
+            row["columns"][0]["value"] = name;
+
+            bool is_selected_preset = false;
+            if (name == active_preset)
+            {
+                row["columns"][1]["column"] = "icon";
+                row["columns"][1]["type"] = "icon";
+                row["columns"][1]["value"] = "Check_Mark";
+
+                is_selected_preset = true;
+            }
+
+            LLScrollListItem* new_item = scroll->addElement(row);
+            new_item->setSelected(is_selected_preset);
+        }
+    }
 }
 
 /*virtual*/
 void LLPanelPresetsCameraPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
 {
-	mHoverTimer.stop();
-	LLPanel::onMouseEnter(x,y,mask);
+    mHoverTimer.stop();
+    LLPanel::onMouseEnter(x,y,mask);
 }
 
 /*virtual*/
 void LLPanelPresetsCameraPulldown::onTopLost()
 {
-	setVisible(FALSE);
+    setVisible(FALSE);
 }
 
 /*virtual*/
@@ -155,45 +155,45 @@ BOOL LLPanelPresetsCameraPulldown::handleDoubleClick(S32 x, S32 y, MASK mask)
 /*virtual*/
 void LLPanelPresetsCameraPulldown::onMouseLeave(S32 x, S32 y, MASK mask)
 {
-	mHoverTimer.start();
-	LLPanel::onMouseLeave(x,y,mask);
+    mHoverTimer.start();
+    LLPanel::onMouseLeave(x,y,mask);
 }
 
 /*virtual*/ 
 void LLPanelPresetsCameraPulldown::onVisibilityChange ( BOOL new_visibility )
 {
-	if (new_visibility)	
-	{
-		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-	}
-	else
-	{
-		mHoverTimer.stop();
-
-	}
+    if (new_visibility) 
+    {
+        mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
+    }
+    else
+    {
+        mHoverTimer.stop();
+
+    }
 }
 
 void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
 {
-	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
+    LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
 
-	if (scroll)
-	{
-		LLScrollListItem* item = scroll->getFirstSelected();
-		if (item)
-		{
-			std::string name = item->getColumn(1)->getValue().asString();
+    if (scroll)
+    {
+        LLScrollListItem* item = scroll->getFirstSelected();
+        if (item)
+        {
+            std::string name = item->getColumn(1)->getValue().asString();
 
             LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL;
-			LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
+            LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
 
-			setVisible(FALSE);
-		}
+            setVisible(FALSE);
+        }
         else
         {
             LL_DEBUGS() << "none selected" << LL_ENDL;
         }
-	}
+    }
     else
     {
         LL_DEBUGS() << "no scroll" << LL_ENDL;
@@ -202,36 +202,36 @@ void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
 
 void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data)
 {
-	// close the minicontrol, we're bringing up the big one
-	setVisible(FALSE);
-
-	// bring up the prefs floater
-	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
-	if (prefsfloater)
-	{
-		// grab the 'view' panel from the preferences floater and
-		// bring it the front!
-		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
-		if (tabcontainer && graphicspanel)
-		{
-			tabcontainer->selectTabPanel(graphicspanel);
-		}
-	}
+    // close the minicontrol, we're bringing up the big one
+    setVisible(FALSE);
+
+    // bring up the prefs floater
+    LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
+    if (prefsfloater)
+    {
+        // grab the 'view' panel from the preferences floater and
+        // bring it the front!
+        LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+        LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
+        if (tabcontainer && graphicspanel)
+        {
+            tabcontainer->selectTabPanel(graphicspanel);
+        }
+    }
 }
 
 //virtual
 void LLPanelPresetsCameraPulldown::draw()
 {
-	F32 alpha = mHoverTimer.getStarted() 
-		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
-		: 1.0f;
-	LLViewDrawContext context(alpha);
+    F32 alpha = mHoverTimer.getStarted() 
+        ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
+        : 1.0f;
+    LLViewDrawContext context(alpha);
 
-	LLPanel::draw();
+    LLPanel::draw();
 
-	if (alpha == 0.f)
-	{
-		setVisible(FALSE);
-	}
+    if (alpha == 0.f)
+    {
+        setVisible(FALSE);
+    }
 }
diff --git a/indra/newview/llpanelpresetscamerapulldown.h b/indra/newview/llpanelpresetscamerapulldown.h
index 12d9bc26ec..069d587086 100644
--- a/indra/newview/llpanelpresetscamerapulldown.h
+++ b/indra/newview/llpanelpresetscamerapulldown.h
@@ -36,26 +36,26 @@ class LLFrameTimer;
 class LLPanelPresetsCameraPulldown : public LLPanel
 {
  public:
-	LLPanelPresetsCameraPulldown();
-	/*virtual*/ void draw();
-	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+    LLPanelPresetsCameraPulldown();
+    /*virtual*/ void draw();
+    /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
+    /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
     /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
     /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
     /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onTopLost();
-	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
-	/*virtual*/ BOOL postBuild();
-	void populatePanel();
-	
+    /*virtual*/ void onTopLost();
+    /*virtual*/ void onVisibilityChange ( BOOL new_visibility );
+    /*virtual*/ BOOL postBuild();
+    void populatePanel();
+    
  private:
-	void onViewButtonClick(const LLSD& user_data);
-	void onRowClick(const LLSD& user_data);
+    void onViewButtonClick(const LLSD& user_data);
+    void onRowClick(const LLSD& user_data);
 
-	std::list<std::string> mPresetNames;
-	LLFrameTimer mHoverTimer;
-	static const F32 sAutoCloseFadeStartTimeSec;
-	static const F32 sAutoCloseTotalTimeSec;
+    std::list<std::string> mPresetNames;
+    LLFrameTimer mHoverTimer;
+    static const F32 sAutoCloseFadeStartTimeSec;
+    static const F32 sAutoCloseTotalTimeSec;
     LOG_CLASS(LLPanelPresetsCameraPulldown);
 };
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index c1702b4132..fb36c5875d 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -48,35 +48,35 @@ LLPresetsManager::LLPresetsManager()
 
 LLPresetsManager::~LLPresetsManager()
 {
-	mCameraChangedSignal.disconnect();
+    mCameraChangedSignal.disconnect();
 }
 
 void LLPresetsManager::triggerChangeCameraSignal()
 {
-	mPresetListChangeCameraSignal();
+    mPresetListChangeCameraSignal();
 }
 
 void LLPresetsManager::triggerChangeSignal()
 {
-	mPresetListChangeSignal();
+    mPresetListChangeSignal();
 }
 
 void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 {
-	if(gDirUtilp->getLindenUserDir().empty())
-	{
-		return;
-	}
-
-	std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
-															  subdirectory, PRESETS_DEFAULT + ".xml");
-	if (!gDirUtilp->fileExists(default_file))
-	{
-		LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
-
-		// Write current settings as the default
+    if(gDirUtilp->getLindenUserDir().empty())
+    {
+        return;
+    }
+
+    std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
+                                                              subdirectory, PRESETS_DEFAULT + ".xml");
+    if (!gDirUtilp->fileExists(default_file))
+    {
+        LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
+
+        // Write current settings as the default
         savePreset(subdirectory, PRESETS_DEFAULT, true);
-	}
+    }
     else
     {
         LL_DEBUGS() << "default preset exists; no-op" << LL_ENDL;
@@ -85,330 +85,330 @@ void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 
 void LLPresetsManager::startWatching(const std::string& subdirectory)
 {
-	if (PRESETS_CAMERA == subdirectory)
-	{
-		std::vector<std::string> name_list;
-		getControlNames(name_list);
-
-		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
-		{
-			std::string ctrl_name = *it;
-			if (gSavedSettings.controlExists(ctrl_name))
-			{
-				LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
-				if (cntrl_ptr.isNull())
-				{
-					LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
-									<< "'" << LL_ENDL;
-				}
-				else
-				{
-					mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged));
-				}
-			}
-		}
-	}
+    if (PRESETS_CAMERA == subdirectory)
+    {
+        std::vector<std::string> name_list;
+        getControlNames(name_list);
+
+        for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+        {
+            std::string ctrl_name = *it;
+            if (gSavedSettings.controlExists(ctrl_name))
+            {
+                LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
+                if (cntrl_ptr.isNull())
+                {
+                    LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
+                                    << "'" << LL_ENDL;
+                }
+                else
+                {
+                    mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged));
+                }
+            }
+        }
+    }
 }
 
 std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 {
-	std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR);
-
-	LLFile::mkdir(presets_path);
-
-	std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory);
-	if (!gDirUtilp->fileExists(dest_path))
-		LLFile::mkdir(dest_path);
-
-		if (PRESETS_CAMERA == subdirectory)
-		{
-			std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
-			LLDirIterator dir_iter(source_dir, "*.xml");
-			bool found = true;
-			while (found)
-			{
-				std::string file;
-				found = dir_iter.next(file);
-
-				if (found)
-				{
-					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
-					file = LLURI::escape(file);
-					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
-					LLFile::copy(source, dest);
-				}
-			}
-		}
-
-	return dest_path;
+    std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR);
+
+    LLFile::mkdir(presets_path);
+
+    std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory);
+    if (!gDirUtilp->fileExists(dest_path))
+        LLFile::mkdir(dest_path);
+
+        if (PRESETS_CAMERA == subdirectory)
+        {
+            std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
+            LLDirIterator dir_iter(source_dir, "*.xml");
+            bool found = true;
+            while (found)
+            {
+                std::string file;
+                found = dir_iter.next(file);
+
+                if (found)
+                {
+                    std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
+                    file = LLURI::escape(file);
+                    std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
+                    LLFile::copy(source, dest);
+                }
+            }
+        }
+
+    return dest_path;
 }
 
 void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option)
 {
-	LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL;
+    LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL;
 
-	mPresetNames.clear();
+    mPresetNames.clear();
 
-	LLDirIterator dir_iter(dir, "*.xml");
-	bool found = true;
-	while (found)
-	{
-		std::string file;
-		found = dir_iter.next(file);
+    LLDirIterator dir_iter(dir, "*.xml");
+    bool found = true;
+    while (found)
+    {
+        std::string file;
+        found = dir_iter.next(file);
 
-		if (found)
-		{
-			std::string path = gDirUtilp->add(dir, file);
-			std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
+        if (found)
+        {
+            std::string path = gDirUtilp->add(dir, file);
+            std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
             LL_DEBUGS() << "  Found preset '" << name << "'" << LL_ENDL;
 
-			if (PRESETS_DEFAULT != name)
-			{
-				mPresetNames.push_back(name);
-			}
-			else
-			{
-				switch (default_option)
-				{
-					case DEFAULT_SHOW:
-						mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT));
-						break;
-
-					case DEFAULT_TOP:
-						mPresetNames.push_front(LLTrans::getString(PRESETS_DEFAULT));
-						break;
-
-					case DEFAULT_HIDE:
-					default:
-						break;
-				}
-			}
-		}
-	}
-
-	presets = mPresetNames;
+            if (PRESETS_DEFAULT != name)
+            {
+                mPresetNames.push_back(name);
+            }
+            else
+            {
+                switch (default_option)
+                {
+                    case DEFAULT_SHOW:
+                        mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT));
+                        break;
+
+                    case DEFAULT_TOP:
+                        mPresetNames.push_front(LLTrans::getString(PRESETS_DEFAULT));
+                        break;
+
+                    case DEFAULT_HIDE:
+                    default:
+                        break;
+                }
+            }
+        }
+    }
+
+    presets = mPresetNames;
 }
 
 bool LLPresetsManager::mCameraDirty = false;
 
 void LLPresetsManager::setCameraDirty(bool dirty)
 {
-	mCameraDirty = dirty;
+    mCameraDirty = dirty;
 }
 
 bool LLPresetsManager::isCameraDirty()
 {
-	return mCameraDirty;
+    return mCameraDirty;
 }
 
 void LLPresetsManager::settingChanged()
 {
-	setCameraDirty(true);
+    setCameraDirty(true);
 
-	gSavedSettings.setString("PresetCameraActive", "");
+    gSavedSettings.setString("PresetCameraActive", "");
 
 // Hack call because this is a static routine
-	LLPresetsManager::getInstance()->triggerChangeCameraSignal();
+    LLPresetsManager::getInstance()->triggerChangeCameraSignal();
 
 }
 
 void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 {
-	const std::vector<std::string> camera_controls = boost::assign::list_of
-		// From panel_preferences_move.xml
-		("CameraAngle")
-		("CameraOffsetScale")
-		("EditCameraMovement")
-		("AppearanceCameraMovement")
-		// From llagentcamera.cpp
-		("CameraOffsetBuild")
-		("CameraOffsetRearView")
-		("FocusOffsetRearView")
-		("CameraOffsetScale")
-		("TrackFocusObject")
+    const std::vector<std::string> camera_controls = boost::assign::list_of
+        // From panel_preferences_move.xml
+        ("CameraAngle")
+        ("CameraOffsetScale")
+        ("EditCameraMovement")
+        ("AppearanceCameraMovement")
+        // From llagentcamera.cpp
+        ("CameraOffsetBuild")
+        ("CameraOffsetRearView")
+        ("FocusOffsetRearView")
+        ("CameraOffsetScale")
+        ("TrackFocusObject")
         ;
     names = camera_controls;
 }
 
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
 {
-	if (LLTrans::getString(PRESETS_DEFAULT) == name)
-	{
-		name = PRESETS_DEFAULT;
-	}
-	if (!createDefault && name == PRESETS_DEFAULT)
-	{
-		LL_WARNS() << "Should not overwrite default" << LL_ENDL;
-		return false;
-	}
-
-	bool saved = false;
-	std::vector<std::string> name_list;
-
-	if(PRESETS_GRAPHIC == subdirectory)
-	{
-		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-		if (instance && !createDefault)
-		{
-			gSavedSettings.setString("PresetGraphicActive", name);
-			instance->getControlNames(name_list);
-			LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
-			name_list.push_back("PresetGraphicActive");
-		}
-		else
+    if (LLTrans::getString(PRESETS_DEFAULT) == name)
+    {
+        name = PRESETS_DEFAULT;
+    }
+    if (!createDefault && name == PRESETS_DEFAULT)
+    {
+        LL_WARNS() << "Should not overwrite default" << LL_ENDL;
+        return false;
+    }
+
+    bool saved = false;
+    std::vector<std::string> name_list;
+
+    if(PRESETS_GRAPHIC == subdirectory)
+    {
+        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+        if (instance && !createDefault)
+        {
+            gSavedSettings.setString("PresetGraphicActive", name);
+            instance->getControlNames(name_list);
+            LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
+            name_list.push_back("PresetGraphicActive");
+        }
+        else
         {
-			LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL;
-		}
-	}
-	else if(PRESETS_CAMERA == subdirectory)
-	{
-		gSavedSettings.setString("PresetGraphicActive", name);
-
-		name_list.clear();
-		getControlNames(name_list);
-		name_list.push_back("PresetCameraActive");
-	}
-	else
-	{
-		LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
-	}
+            LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL;
+        }
+    }
+    else if(PRESETS_CAMERA == subdirectory)
+    {
+        gSavedSettings.setString("PresetGraphicActive", name);
+
+        name_list.clear();
+        getControlNames(name_list);
+        name_list.push_back("PresetCameraActive");
+    }
+    else
+    {
+        LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
+    }
  
-	// make an empty llsd
-	LLSD paramsData(LLSD::emptyMap());
-
-	// Create a default graphics preset from hw recommended settings 
-	if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)
-	{
-		paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
-		if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
-		{
-			// use the recommended setting as an initial one (MAINT-6435)
-			gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
-		}
-	}
-	else
-	{
-		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
-		{
-			std::string ctrl_name = *it;
-			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
-			std::string comment = ctrl->getComment();
-			std::string type = LLControlGroup::typeEnumToString(ctrl->type());
-			LLSD value = ctrl->getValue();
-
-			paramsData[ctrl_name]["Comment"] = comment;
-			paramsData[ctrl_name]["Persist"] = 1;
-			paramsData[ctrl_name]["Type"] = type;
-			paramsData[ctrl_name]["Value"] = value;
-		}
-	}
-
-	std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
+    // make an empty llsd
+    LLSD paramsData(LLSD::emptyMap());
+
+    // Create a default graphics preset from hw recommended settings 
+    if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)
+    {
+        paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
+        if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
+        {
+            // use the recommended setting as an initial one (MAINT-6435)
+            gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
+        }
+    }
+    else
+    {
+        for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+        {
+            std::string ctrl_name = *it;
+            LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
+            std::string comment = ctrl->getComment();
+            std::string type = LLControlGroup::typeEnumToString(ctrl->type());
+            LLSD value = ctrl->getValue();
+
+            paramsData[ctrl_name]["Comment"] = comment;
+            paramsData[ctrl_name]["Persist"] = 1;
+            paramsData[ctrl_name]["Type"] = type;
+            paramsData[ctrl_name]["Value"] = value;
+        }
+    }
+
+    std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
 
  // If the active preset name is the only thing in the list, don't save the list
-	if (paramsData.size() > 1)
-	{
-		// write to file
-		llofstream presetsXML(pathName.c_str());
-		if (presetsXML.is_open())
-		{
-			LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
-			formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
-			presetsXML.close();
-			saved = true;
+    if (paramsData.size() > 1)
+    {
+        // write to file
+        llofstream presetsXML(pathName.c_str());
+        if (presetsXML.is_open())
+        {
+            LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
+            formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
+            presetsXML.close();
+            saved = true;
             
-			LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
-
-			if (subdirectory == PRESETS_GRAPHIC)
-			{
-				gSavedSettings.setString("PresetGraphicActive", name);
-				// signal interested parties
-				triggerChangeSignal();
-			}
-
-			if (subdirectory == PRESETS_CAMERA)
-			{
-				gSavedSettings.setString("PresetCameraActive", name);
-				setCameraDirty(false);
-				// signal interested parties
-				triggerChangeCameraSignal();
-			}
-		}
-		else
-		{
-			LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
-		}
-	}
+            LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
+
+            if (subdirectory == PRESETS_GRAPHIC)
+            {
+                gSavedSettings.setString("PresetGraphicActive", name);
+                // signal interested parties
+                triggerChangeSignal();
+            }
+
+            if (subdirectory == PRESETS_CAMERA)
+            {
+                gSavedSettings.setString("PresetCameraActive", name);
+                setCameraDirty(false);
+                // signal interested parties
+                triggerChangeCameraSignal();
+            }
+        }
+        else
+        {
+            LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
+        }
+    }
     else
-	{
-		LL_INFOS() << "No settings available to be saved" << LL_ENDL;
-	}
+    {
+        LL_INFOS() << "No settings available to be saved" << LL_ENDL;
+    }
     
-	return saved;
+    return saved;
 }
 
 bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option)
 {
-	bool sts = true;
-
-	combo->clearRows();
-
-	std::string presets_dir = getPresetsDir(subdirectory);
-
-	if (!presets_dir.empty())
-	{
-		std::list<std::string> preset_names;
-		loadPresetNamesFromDir(presets_dir, preset_names, default_option);
-
-		std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-
-		if (preset_names.begin() != preset_names.end())
-		{
-			for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
-			{
-				const std::string& name = *it;
-				combo->add(name, LLSD().with(0, name));
-			}
-		}
-		else
-		{
-			combo->setLabel(LLTrans::getString("preset_combo_label"));
-			sts = false;
-		}
-	}
-	return sts;
+    bool sts = true;
+
+    combo->clearRows();
+
+    std::string presets_dir = getPresetsDir(subdirectory);
+
+    if (!presets_dir.empty())
+    {
+        std::list<std::string> preset_names;
+        loadPresetNamesFromDir(presets_dir, preset_names, default_option);
+
+        std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+
+        if (preset_names.begin() != preset_names.end())
+        {
+            for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
+            {
+                const std::string& name = *it;
+                combo->add(name, LLSD().with(0, name));
+            }
+        }
+        else
+        {
+            combo->setLabel(LLTrans::getString("preset_combo_label"));
+            sts = false;
+        }
+    }
+    return sts;
 }
 
 void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string name)
 {
-	if (LLTrans::getString(PRESETS_DEFAULT) == name)
-	{
-		name = PRESETS_DEFAULT;
-	}
+    if (LLTrans::getString(PRESETS_DEFAULT) == name)
+    {
+        name = PRESETS_DEFAULT;
+    }
 
-	std::string full_path(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
+    std::string full_path(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
 
     LL_DEBUGS() << "attempting to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
 
-	if(gSavedSettings.loadFromFile(full_path, false, true) > 0)
-	{
-		if(PRESETS_GRAPHIC == subdirectory)
-		{
-			gSavedSettings.setString("PresetGraphicActive", name);
-
-			LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-			if (instance)
-			{
-				instance->refreshEnabledGraphics();
-			}
-			triggerChangeSignal();
-		}
-		if(PRESETS_CAMERA == subdirectory)
-		{
-			gSavedSettings.setString("PresetCameraActive", name);
-			triggerChangeCameraSignal();
-		}
-	}
+    if(gSavedSettings.loadFromFile(full_path, false, true) > 0)
+    {
+        if(PRESETS_GRAPHIC == subdirectory)
+        {
+            gSavedSettings.setString("PresetGraphicActive", name);
+
+            LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+            if (instance)
+            {
+                instance->refreshEnabledGraphics();
+            }
+            triggerChangeSignal();
+        }
+        if(PRESETS_CAMERA == subdirectory)
+        {
+            gSavedSettings.setString("PresetCameraActive", name);
+            triggerChangeCameraSignal();
+        }
+    }
     else
     {
         LL_WARNS("Presets") << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
@@ -417,56 +417,56 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n
 
 bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string name)
 {
-	if (LLTrans::getString(PRESETS_DEFAULT) == name)
-	{
-		name = PRESETS_DEFAULT;
-	}
-
-	bool sts = true;
-
-	if (PRESETS_DEFAULT == name)
-	{
-		// This code should never execute
-		LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL;
-		sts = false;
-	}
-
-	if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1)
-	{
-		LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL;
-		sts = false;
-	}
-
-	// If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded.
-	if(PRESETS_GRAPHIC == subdirectory)
-	{
-		if (gSavedSettings.getString("PresetGraphicActive") == name)
-		{
-			gSavedSettings.setString("PresetGraphicActive", "");
-		}
-		// signal interested parties
-		triggerChangeSignal();
-	}
-
-	if(PRESETS_CAMERA == subdirectory)
-	{
-		if (gSavedSettings.getString("PresetCameraActive") == name)
-		{
-			gSavedSettings.setString("PresetCameraActive", "");
-		}
-		// signal interested parties
-		triggerChangeCameraSignal();
-	}
-
-	return sts;
+    if (LLTrans::getString(PRESETS_DEFAULT) == name)
+    {
+        name = PRESETS_DEFAULT;
+    }
+
+    bool sts = true;
+
+    if (PRESETS_DEFAULT == name)
+    {
+        // This code should never execute
+        LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL;
+        sts = false;
+    }
+
+    if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1)
+    {
+        LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL;
+        sts = false;
+    }
+
+    // If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded.
+    if(PRESETS_GRAPHIC == subdirectory)
+    {
+        if (gSavedSettings.getString("PresetGraphicActive") == name)
+        {
+            gSavedSettings.setString("PresetGraphicActive", "");
+        }
+        // signal interested parties
+        triggerChangeSignal();
+    }
+
+    if(PRESETS_CAMERA == subdirectory)
+    {
+        if (gSavedSettings.getString("PresetCameraActive") == name)
+        {
+            gSavedSettings.setString("PresetCameraActive", "");
+        }
+        // signal interested parties
+        triggerChangeCameraSignal();
+    }
+
+    return sts;
 }
 
 boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
 {
-	return mPresetListChangeCameraSignal.connect(cb);
+    return mPresetListChangeCameraSignal.connect(cb);
 }
 
 boost::signals2::connection LLPresetsManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb)
 {
-	return mPresetListChangeSignal.connect(cb);
+    return mPresetListChangeSignal.connect(cb);
 }
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 7370e0a3b1..c3a6c0795c 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -39,54 +39,54 @@ static const std::string PRESETS_CAMERA = "camera";
 
 enum EDefaultOptions
 {
-	DEFAULT_SHOW,
-	DEFAULT_TOP,
-	DEFAULT_HIDE				// Do not display "Default" in a list
+    DEFAULT_SHOW,
+    DEFAULT_TOP,
+    DEFAULT_HIDE                // Do not display "Default" in a list
 };
 
 class LLPresetsManager : public LLSingleton<LLPresetsManager>
 {
-	LLSINGLETON(LLPresetsManager);
-	~LLPresetsManager();
+    LLSINGLETON(LLPresetsManager);
+    ~LLPresetsManager();
 
 public:
 
-	typedef std::list<std::string> preset_name_list_t;
-	typedef boost::signals2::signal<void()> preset_list_signal_t;
+    typedef std::list<std::string> preset_name_list_t;
+    typedef boost::signals2::signal<void()> preset_list_signal_t;
 
-	void createMissingDefault(const std::string& subdirectory);
-	void startWatching(const std::string& subdirectory);
-	void triggerChangeCameraSignal();
-	void triggerChangeSignal();
-	static std::string getPresetsDir(const std::string& subdirectory);
-	bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
-	void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
-	bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
-	void loadPreset(const std::string& subdirectory, std::string name);
-	bool deletePreset(const std::string& subdirectory, std::string name);
-	bool isCameraDirty();
-	static void setCameraDirty(bool dirty);
+    void createMissingDefault(const std::string& subdirectory);
+    void startWatching(const std::string& subdirectory);
+    void triggerChangeCameraSignal();
+    void triggerChangeSignal();
+    static std::string getPresetsDir(const std::string& subdirectory);
+    bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
+    void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
+    bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
+    void loadPreset(const std::string& subdirectory, std::string name);
+    bool deletePreset(const std::string& subdirectory, std::string name);
+    bool isCameraDirty();
+    static void setCameraDirty(bool dirty);
 
-	// Emitted when a preset gets loaded, deleted, or saved.
-	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
-	boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
+    // Emitted when a preset gets loaded, deleted, or saved.
+    boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
+    boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
 
-	// Emitted when a preset gets loaded or saved.
+    // Emitted when a preset gets loaded or saved.
 
-	preset_name_list_t mPresetNames;
+    preset_name_list_t mPresetNames;
 
-	preset_list_signal_t mPresetListChangeCameraSignal;
-	preset_list_signal_t mPresetListChangeSignal;
+    preset_list_signal_t mPresetListChangeCameraSignal;
+    preset_list_signal_t mPresetListChangeSignal;
 
   private:
-	LOG_CLASS(LLPresetsManager);
+    LOG_CLASS(LLPresetsManager);
 
-	void getControlNames(std::vector<std::string>& names);
-	static void settingChanged();
+    void getControlNames(std::vector<std::string>& names);
+    static void settingChanged();
 
-	boost::signals2::connection	mCameraChangedSignal;
+    boost::signals2::connection mCameraChangedSignal;
 
-	static bool	mCameraDirty;
+    static bool mCameraDirty;
 };
 
 #endif // LL_PRESETSMANAGER_H
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 398ec953d7..da495cbf21 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -63,7 +63,7 @@
 #include "llworld.h"
 #include "llstatgraph.h"
 #include "llviewermedia.h"
-#include "llviewermenu.h"	// for gMenuBarView
+#include "llviewermenu.h"   // for gMenuBarView
 #include "llviewerparcelmgr.h"
 #include "llviewerthrottle.h"
 #include "lluictrlfactory.h"
@@ -100,42 +100,42 @@ const S32 SIM_STAT_WIDTH = 8;
 const LLColor4 SIM_OK_COLOR(0.f, 1.f, 0.f, 1.f);
 const LLColor4 SIM_WARN_COLOR(1.f, 1.f, 0.f, 1.f);
 const LLColor4 SIM_FULL_COLOR(1.f, 0.f, 0.f, 1.f);
-const F32 ICON_TIMER_EXPIRY		= 3.f; // How long the balance and health icons should flash after a change.
+const F32 ICON_TIMER_EXPIRY     = 3.f; // How long the balance and health icons should flash after a change.
 
 static void onClickVolume(void*);
 
 LLStatusBar::LLStatusBar(const LLRect& rect)
-:	LLPanel(),
-	mTextTime(NULL),
-	mSGBandwidth(NULL),
-	mSGPacketLoss(NULL),
-	mBtnVolume(NULL),
-	mBoxBalance(NULL),
-	mBalance(0),
-	mHealth(100),
-	mSquareMetersCredit(0),
-	mSquareMetersCommitted(0)
+:   LLPanel(),
+    mTextTime(NULL),
+    mSGBandwidth(NULL),
+    mSGPacketLoss(NULL),
+    mBtnVolume(NULL),
+    mBoxBalance(NULL),
+    mBalance(0),
+    mHealth(100),
+    mSquareMetersCredit(0),
+    mSquareMetersCommitted(0)
 {
-	setRect(rect);
-	
-	// status bar can possible overlay menus?
-	setMouseOpaque(FALSE);
+    setRect(rect);
+    
+    // status bar can possible overlay menus?
+    setMouseOpaque(FALSE);
 
-	mBalanceTimer = new LLFrameTimer();
-	mHealthTimer = new LLFrameTimer();
+    mBalanceTimer = new LLFrameTimer();
+    mHealthTimer = new LLFrameTimer();
 
-	buildFromFile("panel_status_bar.xml");
+    buildFromFile("panel_status_bar.xml");
 }
 
 LLStatusBar::~LLStatusBar()
 {
-	delete mBalanceTimer;
-	mBalanceTimer = NULL;
+    delete mBalanceTimer;
+    mBalanceTimer = NULL;
 
-	delete mHealthTimer;
-	mHealthTimer = NULL;
+    delete mHealthTimer;
+    mHealthTimer = NULL;
 
-	// LLView destructor cleans up children
+    // LLView destructor cleans up children
 }
 
 //-----------------------------------------------------------------------
@@ -145,465 +145,465 @@ LLStatusBar::~LLStatusBar()
 // virtual
 void LLStatusBar::draw()
 {
-	refresh();
-	LLPanel::draw();
+    refresh();
+    LLPanel::draw();
 }
 
 BOOL LLStatusBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
 {
-	show_navbar_context_menu(this,x,y);
-	return TRUE;
+    show_navbar_context_menu(this,x,y);
+    return TRUE;
 }
 
 BOOL LLStatusBar::postBuild()
 {
-	gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3));
+    gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3));
 
-	mTextTime = getChild<LLTextBox>("TimeText" );
-	
-	getChild<LLUICtrl>("buyL")->setCommitCallback(
-		boost::bind(&LLStatusBar::onClickBuyCurrency, this));
+    mTextTime = getChild<LLTextBox>("TimeText" );
+    
+    getChild<LLUICtrl>("buyL")->setCommitCallback(
+        boost::bind(&LLStatusBar::onClickBuyCurrency, this));
 
     getChild<LLUICtrl>("goShop")->setCommitCallback(boost::bind(&LLWeb::loadURL, gSavedSettings.getString("MarketplaceURL"), LLStringUtil::null, LLStringUtil::null));
 
-	mBoxBalance = getChild<LLTextBox>("balance");
-	mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this );
-
-	mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" );
-	mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this));
-
-	mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" );
-	mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
-
-	mBtnVolume = getChild<LLButton>( "volume_btn" );
-	mBtnVolume->setClickedCallback( onClickVolume, this );
-	mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this));
-
-	mMediaToggle = getChild<LLButton>("media_toggle_btn");
-	mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this );
-	mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this));
-
-	LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle());
-
-	gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
-
-	// Adding Net Stat Graph
-	S32 x = getRect().getWidth() - 2;
-	S32 y = 0;
-	LLRect r;
-	r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
-	LLStatGraph::Params sgp;
-	sgp.name("BandwidthGraph");
-	sgp.rect(r);
-	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
-	sgp.mouse_opaque(false);
-	sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED);
-	sgp.units("Kbps");
-	sgp.precision(0);
-	sgp.per_sec(true);
-	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
-	addChild(mSGBandwidth);
-	x -= SIM_STAT_WIDTH + 2;
-
-	r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
-	//these don't seem to like being reused
-	LLStatGraph::Params pgp;
-	pgp.name("PacketLossPercent");
-	pgp.rect(r);
-	pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
-	pgp.mouse_opaque(false);
-	pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
-	pgp.units("%");
-	pgp.min(0.f);
-	pgp.max(5.f);
-	pgp.precision(1);
-	pgp.per_sec(false);
-	LLStatGraph::Thresholds thresholds;
-	thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green))
-						.add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow))
-						.add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red));
-
-	pgp.thresholds(thresholds);
-
-	mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
-	addChild(mSGPacketLoss);
-
-	mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown();
-	addChild(mPanelPresetsCameraPulldown);
-	mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-	mPanelPresetsCameraPulldown->setVisible(FALSE);
-
-	mPanelPresetsPulldown = new LLPanelPresetsPulldown();
-	addChild(mPanelPresetsPulldown);
-	mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-	mPanelPresetsPulldown->setVisible(FALSE);
-
-	mPanelVolumePulldown = new LLPanelVolumePulldown();
-	addChild(mPanelVolumePulldown);
-	mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-	mPanelVolumePulldown->setVisible(FALSE);
-
-	mPanelNearByMedia = new LLPanelNearByMedia();
-	addChild(mPanelNearByMedia);
-	mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-	mPanelNearByMedia->setVisible(FALSE);
-
-	return TRUE;
+    mBoxBalance = getChild<LLTextBox>("balance");
+    mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this );
+
+    mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" );
+    mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this));
+
+    mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" );
+    mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
+
+    mBtnVolume = getChild<LLButton>( "volume_btn" );
+    mBtnVolume->setClickedCallback( onClickVolume, this );
+    mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this));
+
+    mMediaToggle = getChild<LLButton>("media_toggle_btn");
+    mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this );
+    mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this));
+
+    LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle());
+
+    gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
+
+    // Adding Net Stat Graph
+    S32 x = getRect().getWidth() - 2;
+    S32 y = 0;
+    LLRect r;
+    r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
+    LLStatGraph::Params sgp;
+    sgp.name("BandwidthGraph");
+    sgp.rect(r);
+    sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+    sgp.mouse_opaque(false);
+    sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED);
+    sgp.units("Kbps");
+    sgp.precision(0);
+    sgp.per_sec(true);
+    mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
+    addChild(mSGBandwidth);
+    x -= SIM_STAT_WIDTH + 2;
+
+    r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
+    //these don't seem to like being reused
+    LLStatGraph::Params pgp;
+    pgp.name("PacketLossPercent");
+    pgp.rect(r);
+    pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+    pgp.mouse_opaque(false);
+    pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
+    pgp.units("%");
+    pgp.min(0.f);
+    pgp.max(5.f);
+    pgp.precision(1);
+    pgp.per_sec(false);
+    LLStatGraph::Thresholds thresholds;
+    thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green))
+                        .add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow))
+                        .add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red));
+
+    pgp.thresholds(thresholds);
+
+    mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
+    addChild(mSGPacketLoss);
+
+    mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown();
+    addChild(mPanelPresetsCameraPulldown);
+    mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+    mPanelPresetsCameraPulldown->setVisible(FALSE);
+
+    mPanelPresetsPulldown = new LLPanelPresetsPulldown();
+    addChild(mPanelPresetsPulldown);
+    mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+    mPanelPresetsPulldown->setVisible(FALSE);
+
+    mPanelVolumePulldown = new LLPanelVolumePulldown();
+    addChild(mPanelVolumePulldown);
+    mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+    mPanelVolumePulldown->setVisible(FALSE);
+
+    mPanelNearByMedia = new LLPanelNearByMedia();
+    addChild(mPanelNearByMedia);
+    mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+    mPanelNearByMedia->setVisible(FALSE);
+
+    return TRUE;
 }
 
 // Per-frame updates of visibility
 void LLStatusBar::refresh()
 {
-	static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false);
-	bool net_stats_visible = show_net_stats;
-
-	if (net_stats_visible)
-	{
-		// Adding Net Stat Meter back in
-		F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
-		mSGBandwidth->setMin(0.f);
-		mSGBandwidth->setMax(bwtotal*1.25f);
-		//mSGBandwidth->setThreshold(0, bwtotal*0.75f);
-		//mSGBandwidth->setThreshold(1, bwtotal);
-		//mSGBandwidth->setThreshold(2, bwtotal);
-	}
-	
-	// update clock every 10 seconds
-	if(mClockUpdateTimer.getElapsedTimeF32() > 10.f)
-	{
-		mClockUpdateTimer.reset();
-
-		// Get current UTC time, adjusted for the user's clock
-		// being off.
-		time_t utc_time;
-		utc_time = time_corrected();
-
-		std::string timeStr = getString("time");
-		LLSD substitution;
-		substitution["datetime"] = (S32) utc_time;
-		LLStringUtil::format (timeStr, substitution);
-		mTextTime->setText(timeStr);
-
-		// set the tooltip to have the date
-		std::string dtStr = getString("timeTooltip");
-		LLStringUtil::format (dtStr, substitution);
-		mTextTime->setToolTip (dtStr);
-	}
-
-	LLRect r;
-	const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
-
-	// reshape menu bar to its content's width
-	if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
-	{
-		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
-	}
-
-	mSGBandwidth->setVisible(net_stats_visible);
-	mSGPacketLoss->setVisible(net_stats_visible);
-
-	// update the master volume button state
-	bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
-	mBtnVolume->setToggleState(mute_audio);
-	
-	// Disable media toggle if there's no media, parcel media, and no parcel audio
-	// (or if media is disabled)
-	bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && 
-						  (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
-	mMediaToggle->setEnabled(button_enabled);
-	// Note the "sense" of the toggle is opposite whether media is playing or not
-	bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || 
-							  LLViewerMedia::isParcelMediaPlaying() ||
-							  LLViewerMedia::isParcelAudioPlaying());
-	mMediaToggle->setValue(!any_media_playing);
+    static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false);
+    bool net_stats_visible = show_net_stats;
+
+    if (net_stats_visible)
+    {
+        // Adding Net Stat Meter back in
+        F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
+        mSGBandwidth->setMin(0.f);
+        mSGBandwidth->setMax(bwtotal*1.25f);
+        //mSGBandwidth->setThreshold(0, bwtotal*0.75f);
+        //mSGBandwidth->setThreshold(1, bwtotal);
+        //mSGBandwidth->setThreshold(2, bwtotal);
+    }
+    
+    // update clock every 10 seconds
+    if(mClockUpdateTimer.getElapsedTimeF32() > 10.f)
+    {
+        mClockUpdateTimer.reset();
+
+        // Get current UTC time, adjusted for the user's clock
+        // being off.
+        time_t utc_time;
+        utc_time = time_corrected();
+
+        std::string timeStr = getString("time");
+        LLSD substitution;
+        substitution["datetime"] = (S32) utc_time;
+        LLStringUtil::format (timeStr, substitution);
+        mTextTime->setText(timeStr);
+
+        // set the tooltip to have the date
+        std::string dtStr = getString("timeTooltip");
+        LLStringUtil::format (dtStr, substitution);
+        mTextTime->setToolTip (dtStr);
+    }
+
+    LLRect r;
+    const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
+
+    // reshape menu bar to its content's width
+    if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
+    {
+        gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
+    }
+
+    mSGBandwidth->setVisible(net_stats_visible);
+    mSGPacketLoss->setVisible(net_stats_visible);
+
+    // update the master volume button state
+    bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
+    mBtnVolume->setToggleState(mute_audio);
+    
+    // Disable media toggle if there's no media, parcel media, and no parcel audio
+    // (or if media is disabled)
+    bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && 
+                          (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
+    mMediaToggle->setEnabled(button_enabled);
+    // Note the "sense" of the toggle is opposite whether media is playing or not
+    bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || 
+                              LLViewerMedia::isParcelMediaPlaying() ||
+                              LLViewerMedia::isParcelAudioPlaying());
+    mMediaToggle->setValue(!any_media_playing);
 }
 
 void LLStatusBar::setVisibleForMouselook(bool visible)
 {
-	mTextTime->setVisible(visible);
-	getChild<LLUICtrl>("balance_bg")->setVisible(visible);
-	mBoxBalance->setVisible(visible);
-	mBtnVolume->setVisible(visible);
-	mMediaToggle->setVisible(visible);
-	mSGBandwidth->setVisible(visible);
-	mSGPacketLoss->setVisible(visible);
-	setBackgroundVisible(visible);
-	mIconPresetsCamera->setVisible(visible);
-	mIconPresetsGraphic->setVisible(visible);
+    mTextTime->setVisible(visible);
+    getChild<LLUICtrl>("balance_bg")->setVisible(visible);
+    mBoxBalance->setVisible(visible);
+    mBtnVolume->setVisible(visible);
+    mMediaToggle->setVisible(visible);
+    mSGBandwidth->setVisible(visible);
+    mSGPacketLoss->setVisible(visible);
+    setBackgroundVisible(visible);
+    mIconPresetsCamera->setVisible(visible);
+    mIconPresetsGraphic->setVisible(visible);
 }
 
 void LLStatusBar::debitBalance(S32 debit)
 {
-	setBalance(getBalance() - debit);
+    setBalance(getBalance() - debit);
 }
 
 void LLStatusBar::creditBalance(S32 credit)
 {
-	setBalance(getBalance() + credit);
+    setBalance(getBalance() + credit);
 }
 
 void LLStatusBar::setBalance(S32 balance)
 {
-	if (balance > getBalance() && getBalance() != 0)
-	{
-		LLFirstUse::receiveLindens();
-	}
-
-	std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance );
-
-	LLStringUtil::format_map_t string_args;
-	string_args["[AMT]"] = llformat("%s", money_str.c_str());
-	std::string label_str = getString("buycurrencylabel", string_args);
-	mBoxBalance->setValue(label_str);
-
-	// Resize the L$ balance background to be wide enough for your balance plus the buy button
-	{
-		const S32 HPAD = 24;
-		LLRect balance_rect = mBoxBalance->getTextBoundingRect();
-		LLRect buy_rect = getChildView("buyL")->getRect();
-		LLRect shop_rect = getChildView("goShop")->getRect();
-		LLView* balance_bg_view = getChildView("balance_bg");
-		LLRect balance_bg_rect = balance_bg_view->getRect();
-		balance_bg_rect.mLeft = balance_bg_rect.mRight - (buy_rect.getWidth() + shop_rect.getWidth() + balance_rect.getWidth() + HPAD);
-		balance_bg_view->setShape(balance_bg_rect);
-	}
-
-	if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
-	{
-		if (mBalance > balance)
-			make_ui_sound("UISndMoneyChangeDown");
-		else
-			make_ui_sound("UISndMoneyChangeUp");
-	}
-
-	if( balance != mBalance )
-	{
-		mBalanceTimer->reset();
-		mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
-		mBalance = balance;
-	}
+    if (balance > getBalance() && getBalance() != 0)
+    {
+        LLFirstUse::receiveLindens();
+    }
+
+    std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance );
+
+    LLStringUtil::format_map_t string_args;
+    string_args["[AMT]"] = llformat("%s", money_str.c_str());
+    std::string label_str = getString("buycurrencylabel", string_args);
+    mBoxBalance->setValue(label_str);
+
+    // Resize the L$ balance background to be wide enough for your balance plus the buy button
+    {
+        const S32 HPAD = 24;
+        LLRect balance_rect = mBoxBalance->getTextBoundingRect();
+        LLRect buy_rect = getChildView("buyL")->getRect();
+        LLRect shop_rect = getChildView("goShop")->getRect();
+        LLView* balance_bg_view = getChildView("balance_bg");
+        LLRect balance_bg_rect = balance_bg_view->getRect();
+        balance_bg_rect.mLeft = balance_bg_rect.mRight - (buy_rect.getWidth() + shop_rect.getWidth() + balance_rect.getWidth() + HPAD);
+        balance_bg_view->setShape(balance_bg_rect);
+    }
+
+    if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
+    {
+        if (mBalance > balance)
+            make_ui_sound("UISndMoneyChangeDown");
+        else
+            make_ui_sound("UISndMoneyChangeUp");
+    }
+
+    if( balance != mBalance )
+    {
+        mBalanceTimer->reset();
+        mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
+        mBalance = balance;
+    }
 }
 
 
 // static
 void LLStatusBar::sendMoneyBalanceRequest()
 {
-	LLMessageSystem* msg = gMessageSystem;
-	msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
-	msg->nextBlockFast(_PREHASH_AgentData);
-	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-	msg->nextBlockFast(_PREHASH_MoneyData);
-	msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
-	gAgent.sendReliableMessage();
+    LLMessageSystem* msg = gMessageSystem;
+    msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
+    msg->nextBlockFast(_PREHASH_AgentData);
+    msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+    msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+    msg->nextBlockFast(_PREHASH_MoneyData);
+    msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
+    gAgent.sendReliableMessage();
 }
 
 
 void LLStatusBar::setHealth(S32 health)
 {
-	//LL_INFOS() << "Setting health to: " << buffer << LL_ENDL;
-	if( mHealth > health )
-	{
-		if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
-		{
-			if (isAgentAvatarValid())
-			{
-				if (gAgentAvatarp->getSex() == SEX_FEMALE)
-				{
-					make_ui_sound("UISndHealthReductionF");
-				}
-				else
-				{
-					make_ui_sound("UISndHealthReductionM");
-				}
-			}
-		}
-
-		mHealthTimer->reset();
-		mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
-	}
-
-	mHealth = health;
+    //LL_INFOS() << "Setting health to: " << buffer << LL_ENDL;
+    if( mHealth > health )
+    {
+        if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
+        {
+            if (isAgentAvatarValid())
+            {
+                if (gAgentAvatarp->getSex() == SEX_FEMALE)
+                {
+                    make_ui_sound("UISndHealthReductionF");
+                }
+                else
+                {
+                    make_ui_sound("UISndHealthReductionM");
+                }
+            }
+        }
+
+        mHealthTimer->reset();
+        mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
+    }
+
+    mHealth = health;
 }
 
 S32 LLStatusBar::getBalance() const
 {
-	return mBalance;
+    return mBalance;
 }
 
 
 S32 LLStatusBar::getHealth() const
 {
-	return mHealth;
+    return mHealth;
 }
 
 void LLStatusBar::setLandCredit(S32 credit)
 {
-	mSquareMetersCredit = credit;
+    mSquareMetersCredit = credit;
 }
 void LLStatusBar::setLandCommitted(S32 committed)
 {
-	mSquareMetersCommitted = committed;
+    mSquareMetersCommitted = committed;
 }
 
 BOOL LLStatusBar::isUserTiered() const
 {
-	return (mSquareMetersCredit > 0);
+    return (mSquareMetersCredit > 0);
 }
 
 S32 LLStatusBar::getSquareMetersCredit() const
 {
-	return mSquareMetersCredit;
+    return mSquareMetersCredit;
 }
 
 S32 LLStatusBar::getSquareMetersCommitted() const
 {
-	return mSquareMetersCommitted;
+    return mSquareMetersCommitted;
 }
 
 S32 LLStatusBar::getSquareMetersLeft() const
 {
-	return mSquareMetersCredit - mSquareMetersCommitted;
+    return mSquareMetersCredit - mSquareMetersCommitted;
 }
 
 void LLStatusBar::onClickBuyCurrency()
 {
-	// open a currency floater - actual one open depends on 
-	// value specified in settings.xml
-	LLBuyCurrencyHTML::openCurrencyFloater();
-	LLFirstUse::receiveLindens(false);
+    // open a currency floater - actual one open depends on 
+    // value specified in settings.xml
+    LLBuyCurrencyHTML::openCurrencyFloater();
+    LLFirstUse::receiveLindens(false);
 }
 
 void LLStatusBar::onMouseEnterPresetsCamera()
 {
-	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_camera" );
-	LLRect icon_rect = icon->getRect();
-	LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect();
-	pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
-	     (pulldown_rect.getWidth() - icon_rect.getWidth()),
-			       icon_rect.mBottom,
-			       pulldown_rect.getWidth(),
-			       pulldown_rect.getHeight());
-
-	pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
-	mPanelPresetsCameraPulldown->setShape(pulldown_rect);
-
-	// show the master presets pull-down
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelPresetsCameraPulldown);
-	mPanelNearByMedia->setVisible(FALSE);
-	mPanelVolumePulldown->setVisible(FALSE);
-	mPanelPresetsPulldown->setVisible(FALSE);
-	mPanelPresetsCameraPulldown->setVisible(TRUE);
+    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+    LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_camera" );
+    LLRect icon_rect = icon->getRect();
+    LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect();
+    pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
+         (pulldown_rect.getWidth() - icon_rect.getWidth()),
+                   icon_rect.mBottom,
+                   pulldown_rect.getWidth(),
+                   pulldown_rect.getHeight());
+
+    pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
+    mPanelPresetsCameraPulldown->setShape(pulldown_rect);
+
+    // show the master presets pull-down
+    LLUI::clearPopups();
+    LLUI::addPopup(mPanelPresetsCameraPulldown);
+    mPanelNearByMedia->setVisible(FALSE);
+    mPanelVolumePulldown->setVisible(FALSE);
+    mPanelPresetsPulldown->setVisible(FALSE);
+    mPanelPresetsCameraPulldown->setVisible(TRUE);
 }
 
 void LLStatusBar::onMouseEnterPresets()
 {
-	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_graphic" );
-	LLRect icon_rect = icon->getRect();
-	LLRect pulldown_rect = mPanelPresetsPulldown->getRect();
-	pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
-	     (pulldown_rect.getWidth() - icon_rect.getWidth()),
-			       icon_rect.mBottom,
-			       pulldown_rect.getWidth(),
-			       pulldown_rect.getHeight());
-
-	pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
-	mPanelPresetsPulldown->setShape(pulldown_rect);
-
-	// show the master presets pull-down
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelPresetsPulldown);
-	mPanelNearByMedia->setVisible(FALSE);
-	mPanelVolumePulldown->setVisible(FALSE);
-	mPanelPresetsPulldown->setVisible(TRUE);
+    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+    LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_graphic" );
+    LLRect icon_rect = icon->getRect();
+    LLRect pulldown_rect = mPanelPresetsPulldown->getRect();
+    pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
+         (pulldown_rect.getWidth() - icon_rect.getWidth()),
+                   icon_rect.mBottom,
+                   pulldown_rect.getWidth(),
+                   pulldown_rect.getHeight());
+
+    pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
+    mPanelPresetsPulldown->setShape(pulldown_rect);
+
+    // show the master presets pull-down
+    LLUI::clearPopups();
+    LLUI::addPopup(mPanelPresetsPulldown);
+    mPanelNearByMedia->setVisible(FALSE);
+    mPanelVolumePulldown->setVisible(FALSE);
+    mPanelPresetsPulldown->setVisible(TRUE);
 }
 
 void LLStatusBar::onMouseEnterVolume()
 {
-	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-	LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
-	LLRect vol_btn_rect = volbtn->getRect();
-	LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
-	volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft -
-	     (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth()),
-			       vol_btn_rect.mBottom,
-			       volume_pulldown_rect.getWidth(),
-			       volume_pulldown_rect.getHeight());
-
-	volume_pulldown_rect.translate(popup_holder->getRect().getWidth() - volume_pulldown_rect.mRight, 0);
-	mPanelVolumePulldown->setShape(volume_pulldown_rect);
-
-
-	// show the master volume pull-down
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelVolumePulldown);
-	mPanelPresetsCameraPulldown->setVisible(FALSE);
-	mPanelPresetsPulldown->setVisible(FALSE);
-	mPanelNearByMedia->setVisible(FALSE);
-	mPanelVolumePulldown->setVisible(TRUE);
+    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+    LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
+    LLRect vol_btn_rect = volbtn->getRect();
+    LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
+    volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft -
+         (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth()),
+                   vol_btn_rect.mBottom,
+                   volume_pulldown_rect.getWidth(),
+                   volume_pulldown_rect.getHeight());
+
+    volume_pulldown_rect.translate(popup_holder->getRect().getWidth() - volume_pulldown_rect.mRight, 0);
+    mPanelVolumePulldown->setShape(volume_pulldown_rect);
+
+
+    // show the master volume pull-down
+    LLUI::clearPopups();
+    LLUI::addPopup(mPanelVolumePulldown);
+    mPanelPresetsCameraPulldown->setVisible(FALSE);
+    mPanelPresetsPulldown->setVisible(FALSE);
+    mPanelNearByMedia->setVisible(FALSE);
+    mPanelVolumePulldown->setVisible(TRUE);
 }
 
 void LLStatusBar::onMouseEnterNearbyMedia()
 {
-	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-	LLRect nearby_media_rect = mPanelNearByMedia->getRect();
-	LLButton* nearby_media_btn =  getChild<LLButton>( "media_toggle_btn" );
-	LLRect nearby_media_btn_rect = nearby_media_btn->getRect();
-	nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - 
-										(nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2,
-										nearby_media_btn_rect.mBottom,
-										nearby_media_rect.getWidth(),
-										nearby_media_rect.getHeight());
-	// force onscreen
-	nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0);
-	
-	// show the master volume pull-down
-	mPanelNearByMedia->setShape(nearby_media_rect);
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelNearByMedia);
-
-	mPanelPresetsCameraPulldown->setVisible(FALSE);
-	mPanelPresetsPulldown->setVisible(FALSE);
-	mPanelVolumePulldown->setVisible(FALSE);
-	mPanelNearByMedia->setVisible(TRUE);
+    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+    LLRect nearby_media_rect = mPanelNearByMedia->getRect();
+    LLButton* nearby_media_btn =  getChild<LLButton>( "media_toggle_btn" );
+    LLRect nearby_media_btn_rect = nearby_media_btn->getRect();
+    nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - 
+                                        (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2,
+                                        nearby_media_btn_rect.mBottom,
+                                        nearby_media_rect.getWidth(),
+                                        nearby_media_rect.getHeight());
+    // force onscreen
+    nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0);
+    
+    // show the master volume pull-down
+    mPanelNearByMedia->setShape(nearby_media_rect);
+    LLUI::clearPopups();
+    LLUI::addPopup(mPanelNearByMedia);
+
+    mPanelPresetsCameraPulldown->setVisible(FALSE);
+    mPanelPresetsPulldown->setVisible(FALSE);
+    mPanelVolumePulldown->setVisible(FALSE);
+    mPanelNearByMedia->setVisible(TRUE);
 }
 
 
 static void onClickVolume(void* data)
 {
-	// toggle the master mute setting
-	bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
-	LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio);	
+    // toggle the master mute setting
+    bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
+    LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio); 
 }
 
 //static 
 void LLStatusBar::onClickBalance(void* )
 {
-	// Force a balance request message:
-	LLStatusBar::sendMoneyBalanceRequest();
-	// The refresh of the display (call to setBalance()) will be done by process_money_balance_reply()
+    // Force a balance request message:
+    LLStatusBar::sendMoneyBalanceRequest();
+    // The refresh of the display (call to setBalance()) will be done by process_money_balance_reply()
 }
 
 //static 
 void LLStatusBar::onClickMediaToggle(void* data)
 {
-	LLStatusBar *status_bar = (LLStatusBar*)data;
-	// "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media
-	bool pause = status_bar->mMediaToggle->getValue();
-	LLViewerMedia::setAllMediaPaused(pause);
+    LLStatusBar *status_bar = (LLStatusBar*)data;
+    // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media
+    bool pause = status_bar->mMediaToggle->getValue();
+    LLViewerMedia::setAllMediaPaused(pause);
 }
 
 BOOL can_afford_transaction(S32 cost)
 {
-	return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
+    return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
 }
 
 void LLStatusBar::onVolumeChanged(const LLSD& newvalue)
 {
-	refresh();
+    refresh();
 }
 
 // Implements secondlife:///app/balance/request to request a L$ balance
@@ -611,18 +611,18 @@ void LLStatusBar::onVolumeChanged(const LLSD& newvalue)
 class LLBalanceHandler : public LLCommandHandler
 {
 public:
-	// Requires "trusted" browser/URL source
-	LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { }
-	bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
-	{
-		if (tokens.size() == 1
-			&& tokens[0].asString() == "request")
-		{
-			LLStatusBar::sendMoneyBalanceRequest();
-			return true;
-		}
-		return false;
-	}
+    // Requires "trusted" browser/URL source
+    LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { }
+    bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
+    {
+        if (tokens.size() == 1
+            && tokens[0].asString() == "request")
+        {
+            LLStatusBar::sendMoneyBalanceRequest();
+            return true;
+        }
+        return false;
+    }
 };
 // register with command dispatch system
 LLBalanceHandler gBalanceHandler;
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index 040b7bc949..e9be398601 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -48,82 +48,82 @@ class LLPanelNearByMedia;
 class LLIconCtrl;
 
 class LLStatusBar
-:	public LLPanel
+:   public LLPanel
 {
 public:
-	LLStatusBar(const LLRect& rect );
-	/*virtual*/ ~LLStatusBar();
-	
-	/*virtual*/ void draw();
+    LLStatusBar(const LLRect& rect );
+    /*virtual*/ ~LLStatusBar();
+    
+    /*virtual*/ void draw();
 
-	/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-	/*virtual*/ BOOL postBuild();
+    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL postBuild();
 
-	// MANIPULATORS
-	void		setBalance(S32 balance);
-	void		debitBalance(S32 debit);
-	void		creditBalance(S32 credit);
+    // MANIPULATORS
+    void        setBalance(S32 balance);
+    void        debitBalance(S32 debit);
+    void        creditBalance(S32 credit);
 
-	// Request the latest currency balance from the server
-	static void sendMoneyBalanceRequest();
+    // Request the latest currency balance from the server
+    static void sendMoneyBalanceRequest();
 
-	void		setHealth(S32 percent);
+    void        setHealth(S32 percent);
 
-	void setLandCredit(S32 credit);
-	void setLandCommitted(S32 committed);
+    void setLandCredit(S32 credit);
+    void setLandCommitted(S32 committed);
 
-	void		refresh();
-	void setVisibleForMouselook(bool visible);
-		// some elements should hide in mouselook
+    void        refresh();
+    void setVisibleForMouselook(bool visible);
+        // some elements should hide in mouselook
 
-	// ACCESSORS
-	S32			getBalance() const;
-	S32			getHealth() const;
+    // ACCESSORS
+    S32         getBalance() const;
+    S32         getHealth() const;
 
-	BOOL isUserTiered() const;
-	S32 getSquareMetersCredit() const;
-	S32 getSquareMetersCommitted() const;
-	S32 getSquareMetersLeft() const;
+    BOOL isUserTiered() const;
+    S32 getSquareMetersCredit() const;
+    S32 getSquareMetersCommitted() const;
+    S32 getSquareMetersLeft() const;
 
-	LLPanelNearByMedia* getNearbyMediaPanel() { return mPanelNearByMedia; }
+    LLPanelNearByMedia* getNearbyMediaPanel() { return mPanelNearByMedia; }
 
 private:
-	
-	void onClickBuyCurrency();
-	void onVolumeChanged(const LLSD& newvalue);
+    
+    void onClickBuyCurrency();
+    void onVolumeChanged(const LLSD& newvalue);
 
-	void onMouseEnterPresetsCamera();
-	void onMouseEnterPresets();
-	void onMouseEnterVolume();
-	void onMouseEnterNearbyMedia();
-	void onClickScreen(S32 x, S32 y);
+    void onMouseEnterPresetsCamera();
+    void onMouseEnterPresets();
+    void onMouseEnterVolume();
+    void onMouseEnterNearbyMedia();
+    void onClickScreen(S32 x, S32 y);
 
-	static void onClickMediaToggle(void* data);
-	static void onClickBalance(void* data);
+    static void onClickMediaToggle(void* data);
+    static void onClickBalance(void* data);
 
 private:
-	LLTextBox	*mTextTime;
-
-	LLStatGraph *mSGBandwidth;
-	LLStatGraph *mSGPacketLoss;
-
-	LLIconCtrl	*mIconPresetsCamera;
-	LLIconCtrl	*mIconPresetsGraphic;
-	LLButton	*mBtnVolume;
-	LLTextBox	*mBoxBalance;
-	LLButton	*mMediaToggle;
-	LLFrameTimer	mClockUpdateTimer;
-
-	S32				mBalance;
-	S32				mHealth;
-	S32				mSquareMetersCredit;
-	S32				mSquareMetersCommitted;
-	LLFrameTimer*	mBalanceTimer;
-	LLFrameTimer*	mHealthTimer;
-	LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown;
-	LLPanelPresetsPulldown* mPanelPresetsPulldown;
-	LLPanelVolumePulldown* mPanelVolumePulldown;
-	LLPanelNearByMedia*	mPanelNearByMedia;
+    LLTextBox   *mTextTime;
+
+    LLStatGraph *mSGBandwidth;
+    LLStatGraph *mSGPacketLoss;
+
+    LLIconCtrl  *mIconPresetsCamera;
+    LLIconCtrl  *mIconPresetsGraphic;
+    LLButton    *mBtnVolume;
+    LLTextBox   *mBoxBalance;
+    LLButton    *mMediaToggle;
+    LLFrameTimer    mClockUpdateTimer;
+
+    S32             mBalance;
+    S32             mHealth;
+    S32             mSquareMetersCredit;
+    S32             mSquareMetersCommitted;
+    LLFrameTimer*   mBalanceTimer;
+    LLFrameTimer*   mHealthTimer;
+    LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown;
+    LLPanelPresetsPulldown* mPanelPresetsPulldown;
+    LLPanelVolumePulldown* mPanelVolumePulldown;
+    LLPanelNearByMedia* mPanelNearByMedia;
 };
 
 // *HACK: Status bar owns your cached money balance. JC
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 5237986cd6..968472fe4c 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -166,216 +166,216 @@
 class LLFloaterOpenHandler : public LLCommandHandler
 {
 public:
-	// requires trusted browser to trigger
-	LLFloaterOpenHandler() : LLCommandHandler("openfloater", UNTRUSTED_THROTTLE) { }
+    // requires trusted browser to trigger
+    LLFloaterOpenHandler() : LLCommandHandler("openfloater", UNTRUSTED_THROTTLE) { }
 
-	bool handle(const LLSD& params, const LLSD& query_map,
-				LLMediaCtrl* web)
-	{
-		if (params.size() != 1)
-		{
-			return false;
-		}
+    bool handle(const LLSD& params, const LLSD& query_map,
+                LLMediaCtrl* web)
+    {
+        if (params.size() != 1)
+        {
+            return false;
+        }
 
-		const std::string floater_name = LLURI::unescape(params[0].asString());
-		LLFloaterReg::showInstance(floater_name);
+        const std::string floater_name = LLURI::unescape(params[0].asString());
+        LLFloaterReg::showInstance(floater_name);
 
-		return true;
-	}
+        return true;
+    }
 };
 
 LLFloaterOpenHandler gFloaterOpenHandler;
 
 void LLViewerFloaterReg::registerFloaters()
 {
-	// *NOTE: Please keep these alphabetized for easier merges
+    // *NOTE: Please keep these alphabetized for easier merges
 
-	LLFloaterAboutUtil::registerFloater();
-	LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
-	LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>);
-	LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-	LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>);
-	LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>);
-	LLFloaterReg::add("avatar", "floater_avatar.xml",  (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>);
-	LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>);
-	LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>);
-	LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>);
+    LLFloaterAboutUtil::registerFloater();
+    LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
+    LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>);
+    LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+    LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>);
+    LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>);
+    LLFloaterReg::add("avatar", "floater_avatar.xml",  (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>);
+    LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>);
+    LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>);
+    LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>);
 
-	LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>);
-	LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>);
-	LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater);
-	LLFloaterReg::add("buy_currency_html", "floater_buy_currency_html.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyCurrencyHTML>);	
-	LLFloaterReg::add("buy_land", "floater_buy_land.xml", &LLFloaterBuyLand::buildFloater);
-	LLFloaterReg::add("buy_object", "floater_buy_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuy>);
-	LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>);
-	LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>);
-	LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>);
-	LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
+    LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>);
+    LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>);
+    LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater);
+    LLFloaterReg::add("buy_currency_html", "floater_buy_currency_html.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyCurrencyHTML>);    
+    LLFloaterReg::add("buy_land", "floater_buy_land.xml", &LLFloaterBuyLand::buildFloater);
+    LLFloaterReg::add("buy_object", "floater_buy_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuy>);
+    LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>);
+    LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>);
+    LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>);
+    LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
 
-	LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
-	LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>);
-	LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater);
-	LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);
-	LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>);
+    LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
+    LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>);
+    LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater);
+    LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);
+    LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>);
 
-	LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>);
-	LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>);
+    LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>);
+    LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>);
 
-	LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>);
-	LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>);
-	LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>);
-	LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>);
-	LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>);
-	LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>);
+    LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>);
+    LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>);
+    LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>);
+    LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>);
+    LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>);
+    LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>);
 
     LLFloaterReg::add("event", "floater_event.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEvent>);
     LLFloaterReg::add("experiences", "floater_experiences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiences>);
-	LLFloaterReg::add("experience_profile", "floater_experienceprofile.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperienceProfile>);
-	LLFloaterReg::add("experience_search", "floater_experience_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiencePicker>);
+    LLFloaterReg::add("experience_profile", "floater_experienceprofile.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperienceProfile>);
+    LLFloaterReg::add("experience_search", "floater_experience_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiencePicker>);
 
-	LLFloaterReg::add("font_test", "floater_font_test.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFontTest>);
+    LLFloaterReg::add("font_test", "floater_font_test.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFontTest>);
 
-	LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>);
-	LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>);
-	LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>);
-	LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>);
+    LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>);
+    LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>);
+    LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>);
+    LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>);
 
-	LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>);
-	LLFloaterReg::add("edit_hover_height", "floater_edit_hover_height.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHoverHeight>);
-	LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>);
+    LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>);
+    LLFloaterReg::add("edit_hover_height", "floater_edit_hover_height.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHoverHeight>);
+    LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>);
 
-	LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMSession>);
-	LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMContainer>);
-	LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>);
-	LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>);
-	LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-	LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>);
-	LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>);
-	LLInspectAvatarUtil::registerFloater();
-	LLInspectGroupUtil::registerFloater();
-	LLInspectObjectUtil::registerFloater();
-	LLInspectRemoteObjectUtil::registerFloater();
-	LLFloaterVoiceVolumeUtil::registerFloater();
-	LLNotificationsUI::registerFloater();
-	
-	LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
-	LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
-	LLFloaterReg::add("linkreplace", "floater_linkreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLinkReplace>);
-	LLFloaterReg::add("load_pref_preset", "floater_load_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLoadPrefPreset>);
-	
-	LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>);
+    LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMSession>);
+    LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMContainer>);
+    LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>);
+    LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>);
+    LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+    LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>);
+    LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>);
+    LLInspectAvatarUtil::registerFloater();
+    LLInspectGroupUtil::registerFloater();
+    LLInspectObjectUtil::registerFloater();
+    LLInspectRemoteObjectUtil::registerFloater();
+    LLFloaterVoiceVolumeUtil::registerFloater();
+    LLNotificationsUI::registerFloater();
+    
+    LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
+    LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
+    LLFloaterReg::add("linkreplace", "floater_linkreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLinkReplace>);
+    LLFloaterReg::add("load_pref_preset", "floater_load_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLoadPrefPreset>);
+    
+    LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>);
 
-	if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
-	{
-		LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>);
-	}
-	LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>);	
-	LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>);
-	LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>);
-	LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
-	LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
-	LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMove>);
-	LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGetBlockedObjectName>);
-	LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMap>);
+    if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
+    {
+        LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>);
+    }
+    LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>);    
+    LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>);
+    LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>);
+    LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
+    LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
+    LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMove>);
+    LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGetBlockedObjectName>);
+    LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMap>);
 
-	LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationConsole>);
-	
-	LLFloaterReg::add("notification_well_window", "floater_notifications_tabbed.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationsTabbed>);
+    LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationConsole>);
+    
+    LLFloaterReg::add("notification_well_window", "floater_notifications_tabbed.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationsTabbed>);
 
-	LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterObjectWeights>);
-	LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>);
-	LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>);
-	LLFloaterReg::add("outfit_photo_preview", "floater_outfit_photo_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitPhotoPreview>);
-	LLFloaterPayUtil::registerFloater();
+    LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterObjectWeights>);
+    LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>);
+    LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>);
+    LLFloaterReg::add("outfit_photo_preview", "floater_outfit_photo_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitPhotoPreview>);
+    LLFloaterPayUtil::registerFloater();
 
-	LLFloaterReg::add("pathfinding_characters", "floater_pathfinding_characters.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingCharacters>);
-	LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>);
-	LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>);
-	LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-	LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>);
-	LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
-	LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>);
-	LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>);
-	LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
-	LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>);
-	LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
-	LLFloaterReg::add("prefs_spellchecker", "floater_spellcheck.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerSettings>);
-	LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAutoReplaceSettings>);
-	LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-	LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>);
-	LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview");
-	LLFloaterReg::add("preview_conversation", "floater_conversation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationPreview>);
-	LLFloaterReg::add("preview_gesture", "floater_preview_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewGesture>, "preview");
-	LLFloaterReg::add("preview_notecard", "floater_preview_notecard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewNotecard>, "preview");
-	LLFloaterReg::add("preview_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewLSL>, "preview");
-	LLFloaterReg::add("preview_scriptedit", "floater_live_lsleditor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLLiveLSLEditor>, "preview");
-	LLFloaterReg::add("preview_sound", "floater_preview_sound.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewSound>, "preview");
-	LLFloaterReg::add("preview_texture", "floater_preview_texture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewTexture>, "preview");
-	LLFloaterReg::add("preview_trash", "floater_preview_trash.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreviewTrash>);
-	LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>);
-	LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>);
-	LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>);
-	LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>);
+    LLFloaterReg::add("pathfinding_characters", "floater_pathfinding_characters.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingCharacters>);
+    LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>);
+    LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>);
+    LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+    LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>);
+    LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+    LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
+    LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>);
+    LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>);
+    LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
+    LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>);
+    LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
+    LLFloaterReg::add("prefs_spellchecker", "floater_spellcheck.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerSettings>);
+    LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAutoReplaceSettings>);
+    LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+    LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>);
+    LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview");
+    LLFloaterReg::add("preview_conversation", "floater_conversation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationPreview>);
+    LLFloaterReg::add("preview_gesture", "floater_preview_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewGesture>, "preview");
+    LLFloaterReg::add("preview_notecard", "floater_preview_notecard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewNotecard>, "preview");
+    LLFloaterReg::add("preview_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewLSL>, "preview");
+    LLFloaterReg::add("preview_scriptedit", "floater_live_lsleditor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLLiveLSLEditor>, "preview");
+    LLFloaterReg::add("preview_sound", "floater_preview_sound.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewSound>, "preview");
+    LLFloaterReg::add("preview_texture", "floater_preview_texture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewTexture>, "preview");
+    LLFloaterReg::add("preview_trash", "floater_preview_trash.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreviewTrash>);
+    LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>);
+    LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>);
+    LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>);
+    LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>);
 
-	LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>);
-	LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build<LLFloaterTestInspectors>);
-	//LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build<LLFloaterTestListView>);
-	LLFloaterReg::add("test_textbox", "floater_test_textbox.xml", &LLFloaterReg::build<LLFloater>);
-	LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>);
-	LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>);
-	LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>);
-	LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>);
-	
-	LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>);
-	LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>);
-	LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>);
-	LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>);
-	LLFloaterReg::add("region_restarting", "floater_region_restarting.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionRestarting>);
-	
-	LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>);
-	LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>);
-	LLFloaterReg::add("script_floater", "floater_script.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLScriptFloater>);
-	LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptLimits>);
-	LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater);
-	LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>);
-	LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>);
-	LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
-	LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>);
-	LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>);
-	LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
-	LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
+    LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>);
+    LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build<LLFloaterTestInspectors>);
+    //LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build<LLFloaterTestListView>);
+    LLFloaterReg::add("test_textbox", "floater_test_textbox.xml", &LLFloaterReg::build<LLFloater>);
+    LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>);
+    LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>);
+    LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>);
+    LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>);
+    
+    LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>);
+    LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>);
+    LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>);
+    LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>);
+    LLFloaterReg::add("region_restarting", "floater_region_restarting.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionRestarting>);
+    
+    LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>);
+    LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>);
+    LLFloaterReg::add("script_floater", "floater_script.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLScriptFloater>);
+    LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptLimits>);
+    LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater);
+    LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>);
+    LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>);
+    LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
+    LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>);
+    LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>);
+    LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
+    LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
     LLFloaterReg::add("outfit_snapshot", "floater_outfit_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitSnapshot>);
     LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSearch>);
-	LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
-	LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
-	LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+    LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
+    LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
+    LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
 
-	LLFloaterReg::add("fbc_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-	LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-	LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-	
-	LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>);
-	LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>);
-	LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>);
-	LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>);
-	
-	LLFloaterUIPreviewUtil::registerFloater();
-	LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload");
-	LLFloaterReg::add("upload_anim_anim", "floater_animation_anim_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
-	LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
-	LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
-	LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload");
-	LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
+    LLFloaterReg::add("fbc_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+    LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+    LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+    
+    LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>);
+    LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>);
+    LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>);
+    LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>);
+    
+    LLFloaterUIPreviewUtil::registerFloater();
+    LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload");
+    LLFloaterReg::add("upload_anim_anim", "floater_animation_anim_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
+    LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
+    LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
+    LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload");
+    LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
 
-	LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>);
+    LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>);
 
-	LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);	
-	LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>);	
-	LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>);
-	LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>);	
+    LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);  
+    LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>); 
+    LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>);
+    LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>);   
 
-	// *NOTE: Please keep these alphabetized for easier merges
-	
-	LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving
+    // *NOTE: Please keep these alphabetized for easier merges
+    
+    LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving
 }
-- 
cgit v1.2.3


From ac2fc3029f3b9b6ba182949c29a7919f2f87eb02 Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Tue, 12 Mar 2019 08:56:26 -0700
Subject: Backout tabs v spaces changes.

'warn-on-failure:no-tabs'
---
 indra/llcorehttp/tests/llcorehttp_test.cpp        |  148 +-
 indra/llui/llfloater.cpp                          | 5446 ++++++++++-----------
 indra/llui/lluictrl.h                             |  518 +-
 indra/llui/tests/llurlentry_stub.cpp              |  128 +-
 indra/newview/llagentcamera.cpp                   | 4578 ++++++++---------
 indra/newview/llagentcamera.h                     |  564 +--
 indra/newview/lldrawpoolwater.cpp                 | 1178 ++---
 indra/newview/llfloatercamera.cpp                 |  670 +--
 indra/newview/llfloatercamera.h                   |  166 +-
 indra/newview/llfloaterdeleteprefpreset.cpp       |   66 +-
 indra/newview/llfloaterloadprefpreset.cpp         |   50 +-
 indra/newview/llfloaterpreference.cpp             | 4160 ++++++++--------
 indra/newview/llfloaterpreference.h               |  474 +-
 indra/newview/llfloaterpreferenceviewadvanced.cpp |   74 +-
 indra/newview/llfloaterpreferenceviewadvanced.h   |   28 +-
 indra/newview/llfloatersaveprefpreset.cpp         |   86 +-
 indra/newview/llnavigationbar.h                   |  178 +-
 indra/newview/llpanelpresetscamerapulldown.cpp    |  192 +-
 indra/newview/llpanelpresetscamerapulldown.h      |   30 +-
 indra/newview/llpresetsmanager.cpp                |  648 +--
 indra/newview/llpresetsmanager.h                  |   62 +-
 indra/newview/llstatusbar.cpp                     |  752 +--
 indra/newview/llstatusbar.h                       |  118 +-
 indra/newview/llviewerfloaterreg.cpp              |  360 +-
 24 files changed, 10337 insertions(+), 10337 deletions(-)

diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp
index 35bda78463..a310fc0508 100755
--- a/indra/llcorehttp/tests/llcorehttp_test.cpp
+++ b/indra/llcorehttp/tests/llcorehttp_test.cpp
@@ -51,26 +51,26 @@
 unsigned long ssl_thread_id_callback(void);
 void ssl_locking_callback(int mode, int type, const char * file, int line);
 
-#if 0   // lltut provides main and runner
+#if 0	// lltut provides main and runner
 
 namespace tut
 {
-    test_runner_singleton runner;
+	test_runner_singleton runner;
 }
 
 int main()
 {
-    curl_global_init(CURL_GLOBAL_ALL);
+	curl_global_init(CURL_GLOBAL_ALL);
 
-    // *FIXME:  Need threaded/SSL curl setup here.
-    
-    tut::reporter reporter;
+	// *FIXME:  Need threaded/SSL curl setup here.
+	
+	tut::reporter reporter;
 
-    tut::runner.get().set_callback(&reporter);
-    tut::runner.get().run_tests();
-    return !reporter.all_ok();
+	tut::runner.get().set_callback(&reporter);
+	tut::runner.get().run_tests();
+	return !reporter.all_ok();
 
-    curl_global_cleanup();
+	curl_global_cleanup();
 }
 
 #endif // 0
@@ -80,97 +80,97 @@ LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
 
 void init_curl()
 {
-    curl_global_init(CURL_GLOBAL_ALL);
-
-    ssl_mutex_count = CRYPTO_num_locks();
-    if (ssl_mutex_count > 0)
-    {
-        ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
-        
-        for (int i(0); i < ssl_mutex_count; ++i)
-        {
-            ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
-        }
-
-        CRYPTO_set_locking_callback(ssl_locking_callback);
-        CRYPTO_set_id_callback(ssl_thread_id_callback);
-    }
-
-    LLProxy::getInstance();
+	curl_global_init(CURL_GLOBAL_ALL);
+
+	ssl_mutex_count = CRYPTO_num_locks();
+	if (ssl_mutex_count > 0)
+	{
+		ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
+		
+		for (int i(0); i < ssl_mutex_count; ++i)
+		{
+			ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
+		}
+
+		CRYPTO_set_locking_callback(ssl_locking_callback);
+		CRYPTO_set_id_callback(ssl_thread_id_callback);
+	}
+
+	LLProxy::getInstance();
 }
 
 
 void term_curl()
 {
-    SUBSYSTEM_CLEANUP(LLProxy);
-    
-    CRYPTO_set_locking_callback(NULL);
-    for (int i(0); i < ssl_mutex_count; ++i)
-    {
-        delete ssl_mutex_list[i];
-    }
-    delete [] ssl_mutex_list;
+	SUBSYSTEM_CLEANUP(LLProxy);
+	
+	CRYPTO_set_locking_callback(NULL);
+	for (int i(0); i < ssl_mutex_count; ++i)
+	{
+		delete ssl_mutex_list[i];
+	}
+	delete [] ssl_mutex_list;
 }
 
 
 unsigned long ssl_thread_id_callback(void)
 {
 #if defined(WIN32)
-    return (unsigned long) GetCurrentThread();
+	return (unsigned long) GetCurrentThread();
 #else
-    return (unsigned long) pthread_self();
+	return (unsigned long) pthread_self();
 #endif
 }
 
 
 void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
 {
-    if (type >= 0 && type < ssl_mutex_count)
-    {
-        if (mode & CRYPTO_LOCK)
-        {
-            ssl_mutex_list[type]->lock();
-        }
-        else
-        {
-            ssl_mutex_list[type]->unlock();
-        }
-    }
+	if (type >= 0 && type < ssl_mutex_count)
+	{
+		if (mode & CRYPTO_LOCK)
+		{
+			ssl_mutex_list[type]->lock();
+		}
+		else
+		{
+			ssl_mutex_list[type]->unlock();
+		}
+	}
 }
 
 
 std::string get_base_url()
 {
-    const char * env(getenv("LL_TEST_PORT"));
-
-    if (! env)
-    {
-        std::cerr << "LL_TEST_PORT environment variable missing." << std::endl;
-        std::cerr << "Test expects to run in test_llcorehttp_peer.py script." << std::endl;
-        tut::ensure("LL_TEST_PORT set in environment", NULL != env);
-    }
-
-    int port(atoi(env));
-    std::ostringstream out;
-    out << "http://localhost:" << port << "/";
-    return out.str();
+	const char * env(getenv("LL_TEST_PORT"));
+
+	if (! env)
+	{
+		std::cerr << "LL_TEST_PORT environment variable missing." << std::endl;
+		std::cerr << "Test expects to run in test_llcorehttp_peer.py script." << std::endl;
+		tut::ensure("LL_TEST_PORT set in environment", NULL != env);
+	}
+
+	int port(atoi(env));
+	std::ostringstream out;
+	out << "http://localhost:" << port << "/";
+	return out.str();
 }
 
 
 void stop_thread(LLCore::HttpRequest * req)
 {
-    if (req)
-    {
-        req->requestStopThread(LLCore::HttpHandler::ptr_t());
-    
-        int count = 0;
-        int limit = 10;
-        while (count++ < limit && ! HttpService::isStopped())
-        {
-            req->update(1000);
-            usleep(100000);
-        }
-    }
+	if (req)
+	{
+		req->requestStopThread(LLCore::HttpHandler::ptr_t());
+	
+		int count = 0;
+		int limit = 10;
+		while (count++ < limit && ! HttpService::isStopped())
+		{
+			req->update(1000);
+			usleep(100000);
+		}
+	}
 }
 
-    
+	
diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 6b325f6232..2dcc62ce79 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -43,7 +43,7 @@
 #include "llresizebar.h"
 #include "llresizehandle.h"
 #include "llkeyboard.h"
-#include "llmenugl.h"   // MENU_BAR_HEIGHT
+#include "llmenugl.h"	// MENU_BAR_HEIGHT
 #include "llmodaldialog.h"
 #include "lltextbox.h"
 #include "llresmgr.h"
@@ -65,23 +65,23 @@ const S32 TABBED_FLOATER_OFFSET = 0;
 
 namespace LLInitParam
 {
-    void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
-    {
-        declare("relative",   LLFloaterEnums::POSITIONING_RELATIVE);
-        declare("cascading",  LLFloaterEnums::POSITIONING_CASCADING);
-        declare("centered",   LLFloaterEnums::POSITIONING_CENTERED);
-        declare("specified",  LLFloaterEnums::POSITIONING_SPECIFIED);
-    }
+	void TypeValues<LLFloaterEnums::EOpenPositioning>::declareValues()
+	{
+		declare("relative",   LLFloaterEnums::POSITIONING_RELATIVE);
+		declare("cascading",  LLFloaterEnums::POSITIONING_CASCADING);
+		declare("centered",   LLFloaterEnums::POSITIONING_CENTERED);
+		declare("specified",  LLFloaterEnums::POSITIONING_SPECIFIED);
+	}
 }
 
-std::string LLFloater::sButtonNames[BUTTON_COUNT] = 
+std::string	LLFloater::sButtonNames[BUTTON_COUNT] = 
 {
-    "llfloater_close_btn",      //BUTTON_CLOSE
-    "llfloater_restore_btn",    //BUTTON_RESTORE
-    "llfloater_minimize_btn",   //BUTTON_MINIMIZE
-    "llfloater_tear_off_btn",   //BUTTON_TEAR_OFF
-    "llfloater_dock_btn",       //BUTTON_DOCK
-    "llfloater_help_btn"        //BUTTON_HELP
+	"llfloater_close_btn",		//BUTTON_CLOSE
+	"llfloater_restore_btn",	//BUTTON_RESTORE
+	"llfloater_minimize_btn",	//BUTTON_MINIMIZE
+	"llfloater_tear_off_btn",	//BUTTON_TEAR_OFF
+	"llfloater_dock_btn",		//BUTTON_DOCK
+	"llfloater_help_btn"		//BUTTON_HELP
 };
 
 std::string LLFloater::sButtonToolTips[BUTTON_COUNT];
@@ -89,29 +89,29 @@ std::string LLFloater::sButtonToolTips[BUTTON_COUNT];
 std::string LLFloater::sButtonToolTipsIndex[BUTTON_COUNT]=
 {
 #ifdef LL_DARWIN
-    "BUTTON_CLOSE_DARWIN",  //"Close (Cmd-W)",  //BUTTON_CLOSE
+	"BUTTON_CLOSE_DARWIN",	//"Close (Cmd-W)",	//BUTTON_CLOSE
 #else
-    "BUTTON_CLOSE_WIN",     //"Close (Ctrl-W)", //BUTTON_CLOSE
+	"BUTTON_CLOSE_WIN",		//"Close (Ctrl-W)",	//BUTTON_CLOSE
 #endif
-    "BUTTON_RESTORE",       //"Restore",    //BUTTON_RESTORE
-    "BUTTON_MINIMIZE",      //"Minimize",   //BUTTON_MINIMIZE
-    "BUTTON_TEAR_OFF",      //"Tear Off",   //BUTTON_TEAR_OFF
-    "BUTTON_DOCK",
-    "BUTTON_HELP"
+	"BUTTON_RESTORE",		//"Restore",	//BUTTON_RESTORE
+	"BUTTON_MINIMIZE",		//"Minimize",	//BUTTON_MINIMIZE
+	"BUTTON_TEAR_OFF",		//"Tear Off",	//BUTTON_TEAR_OFF
+	"BUTTON_DOCK",
+	"BUTTON_HELP"
 };
 
 LLFloater::click_callback LLFloater::sButtonCallbacks[BUTTON_COUNT] =
 {
-    LLFloater::onClickClose,    //BUTTON_CLOSE
-    LLFloater::onClickMinimize, //BUTTON_RESTORE
-    LLFloater::onClickMinimize, //BUTTON_MINIMIZE
-    LLFloater::onClickTearOff,  //BUTTON_TEAR_OFF
-    LLFloater::onClickDock,     //BUTTON_DOCK
-    LLFloater::onClickHelp      //BUTTON_HELP
+	LLFloater::onClickClose,	//BUTTON_CLOSE
+	LLFloater::onClickMinimize, //BUTTON_RESTORE
+	LLFloater::onClickMinimize, //BUTTON_MINIMIZE
+	LLFloater::onClickTearOff,	//BUTTON_TEAR_OFF
+	LLFloater::onClickDock,		//BUTTON_DOCK
+	LLFloater::onClickHelp		//BUTTON_HELP
 };
 
 LLMultiFloater* LLFloater::sHostp = NULL;
-BOOL            LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting
+BOOL			LLFloater::sQuitting = FALSE; // Flag to prevent storing visibility controls while quitting
 
 LLFloaterView* gFloaterView = NULL;
 
@@ -128,105 +128,105 @@ LLFloaterView* gFloaterView = NULL;
 //static
 bool LLFloater::KeyCompare::compare(const LLSD& a, const LLSD& b)
 {
-    if (a.type() != b.type())
-    {
-        //LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL;
-        return false;
-    }
-    else if (a.isUndefined())
-        return false;
-    else if (a.isInteger())
-        return a.asInteger() < b.asInteger();
-    else if (a.isReal())
-        return a.asReal() < b.asReal();
-    else if (a.isString())
-        return a.asString() < b.asString();
-    else if (a.isUUID())
-        return a.asUUID() < b.asUUID();
-    else if (a.isDate())
-        return a.asDate() < b.asDate();
-    else if (a.isURI())
-        return a.asString() < b.asString(); // compare URIs as strings
-    else if (a.isBoolean())
-        return a.asBoolean() < b.asBoolean();
-    else
-        return false; // no valid operation for Binary
+	if (a.type() != b.type())
+	{
+		//LL_ERRS() << "Mismatched LLSD types: (" << a << ") mismatches (" << b << ")" << LL_ENDL;
+		return false;
+	}
+	else if (a.isUndefined())
+		return false;
+	else if (a.isInteger())
+		return a.asInteger() < b.asInteger();
+	else if (a.isReal())
+		return a.asReal() < b.asReal();
+	else if (a.isString())
+		return a.asString() < b.asString();
+	else if (a.isUUID())
+		return a.asUUID() < b.asUUID();
+	else if (a.isDate())
+		return a.asDate() < b.asDate();
+	else if (a.isURI())
+		return a.asString() < b.asString(); // compare URIs as strings
+	else if (a.isBoolean())
+		return a.asBoolean() < b.asBoolean();
+	else
+		return false; // no valid operation for Binary
 }
 |*==========================================================================*/
 
 bool LLFloater::KeyCompare::equate(const LLSD& a, const LLSD& b)
 {
-    return llsd_equals(a, b);
+	return llsd_equals(a, b);
 }
 
 //************************************
 
 LLFloater::Params::Params()
-:   title("title"),
-    short_title("short_title"),
-    single_instance("single_instance", false),
-    reuse_instance("reuse_instance", false),
-    can_resize("can_resize", false),
-    can_minimize("can_minimize", true),
-    can_close("can_close", true),
-    can_drag_on_left("can_drag_on_left", false),
-    can_tear_off("can_tear_off", true),
-    save_dock_state("save_dock_state", false),
-    save_rect("save_rect", false),
-    save_visibility("save_visibility", false),
-    can_dock("can_dock", false),
-    show_title("show_title", true),
-    positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE),
-    header_height("header_height", 0),
-    legacy_header_height("legacy_header_height", 0),
-    close_image("close_image"),
-    restore_image("restore_image"),
-    minimize_image("minimize_image"),
-    tear_off_image("tear_off_image"),
-    dock_image("dock_image"),
-    help_image("help_image"),
-    close_pressed_image("close_pressed_image"),
-    restore_pressed_image("restore_pressed_image"),
-    minimize_pressed_image("minimize_pressed_image"),
-    tear_off_pressed_image("tear_off_pressed_image"),
-    dock_pressed_image("dock_pressed_image"),
-    help_pressed_image("help_pressed_image"),
-    open_callback("open_callback"),
-    close_callback("close_callback"),
-    follows("follows")
-{
-    changeDefault(visible, false);
+:	title("title"),
+	short_title("short_title"),
+	single_instance("single_instance", false),
+	reuse_instance("reuse_instance", false),
+	can_resize("can_resize", false),
+	can_minimize("can_minimize", true),
+	can_close("can_close", true),
+	can_drag_on_left("can_drag_on_left", false),
+	can_tear_off("can_tear_off", true),
+	save_dock_state("save_dock_state", false),
+	save_rect("save_rect", false),
+	save_visibility("save_visibility", false),
+	can_dock("can_dock", false),
+	show_title("show_title", true),
+	positioning("positioning", LLFloaterEnums::POSITIONING_RELATIVE),
+	header_height("header_height", 0),
+	legacy_header_height("legacy_header_height", 0),
+	close_image("close_image"),
+	restore_image("restore_image"),
+	minimize_image("minimize_image"),
+	tear_off_image("tear_off_image"),
+	dock_image("dock_image"),
+	help_image("help_image"),
+	close_pressed_image("close_pressed_image"),
+	restore_pressed_image("restore_pressed_image"),
+	minimize_pressed_image("minimize_pressed_image"),
+	tear_off_pressed_image("tear_off_pressed_image"),
+	dock_pressed_image("dock_pressed_image"),
+	help_pressed_image("help_pressed_image"),
+	open_callback("open_callback"),
+	close_callback("close_callback"),
+	follows("follows")
+{
+	changeDefault(visible, false);
 }
 
 
 //static 
 const LLFloater::Params& LLFloater::getDefaultParams()
 {
-    return LLUICtrlFactory::getDefaultParams<LLFloater>();
+	return LLUICtrlFactory::getDefaultParams<LLFloater>();
 }
 
 //static
 void LLFloater::initClass()
 {
-    // translate tooltips for floater buttons
-    for (S32 i = 0; i < BUTTON_COUNT; i++)
-    {
-        sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] );
-    }
+	// translate tooltips for floater buttons
+	for (S32 i = 0; i < BUTTON_COUNT; i++)
+	{
+		sButtonToolTips[i] = LLTrans::getString( sButtonToolTipsIndex[i] );
+	}
 
-    LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get();
-    if (ctrl)
-    {
-        ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency));
-        updateActiveFloaterTransparency();
-    }
+	LLControlVariable* ctrl = LLUI::sSettingGroups["config"]->getControl("ActiveFloaterTransparency").get();
+	if (ctrl)
+	{
+		ctrl->getSignal()->connect(boost::bind(&LLFloater::updateActiveFloaterTransparency));
+		updateActiveFloaterTransparency();
+	}
 
-    ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get();
-    if (ctrl)
-    {
-        ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency));
-        updateInactiveFloaterTransparency();
-    }
+	ctrl = LLUI::sSettingGroups["config"]->getControl("InactiveFloaterTransparency").get();
+	if (ctrl)
+	{
+		ctrl->getSignal()->connect(boost::bind(&LLFloater::updateInactiveFloaterTransparency));
+		updateInactiveFloaterTransparency();
+	}
 
 }
 
@@ -234,1998 +234,1998 @@ void LLFloater::initClass()
 static LLWidgetNameRegistry::StaticRegistrar sRegisterFloaterParams(&typeid(LLFloater::Params), "floater");
 
 LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
-:   LLPanel(),  // intentionally do not pass params here, see initFromParams
-    mDragHandle(NULL),
-    mTitle(p.title),
-    mShortTitle(p.short_title),
-    mSingleInstance(p.single_instance),
-    mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default
-    mKey(key),
-    mCanTearOff(p.can_tear_off),
-    mCanMinimize(p.can_minimize),
-    mCanClose(p.can_close),
-    mDragOnLeft(p.can_drag_on_left),
-    mResizable(p.can_resize),
-    mPositioning(p.positioning),
-    mMinWidth(p.min_width),
-    mMinHeight(p.min_height),
-    mHeaderHeight(p.header_height),
-    mLegacyHeaderHeight(p.legacy_header_height),
-    mMinimized(FALSE),
-    mForeground(FALSE),
-    mFirstLook(TRUE),
-    mButtonScale(1.0f),
-    mAutoFocus(TRUE), // automatically take focus when opened
-    mCanDock(false),
-    mDocked(false),
-    mTornOff(false),
-    mHasBeenDraggedWhileMinimized(FALSE),
-    mPreviousMinimizedBottom(0),
-    mPreviousMinimizedLeft(0),
-    mMinimizeSignal(NULL)
-//  mNotificationContext(NULL)
-{
-    mPosition.setFloater(*this);
-//  mNotificationContext = new LLFloaterNotificationContext(getHandle());
-
-    // Clicks stop here.
-    setMouseOpaque(TRUE);
-    
-    // Floaters always draw their background, unlike every other panel.
-    setBackgroundVisible(TRUE);
-
-    // Floaters start not minimized.  When minimized, they save their
-    // prior rectangle to be used on restore.
-    mExpandedRect.set(0,0,0,0);
-    
-    memset(mButtonsEnabled, 0, BUTTON_COUNT * sizeof(bool));
-    memset(mButtons, 0, BUTTON_COUNT * sizeof(LLButton*));
-    
-    addDragHandle();
-    addResizeCtrls();
-    
-    initFromParams(p);
-    
-    initFloater(p);
+:	LLPanel(),	// intentionally do not pass params here, see initFromParams
+ 	mDragHandle(NULL),
+	mTitle(p.title),
+	mShortTitle(p.short_title),
+	mSingleInstance(p.single_instance),
+	mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default
+	mKey(key),
+	mCanTearOff(p.can_tear_off),
+	mCanMinimize(p.can_minimize),
+	mCanClose(p.can_close),
+	mDragOnLeft(p.can_drag_on_left),
+	mResizable(p.can_resize),
+	mPositioning(p.positioning),
+	mMinWidth(p.min_width),
+	mMinHeight(p.min_height),
+	mHeaderHeight(p.header_height),
+	mLegacyHeaderHeight(p.legacy_header_height),
+	mMinimized(FALSE),
+	mForeground(FALSE),
+	mFirstLook(TRUE),
+	mButtonScale(1.0f),
+	mAutoFocus(TRUE), // automatically take focus when opened
+	mCanDock(false),
+	mDocked(false),
+	mTornOff(false),
+	mHasBeenDraggedWhileMinimized(FALSE),
+	mPreviousMinimizedBottom(0),
+	mPreviousMinimizedLeft(0),
+	mMinimizeSignal(NULL)
+//	mNotificationContext(NULL)
+{
+	mPosition.setFloater(*this);
+//	mNotificationContext = new LLFloaterNotificationContext(getHandle());
+
+	// Clicks stop here.
+	setMouseOpaque(TRUE);
+	
+	// Floaters always draw their background, unlike every other panel.
+	setBackgroundVisible(TRUE);
+
+	// Floaters start not minimized.  When minimized, they save their
+	// prior rectangle to be used on restore.
+	mExpandedRect.set(0,0,0,0);
+	
+	memset(mButtonsEnabled, 0, BUTTON_COUNT * sizeof(bool));
+	memset(mButtons, 0, BUTTON_COUNT * sizeof(LLButton*));
+	
+	addDragHandle();
+	addResizeCtrls();
+	
+	initFromParams(p);
+	
+	initFloater(p);
 }
 
 // Note: Floaters constructed from XML call init() twice!
 void LLFloater::initFloater(const Params& p)
 {
-    // Close button.
-    if (mCanClose)
-    {
-        mButtonsEnabled[BUTTON_CLOSE] = TRUE;
-    }
+	// Close button.
+	if (mCanClose)
+	{
+		mButtonsEnabled[BUTTON_CLOSE] = TRUE;
+	}
 
-    // Help button: '?'
-    if ( !mHelpTopic.empty() )
-    {
-        mButtonsEnabled[BUTTON_HELP] = TRUE;
-    }
+	// Help button: '?'
+	if ( !mHelpTopic.empty() )
+	{
+		mButtonsEnabled[BUTTON_HELP] = TRUE;
+	}
 
-    // Minimize button only for top draggers
-    if ( !mDragOnLeft && mCanMinimize )
-    {
-        mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
-    }
+	// Minimize button only for top draggers
+	if ( !mDragOnLeft && mCanMinimize )
+	{
+		mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
+	}
 
-    if(mCanDock)
-    {
-        mButtonsEnabled[BUTTON_DOCK] = TRUE;
-    }
+	if(mCanDock)
+	{
+		mButtonsEnabled[BUTTON_DOCK] = TRUE;
+	}
 
-    buildButtons(p);
+	buildButtons(p);
 
-    // Floaters are created in the invisible state  
-    setVisible(FALSE);
+	// Floaters are created in the invisible state	
+	setVisible(FALSE);
 
-    if (!getParent())
-    {
-        gFloaterView->addChild(this);
-    }
+	if (!getParent())
+	{
+		gFloaterView->addChild(this);
+	}
 }
 
 void LLFloater::addDragHandle()
 {
-    if (!mDragHandle)
-    {
-        if (mDragOnLeft)
-        {
-            LLDragHandleLeft::Params p;
-            p.name("drag");
-            p.follows.flags(FOLLOWS_ALL);
-            p.label(mTitle);
-            mDragHandle = LLUICtrlFactory::create<LLDragHandleLeft>(p);
-        }
-        else // drag on top
-        {
-            LLDragHandleTop::Params p;
-            p.name("Drag Handle");
-            p.follows.flags(FOLLOWS_ALL);
-            p.label(mTitle);
-            mDragHandle = LLUICtrlFactory::create<LLDragHandleTop>(p);
-        }
-        addChild(mDragHandle);
-    }
-    layoutDragHandle();
-    applyTitle();
+	if (!mDragHandle)
+	{
+		if (mDragOnLeft)
+		{
+			LLDragHandleLeft::Params p;
+			p.name("drag");
+			p.follows.flags(FOLLOWS_ALL);
+			p.label(mTitle);
+			mDragHandle = LLUICtrlFactory::create<LLDragHandleLeft>(p);
+		}
+		else // drag on top
+		{
+			LLDragHandleTop::Params p;
+			p.name("Drag Handle");
+			p.follows.flags(FOLLOWS_ALL);
+			p.label(mTitle);
+			mDragHandle = LLUICtrlFactory::create<LLDragHandleTop>(p);
+		}
+		addChild(mDragHandle);
+	}
+	layoutDragHandle();
+	applyTitle();
 }
 
 void LLFloater::layoutDragHandle()
 {
-    static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
-    S32 close_box_size = mCanClose ? floater_close_box_size : 0;
-    
-    LLRect rect;
-    if (mDragOnLeft)
-    {
-        rect.setLeftTopAndSize(0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size);
-    }
-    else // drag on top
-    {
-        rect = getLocalRect();
-    }
-    mDragHandle->setShape(rect);
-    updateTitleButtons();
+	static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
+	S32 close_box_size = mCanClose ? floater_close_box_size : 0;
+	
+	LLRect rect;
+	if (mDragOnLeft)
+	{
+		rect.setLeftTopAndSize(0, 0, DRAG_HANDLE_WIDTH, getRect().getHeight() - LLPANEL_BORDER_WIDTH - close_box_size);
+	}
+	else // drag on top
+	{
+		rect = getLocalRect();
+	}
+	mDragHandle->setShape(rect);
+	updateTitleButtons();
 }
 
 // static
 void LLFloater::updateActiveFloaterTransparency()
 {
-    sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency");
+	sActiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("ActiveFloaterTransparency");
 }
 
 // static
 void LLFloater::updateInactiveFloaterTransparency()
 {
-    sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency");
+	sInactiveControlTransparency = LLUI::sSettingGroups["config"]->getF32("InactiveFloaterTransparency");
 }
 
 void LLFloater::addResizeCtrls()
-{   
-    // Resize bars (sides)
-    LLResizeBar::Params p;
-    p.name("resizebar_left");
-    p.resizing_view(this);
-    p.min_size(mMinWidth);
-    p.side(LLResizeBar::LEFT);
-    mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p);
-    addChild( mResizeBar[LLResizeBar::LEFT] );
-
-    p.name("resizebar_top");
-    p.min_size(mMinHeight);
-    p.side(LLResizeBar::TOP);
-
-    mResizeBar[LLResizeBar::TOP] = LLUICtrlFactory::create<LLResizeBar>(p);
-    addChild( mResizeBar[LLResizeBar::TOP] );
-
-    p.name("resizebar_right");
-    p.min_size(mMinWidth);
-    p.side(LLResizeBar::RIGHT); 
-    mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p);
-    addChild( mResizeBar[LLResizeBar::RIGHT] );
-
-    p.name("resizebar_bottom");
-    p.min_size(mMinHeight);
-    p.side(LLResizeBar::BOTTOM);
-    mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p);
-    addChild( mResizeBar[LLResizeBar::BOTTOM] );
-
-    // Resize handles (corners)
-    LLResizeHandle::Params handle_p;
-    // handles must not be mouse-opaque, otherwise they block hover events
-    // to other buttons like the close box. JC
-    handle_p.mouse_opaque(false);
-    handle_p.min_width(mMinWidth);
-    handle_p.min_height(mMinHeight);
-    handle_p.corner(LLResizeHandle::RIGHT_BOTTOM);
-    mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-    addChild(mResizeHandle[0]);
-
-    handle_p.corner(LLResizeHandle::RIGHT_TOP);
-    mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-    addChild(mResizeHandle[1]);
-    
-    handle_p.corner(LLResizeHandle::LEFT_BOTTOM);
-    mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-    addChild(mResizeHandle[2]);
-
-    handle_p.corner(LLResizeHandle::LEFT_TOP);
-    mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
-    addChild(mResizeHandle[3]);
-
-    layoutResizeCtrls();
+{	
+	// Resize bars (sides)
+	LLResizeBar::Params p;
+	p.name("resizebar_left");
+	p.resizing_view(this);
+	p.min_size(mMinWidth);
+	p.side(LLResizeBar::LEFT);
+	mResizeBar[LLResizeBar::LEFT] = LLUICtrlFactory::create<LLResizeBar>(p);
+	addChild( mResizeBar[LLResizeBar::LEFT] );
+
+	p.name("resizebar_top");
+	p.min_size(mMinHeight);
+	p.side(LLResizeBar::TOP);
+
+	mResizeBar[LLResizeBar::TOP] = LLUICtrlFactory::create<LLResizeBar>(p);
+	addChild( mResizeBar[LLResizeBar::TOP] );
+
+	p.name("resizebar_right");
+	p.min_size(mMinWidth);
+	p.side(LLResizeBar::RIGHT);	
+	mResizeBar[LLResizeBar::RIGHT] = LLUICtrlFactory::create<LLResizeBar>(p);
+	addChild( mResizeBar[LLResizeBar::RIGHT] );
+
+	p.name("resizebar_bottom");
+	p.min_size(mMinHeight);
+	p.side(LLResizeBar::BOTTOM);
+	mResizeBar[LLResizeBar::BOTTOM] = LLUICtrlFactory::create<LLResizeBar>(p);
+	addChild( mResizeBar[LLResizeBar::BOTTOM] );
+
+	// Resize handles (corners)
+	LLResizeHandle::Params handle_p;
+	// handles must not be mouse-opaque, otherwise they block hover events
+	// to other buttons like the close box. JC
+	handle_p.mouse_opaque(false);
+	handle_p.min_width(mMinWidth);
+	handle_p.min_height(mMinHeight);
+	handle_p.corner(LLResizeHandle::RIGHT_BOTTOM);
+	mResizeHandle[0] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+	addChild(mResizeHandle[0]);
+
+	handle_p.corner(LLResizeHandle::RIGHT_TOP);
+	mResizeHandle[1] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+	addChild(mResizeHandle[1]);
+	
+	handle_p.corner(LLResizeHandle::LEFT_BOTTOM);
+	mResizeHandle[2] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+	addChild(mResizeHandle[2]);
+
+	handle_p.corner(LLResizeHandle::LEFT_TOP);
+	mResizeHandle[3] = LLUICtrlFactory::create<LLResizeHandle>(handle_p);
+	addChild(mResizeHandle[3]);
+
+	layoutResizeCtrls();
 }
 
 void LLFloater::layoutResizeCtrls()
 {
-    LLRect rect;
+	LLRect rect;
 
-    // Resize bars (sides)
-    const S32 RESIZE_BAR_THICKNESS = 3;
-    rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0);
-    mResizeBar[LLResizeBar::LEFT]->setRect(rect);
+	// Resize bars (sides)
+	const S32 RESIZE_BAR_THICKNESS = 3;
+	rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0);
+	mResizeBar[LLResizeBar::LEFT]->setRect(rect);
 
-    rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS);
-    mResizeBar[LLResizeBar::TOP]->setRect(rect);
+	rect = LLRect( 0, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_BAR_THICKNESS);
+	mResizeBar[LLResizeBar::TOP]->setRect(rect);
 
-    rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0);
-    mResizeBar[LLResizeBar::RIGHT]->setRect(rect);
+	rect = LLRect(getRect().getWidth() - RESIZE_BAR_THICKNESS, getRect().getHeight(), getRect().getWidth(), 0);
+	mResizeBar[LLResizeBar::RIGHT]->setRect(rect);
 
-    rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0);
-    mResizeBar[LLResizeBar::BOTTOM]->setRect(rect);
+	rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0);
+	mResizeBar[LLResizeBar::BOTTOM]->setRect(rect);
 
-    // Resize handles (corners)
-    rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0);
-    mResizeHandle[0]->setRect(rect);
+	// Resize handles (corners)
+	rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, RESIZE_HANDLE_HEIGHT, getRect().getWidth(), 0);
+	mResizeHandle[0]->setRect(rect);
 
-    rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT);
-    mResizeHandle[1]->setRect(rect);
-    
-    rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 );
-    mResizeHandle[2]->setRect(rect);
+	rect = LLRect( getRect().getWidth() - RESIZE_HANDLE_WIDTH, getRect().getHeight(), getRect().getWidth(), getRect().getHeight() - RESIZE_HANDLE_HEIGHT);
+	mResizeHandle[1]->setRect(rect);
+	
+	rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 );
+	mResizeHandle[2]->setRect(rect);
 
-    rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT );
-    mResizeHandle[3]->setRect(rect);
+	rect = LLRect( 0, getRect().getHeight(), RESIZE_HANDLE_WIDTH, getRect().getHeight() - RESIZE_HANDLE_HEIGHT );
+	mResizeHandle[3]->setRect(rect);
 }
 
 void LLFloater::enableResizeCtrls(bool enable, bool width, bool height)
 {
-    mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width);
-    mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width);
+	mResizeBar[LLResizeBar::LEFT]->setVisible(enable && width);
+	mResizeBar[LLResizeBar::LEFT]->setEnabled(enable && width);
 
-    mResizeBar[LLResizeBar::TOP]->setVisible(enable && height);
-    mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height);
-    
-    mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width);
-    mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width);
-    
-    mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height);
-    mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height);
+	mResizeBar[LLResizeBar::TOP]->setVisible(enable && height);
+	mResizeBar[LLResizeBar::TOP]->setEnabled(enable && height);
+	
+	mResizeBar[LLResizeBar::RIGHT]->setVisible(enable && width);
+	mResizeBar[LLResizeBar::RIGHT]->setEnabled(enable && width);
+	
+	mResizeBar[LLResizeBar::BOTTOM]->setVisible(enable && height);
+	mResizeBar[LLResizeBar::BOTTOM]->setEnabled(enable && height);
 
-    for (S32 i = 0; i < 4; ++i)
-    {
-        mResizeHandle[i]->setVisible(enable && width && height);
-        mResizeHandle[i]->setEnabled(enable && width && height);
-    }
+	for (S32 i = 0; i < 4; ++i)
+	{
+		mResizeHandle[i]->setVisible(enable && width && height);
+		mResizeHandle[i]->setEnabled(enable && width && height);
+	}
 }
 
 void LLFloater::destroy()
 {
-    // LLFloaterReg should be synchronized with "dead" floater to avoid returning dead instance before
-    // it was deleted via LLMortician::updateClass(). See EXT-8458.
-    LLFloaterReg::removeInstance(mInstanceName, mKey);
-    die();
+	// LLFloaterReg should be synchronized with "dead" floater to avoid returning dead instance before
+	// it was deleted via LLMortician::updateClass(). See EXT-8458.
+	LLFloaterReg::removeInstance(mInstanceName, mKey);
+	die();
 }
 
 // virtual
 LLFloater::~LLFloater()
 {
-    LLFloaterReg::removeInstance(mInstanceName, mKey);
-    
-    if( gFocusMgr.childHasKeyboardFocus(this))
-    {
-        // Just in case we might still have focus here, release it.
-        releaseFocus();
-    }
-
-    // This is important so that floaters with persistent rects (i.e., those
-    // created with rect control rather than an LLRect) are restored in their
-    // correct, non-minimized positions.
-    setMinimized( FALSE );
-
-    delete mDragHandle;
-    for (S32 i = 0; i < 4; i++) 
-    {
-        delete mResizeBar[i];
-        delete mResizeHandle[i];
-    }
-
-    setVisible(false); // We're not visible if we're destroyed
-    storeVisibilityControl();
-    storeDockStateControl();
-    delete mMinimizeSignal;
+	LLFloaterReg::removeInstance(mInstanceName, mKey);
+	
+	if( gFocusMgr.childHasKeyboardFocus(this))
+	{
+		// Just in case we might still have focus here, release it.
+		releaseFocus();
+	}
+
+	// This is important so that floaters with persistent rects (i.e., those
+	// created with rect control rather than an LLRect) are restored in their
+	// correct, non-minimized positions.
+	setMinimized( FALSE );
+
+	delete mDragHandle;
+	for (S32 i = 0; i < 4; i++) 
+	{
+		delete mResizeBar[i];
+		delete mResizeHandle[i];
+	}
+
+	setVisible(false); // We're not visible if we're destroyed
+	storeVisibilityControl();
+	storeDockStateControl();
+	delete mMinimizeSignal;
 }
 
 void LLFloater::storeRectControl()
 {
-    if (!mRectControl.empty())
-    {
-        getControlGroup()->setRect( mRectControl, getRect() );
-    }
-    if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
-    {
-        getControlGroup()->setF32( mPosXControl, mPosition.mX );
-    }
-    if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
-    {
-        getControlGroup()->setF32( mPosYControl, mPosition.mY );
-    }
+	if (!mRectControl.empty())
+	{
+		getControlGroup()->setRect( mRectControl, getRect() );
+	}
+	if (!mPosXControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
+	{
+		getControlGroup()->setF32( mPosXControl, mPosition.mX );
+	}
+	if (!mPosYControl.empty() && mPositioning == LLFloaterEnums::POSITIONING_RELATIVE)
+	{
+		getControlGroup()->setF32( mPosYControl, mPosition.mY );
+	}
 }
 
 void LLFloater::storeVisibilityControl()
 {
-    if( !sQuitting && mVisibilityControl.size() > 1 )
-    {
-        getControlGroup()->setBOOL( mVisibilityControl, getVisible() );
-    }
+	if( !sQuitting && mVisibilityControl.size() > 1 )
+	{
+		getControlGroup()->setBOOL( mVisibilityControl, getVisible() );
+	}
 }
 
 void LLFloater::storeDockStateControl()
 {
-    if( !sQuitting && mDocStateControl.size() > 1 )
-    {
-        getControlGroup()->setBOOL( mDocStateControl, isDocked() );
-    }
+	if( !sQuitting && mDocStateControl.size() > 1 )
+	{
+		getControlGroup()->setBOOL( mDocStateControl, isDocked() );
+	}
 }
 
 // static
 std::string LLFloater::getControlName(const std::string& name, const LLSD& key)
 {
-    std::string ctrl_name = name;
+	std::string ctrl_name = name;
 
-    // Add the key to the control name if appropriate.
-    if (key.isString() && !key.asString().empty())
-    {
-        ctrl_name += "_" + key.asString();
-    }
+	// Add the key to the control name if appropriate.
+	if (key.isString() && !key.asString().empty())
+	{
+		ctrl_name += "_" + key.asString();
+	}
 
-    return ctrl_name;
+	return ctrl_name;
 }
 
 // static
-LLControlGroup* LLFloater::getControlGroup()
+LLControlGroup*	LLFloater::getControlGroup()
 {
-    // Floater size, position, visibility, etc are saved in per-account settings.
-    return LLUI::sSettingGroups["account"];
+	// Floater size, position, visibility, etc are saved in per-account settings.
+	return LLUI::sSettingGroups["account"];
 }
 
 void LLFloater::setVisible( BOOL visible )
 {
-    LLPanel::setVisible(visible); // calls onVisibilityChange()
-    if( visible && mFirstLook )
-    {
-        mFirstLook = FALSE;
-    }
+	LLPanel::setVisible(visible); // calls onVisibilityChange()
+	if( visible && mFirstLook )
+	{
+		mFirstLook = FALSE;
+	}
 
-    if( !visible )
-    {
-        LLUI::removePopup(this);
+	if( !visible )
+	{
+		LLUI::removePopup(this);
 
-        if( gFocusMgr.childHasMouseCapture( this ) )
-        {
-            gFocusMgr.setMouseCapture(NULL);
-        }
-    }
+		if( gFocusMgr.childHasMouseCapture( this ) )
+		{
+			gFocusMgr.setMouseCapture(NULL);
+		}
+	}
 
-    for(handle_set_iter_t dependent_it = mDependents.begin();
-        dependent_it != mDependents.end(); )
-    {
-        LLFloater* floaterp = dependent_it->get();
+	for(handle_set_iter_t dependent_it = mDependents.begin();
+		dependent_it != mDependents.end(); )
+	{
+		LLFloater* floaterp = dependent_it->get();
 
-        if (floaterp)
-        {
-            floaterp->setVisible(visible);
-        }
-        ++dependent_it;
-    }
+		if (floaterp)
+		{
+			floaterp->setVisible(visible);
+		}
+		++dependent_it;
+	}
 
-    storeVisibilityControl();
+	storeVisibilityControl();
 }
 
 
 void LLFloater::setIsSingleInstance(BOOL is_single_instance)
 {
-    mSingleInstance = is_single_instance;
-    if (!mIsReuseInitialized)
-    {
-        mReuseInstance = is_single_instance; // reuse single-instance floaters by default
-    }
+	mSingleInstance = is_single_instance;
+	if (!mIsReuseInitialized)
+	{
+		mReuseInstance = is_single_instance; // reuse single-instance floaters by default
+	}
 }
 
 
 // virtual
 void LLFloater::onVisibilityChange ( BOOL new_visibility )
 {
-    if (new_visibility)
-    {
-        if (getHost())
-            getHost()->setFloaterFlashing(this, FALSE);
-    }
-    LLPanel::onVisibilityChange ( new_visibility );
+	if (new_visibility)
+	{
+		if (getHost())
+			getHost()->setFloaterFlashing(this, FALSE);
+	}
+	LLPanel::onVisibilityChange ( new_visibility );
 }
 
 void LLFloater::openFloater(const LLSD& key)
 {
     LL_INFOS() << "Opening floater " << getName() << " full path: " << getPathname() << LL_ENDL;
 
-    LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string
-
-    mKey = key; // in case we need to open ourselves again
-    
-    if (getSoundFlags() != SILENT 
-    // don't play open sound for hosted (tabbed) windows
-        && !getHost() 
-        && !getFloaterHost()
-        && (!getVisible() || isMinimized()))
-    {
-        make_ui_sound("UISndWindowOpen");
-    }
-
-    //RN: for now, we don't allow rehosting from one multifloater to another
-    // just need to fix the bugs
-    if (getFloaterHost() != NULL && getHost() == NULL)
-    {
-        // needs a host
-        // only select tabs if window they are hosted in is visible
-        getFloaterHost()->addFloater(this, getFloaterHost()->getVisible());
-    }
-
-    if (getHost() != NULL)
-    {
-        getHost()->setMinimized(FALSE);
-        getHost()->setVisibleAndFrontmost(mAutoFocus);
-        getHost()->showFloater(this);
-    }
-    else
-    {
-        LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
-        if (!floater_to_stack)
-        {
-            floater_to_stack = LLFloaterReg::getLastFloaterCascading();
-        }
-        applyControlsAndPosition(floater_to_stack);
-        setMinimized(FALSE);
-        setVisibleAndFrontmost(mAutoFocus);
-    }
-
-    mOpenSignal(this, key);
-    onOpen(key);
-
-    dirtyRect();
+	LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), true,"floater"); // Last param is event subtype or empty string
+
+	mKey = key; // in case we need to open ourselves again
+	
+	if (getSoundFlags() != SILENT 
+	// don't play open sound for hosted (tabbed) windows
+		&& !getHost() 
+		&& !getFloaterHost()
+		&& (!getVisible() || isMinimized()))
+	{
+		make_ui_sound("UISndWindowOpen");
+	}
+
+	//RN: for now, we don't allow rehosting from one multifloater to another
+	// just need to fix the bugs
+	if (getFloaterHost() != NULL && getHost() == NULL)
+	{
+		// needs a host
+		// only select tabs if window they are hosted in is visible
+		getFloaterHost()->addFloater(this, getFloaterHost()->getVisible());
+	}
+
+	if (getHost() != NULL)
+	{
+		getHost()->setMinimized(FALSE);
+		getHost()->setVisibleAndFrontmost(mAutoFocus);
+		getHost()->showFloater(this);
+	}
+	else
+	{
+		LLFloater* floater_to_stack = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+		if (!floater_to_stack)
+		{
+			floater_to_stack = LLFloaterReg::getLastFloaterCascading();
+		}
+		applyControlsAndPosition(floater_to_stack);
+		setMinimized(FALSE);
+		setVisibleAndFrontmost(mAutoFocus);
+	}
+
+	mOpenSignal(this, key);
+	onOpen(key);
+
+	dirtyRect();
 }
 
 void LLFloater::closeFloater(bool app_quitting)
 {
-    LL_INFOS() << "Closing floater " << getName() << LL_ENDL;
-    LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string
-    if (app_quitting)
-    {
-        LLFloater::sQuitting = true;
-    }
-    
-    // Always unminimize before trying to close.
-    // Most of the time the user will never see this state.
-    setMinimized(FALSE);
-
-    if (canClose())
-    {
-        if (getHost())
-        {
-            ((LLMultiFloater*)getHost())->removeFloater(this);
-            gFloaterView->addChild(this);
-        }
-
-        if (getSoundFlags() != SILENT
-            && getVisible()
-            && !getHost()
-            && !app_quitting)
-        {
-            make_ui_sound("UISndWindowClose");
-        }
-
-        gFocusMgr.clearLastFocusForGroup(this);
-
-            if (hasFocus())
-            {
-                // Do this early, so UI controls will commit before the
-                // window is taken down.
-                releaseFocus();
-
-                // give focus to dependee floater if it exists, and we had focus first
-                if (isDependent())
-                {
-                    LLFloater* dependee = mDependeeHandle.get();
-                    if (dependee && !dependee->isDead())
-                    {
-                        dependee->setFocus(TRUE);
-                    }
-                }
-            }
-
-
-        //If floater is a dependent, remove it from parent (dependee)
+	LL_INFOS() << "Closing floater " << getName() << LL_ENDL;
+	LLViewerEventRecorder::instance().logVisibilityChange( getPathname(), getName(), false,"floater"); // Last param is event subtype or empty string
+	if (app_quitting)
+	{
+		LLFloater::sQuitting = true;
+	}
+	
+	// Always unminimize before trying to close.
+	// Most of the time the user will never see this state.
+	setMinimized(FALSE);
+
+	if (canClose())
+	{
+		if (getHost())
+		{
+			((LLMultiFloater*)getHost())->removeFloater(this);
+			gFloaterView->addChild(this);
+		}
+
+		if (getSoundFlags() != SILENT
+			&& getVisible()
+			&& !getHost()
+			&& !app_quitting)
+		{
+			make_ui_sound("UISndWindowClose");
+		}
+
+		gFocusMgr.clearLastFocusForGroup(this);
+
+			if (hasFocus())
+			{
+				// Do this early, so UI controls will commit before the
+				// window is taken down.
+				releaseFocus();
+
+				// give focus to dependee floater if it exists, and we had focus first
+				if (isDependent())
+				{
+					LLFloater* dependee = mDependeeHandle.get();
+					if (dependee && !dependee->isDead())
+					{
+						dependee->setFocus(TRUE);
+					}
+				}
+			}
+
+
+		//If floater is a dependent, remove it from parent (dependee)
         LLFloater* dependee = mDependeeHandle.get();
         if (dependee)
         {
             dependee->removeDependentFloater(this);
         }
 
-        // now close dependent floater
-        for(handle_set_iter_t dependent_it = mDependents.begin();
-            dependent_it != mDependents.end(); )
-        {
-            
-            LLFloater* floaterp = dependent_it->get();
-            if (floaterp)
-            {
-                ++dependent_it;
-                floaterp->closeFloater(app_quitting);
-            }
-            else
-            {
-                mDependents.erase(dependent_it++);
-            }
-        }
-        
-        cleanupHandles();
-
-        dirtyRect();
-
-        // Close callbacks
-        onClose(app_quitting);
-        mCloseSignal(this, LLSD(app_quitting));
-        
-        // Hide or Destroy
-        if (mSingleInstance)
-        {
-            // Hide the instance
-            if (getHost())
-            {
-                getHost()->setVisible(FALSE);
-            }
-            else
-            {
-                setVisible(FALSE);
-                if (!mReuseInstance)
-                {
-                    destroy();
-                }
-            }
-        }
-        else
-        {
-            setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called)
-            if (!mReuseInstance)
-            {
-                destroy();
-            }
-        }
-    }
+		// now close dependent floater
+		for(handle_set_iter_t dependent_it = mDependents.begin();
+			dependent_it != mDependents.end(); )
+		{
+			
+			LLFloater* floaterp = dependent_it->get();
+			if (floaterp)
+			{
+				++dependent_it;
+				floaterp->closeFloater(app_quitting);
+			}
+			else
+			{
+				mDependents.erase(dependent_it++);
+			}
+		}
+		
+		cleanupHandles();
+
+		dirtyRect();
+
+		// Close callbacks
+		onClose(app_quitting);
+		mCloseSignal(this, LLSD(app_quitting));
+		
+		// Hide or Destroy
+		if (mSingleInstance)
+		{
+			// Hide the instance
+			if (getHost())
+			{
+				getHost()->setVisible(FALSE);
+			}
+			else
+			{
+				setVisible(FALSE);
+				if (!mReuseInstance)
+				{
+					destroy();
+				}
+			}
+		}
+		else
+		{
+			setVisible(FALSE); // hide before destroying (so onVisibilityChange() gets called)
+			if (!mReuseInstance)
+			{
+				destroy();
+			}
+		}
+	}
 }
 
 /*virtual*/
 void LLFloater::closeHostedFloater()
 {
-    // When toggling *visibility*, close the host instead of the floater when hosted
-    if (getHost())
-    {
-        getHost()->closeFloater();
-    }
-    else
-    {
-        closeFloater();
-    }
+	// When toggling *visibility*, close the host instead of the floater when hosted
+	if (getHost())
+	{
+		getHost()->closeFloater();
+	}
+	else
+	{
+		closeFloater();
+	}
 }
 
 /*virtual*/
 void LLFloater::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
-    LLPanel::reshape(width, height, called_from_parent);
+	LLPanel::reshape(width, height, called_from_parent);
 }
 
 void LLFloater::releaseFocus()
 {
-    LLUI::removePopup(this);
+	LLUI::removePopup(this);
 
-    setFocus(FALSE);
+	setFocus(FALSE);
 
-    if( gFocusMgr.childHasMouseCapture( this ) )
-    {
-        gFocusMgr.setMouseCapture(NULL);
-    }
+	if( gFocusMgr.childHasMouseCapture( this ) )
+	{
+		gFocusMgr.setMouseCapture(NULL);
+	}
 }
 
 
 void LLFloater::setResizeLimits( S32 min_width, S32 min_height )
 {
-    mMinWidth = min_width;
-    mMinHeight = min_height;
-
-    for( S32 i = 0; i < 4; i++ )
-    {
-        if( mResizeBar[i] )
-        {
-            if (i == LLResizeBar::LEFT || i == LLResizeBar::RIGHT)
-            {
-                mResizeBar[i]->setResizeLimits( min_width, S32_MAX );
-            }
-            else
-            {
-                mResizeBar[i]->setResizeLimits( min_height, S32_MAX );
-            }
-        }
-        if( mResizeHandle[i] )
-        {
-            mResizeHandle[i]->setResizeLimits( min_width, min_height );
-        }
-    }
+	mMinWidth = min_width;
+	mMinHeight = min_height;
+
+	for( S32 i = 0; i < 4; i++ )
+	{
+		if( mResizeBar[i] )
+		{
+			if (i == LLResizeBar::LEFT || i == LLResizeBar::RIGHT)
+			{
+				mResizeBar[i]->setResizeLimits( min_width, S32_MAX );
+			}
+			else
+			{
+				mResizeBar[i]->setResizeLimits( min_height, S32_MAX );
+			}
+		}
+		if( mResizeHandle[i] )
+		{
+			mResizeHandle[i]->setResizeLimits( min_width, min_height );
+		}
+	}
 }
 
 
 void LLFloater::center()
 {
-    if(getHost())
-    {
-        // hosted floaters can't move
-        return;
-    }
-    centerWithin(gFloaterView->getRect());
+	if(getHost())
+	{
+		// hosted floaters can't move
+		return;
+	}
+	centerWithin(gFloaterView->getRect());
 }
 
 LLMultiFloater* LLFloater::getHost()
 { 
-    return (LLMultiFloater*)mHostHandle.get(); 
+	return (LLMultiFloater*)mHostHandle.get(); 
 }
 
 void LLFloater::applyControlsAndPosition(LLFloater* other)
 {
-    if (!applyDockState())
-    {
-        if (!applyRectControl())
-        {
-            applyPositioning(other, true);
-        }
-    }
+	if (!applyDockState())
+	{
+		if (!applyRectControl())
+		{
+			applyPositioning(other, true);
+		}
+	}
 }
 
 bool LLFloater::applyRectControl()
 {
-    bool saved_rect = false;
-
-    LLRect screen_rect = calcScreenRect();
-    mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
-    
-    LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
-    if (last_in_group && last_in_group != this)
-    {
-        // other floaters in our group, position ourselves relative to them and don't save the rect
-        mRectControl.clear();
-        mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
-    }
-    else
-    {
-        bool rect_specified = false;
-        if (!mRectControl.empty())
-        {
-            // If we have a saved rect, use it
-            const LLRect& rect = getControlGroup()->getRect(mRectControl);
-            if (rect.notEmpty()) saved_rect = true;
-            if (saved_rect)
-            {
-                setOrigin(rect.mLeft, rect.mBottom);
-
-                if (mResizable)
-                {
-                    reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
-                }
-                mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-                LLRect screen_rect = calcScreenRect();
-                mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
-                rect_specified = true;
-            }
-        }
-
-        LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl);
-        LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl);
-        if (x_control.notNull() 
-            && y_control.notNull()
-            && !x_control->isDefault()
-            && !y_control->isDefault())
-        {
-            mPosition.mX = x_control->getValue().asReal();
-            mPosition.mY = y_control->getValue().asReal();
-            mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-            applyRelativePosition();
-
-            saved_rect = true;
-        }
-
-        // remember updated position
-        if (rect_specified)
-        {
-            storeRectControl();
-        }
-    }
-
-    if (saved_rect)
-    {
-        // propagate any derived positioning data back to settings file
-        storeRectControl();
-    }
-
-
-    return saved_rect;
+	bool saved_rect = false;
+
+	LLRect screen_rect = calcScreenRect();
+	mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+	
+	LLFloater* last_in_group = LLFloaterReg::getLastFloaterInGroup(mInstanceName);
+	if (last_in_group && last_in_group != this)
+	{
+		// other floaters in our group, position ourselves relative to them and don't save the rect
+		mRectControl.clear();
+		mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
+	}
+	else
+	{
+		bool rect_specified = false;
+		if (!mRectControl.empty())
+		{
+			// If we have a saved rect, use it
+			const LLRect& rect = getControlGroup()->getRect(mRectControl);
+			if (rect.notEmpty()) saved_rect = true;
+			if (saved_rect)
+			{
+				setOrigin(rect.mLeft, rect.mBottom);
+
+				if (mResizable)
+				{
+					reshape(llmax(mMinWidth, rect.getWidth()), llmax(mMinHeight, rect.getHeight()));
+				}
+				mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+				LLRect screen_rect = calcScreenRect();
+				mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+				rect_specified = true;
+			}
+		}
+
+		LLControlVariablePtr x_control = getControlGroup()->getControl(mPosXControl);
+		LLControlVariablePtr y_control = getControlGroup()->getControl(mPosYControl);
+		if (x_control.notNull() 
+			&& y_control.notNull()
+			&& !x_control->isDefault()
+			&& !y_control->isDefault())
+		{
+			mPosition.mX = x_control->getValue().asReal();
+			mPosition.mY = y_control->getValue().asReal();
+			mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+			applyRelativePosition();
+
+			saved_rect = true;
+		}
+
+		// remember updated position
+		if (rect_specified)
+		{
+			storeRectControl();
+		}
+	}
+
+	if (saved_rect)
+	{
+		// propagate any derived positioning data back to settings file
+		storeRectControl();
+	}
+
+
+	return saved_rect;
 }
 
 bool LLFloater::applyDockState()
 {
-    bool docked = false;
+	bool docked = false;
 
-    if (mDocStateControl.size() > 1)
-    {
-        docked = getControlGroup()->getBOOL(mDocStateControl);
-        setDocked(docked);
-    }
+	if (mDocStateControl.size() > 1)
+	{
+		docked = getControlGroup()->getBOOL(mDocStateControl);
+		setDocked(docked);
+	}
 
-    return docked;
+	return docked;
 }
 
 void LLFloater::applyPositioning(LLFloater* other, bool on_open)
 {
-    // Otherwise position according to the positioning code
-    switch (mPositioning)
-    {
-    case LLFloaterEnums::POSITIONING_CENTERED:
-        center();
-        break;
-
-    case LLFloaterEnums::POSITIONING_SPECIFIED:
-        break;
-
-    case LLFloaterEnums::POSITIONING_CASCADING:
-        if (!on_open)
-        {
-            applyRelativePosition();
-        }
-        // fall through
-    case LLFloaterEnums::POSITIONING_CASCADE_GROUP:
-        if (on_open)
-        {
-            if (other != NULL && other != this)
-            {
-                stackWith(*other);
-            }
-            else
-            {
-                static const U32 CASCADING_FLOATER_HOFFSET = 0;
-                static const U32 CASCADING_FLOATER_VOFFSET = 0;
-            
-                const LLRect& snap_rect = gFloaterView->getSnapRect();
-
-                const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET;
-                const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET;
-
-                S32 rect_height = getRect().getHeight();
-                setOrigin(horizontal_offset, vertical_offset - rect_height);
-
-                translate(snap_rect.mLeft, snap_rect.mBottom);
-            }
-            setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
-        }
-        break;
-
-    case LLFloaterEnums::POSITIONING_RELATIVE:
-        {
-            applyRelativePosition();
-
-            break;
-        }
-    default:
-        // Do nothing
-        break;
-    }
+	// Otherwise position according to the positioning code
+	switch (mPositioning)
+	{
+	case LLFloaterEnums::POSITIONING_CENTERED:
+		center();
+		break;
+
+	case LLFloaterEnums::POSITIONING_SPECIFIED:
+		break;
+
+	case LLFloaterEnums::POSITIONING_CASCADING:
+		if (!on_open)
+		{
+			applyRelativePosition();
+		}
+		// fall through
+	case LLFloaterEnums::POSITIONING_CASCADE_GROUP:
+		if (on_open)
+		{
+			if (other != NULL && other != this)
+			{
+				stackWith(*other);
+			}
+			else
+			{
+				static const U32 CASCADING_FLOATER_HOFFSET = 0;
+				static const U32 CASCADING_FLOATER_VOFFSET = 0;
+			
+				const LLRect& snap_rect = gFloaterView->getSnapRect();
+
+				const S32 horizontal_offset = CASCADING_FLOATER_HOFFSET;
+				const S32 vertical_offset = snap_rect.getHeight() - CASCADING_FLOATER_VOFFSET;
+
+				S32 rect_height = getRect().getHeight();
+				setOrigin(horizontal_offset, vertical_offset - rect_height);
+
+				translate(snap_rect.mLeft, snap_rect.mBottom);
+			}
+			setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
+		}
+		break;
+
+	case LLFloaterEnums::POSITIONING_RELATIVE:
+		{
+			applyRelativePosition();
+
+			break;
+		}
+	default:
+		// Do nothing
+		break;
+	}
 }
 
 void LLFloater::applyTitle()
 {
-    if (!mDragHandle)
-    {
-        return;
-    }
+	if (!mDragHandle)
+	{
+		return;
+	}
 
-    if (isMinimized() && !mShortTitle.empty())
-    {
-        mDragHandle->setTitle( mShortTitle );
-    }
-    else
-    {
-        mDragHandle->setTitle ( mTitle );
-    }
+	if (isMinimized() && !mShortTitle.empty())
+	{
+		mDragHandle->setTitle( mShortTitle );
+	}
+	else
+	{
+		mDragHandle->setTitle ( mTitle );
+	}
 
-    if (getHost())
-    {
-        getHost()->updateFloaterTitle(this);    
-    }
+	if (getHost())
+	{
+		getHost()->updateFloaterTitle(this);	
+	}
 }
 
 std::string LLFloater::getCurrentTitle() const
 {
-    return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
+	return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
 }
 
 void LLFloater::setTitle( const std::string& title )
 {
-    mTitle = title;
-    applyTitle();
+	mTitle = title;
+	applyTitle();
 }
 
 std::string LLFloater::getTitle() const
 {
-    if (mTitle.empty())
-    {
-        return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
-    }
-    else
-    {
-        return mTitle;
-    }
+	if (mTitle.empty())
+	{
+		return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
+	}
+	else
+	{
+		return mTitle;
+	}
 }
 
 void LLFloater::setShortTitle( const std::string& short_title )
 {
-    mShortTitle = short_title;
-    applyTitle();
+	mShortTitle = short_title;
+	applyTitle();
 }
 
 std::string LLFloater::getShortTitle() const
 {
-    if (mShortTitle.empty())
-    {
-        return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
-    }
-    else
-    {
-        return mShortTitle;
-    }
+	if (mShortTitle.empty())
+	{
+		return mDragHandle ? mDragHandle->getTitle() : LLStringUtil::null;
+	}
+	else
+	{
+		return mShortTitle;
+	}
 }
 
 BOOL LLFloater::canSnapTo(const LLView* other_view)
 {
-    if (NULL == other_view)
-    {
-        LL_WARNS() << "other_view is NULL" << LL_ENDL;
-        return FALSE;
-    }
-
-    if (other_view != getParent())
-    {
-        const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);       
-        if (other_floaterp 
-            && other_floaterp->getSnapTarget() == getHandle() 
-            && mDependents.find(other_floaterp->getHandle()) != mDependents.end())
-        {
-            // this is a dependent that is already snapped to us, so don't snap back to it
-            return FALSE;
-        }
-    }
+	if (NULL == other_view)
+	{
+		LL_WARNS() << "other_view is NULL" << LL_ENDL;
+		return FALSE;
+	}
 
-    return LLPanel::canSnapTo(other_view);
+	if (other_view != getParent())
+	{
+		const LLFloater* other_floaterp = dynamic_cast<const LLFloater*>(other_view);		
+		if (other_floaterp 
+			&& other_floaterp->getSnapTarget() == getHandle() 
+			&& mDependents.find(other_floaterp->getHandle()) != mDependents.end())
+		{
+			// this is a dependent that is already snapped to us, so don't snap back to it
+			return FALSE;
+		}
+	}
+
+	return LLPanel::canSnapTo(other_view);
 }
 
 void LLFloater::setSnappedTo(const LLView* snap_view)
 {
-    if (!snap_view || snap_view == getParent())
-    {
-        clearSnapTarget();
-    }
-    else
-    {
-        //RN: assume it's a floater as it must be a sibling to our parent floater
-        const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view);
-        if (floaterp)
-        {
-            setSnapTarget(floaterp->getHandle());
-        }
-    }
+	if (!snap_view || snap_view == getParent())
+	{
+		clearSnapTarget();
+	}
+	else
+	{
+		//RN: assume it's a floater as it must be a sibling to our parent floater
+		const LLFloater* floaterp = dynamic_cast<const LLFloater*>(snap_view);
+		if (floaterp)
+		{
+			setSnapTarget(floaterp->getHandle());
+		}
+	}
 }
 
 void LLFloater::handleReshape(const LLRect& new_rect, bool by_user)
 {
-    const LLRect old_rect = getRect();
-    LLView::handleReshape(new_rect, by_user);
-
-    if (by_user && !getHost())
-    {
-        LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent());
-        if (floaterVp)
-        {
-            floaterVp->adjustToFitScreen(this, !isMinimized());
-        }
-    }
-
-    // if not minimized, adjust all snapped dependents to new shape
-    if (!isMinimized())
-    {
-        if (by_user)
-        {
-            if (isDocked())
-            {
-                setDocked( false, false);
-            }
-        mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-        LLRect screen_rect = calcScreenRect();
-        mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
-        }
-        storeRectControl();
-
-        // gather all snapped dependents
-        for(handle_set_iter_t dependent_it = mDependents.begin();
-            dependent_it != mDependents.end(); ++dependent_it)
-        {
-            LLFloater* floaterp = dependent_it->get();
-            // is a dependent snapped to us?
-            if (floaterp && floaterp->getSnapTarget() == getHandle())
-            {
-                S32 delta_x = 0;
-                S32 delta_y = 0;
-                // check to see if it snapped to right or top, and move if dependee floater is resizing
-                LLRect dependent_rect = floaterp->getRect();
-                if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right?
-                    dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right
-                {
-                    // was snapped directly onto right side or aligned with it
-                    delta_x += new_rect.getWidth() - old_rect.getWidth();
-                }
-                if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() ||
-                    dependent_rect.mTop == getRect().mBottom + old_rect.getHeight())
-                {
-                    // was snapped directly onto top side or aligned with it
-                    delta_y += new_rect.getHeight() - old_rect.getHeight();
-                }
-
-                // take translation of dependee floater into account as well
-                delta_x += new_rect.mLeft - old_rect.mLeft;
-                delta_y += new_rect.mBottom - old_rect.mBottom;
-
-                dependent_rect.translate(delta_x, delta_y);
-                floaterp->setShape(dependent_rect, by_user);
-            }
-        }
-    }
-    else
-    {
-        // If minimized, and origin has changed, set
-        // mHasBeenDraggedWhileMinimized to TRUE
-        if ((new_rect.mLeft != old_rect.mLeft) ||
-            (new_rect.mBottom != old_rect.mBottom))
-        {
-            mHasBeenDraggedWhileMinimized = TRUE;
-        }
-    }
+	const LLRect old_rect = getRect();
+	LLView::handleReshape(new_rect, by_user);
+
+	if (by_user && !getHost())
+	{
+		LLFloaterView * floaterVp = dynamic_cast<LLFloaterView*>(getParent());
+		if (floaterVp)
+		{
+			floaterVp->adjustToFitScreen(this, !isMinimized());
+		}
+	}
+
+	// if not minimized, adjust all snapped dependents to new shape
+	if (!isMinimized())
+	{
+		if (by_user)
+		{
+			if (isDocked())
+			{
+				setDocked( false, false);
+			}
+		mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+		LLRect screen_rect = calcScreenRect();
+		mPosition = LLCoordGL(screen_rect.getCenterX(), screen_rect.getCenterY()).convert();
+		}
+		storeRectControl();
+
+		// gather all snapped dependents
+		for(handle_set_iter_t dependent_it = mDependents.begin();
+			dependent_it != mDependents.end(); ++dependent_it)
+		{
+			LLFloater* floaterp = dependent_it->get();
+			// is a dependent snapped to us?
+			if (floaterp && floaterp->getSnapTarget() == getHandle())
+			{
+				S32 delta_x = 0;
+				S32 delta_y = 0;
+				// check to see if it snapped to right or top, and move if dependee floater is resizing
+				LLRect dependent_rect = floaterp->getRect();
+				if (dependent_rect.mLeft - getRect().mLeft >= old_rect.getWidth() || // dependent on my right?
+					dependent_rect.mRight == getRect().mLeft + old_rect.getWidth()) // dependent aligned with my right
+				{
+					// was snapped directly onto right side or aligned with it
+					delta_x += new_rect.getWidth() - old_rect.getWidth();
+				}
+				if (dependent_rect.mBottom - getRect().mBottom >= old_rect.getHeight() ||
+					dependent_rect.mTop == getRect().mBottom + old_rect.getHeight())
+				{
+					// was snapped directly onto top side or aligned with it
+					delta_y += new_rect.getHeight() - old_rect.getHeight();
+				}
+
+				// take translation of dependee floater into account as well
+				delta_x += new_rect.mLeft - old_rect.mLeft;
+				delta_y += new_rect.mBottom - old_rect.mBottom;
+
+				dependent_rect.translate(delta_x, delta_y);
+				floaterp->setShape(dependent_rect, by_user);
+			}
+		}
+	}
+	else
+	{
+		// If minimized, and origin has changed, set
+		// mHasBeenDraggedWhileMinimized to TRUE
+		if ((new_rect.mLeft != old_rect.mLeft) ||
+			(new_rect.mBottom != old_rect.mBottom))
+		{
+			mHasBeenDraggedWhileMinimized = TRUE;
+		}
+	}
 }
 
 void LLFloater::setMinimized(BOOL minimize)
 {
-    const LLFloater::Params& default_params = LLFloater::getDefaultParams();
-    S32 floater_header_size = default_params.header_height;
-    static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
-
-    if (minimize == mMinimized) return;
-
-    if (mMinimizeSignal)
-    {
-        (*mMinimizeSignal)(this, LLSD(minimize));
-    }
-
-    if (minimize)
-    {
-        // minimized flag should be turned on before release focus
-        mMinimized = TRUE;
-        mExpandedRect = getRect();
-
-        // If the floater has been dragged while minimized in the
-        // past, then locate it at its previous minimized location.
-        // Otherwise, ask the view for a minimize position.
-        if (mHasBeenDraggedWhileMinimized)
-        {
-            setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom);
-        }
-        else
-        {
-            S32 left, bottom;
-            gFloaterView->getMinimizePosition(&left, &bottom);
-            setOrigin( left, bottom );
-        }
-
-        if (mButtonsEnabled[BUTTON_MINIMIZE])
-        {
-            mButtonsEnabled[BUTTON_MINIMIZE] = FALSE;
-            mButtonsEnabled[BUTTON_RESTORE] = TRUE;
-        }
-
-        setBorderVisible(TRUE);
-
-        for(handle_set_iter_t dependent_it = mDependents.begin();
-            dependent_it != mDependents.end();
-            ++dependent_it)
-        {
-            LLFloater* floaterp = dependent_it->get();
-            if (floaterp)
-            {
-                if (floaterp->isMinimizeable())
-                {
-                    floaterp->setMinimized(TRUE);
-                }
-                else if (!floaterp->isMinimized())
-                {
-                    floaterp->setVisible(FALSE);
-                }
-            }
-        }
-
-        // Lose keyboard focus when minimized
-        releaseFocus();
-
-        for (S32 i = 0; i < 4; i++)
-        {
-            if (mResizeBar[i] != NULL)
-            {
-                mResizeBar[i]->setEnabled(FALSE);
-            }
-            if (mResizeHandle[i] != NULL)
-            {
-                mResizeHandle[i]->setEnabled(FALSE);
-            }
-        }
-        
-        // Reshape *after* setting mMinimized
-        reshape( minimized_width, floater_header_size, TRUE);
-    }
-    else
-    {
-        // If this window has been dragged while minimized (at any time),
-        // remember its position for the next time it's minimized.
-        if (mHasBeenDraggedWhileMinimized)
-        {
-            const LLRect& currentRect = getRect();
-            mPreviousMinimizedLeft = currentRect.mLeft;
-            mPreviousMinimizedBottom = currentRect.mBottom;
-        }
-
-        setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom );
-        if (mButtonsEnabled[BUTTON_RESTORE])
-        {
-            mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
-            mButtonsEnabled[BUTTON_RESTORE] = FALSE;
-        }
-
-        // show dependent floater
-        for(handle_set_iter_t dependent_it = mDependents.begin();
-            dependent_it != mDependents.end();
-            ++dependent_it)
-        {
-            LLFloater* floaterp = dependent_it->get();
-            if (floaterp)
-            {
-                floaterp->setMinimized(FALSE);
-                floaterp->setVisible(TRUE);
-            }
-        }
-
-        for (S32 i = 0; i < 4; i++)
-        {
-            if (mResizeBar[i] != NULL)
-            {
-                mResizeBar[i]->setEnabled(isResizable());
-            }
-            if (mResizeHandle[i] != NULL)
-            {
-                mResizeHandle[i]->setEnabled(isResizable());
-            }
-        }
-        
-        mMinimized = FALSE;
-        setFrontmost();
-        // Reshape *after* setting mMinimized
-        reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
-    }
-
-    make_ui_sound("UISndWindowClose");
-    updateTitleButtons();
-    applyTitle ();
+	const LLFloater::Params& default_params = LLFloater::getDefaultParams();
+	S32 floater_header_size = default_params.header_height;
+	static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
+
+	if (minimize == mMinimized) return;
+
+	if (mMinimizeSignal)
+	{
+		(*mMinimizeSignal)(this, LLSD(minimize));
+	}
+
+	if (minimize)
+	{
+		// minimized flag should be turned on before release focus
+		mMinimized = TRUE;
+		mExpandedRect = getRect();
+
+		// If the floater has been dragged while minimized in the
+		// past, then locate it at its previous minimized location.
+		// Otherwise, ask the view for a minimize position.
+		if (mHasBeenDraggedWhileMinimized)
+		{
+			setOrigin(mPreviousMinimizedLeft, mPreviousMinimizedBottom);
+		}
+		else
+		{
+			S32 left, bottom;
+			gFloaterView->getMinimizePosition(&left, &bottom);
+			setOrigin( left, bottom );
+		}
+
+		if (mButtonsEnabled[BUTTON_MINIMIZE])
+		{
+			mButtonsEnabled[BUTTON_MINIMIZE] = FALSE;
+			mButtonsEnabled[BUTTON_RESTORE] = TRUE;
+		}
+
+		setBorderVisible(TRUE);
+
+		for(handle_set_iter_t dependent_it = mDependents.begin();
+			dependent_it != mDependents.end();
+			++dependent_it)
+		{
+			LLFloater* floaterp = dependent_it->get();
+			if (floaterp)
+			{
+				if (floaterp->isMinimizeable())
+				{
+					floaterp->setMinimized(TRUE);
+				}
+				else if (!floaterp->isMinimized())
+				{
+					floaterp->setVisible(FALSE);
+				}
+			}
+		}
+
+		// Lose keyboard focus when minimized
+		releaseFocus();
+
+		for (S32 i = 0; i < 4; i++)
+		{
+			if (mResizeBar[i] != NULL)
+			{
+				mResizeBar[i]->setEnabled(FALSE);
+			}
+			if (mResizeHandle[i] != NULL)
+			{
+				mResizeHandle[i]->setEnabled(FALSE);
+			}
+		}
+		
+		// Reshape *after* setting mMinimized
+		reshape( minimized_width, floater_header_size, TRUE);
+	}
+	else
+	{
+		// If this window has been dragged while minimized (at any time),
+		// remember its position for the next time it's minimized.
+		if (mHasBeenDraggedWhileMinimized)
+		{
+			const LLRect& currentRect = getRect();
+			mPreviousMinimizedLeft = currentRect.mLeft;
+			mPreviousMinimizedBottom = currentRect.mBottom;
+		}
+
+		setOrigin( mExpandedRect.mLeft, mExpandedRect.mBottom );
+		if (mButtonsEnabled[BUTTON_RESTORE])
+		{
+			mButtonsEnabled[BUTTON_MINIMIZE] = TRUE;
+			mButtonsEnabled[BUTTON_RESTORE] = FALSE;
+		}
+
+		// show dependent floater
+		for(handle_set_iter_t dependent_it = mDependents.begin();
+			dependent_it != mDependents.end();
+			++dependent_it)
+		{
+			LLFloater* floaterp = dependent_it->get();
+			if (floaterp)
+			{
+				floaterp->setMinimized(FALSE);
+				floaterp->setVisible(TRUE);
+			}
+		}
+
+		for (S32 i = 0; i < 4; i++)
+		{
+			if (mResizeBar[i] != NULL)
+			{
+				mResizeBar[i]->setEnabled(isResizable());
+			}
+			if (mResizeHandle[i] != NULL)
+			{
+				mResizeHandle[i]->setEnabled(isResizable());
+			}
+		}
+		
+		mMinimized = FALSE;
+		setFrontmost();
+		// Reshape *after* setting mMinimized
+		reshape( mExpandedRect.getWidth(), mExpandedRect.getHeight(), TRUE );
+	}
+
+	make_ui_sound("UISndWindowClose");
+	updateTitleButtons();
+	applyTitle ();
 }
 
 void LLFloater::setFocus( BOOL b )
 {
-    if (b && getIsChrome())
-    {
-        return;
-    }
-    LLView* last_focus = gFocusMgr.getLastFocusForGroup(this);
-    // a descendent already has focus
-    BOOL child_had_focus = hasFocus();
-
-    // give focus to first valid descendent
-    LLPanel::setFocus(b);
-
-    if (b)
-    {
-        // only push focused floaters to front of stack if not in midst of ctrl-tab cycle
-        LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent());
-        if (!getHost() && parent && !parent->getCycleMode())
-        {
-            if (!isFrontmost())
-            {
-                setFrontmost();
-            }
-        }
-
-        // when getting focus, delegate to last descendent which had focus
-        if (last_focus && !child_had_focus && 
-            last_focus->isInEnabledChain() &&
-            last_focus->isInVisibleChain())
-        {
-            // *FIX: should handle case where focus doesn't stick
-            last_focus->setFocus(TRUE);
-        }
-    }
-    updateTransparency(b ? TT_ACTIVE : TT_INACTIVE);
+	if (b && getIsChrome())
+	{
+		return;
+	}
+	LLView* last_focus = gFocusMgr.getLastFocusForGroup(this);
+	// a descendent already has focus
+	BOOL child_had_focus = hasFocus();
+
+	// give focus to first valid descendent
+	LLPanel::setFocus(b);
+
+	if (b)
+	{
+		// only push focused floaters to front of stack if not in midst of ctrl-tab cycle
+		LLFloaterView * parent = dynamic_cast<LLFloaterView *>(getParent());
+		if (!getHost() && parent && !parent->getCycleMode())
+		{
+			if (!isFrontmost())
+			{
+				setFrontmost();
+			}
+		}
+
+		// when getting focus, delegate to last descendent which had focus
+		if (last_focus && !child_had_focus && 
+			last_focus->isInEnabledChain() &&
+			last_focus->isInVisibleChain())
+		{
+			// *FIX: should handle case where focus doesn't stick
+			last_focus->setFocus(TRUE);
+		}
+	}
+	updateTransparency(b ? TT_ACTIVE : TT_INACTIVE);
 }
 
 // virtual
 void LLFloater::setRect(const LLRect &rect)
 {
-    LLPanel::setRect(rect);
-    layoutDragHandle();
-    layoutResizeCtrls();
+	LLPanel::setRect(rect);
+	layoutDragHandle();
+	layoutResizeCtrls();
 }
 
 // virtual
 void LLFloater::setIsChrome(BOOL is_chrome)
 {
-    // chrome floaters don't take focus at all
-    if (is_chrome)
-    {
-        // remove focus if we're changing to chrome
-        setFocus(FALSE);
-        // can't Ctrl-Tab to "chrome" floaters
-        setFocusRoot(FALSE);
-        mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome)));
-    }
-    
-    LLPanel::setIsChrome(is_chrome);
+	// chrome floaters don't take focus at all
+	if (is_chrome)
+	{
+		// remove focus if we're changing to chrome
+		setFocus(FALSE);
+		// can't Ctrl-Tab to "chrome" floaters
+		setFocusRoot(FALSE);
+		mButtons[BUTTON_CLOSE]->setToolTip(LLStringExplicit(getButtonTooltip(Params(), BUTTON_CLOSE, is_chrome)));
+	}
+	
+	LLPanel::setIsChrome(is_chrome);
 }
 
 // Change the draw style to account for the foreground state.
 void LLFloater::setForeground(BOOL front)
 {
-    if (front != mForeground)
-    {
-        mForeground = front;
-        if (mDragHandle)
-            mDragHandle->setForeground( front );
+	if (front != mForeground)
+	{
+		mForeground = front;
+		if (mDragHandle)
+			mDragHandle->setForeground( front );
 
-        if (!front)
-        {
-            releaseFocus();
-        }
+		if (!front)
+		{
+			releaseFocus();
+		}
 
-        setBackgroundOpaque( front ); 
-    }
+		setBackgroundOpaque( front ); 
+	}
 }
 
 void LLFloater::cleanupHandles()
 {
-    // remove handles to non-existent dependents
-    for(handle_set_iter_t dependent_it = mDependents.begin();
-        dependent_it != mDependents.end(); )
-    {
-        LLFloater* floaterp = dependent_it->get();
-        if (!floaterp)
-        {
-            mDependents.erase(dependent_it++);
-        }
-        else
-        {
-            ++dependent_it;
-        }
-    }
+	// remove handles to non-existent dependents
+	for(handle_set_iter_t dependent_it = mDependents.begin();
+		dependent_it != mDependents.end(); )
+	{
+		LLFloater* floaterp = dependent_it->get();
+		if (!floaterp)
+		{
+			mDependents.erase(dependent_it++);
+		}
+		else
+		{
+			++dependent_it;
+		}
+	}
 }
 
 void LLFloater::setHost(LLMultiFloater* host)
 {
-    if (mHostHandle.isDead() && host)
-    {
-        // make buttons smaller for hosted windows to differentiate from parent
-        mButtonScale = 0.9f;
-
-        // add tear off button
-        if (mCanTearOff)
-        {
-            mButtonsEnabled[BUTTON_TEAR_OFF] = TRUE;
-        }
-    }
-    else if (!mHostHandle.isDead() && !host)
-    {
-        mButtonScale = 1.f;
-        //mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE;
-    }
-    if (host)
-    {
-        mHostHandle = host->getHandle();
-        mLastHostHandle = host->getHandle();
-    }
-    else
-    {
-        mHostHandle.markDead();
-    }
+	if (mHostHandle.isDead() && host)
+	{
+		// make buttons smaller for hosted windows to differentiate from parent
+		mButtonScale = 0.9f;
+
+		// add tear off button
+		if (mCanTearOff)
+		{
+			mButtonsEnabled[BUTTON_TEAR_OFF] = TRUE;
+		}
+	}
+	else if (!mHostHandle.isDead() && !host)
+	{
+		mButtonScale = 1.f;
+		//mButtonsEnabled[BUTTON_TEAR_OFF] = FALSE;
+	}
+	if (host)
+	{
+		mHostHandle = host->getHandle();
+		mLastHostHandle = host->getHandle();
+	}
+	else
+	{
+		mHostHandle.markDead();
+	}
     
-    updateTitleButtons();
+	updateTitleButtons();
 }
 
 void LLFloater::moveResizeHandlesToFront()
 {
-    for( S32 i = 0; i < 4; i++ )
-    {
-        if( mResizeBar[i] )
-        {
-            sendChildToFront(mResizeBar[i]);
-        }
-    }
+	for( S32 i = 0; i < 4; i++ )
+	{
+		if( mResizeBar[i] )
+		{
+			sendChildToFront(mResizeBar[i]);
+		}
+	}
 
-    for( S32 i = 0; i < 4; i++ )
-    {
-        if( mResizeHandle[i] )
-        {
-            sendChildToFront(mResizeHandle[i]);
-        }
-    }
+	for( S32 i = 0; i < 4; i++ )
+	{
+		if( mResizeHandle[i] )
+		{
+			sendChildToFront(mResizeHandle[i]);
+		}
+	}
 }
 
 /*virtual*/
 BOOL LLFloater::isFrontmost()
 {
-    LLFloaterView* floater_view = getParentByType<LLFloaterView>();
-    return getVisible()
-            && (floater_view 
-                && floater_view->getFrontmost() == this);
+	LLFloaterView* floater_view = getParentByType<LLFloaterView>();
+	return getVisible()
+			&& (floater_view 
+				&& floater_view->getFrontmost() == this);
 }
 
 void LLFloater::addDependentFloater(LLFloater* floaterp, BOOL reposition)
 {
-    mDependents.insert(floaterp->getHandle());
-    floaterp->mDependeeHandle = getHandle();
+	mDependents.insert(floaterp->getHandle());
+	floaterp->mDependeeHandle = getHandle();
 
-    if (reposition)
-    {
-        floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp));
-        floaterp->setSnapTarget(getHandle());
-    }
-    gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE);
-    if (floaterp->isFrontmost())
-    {
-        // make sure to bring self and sibling floaters to front
-        gFloaterView->bringToFront(floaterp);
-    }
+	if (reposition)
+	{
+		floaterp->setRect(gFloaterView->findNeighboringPosition(this, floaterp));
+		floaterp->setSnapTarget(getHandle());
+	}
+	gFloaterView->adjustToFitScreen(floaterp, FALSE, TRUE);
+	if (floaterp->isFrontmost())
+	{
+		// make sure to bring self and sibling floaters to front
+		gFloaterView->bringToFront(floaterp);
+	}
 }
 
 void LLFloater::addDependentFloater(LLHandle<LLFloater> dependent, BOOL reposition)
 {
-    LLFloater* dependent_floaterp = dependent.get();
-    if(dependent_floaterp)
-    {
-        addDependentFloater(dependent_floaterp, reposition);
-    }
+	LLFloater* dependent_floaterp = dependent.get();
+	if(dependent_floaterp)
+	{
+		addDependentFloater(dependent_floaterp, reposition);
+	}
 }
 
 void LLFloater::removeDependentFloater(LLFloater* floaterp)
 {
-    mDependents.erase(floaterp->getHandle());
-    floaterp->mDependeeHandle = LLHandle<LLFloater>();
+	mDependents.erase(floaterp->getHandle());
+	floaterp->mDependeeHandle = LLHandle<LLFloater>();
 }
 
 BOOL LLFloater::offerClickToButton(S32 x, S32 y, MASK mask, EFloaterButton index)
 {
-    if( mButtonsEnabled[index] )
-    {
-        LLButton* my_butt = mButtons[index];
-        S32 local_x = x - my_butt->getRect().mLeft;
-        S32 local_y = y - my_butt->getRect().mBottom;
+	if( mButtonsEnabled[index] )
+	{
+		LLButton* my_butt = mButtons[index];
+		S32 local_x = x - my_butt->getRect().mLeft;
+		S32 local_y = y - my_butt->getRect().mBottom;
 
-        if (
-            my_butt->pointInView(local_x, local_y) &&
-            my_butt->handleMouseDown(local_x, local_y, mask))
-        {
-            // the button handled it
-            return TRUE;
-        }
-    }
-    return FALSE;
+		if (
+			my_butt->pointInView(local_x, local_y) &&
+			my_butt->handleMouseDown(local_x, local_y, mask))
+		{
+			// the button handled it
+			return TRUE;
+		}
+	}
+	return FALSE;
 }
 
 BOOL LLFloater::handleScrollWheel(S32 x, S32 y, S32 clicks)
 {
-    LLPanel::handleScrollWheel(x,y,clicks);
-    return TRUE;//always
+	LLPanel::handleScrollWheel(x,y,clicks);
+	return TRUE;//always
 }
 
 // virtual
 BOOL LLFloater::handleMouseUp(S32 x, S32 y, MASK mask)
 {
-    LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL;
-    BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView
-    if (handled) {
-        LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname());
-    }
-    return handled;
+	LL_DEBUGS() << "LLFloater::handleMouseUp calling LLPanel (really LLView)'s handleMouseUp (first initialized xui to: " << getPathname() << " )" << LL_ENDL;
+	BOOL handled = LLPanel::handleMouseUp(x,y,mask); // Not implemented in LLPanel so this actually calls LLView
+	if (handled) {
+		LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname());
+	}
+	return handled;
 }
 
 // virtual
 BOOL LLFloater::handleMouseDown(S32 x, S32 y, MASK mask)
 {
-    if( mMinimized )
-    {
-        // Offer the click to titlebar buttons.
-        // Note: this block and the offerClickToButton helper method can be removed
-        // because the parent container will handle it for us but we'll keep it here
-        // for safety until after reworking the panel code to manage hidden children.
-        if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE;
-        if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE;
-        if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE;
-        if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE;
-
-        setFrontmost(TRUE, FALSE);
-        // Otherwise pass to drag handle for movement
-        return mDragHandle->handleMouseDown(x, y, mask);
-    }
-    else
-    {
-        bringToFront( x, y );
-        BOOL handled = LLPanel::handleMouseDown( x, y, mask ); 
-        if (handled) {
-            LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); 
-        }
-        return handled;
-    }
+	if( mMinimized )
+	{
+		// Offer the click to titlebar buttons.
+		// Note: this block and the offerClickToButton helper method can be removed
+		// because the parent container will handle it for us but we'll keep it here
+		// for safety until after reworking the panel code to manage hidden children.
+		if(offerClickToButton(x, y, mask, BUTTON_CLOSE)) return TRUE;
+		if(offerClickToButton(x, y, mask, BUTTON_RESTORE)) return TRUE;
+		if(offerClickToButton(x, y, mask, BUTTON_TEAR_OFF)) return TRUE;
+		if(offerClickToButton(x, y, mask, BUTTON_DOCK)) return TRUE;
+
+		setFrontmost(TRUE, FALSE);
+		// Otherwise pass to drag handle for movement
+		return mDragHandle->handleMouseDown(x, y, mask);
+	}
+	else
+	{
+		bringToFront( x, y );
+		BOOL handled = LLPanel::handleMouseDown( x, y, mask ); 
+		if (handled) {
+			LLViewerEventRecorder::instance().updateMouseEventInfo(x,y,-55,-55,getPathname()); 
+		}
+		return handled;
+	}
 }
 
 // virtual
 BOOL LLFloater::handleRightMouseDown(S32 x, S32 y, MASK mask)
 {
-    BOOL was_minimized = mMinimized;
-    bringToFront( x, y );
-    return was_minimized || LLPanel::handleRightMouseDown( x, y, mask );
+	BOOL was_minimized = mMinimized;
+	bringToFront( x, y );
+	return was_minimized || LLPanel::handleRightMouseDown( x, y, mask );
 }
 
 BOOL LLFloater::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
 {
-    bringToFront( x, y );
-    return LLPanel::handleMiddleMouseDown( x, y, mask );
+	bringToFront( x, y );
+	return LLPanel::handleMiddleMouseDown( x, y, mask );
 }
 
 
 // virtual
 BOOL LLFloater::handleDoubleClick(S32 x, S32 y, MASK mask)
 {
-    BOOL was_minimized = mMinimized;
-    setMinimized(FALSE);
-    return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
+	BOOL was_minimized = mMinimized;
+	setMinimized(FALSE);
+	return was_minimized || LLPanel::handleDoubleClick(x, y, mask);
 }
 
 void LLFloater::bringToFront( S32 x, S32 y )
 {
-    if (getVisible() && pointInView(x, y))
-    {
-        LLMultiFloater* hostp = getHost();
-        if (hostp)
-        {
-            hostp->showFloater(this);
-        }
-        else
-        {
-            LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() );
-            if (parent)
-            {
-                parent->bringToFront( this );
-            }
-        }
-    }
+	if (getVisible() && pointInView(x, y))
+	{
+		LLMultiFloater* hostp = getHost();
+		if (hostp)
+		{
+			hostp->showFloater(this);
+		}
+		else
+		{
+			LLFloaterView* parent = dynamic_cast<LLFloaterView*>( getParent() );
+			if (parent)
+			{
+				parent->bringToFront( this );
+			}
+		}
+	}
 }
 
 
 // virtual
 void LLFloater::setVisibleAndFrontmost(BOOL take_focus,const LLSD& key)
 {
-    LLMultiFloater* hostp = getHost();
-    if (hostp)
-    {
-        hostp->setVisible(TRUE);
-        hostp->setFrontmost(take_focus);
-    }
-    else
-    {
-        setVisible(TRUE);
-        setFrontmost(take_focus);
-    }
+	LLMultiFloater* hostp = getHost();
+	if (hostp)
+	{
+		hostp->setVisible(TRUE);
+		hostp->setFrontmost(take_focus);
+	}
+	else
+	{
+		setVisible(TRUE);
+		setFrontmost(take_focus);
+	}
 }
 
 void LLFloater::setFrontmost(BOOL take_focus, BOOL restore)
 {
-    LLMultiFloater* hostp = getHost();
-    if (hostp)
-    {
-        // this will bring the host floater to the front and select
-        // the appropriate panel
-        hostp->showFloater(this);
-    }
-    else
-    {
-        // there are more than one floater view
-        // so we need to query our parent directly
-        LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() );
-        if (parent)
-        {
-            parent->bringToFront(this, take_focus, restore);
-        }
-
-        // Make sure to set the appropriate transparency type (STORM-732).
-        updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE);
-    }
+	LLMultiFloater* hostp = getHost();
+	if (hostp)
+	{
+		// this will bring the host floater to the front and select
+		// the appropriate panel
+		hostp->showFloater(this);
+	}
+	else
+	{
+		// there are more than one floater view
+		// so we need to query our parent directly
+		LLFloaterView * parent = dynamic_cast<LLFloaterView*>( getParent() );
+		if (parent)
+		{
+			parent->bringToFront(this, take_focus, restore);
+		}
+
+		// Make sure to set the appropriate transparency type (STORM-732).
+		updateTransparency(hasFocus() || getIsChrome() ? TT_ACTIVE : TT_INACTIVE);
+	}
 }
 
 void LLFloater::setCanDock(bool b)
 {
-    if(b != mCanDock)
-    {
-        mCanDock = b;
-        if(mCanDock)
-        {
-            mButtonsEnabled[BUTTON_DOCK] = !mDocked;
-        }
-        else
-        {
-            mButtonsEnabled[BUTTON_DOCK] = FALSE;
-        }
-    }
-    updateTitleButtons();
+	if(b != mCanDock)
+	{
+		mCanDock = b;
+		if(mCanDock)
+		{
+			mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+		}
+		else
+		{
+			mButtonsEnabled[BUTTON_DOCK] = FALSE;
+		}
+	}
+	updateTitleButtons();
 }
 
 void LLFloater::setDocked(bool docked, bool pop_on_undock)
 {
-    if(docked != mDocked && mCanDock)
-    {
-        mDocked = docked;
-        mButtonsEnabled[BUTTON_DOCK] = !mDocked;
+	if(docked != mDocked && mCanDock)
+	{
+		mDocked = docked;
+		mButtonsEnabled[BUTTON_DOCK] = !mDocked;
 
-        if (mDocked)
-        {
-            setMinimized(FALSE);
-            mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
-        }
+		if (mDocked)
+		{
+			setMinimized(FALSE);
+			mPositioning = LLFloaterEnums::POSITIONING_RELATIVE;
+		}
 
-        updateTitleButtons();
+		updateTitleButtons();
 
-        storeDockStateControl();
-    }
-    
+		storeDockStateControl();
+	}
+	
 }
 
 // static
 void LLFloater::onClickMinimize(LLFloater* self)
 {
-    if (!self)
-        return;
-    self->setMinimized( !self->isMinimized() );
+	if (!self)
+		return;
+	self->setMinimized( !self->isMinimized() );
 }
 
 void LLFloater::onClickTearOff(LLFloater* self)
 {
-    if (!self)
-        return;
-    S32 floater_header_size = self->mHeaderHeight;
-    LLMultiFloater* host_floater = self->getHost();
-    if (host_floater) //Tear off
-    {
-        LLRect new_rect;
-        host_floater->removeFloater(self);
-        // reparent to floater view
-        gFloaterView->addChild(self);
-
-        self->openFloater(self->getKey());
-        if (self->mSaveRect && !self->mRectControl.empty())
-        {
-            self->applyRectControl();
-        }
-        else
-        {   // only force position for floaters that don't have that data saved
-            new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
-            self->setRect(new_rect);
-        }
-        gFloaterView->adjustToFitScreen(self, FALSE);
-        // give focus to new window to keep continuity for the user
-        self->setFocus(TRUE);
-        self->setTornOff(true);
-    }
-    else  //Attach to parent.
-    {
-        LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
-        if (new_host)
-        {
-            if (self->mSaveRect)
-            {
-                self->storeRectControl();
-            }
-            self->setMinimized(FALSE); // to reenable minimize button if it was minimized
-            new_host->showFloater(self);
-            // make sure host is visible
-            new_host->openFloater(new_host->getKey());
-        }
-        self->setTornOff(false);
-    }
-    self->updateTitleButtons();
+	if (!self)
+		return;
+	S32 floater_header_size = self->mHeaderHeight;
+	LLMultiFloater* host_floater = self->getHost();
+	if (host_floater) //Tear off
+	{
+		LLRect new_rect;
+		host_floater->removeFloater(self);
+		// reparent to floater view
+		gFloaterView->addChild(self);
+
+		self->openFloater(self->getKey());
+		if (self->mSaveRect && !self->mRectControl.empty())
+		{
+			self->applyRectControl();
+		}
+		else
+		{   // only force position for floaters that don't have that data saved
+			new_rect.setLeftTopAndSize(host_floater->getRect().mLeft + 5, host_floater->getRect().mTop - floater_header_size - 5, self->getRect().getWidth(), self->getRect().getHeight());
+			self->setRect(new_rect);
+		}
+		gFloaterView->adjustToFitScreen(self, FALSE);
+		// give focus to new window to keep continuity for the user
+		self->setFocus(TRUE);
+		self->setTornOff(true);
+	}
+	else  //Attach to parent.
+	{
+		LLMultiFloater* new_host = (LLMultiFloater*)self->mLastHostHandle.get();
+		if (new_host)
+		{
+			if (self->mSaveRect)
+			{
+				self->storeRectControl();
+			}
+			self->setMinimized(FALSE); // to reenable minimize button if it was minimized
+			new_host->showFloater(self);
+			// make sure host is visible
+			new_host->openFloater(new_host->getKey());
+		}
+		self->setTornOff(false);
+	}
+	self->updateTitleButtons();
     self->setOpenPositioning(LLFloaterEnums::POSITIONING_RELATIVE);
 }
 
 // static
 void LLFloater::onClickDock(LLFloater* self)
 {
-    if(self && self->mCanDock)
-    {
-        self->setDocked(!self->mDocked, true);
-    }
+	if(self && self->mCanDock)
+	{
+		self->setDocked(!self->mDocked, true);
+	}
 }
 
 // static
 void LLFloater::onClickHelp( LLFloater* self )
 {
-    if (self && LLUI::sHelpImpl)
-    {
-        // find the current help context for this floater
-        std::string help_topic;
-        if (self->findHelpTopic(help_topic))
-        {
-            LLUI::sHelpImpl->showTopic(help_topic);
-        }
-    }
+	if (self && LLUI::sHelpImpl)
+	{
+		// find the current help context for this floater
+		std::string help_topic;
+		if (self->findHelpTopic(help_topic))
+		{
+			LLUI::sHelpImpl->showTopic(help_topic);
+		}
+	}
 }
 
 void LLFloater::initRectControl()
 {
-    // save_rect and save_visibility only apply to registered floaters
-    if (mSaveRect)
-    {
-        std::string ctrl_name = getControlName(mInstanceName, mKey);
-        mRectControl = LLFloaterReg::declareRectControl(ctrl_name);
-        mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name);
-        mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name);
-    }
+	// save_rect and save_visibility only apply to registered floaters
+	if (mSaveRect)
+	{
+		std::string ctrl_name = getControlName(mInstanceName, mKey);
+		mRectControl = LLFloaterReg::declareRectControl(ctrl_name);
+		mPosXControl = LLFloaterReg::declarePosXControl(ctrl_name);
+		mPosYControl = LLFloaterReg::declarePosYControl(ctrl_name);
+	}
 }
 
 // static
 void LLFloater::closeFrontmostFloater()
 {
-    LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater();
-    if(floater_to_close)
-    {
-        floater_to_close->closeFloater();
-    }
+	LLFloater* floater_to_close = gFloaterView->getFrontmostClosableFloater();
+	if(floater_to_close)
+	{
+		floater_to_close->closeFloater();
+	}
 
-    // if nothing took focus after closing focused floater
-    // give it to next floater (to allow closing multiple windows via keyboard in rapid succession)
-    if (gFocusMgr.getKeyboardFocus() == NULL)
-    {
-        // HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window
-        // which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view
-        gFloaterView->focusFrontFloater();
-    }
+	// if nothing took focus after closing focused floater
+	// give it to next floater (to allow closing multiple windows via keyboard in rapid succession)
+	if (gFocusMgr.getKeyboardFocus() == NULL)
+	{
+		// HACK: use gFloaterView directly in case we are using Ctrl-W to close snapshot window
+		// which sits in gSnapshotFloaterView, and needs to pass focus on to normal floater view
+		gFloaterView->focusFrontFloater();
+	}
 }
 
 
 // static
 void LLFloater::onClickClose( LLFloater* self )
 {
-    if (!self)
-        return;
-    self->onClickCloseBtn();
+	if (!self)
+		return;
+	self->onClickCloseBtn();
 }
 
 void LLFloater::onClickCloseBtn(bool app_quitting)
 {
-    closeFloater(false);
+	closeFloater(false);
 }
 
 
 // virtual
 void LLFloater::draw()
 {
-    const F32 alpha = getCurrentTransparency();
-
-    // draw background
-    if( isBackgroundVisible() )
-    {
-        drawShadow(this);
-
-        S32 left = LLPANEL_BORDER_WIDTH;
-        S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH;
-        S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH;
-        S32 bottom = LLPANEL_BORDER_WIDTH;
-
-        LLUIImage* image = NULL;
-        LLColor4 color;
-        LLColor4 overlay_color;
-        if (isBackgroundOpaque())
-        {
-            // NOTE: image may not be set
-            image = getBackgroundImage();
-            color = getBackgroundColor();
-            overlay_color = getBackgroundImageOverlay();
-        }
-        else
-        {
-            image = getTransparentImage();
-            color = getTransparentColor();
-            overlay_color = getTransparentImageOverlay();
-        }
-
-        if (image)
-        {
-            // We're using images for this floater's backgrounds
-            image->draw(getLocalRect(), overlay_color % alpha);
-        }
-        else
-        {
-            // We're not using images, use old-school flat colors
-            gl_rect_2d( left, top, right, bottom, color % alpha );
-
-            // draw highlight on title bar to indicate focus.  RDW
-            if(hasFocus() 
-                && !getIsChrome() 
-                && !getCurrentTitle().empty())
-            {
-                static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor");
-                
-                const LLFontGL* font = LLFontGL::getFontSansSerif();
-                LLRect r = getRect();
-                gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1, 
-                    titlebar_focus_color % alpha, 0, TRUE);
-            }
-        }
-    }
-
-    LLPanel::updateDefaultBtn();
-
-    if( getDefaultButton() )
-    {
-        if (hasFocus() && getDefaultButton()->getEnabled())
-        {
-            LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
-            // is this button a direct descendent and not a nested widget (e.g. checkbox)?
-            BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this;
-            // only enable default button when current focus is not a button
-            getDefaultButton()->setBorderEnabled(!focus_is_child_button);
-        }
-        else
-        {
-            getDefaultButton()->setBorderEnabled(FALSE);
-        }
-    }
-    if (isMinimized())
-    {
-        for (S32 i = 0; i < BUTTON_COUNT; i++)
-        {
-            drawChild(mButtons[i]);
-        }
-        drawChild(mDragHandle, 0, 0, TRUE);
-    }
-    else
-    {
-        // don't call LLPanel::draw() since we've implemented custom background rendering
-        LLView::draw();
-    }
-
-    // update tearoff button for torn off floaters
-    // when last host goes away
-    if (mCanTearOff && !getHost())
-    {
-        LLFloater* old_host = mLastHostHandle.get();
-        if (!old_host)
-        {
-            setCanTearOff(FALSE);
-        }
-    }
-}
-
-void    LLFloater::drawShadow(LLPanel* panel)
-{
-    S32 left = LLPANEL_BORDER_WIDTH;
-    S32 top = panel->getRect().getHeight() - LLPANEL_BORDER_WIDTH;
-    S32 right = panel->getRect().getWidth() - LLPANEL_BORDER_WIDTH;
-    S32 bottom = LLPANEL_BORDER_WIDTH;
-
-    static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0);
-    static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow");
-    LLColor4 shadow_color = shadow_color_cached;
-    F32 shadow_offset = (F32)shadow_offset_S32;
-
-    if (!panel->isBackgroundOpaque())
-    {
-        shadow_offset *= 0.2f;
-        shadow_color.mV[VALPHA] *= 0.5f;
-    }
-    gl_drop_shadow(left, top, right, bottom, 
-        shadow_color % getCurrentTransparency(),
-        ll_round(shadow_offset));
+	const F32 alpha = getCurrentTransparency();
+
+	// draw background
+	if( isBackgroundVisible() )
+	{
+		drawShadow(this);
+
+		S32 left = LLPANEL_BORDER_WIDTH;
+		S32 top = getRect().getHeight() - LLPANEL_BORDER_WIDTH;
+		S32 right = getRect().getWidth() - LLPANEL_BORDER_WIDTH;
+		S32 bottom = LLPANEL_BORDER_WIDTH;
+
+		LLUIImage* image = NULL;
+		LLColor4 color;
+		LLColor4 overlay_color;
+		if (isBackgroundOpaque())
+		{
+			// NOTE: image may not be set
+			image = getBackgroundImage();
+			color = getBackgroundColor();
+			overlay_color = getBackgroundImageOverlay();
+		}
+		else
+		{
+			image = getTransparentImage();
+			color = getTransparentColor();
+			overlay_color = getTransparentImageOverlay();
+		}
+
+		if (image)
+		{
+			// We're using images for this floater's backgrounds
+			image->draw(getLocalRect(), overlay_color % alpha);
+		}
+		else
+		{
+			// We're not using images, use old-school flat colors
+			gl_rect_2d( left, top, right, bottom, color % alpha );
+
+			// draw highlight on title bar to indicate focus.  RDW
+			if(hasFocus() 
+				&& !getIsChrome() 
+				&& !getCurrentTitle().empty())
+			{
+				static LLUIColor titlebar_focus_color = LLUIColorTable::instance().getColor("TitleBarFocusColor");
+				
+				const LLFontGL* font = LLFontGL::getFontSansSerif();
+				LLRect r = getRect();
+				gl_rect_2d_offset_local(0, r.getHeight(), r.getWidth(), r.getHeight() - font->getLineHeight() - 1, 
+					titlebar_focus_color % alpha, 0, TRUE);
+			}
+		}
+	}
+
+	LLPanel::updateDefaultBtn();
+
+	if( getDefaultButton() )
+	{
+		if (hasFocus() && getDefaultButton()->getEnabled())
+		{
+			LLFocusableElement* focus_ctrl = gFocusMgr.getKeyboardFocus();
+			// is this button a direct descendent and not a nested widget (e.g. checkbox)?
+			BOOL focus_is_child_button = dynamic_cast<LLButton*>(focus_ctrl) != NULL && dynamic_cast<LLButton*>(focus_ctrl)->getParent() == this;
+			// only enable default button when current focus is not a button
+			getDefaultButton()->setBorderEnabled(!focus_is_child_button);
+		}
+		else
+		{
+			getDefaultButton()->setBorderEnabled(FALSE);
+		}
+	}
+	if (isMinimized())
+	{
+		for (S32 i = 0; i < BUTTON_COUNT; i++)
+		{
+			drawChild(mButtons[i]);
+		}
+		drawChild(mDragHandle, 0, 0, TRUE);
+	}
+	else
+	{
+		// don't call LLPanel::draw() since we've implemented custom background rendering
+		LLView::draw();
+	}
+
+	// update tearoff button for torn off floaters
+	// when last host goes away
+	if (mCanTearOff && !getHost())
+	{
+		LLFloater* old_host = mLastHostHandle.get();
+		if (!old_host)
+		{
+			setCanTearOff(FALSE);
+		}
+	}
+}
+
+void	LLFloater::drawShadow(LLPanel* panel)
+{
+	S32 left = LLPANEL_BORDER_WIDTH;
+	S32 top = panel->getRect().getHeight() - LLPANEL_BORDER_WIDTH;
+	S32 right = panel->getRect().getWidth() - LLPANEL_BORDER_WIDTH;
+	S32 bottom = LLPANEL_BORDER_WIDTH;
+
+	static LLUICachedControl<S32> shadow_offset_S32 ("DropShadowFloater", 0);
+	static LLUIColor shadow_color_cached = LLUIColorTable::instance().getColor("ColorDropShadow");
+	LLColor4 shadow_color = shadow_color_cached;
+	F32 shadow_offset = (F32)shadow_offset_S32;
+
+	if (!panel->isBackgroundOpaque())
+	{
+		shadow_offset *= 0.2f;
+		shadow_color.mV[VALPHA] *= 0.5f;
+	}
+	gl_drop_shadow(left, top, right, bottom, 
+		shadow_color % getCurrentTransparency(),
+		ll_round(shadow_offset));
 }
 
 void LLFloater::updateTransparency(LLView* view, ETypeTransparency transparency_type)
 {
-    if (!view) return;
-    child_list_t children = *view->getChildList();
-    child_list_t::iterator it = children.begin();
+	if (!view) return;
+	child_list_t children = *view->getChildList();
+	child_list_t::iterator it = children.begin();
 
-    LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(view);
-    if (ctrl)
-    {
-        ctrl->setTransparencyType(transparency_type);
-    }
+	LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(view);
+	if (ctrl)
+	{
+		ctrl->setTransparencyType(transparency_type);
+	}
 
-    for(; it != children.end(); ++it)
-    {
-        updateTransparency(*it, transparency_type);
-    }
+	for(; it != children.end(); ++it)
+	{
+		updateTransparency(*it, transparency_type);
+	}
 }
 
 void LLFloater::updateTransparency(ETypeTransparency transparency_type)
 {
-    updateTransparency(this, transparency_type);
+	updateTransparency(this, transparency_type);
 }
 
-void    LLFloater::setCanMinimize(BOOL can_minimize)
+void	LLFloater::setCanMinimize(BOOL can_minimize)
 {
-    // if removing minimize/restore button programmatically,
-    // go ahead and unminimize floater
-    mCanMinimize = can_minimize;
-    if (!can_minimize)
-    {
-        setMinimized(FALSE);
-    }
+	// if removing minimize/restore button programmatically,
+	// go ahead and unminimize floater
+	mCanMinimize = can_minimize;
+	if (!can_minimize)
+	{
+		setMinimized(FALSE);
+	}
 
-    mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized();
-    mButtonsEnabled[BUTTON_RESTORE]  = can_minimize &&  isMinimized();
+	mButtonsEnabled[BUTTON_MINIMIZE] = can_minimize && !isMinimized();
+	mButtonsEnabled[BUTTON_RESTORE]  = can_minimize &&  isMinimized();
 
-    updateTitleButtons();
+	updateTitleButtons();
 }
 
-void    LLFloater::setCanClose(BOOL can_close)
+void	LLFloater::setCanClose(BOOL can_close)
 {
-    mCanClose = can_close;
-    mButtonsEnabled[BUTTON_CLOSE] = can_close;
+	mCanClose = can_close;
+	mButtonsEnabled[BUTTON_CLOSE] = can_close;
 
-    updateTitleButtons();
+	updateTitleButtons();
 }
 
-void    LLFloater::setCanTearOff(BOOL can_tear_off)
+void	LLFloater::setCanTearOff(BOOL can_tear_off)
 {
-    mCanTearOff = can_tear_off;
-    mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead();
+	mCanTearOff = can_tear_off;
+	mButtonsEnabled[BUTTON_TEAR_OFF] = mCanTearOff && !mHostHandle.isDead();
 
-    updateTitleButtons();
+	updateTitleButtons();
 }
 
 
 void LLFloater::setCanResize(BOOL can_resize)
 {
-    mResizable = can_resize;
-    enableResizeCtrls(can_resize);
+	mResizable = can_resize;
+	enableResizeCtrls(can_resize);
 }
 
 void LLFloater::setCanDrag(BOOL can_drag)
 {
-    // if we delete drag handle, we no longer have access to the floater's title
-    // so just enable/disable it
-    if (!can_drag && mDragHandle->getEnabled())
-    {
-        mDragHandle->setEnabled(FALSE);
-    }
-    else if (can_drag && !mDragHandle->getEnabled())
-    {
-        mDragHandle->setEnabled(TRUE);
-    }
+	// if we delete drag handle, we no longer have access to the floater's title
+	// so just enable/disable it
+	if (!can_drag && mDragHandle->getEnabled())
+	{
+		mDragHandle->setEnabled(FALSE);
+	}
+	else if (can_drag && !mDragHandle->getEnabled())
+	{
+		mDragHandle->setEnabled(TRUE);
+	}
 }
 
 bool LLFloater::getCanDrag()
 {
-    return mDragHandle->getEnabled();
+	return mDragHandle->getEnabled();
 }
 
 
 void LLFloater::updateTitleButtons()
 {
-    static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
-    static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
-    LLRect buttons_rect;
-    S32 button_count = 0;
-    for (S32 i = 0; i < BUTTON_COUNT; i++)
-    {
-        if (!mButtons[i])
-        {
-            continue;
-        }
-
-        bool enabled = mButtonsEnabled[i];
-        if (i == BUTTON_HELP)
-        {
-            // don't show the help button if the floater is minimized
-            // or if it is a docked tear-off floater
-            if (isMinimized() || (mButtonsEnabled[BUTTON_TEAR_OFF] && ! mTornOff))
-            {
-                enabled = false;
-            }
-        }
-        if (i == BUTTON_CLOSE && mButtonScale != 1.f)
-        {
-            //*HACK: always render close button for hosted floaters so
-            //that users don't accidentally hit the button when
-            //closing multiple windows in the chatterbox
-            enabled = true;
-        }
-
-        mButtons[i]->setEnabled(enabled);
-
-        if (enabled)
-        {
-            button_count++;
-
-            LLRect btn_rect;
-            if (mDragOnLeft)
-            {
-                btn_rect.setLeftTopAndSize(
-                    LLPANEL_BORDER_WIDTH,
-                    getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * button_count,
-                    ll_round((F32)floater_close_box_size * mButtonScale),
-                    ll_round((F32)floater_close_box_size * mButtonScale));
-            }
-            else
-            {
-                btn_rect.setLeftTopAndSize(
-                    getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * button_count,
-                    getRect().getHeight() - close_box_from_top,
-                    ll_round((F32)floater_close_box_size * mButtonScale),
-                    ll_round((F32)floater_close_box_size * mButtonScale));
-            }
-
-            // first time here, init 'buttons_rect'
-            if(1 == button_count)
-            {
-                buttons_rect = btn_rect;
-            }
-            else
-            {
-                // if mDragOnLeft=true then buttons are on top-left side vertically aligned
-                // title is not displayed in this case, calculating 'buttons_rect' for future use
-                mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : 
-                    buttons_rect.mLeft = btn_rect.mLeft;
-            }
-            mButtons[i]->setRect(btn_rect);
-            mButtons[i]->setVisible(TRUE);
-            // the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
-            mButtons[i]->setTabStop(i == BUTTON_RESTORE);
-        }
-        else
-        {
-            mButtons[i]->setVisible(FALSE);
-        }
-    }
-    if (mDragHandle)
-    {
-        localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle);
-        mDragHandle->setButtonsRect(buttons_rect);
-    }
+	static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
+	static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
+	LLRect buttons_rect;
+	S32 button_count = 0;
+	for (S32 i = 0; i < BUTTON_COUNT; i++)
+	{
+		if (!mButtons[i])
+		{
+			continue;
+		}
+
+		bool enabled = mButtonsEnabled[i];
+		if (i == BUTTON_HELP)
+		{
+			// don't show the help button if the floater is minimized
+			// or if it is a docked tear-off floater
+			if (isMinimized() || (mButtonsEnabled[BUTTON_TEAR_OFF] && ! mTornOff))
+			{
+				enabled = false;
+			}
+		}
+		if (i == BUTTON_CLOSE && mButtonScale != 1.f)
+		{
+			//*HACK: always render close button for hosted floaters so
+			//that users don't accidentally hit the button when
+			//closing multiple windows in the chatterbox
+			enabled = true;
+		}
+
+		mButtons[i]->setEnabled(enabled);
+
+		if (enabled)
+		{
+			button_count++;
+
+			LLRect btn_rect;
+			if (mDragOnLeft)
+			{
+				btn_rect.setLeftTopAndSize(
+					LLPANEL_BORDER_WIDTH,
+					getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * button_count,
+					ll_round((F32)floater_close_box_size * mButtonScale),
+					ll_round((F32)floater_close_box_size * mButtonScale));
+			}
+			else
+			{
+				btn_rect.setLeftTopAndSize(
+					getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * button_count,
+					getRect().getHeight() - close_box_from_top,
+					ll_round((F32)floater_close_box_size * mButtonScale),
+					ll_round((F32)floater_close_box_size * mButtonScale));
+			}
+
+			// first time here, init 'buttons_rect'
+			if(1 == button_count)
+			{
+				buttons_rect = btn_rect;
+			}
+			else
+			{
+				// if mDragOnLeft=true then buttons are on top-left side vertically aligned
+				// title is not displayed in this case, calculating 'buttons_rect' for future use
+				mDragOnLeft ? buttons_rect.mBottom -= btn_rect.mBottom : 
+					buttons_rect.mLeft = btn_rect.mLeft;
+			}
+			mButtons[i]->setRect(btn_rect);
+			mButtons[i]->setVisible(TRUE);
+			// the restore button should have a tab stop so that it takes action when you Ctrl-Tab to a minimized floater
+			mButtons[i]->setTabStop(i == BUTTON_RESTORE);
+		}
+		else
+		{
+			mButtons[i]->setVisible(FALSE);
+		}
+	}
+	if (mDragHandle)
+	{
+		localRectToOtherView(buttons_rect, &buttons_rect, mDragHandle);
+		mDragHandle->setButtonsRect(buttons_rect);
+	}
 }
 
 void LLFloater::buildButtons(const Params& floater_params)
 {
-    static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
-    static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
-    for (S32 i = 0; i < BUTTON_COUNT; i++)
-    {
-        if (mButtons[i])
-        {
-            removeChild(mButtons[i]);
-            delete mButtons[i];
-            mButtons[i] = NULL;
-        }
-        
-        LLRect btn_rect;
-        if (mDragOnLeft)
-        {
-            btn_rect.setLeftTopAndSize(
-                LLPANEL_BORDER_WIDTH,
-                getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * (i + 1),
-                ll_round(floater_close_box_size * mButtonScale),
-                ll_round(floater_close_box_size * mButtonScale));
-        }
-        else
-        {
-            btn_rect.setLeftTopAndSize(
-                getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * (i + 1),
-                getRect().getHeight() - close_box_from_top,
-                ll_round(floater_close_box_size * mButtonScale),
-                ll_round(floater_close_box_size * mButtonScale));
-        }
-
-        LLButton::Params p;
-        p.name(sButtonNames[i]);
-        p.rect(btn_rect);
-        p.image_unselected = getButtonImage(floater_params, (EFloaterButton)i);
-        // Selected, no matter if hovered or not, is "pressed"
-        LLUIImage* pressed_image = getButtonPressedImage(floater_params, (EFloaterButton)i);
-        p.image_selected = pressed_image;
-        p.image_hover_selected = pressed_image;
-        // Use a glow effect when the user hovers over the button
-        // These icons are really small, need glow amount increased
-        p.hover_glow_amount( 0.33f );
-        p.click_callback.function(boost::bind(sButtonCallbacks[i], this));
-        p.tab_stop(false);
-        p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT);
-        p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome());
-        p.scale_image(true);
-        p.chrome(true);
-
-        LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p);
-        addChild(buttonp);
-        mButtons[i] = buttonp;
-    }
-
-    updateTitleButtons();
+	static LLUICachedControl<S32> floater_close_box_size ("UIFloaterCloseBoxSize", 0);
+	static LLUICachedControl<S32> close_box_from_top ("UICloseBoxFromTop", 0);
+	for (S32 i = 0; i < BUTTON_COUNT; i++)
+	{
+		if (mButtons[i])
+		{
+			removeChild(mButtons[i]);
+			delete mButtons[i];
+			mButtons[i] = NULL;
+		}
+		
+		LLRect btn_rect;
+		if (mDragOnLeft)
+		{
+			btn_rect.setLeftTopAndSize(
+				LLPANEL_BORDER_WIDTH,
+				getRect().getHeight() - close_box_from_top - (floater_close_box_size + 1) * (i + 1),
+				ll_round(floater_close_box_size * mButtonScale),
+				ll_round(floater_close_box_size * mButtonScale));
+		}
+		else
+		{
+			btn_rect.setLeftTopAndSize(
+				getRect().getWidth() - LLPANEL_BORDER_WIDTH - (floater_close_box_size + 1) * (i + 1),
+				getRect().getHeight() - close_box_from_top,
+				ll_round(floater_close_box_size * mButtonScale),
+				ll_round(floater_close_box_size * mButtonScale));
+		}
+
+		LLButton::Params p;
+		p.name(sButtonNames[i]);
+		p.rect(btn_rect);
+		p.image_unselected = getButtonImage(floater_params, (EFloaterButton)i);
+		// Selected, no matter if hovered or not, is "pressed"
+		LLUIImage* pressed_image = getButtonPressedImage(floater_params, (EFloaterButton)i);
+		p.image_selected = pressed_image;
+		p.image_hover_selected = pressed_image;
+		// Use a glow effect when the user hovers over the button
+		// These icons are really small, need glow amount increased
+		p.hover_glow_amount( 0.33f );
+		p.click_callback.function(boost::bind(sButtonCallbacks[i], this));
+		p.tab_stop(false);
+		p.follows.flags(FOLLOWS_TOP|FOLLOWS_RIGHT);
+		p.tool_tip = getButtonTooltip(floater_params, (EFloaterButton)i, getIsChrome());
+		p.scale_image(true);
+		p.chrome(true);
+
+		LLButton* buttonp = LLUICtrlFactory::create<LLButton>(p);
+		addChild(buttonp);
+		mButtons[i] = buttonp;
+	}
+
+	updateTitleButtons();
 }
 
 // static
 LLUIImage* LLFloater::getButtonImage(const Params& p, EFloaterButton e)
 {
-    switch(e)
-    {
-        default:
-        case BUTTON_CLOSE:
-            return p.close_image;
-        case BUTTON_RESTORE:
-            return p.restore_image;
-        case BUTTON_MINIMIZE:
-            return p.minimize_image;
-        case BUTTON_TEAR_OFF:
-            return p.tear_off_image;
-        case BUTTON_DOCK:
-            return p.dock_image;
-        case BUTTON_HELP:
-            return p.help_image;
-    }
+	switch(e)
+	{
+		default:
+		case BUTTON_CLOSE:
+			return p.close_image;
+		case BUTTON_RESTORE:
+			return p.restore_image;
+		case BUTTON_MINIMIZE:
+			return p.minimize_image;
+		case BUTTON_TEAR_OFF:
+			return p.tear_off_image;
+		case BUTTON_DOCK:
+			return p.dock_image;
+		case BUTTON_HELP:
+			return p.help_image;
+	}
 }
 
 // static
 LLUIImage* LLFloater::getButtonPressedImage(const Params& p, EFloaterButton e)
 {
-    switch(e)
-    {
-        default:
-        case BUTTON_CLOSE:
-            return p.close_pressed_image;
-        case BUTTON_RESTORE:
-            return p.restore_pressed_image;
-        case BUTTON_MINIMIZE:
-            return p.minimize_pressed_image;
-        case BUTTON_TEAR_OFF:
-            return p.tear_off_pressed_image;
-        case BUTTON_DOCK:
-            return p.dock_pressed_image;
-        case BUTTON_HELP:
-            return p.help_pressed_image;
-    }
+	switch(e)
+	{
+		default:
+		case BUTTON_CLOSE:
+			return p.close_pressed_image;
+		case BUTTON_RESTORE:
+			return p.restore_pressed_image;
+		case BUTTON_MINIMIZE:
+			return p.minimize_pressed_image;
+		case BUTTON_TEAR_OFF:
+			return p.tear_off_pressed_image;
+		case BUTTON_DOCK:
+			return p.dock_pressed_image;
+		case BUTTON_HELP:
+			return p.help_pressed_image;
+	}
 }
 
 // static
 std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool is_chrome)
 {
-    // EXT-4081 (Lag Meter: Ctrl+W does not close floater)
-    // If floater is chrome set 'Close' text for close button's tooltip
-    if(is_chrome && BUTTON_CLOSE == e)
-    {
-        static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME");
-        return close_tooltip_chrome;
-    }
-    // TODO: per-floater localizable tooltips set in XML
-    return sButtonToolTips[e];
+	// EXT-4081 (Lag Meter: Ctrl+W does not close floater)
+	// If floater is chrome set 'Close' text for close button's tooltip
+	if(is_chrome && BUTTON_CLOSE == e)
+	{
+		static std::string close_tooltip_chrome = LLTrans::getString("BUTTON_CLOSE_CHROME");
+		return close_tooltip_chrome;
+	}
+	// TODO: per-floater localizable tooltips set in XML
+	return sButtonToolTips[e];
 }
 
 /////////////////////////////////////////////////////
@@ -2234,946 +2234,946 @@ std::string LLFloater::getButtonTooltip(const Params& p, EFloaterButton e, bool
 static LLDefaultChildRegistry::Register<LLFloaterView> r("floater_view");
 
 LLFloaterView::LLFloaterView (const Params& p)
-:   LLUICtrl (p),
-    mFocusCycleMode(FALSE),
-    mMinimizePositionVOffset(0),
-    mSnapOffsetBottom(0),
-    mSnapOffsetRight(0),
-    mFrontChild(NULL)
+:	LLUICtrl (p),
+	mFocusCycleMode(FALSE),
+	mMinimizePositionVOffset(0),
+	mSnapOffsetBottom(0),
+	mSnapOffsetRight(0),
+	mFrontChild(NULL)
 {
-    mSnapView = getHandle();
+	mSnapView = getHandle();
 }
 
 // By default, adjust vertical.
 void LLFloaterView::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
-    LLView::reshape(width, height, called_from_parent);
-
-    mLastSnapRect = getSnapRect();
-
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLView* viewp = *child_it;
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
-        if (floaterp->isDependent())
-        {
-            // dependents are moved with their "dependee"
-            continue;
-        }
-
-        if (!floaterp->isMinimized() && floaterp->getCanDrag())
-        {
-            LLRect old_rect = floaterp->getRect();
-            floaterp->applyPositioning(NULL, false);
-            LLRect new_rect = floaterp->getRect();
-
-            //LLRect r = floaterp->getRect();
-
-            //// Compute absolute distance from each edge of screen
-            //S32 left_offset = llabs(r.mLeft - 0);
-            //S32 right_offset = llabs(old_right - r.mRight);
-
-            //S32 top_offset = llabs(old_top - r.mTop);
-            //S32 bottom_offset = llabs(r.mBottom - 0);
-
-            S32 translate_x = new_rect.mLeft - old_rect.mLeft;
-            S32 translate_y = new_rect.mBottom - old_rect.mBottom;
-
-            //if (left_offset > right_offset)
-            //{
-            //  translate_x = new_right - old_right;
-            //}
-
-            //if (top_offset < bottom_offset)
-            //{
-            //  translate_y = new_top - old_top;
-            //}
-
-            // don't reposition immovable floaters
-            //if (floaterp->getCanDrag())
-            //{
-            //  floaterp->translate(translate_x, translate_y);
-            //}
-            BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents)
-            {
-                if (dependent_floater.get())
-                {
-                    dependent_floater.get()->translate(translate_x, translate_y);
-                }
-            }
-        }
-    }
+	LLView::reshape(width, height, called_from_parent);
+
+	mLastSnapRect = getSnapRect();
+
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLView* viewp = *child_it;
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
+		if (floaterp->isDependent())
+		{
+			// dependents are moved with their "dependee"
+			continue;
+		}
+
+		if (!floaterp->isMinimized() && floaterp->getCanDrag())
+		{
+			LLRect old_rect = floaterp->getRect();
+			floaterp->applyPositioning(NULL, false);
+			LLRect new_rect = floaterp->getRect();
+
+			//LLRect r = floaterp->getRect();
+
+			//// Compute absolute distance from each edge of screen
+			//S32 left_offset = llabs(r.mLeft - 0);
+			//S32 right_offset = llabs(old_right - r.mRight);
+
+			//S32 top_offset = llabs(old_top - r.mTop);
+			//S32 bottom_offset = llabs(r.mBottom - 0);
+
+			S32 translate_x = new_rect.mLeft - old_rect.mLeft;
+			S32 translate_y = new_rect.mBottom - old_rect.mBottom;
+
+			//if (left_offset > right_offset)
+			//{
+			//	translate_x = new_right - old_right;
+			//}
+
+			//if (top_offset < bottom_offset)
+			//{
+			//	translate_y = new_top - old_top;
+			//}
+
+			// don't reposition immovable floaters
+			//if (floaterp->getCanDrag())
+			//{
+			//	floaterp->translate(translate_x, translate_y);
+			//}
+			BOOST_FOREACH(LLHandle<LLFloater> dependent_floater, floaterp->mDependents)
+			{
+				if (dependent_floater.get())
+				{
+					dependent_floater.get()->translate(translate_x, translate_y);
+				}
+			}
+		}
+	}
 }
 
 
 void LLFloaterView::restoreAll()
 {
-    // make sure all subwindows aren't minimized
-    child_list_t child_list = *(getChildList());
-    for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it)
-    {
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
-        if (floaterp)
-        {
-            floaterp->setMinimized(FALSE);
-        }
-    }
+	// make sure all subwindows aren't minimized
+	child_list_t child_list = *(getChildList());
+	for (child_list_const_iter_t child_it = child_list.begin(); child_it != child_list.end(); ++child_it)
+	{
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+		if (floaterp)
+		{
+			floaterp->setMinimized(FALSE);
+		}
+	}
 
-    // *FIX: make sure dependents are restored
+	// *FIX: make sure dependents are restored
 
-    // children then deleted by default view constructor
+	// children then deleted by default view constructor
 }
 
 
 LLRect LLFloaterView::findNeighboringPosition( LLFloater* reference_floater, LLFloater* neighbor )
 {
-    LLRect base_rect = reference_floater->getRect();
-    LLRect::tCoordType width = neighbor->getRect().getWidth();
-    LLRect::tCoordType height = neighbor->getRect().getHeight();
-    LLRect new_rect = neighbor->getRect();
-
-    LLRect expanded_base_rect = base_rect;
-    expanded_base_rect.stretch(10);
-    for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin();
-        dependent_it != reference_floater->mDependents.end(); ++dependent_it)
-    {
-        LLFloater* sibling = dependent_it->get();
-        // check for dependents within 10 pixels of base floater
-        if (sibling && 
-            sibling != neighbor && 
-            sibling->getVisible() && 
-            expanded_base_rect.overlaps(sibling->getRect()))
-        {
-            base_rect.unionWith(sibling->getRect());
-        }
-    }
-
-    LLRect::tCoordType left_margin = llmax(0, base_rect.mLeft);
-    LLRect::tCoordType right_margin = llmax(0, getRect().getWidth() - base_rect.mRight);
-    LLRect::tCoordType top_margin = llmax(0, getRect().getHeight() - base_rect.mTop);
-    LLRect::tCoordType bottom_margin = llmax(0, base_rect.mBottom);
-
-    // find position for floater in following order
-    // right->left->bottom->top
-    for (S32 i = 0; i < 5; i++)
-    {
-        if (right_margin > width)
-        {
-            new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop);
-            return new_rect;
-        }
-        else if (left_margin > width)
-        {
-            new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop);
-            return new_rect;
-        }
-        else if (bottom_margin > height)
-        {
-            new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop);
-            return new_rect;
-        }
-        else if (top_margin > height)
-        {
-            new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom);
-            return new_rect;
-        }
-
-        // keep growing margins to find "best" fit
-        left_margin += 20;
-        right_margin += 20;
-        top_margin += 20;
-        bottom_margin += 20;
-    }
-
-    // didn't find anything, return initial rect
-    return new_rect;
+	LLRect base_rect = reference_floater->getRect();
+	LLRect::tCoordType width = neighbor->getRect().getWidth();
+	LLRect::tCoordType height = neighbor->getRect().getHeight();
+	LLRect new_rect = neighbor->getRect();
+
+	LLRect expanded_base_rect = base_rect;
+	expanded_base_rect.stretch(10);
+	for(LLFloater::handle_set_iter_t dependent_it = reference_floater->mDependents.begin();
+		dependent_it != reference_floater->mDependents.end(); ++dependent_it)
+	{
+		LLFloater* sibling = dependent_it->get();
+		// check for dependents within 10 pixels of base floater
+		if (sibling && 
+			sibling != neighbor && 
+			sibling->getVisible() && 
+			expanded_base_rect.overlaps(sibling->getRect()))
+		{
+			base_rect.unionWith(sibling->getRect());
+		}
+	}
+
+	LLRect::tCoordType left_margin = llmax(0, base_rect.mLeft);
+	LLRect::tCoordType right_margin = llmax(0, getRect().getWidth() - base_rect.mRight);
+	LLRect::tCoordType top_margin = llmax(0, getRect().getHeight() - base_rect.mTop);
+	LLRect::tCoordType bottom_margin = llmax(0, base_rect.mBottom);
+
+	// find position for floater in following order
+	// right->left->bottom->top
+	for (S32 i = 0; i < 5; i++)
+	{
+		if (right_margin > width)
+		{
+			new_rect.translate(base_rect.mRight - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mTop);
+			return new_rect;
+		}
+		else if (left_margin > width)
+		{
+			new_rect.translate(base_rect.mLeft - neighbor->getRect().mRight, base_rect.mTop - neighbor->getRect().mTop);
+			return new_rect;
+		}
+		else if (bottom_margin > height)
+		{
+			new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mBottom - neighbor->getRect().mTop);
+			return new_rect;
+		}
+		else if (top_margin > height)
+		{
+			new_rect.translate(base_rect.mLeft - neighbor->getRect().mLeft, base_rect.mTop - neighbor->getRect().mBottom);
+			return new_rect;
+		}
+
+		// keep growing margins to find "best" fit
+		left_margin += 20;
+		right_margin += 20;
+		top_margin += 20;
+		bottom_margin += 20;
+	}
+
+	// didn't find anything, return initial rect
+	return new_rect;
 }
 
 
 void LLFloaterView::bringToFront(LLFloater* child, BOOL give_focus, BOOL restore)
 {
-    if (!child)
-        return;
-
-    if (mFrontChild == child)
-    {
-        if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
-        {
-            child->setFocus(TRUE);
-        }
-        return;
-    }
-
-    mFrontChild = child;
-
-    // *TODO: make this respect floater's mAutoFocus value, instead of
-    // using parameter
-    if (child->getHost())
-    {
-        // this floater is hosted elsewhere and hence not one of our children, abort
-        return;
-    }
-    std::vector<LLFloater*> floaters_to_move;
-    // Look at all floaters...tab
-    for (child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it)
-    {
-        LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
-
-        // ...but if I'm a dependent floater...
-        if (floater && child->isDependent())
-        {
-            // ...look for floaters that have me as a dependent...
-            LLFloater::handle_set_iter_t found_dependent = floater->mDependents.find(child->getHandle());
-
-            if (found_dependent != floater->mDependents.end())
-            {
-                // ...and make sure all children of that floater (including me) are brought to front...
-                for (LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
-                    dependent_it != floater->mDependents.end(); ++dependent_it)
-                {
-                    LLFloater* sibling = dependent_it->get();
-                    if (sibling)
-                    {
-                        floaters_to_move.push_back(sibling);
-                    }
-                }
-                //...before bringing my parent to the front...
-                floaters_to_move.push_back(floater);
-            }
-        }
-    }
-
-    std::vector<LLFloater*>::iterator floater_it;
-    for(floater_it = floaters_to_move.begin(); floater_it != floaters_to_move.end(); ++floater_it)
-    {
-        LLFloater* floaterp = *floater_it;
-        sendChildToFront(floaterp);
-
-        // always unminimize dependee, but allow dependents to stay minimized
-        if (!floaterp->isDependent())
-        {
-            floaterp->setMinimized(FALSE);
-        }
-    }
-    floaters_to_move.clear();
-
-    // ...then bringing my own dependents to the front...
-    for (LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin();
-        dependent_it != child->mDependents.end(); ++dependent_it)
-    {
-        LLFloater* dependent = dependent_it->get();
-        if (dependent)
-        {
-            sendChildToFront(dependent);
-        }
-    }
-
-    // ...and finally bringing myself to front 
-    // (do this last, so that I'm left in front at end of this call)
-    if (*beginChild() != child)
-    {
-        sendChildToFront(child);
-    }
-
-    if(restore)
-    {
-        child->setMinimized(FALSE);
-    }
-
-    if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
-    {
-        child->setFocus(TRUE);
-        // floater did not take focus, so relinquish focus to world
-        if (!child->hasFocus())
-        {
-            gFocusMgr.setKeyboardFocus(NULL);
-        }
-    }
+	if (!child)
+		return;
+
+	if (mFrontChild == child)
+	{
+		if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
+		{
+			child->setFocus(TRUE);
+		}
+		return;
+	}
+
+	mFrontChild = child;
+
+	// *TODO: make this respect floater's mAutoFocus value, instead of
+	// using parameter
+	if (child->getHost())
+ 	{
+		// this floater is hosted elsewhere and hence not one of our children, abort
+		return;
+	}
+	std::vector<LLFloater*> floaters_to_move;
+	// Look at all floaters...tab
+	for (child_list_const_iter_t child_it = beginChild(); child_it != endChild(); ++child_it)
+	{
+		LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
+
+		// ...but if I'm a dependent floater...
+		if (floater && child->isDependent())
+		{
+			// ...look for floaters that have me as a dependent...
+			LLFloater::handle_set_iter_t found_dependent = floater->mDependents.find(child->getHandle());
+
+			if (found_dependent != floater->mDependents.end())
+			{
+				// ...and make sure all children of that floater (including me) are brought to front...
+				for (LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
+					dependent_it != floater->mDependents.end(); ++dependent_it)
+				{
+					LLFloater* sibling = dependent_it->get();
+					if (sibling)
+					{
+						floaters_to_move.push_back(sibling);
+					}
+				}
+				//...before bringing my parent to the front...
+				floaters_to_move.push_back(floater);
+			}
+		}
+	}
+
+	std::vector<LLFloater*>::iterator floater_it;
+	for(floater_it = floaters_to_move.begin(); floater_it != floaters_to_move.end(); ++floater_it)
+	{
+		LLFloater* floaterp = *floater_it;
+		sendChildToFront(floaterp);
+
+		// always unminimize dependee, but allow dependents to stay minimized
+		if (!floaterp->isDependent())
+		{
+			floaterp->setMinimized(FALSE);
+		}
+	}
+	floaters_to_move.clear();
+
+	// ...then bringing my own dependents to the front...
+	for (LLFloater::handle_set_iter_t dependent_it = child->mDependents.begin();
+		dependent_it != child->mDependents.end(); ++dependent_it)
+	{
+		LLFloater* dependent = dependent_it->get();
+		if (dependent)
+		{
+			sendChildToFront(dependent);
+		}
+	}
+
+	// ...and finally bringing myself to front 
+	// (do this last, so that I'm left in front at end of this call)
+	if (*beginChild() != child)
+	{
+		sendChildToFront(child);
+	}
+
+	if(restore)
+	{
+		child->setMinimized(FALSE);
+	}
+
+	if (give_focus && !gFocusMgr.childHasKeyboardFocus(child))
+	{
+		child->setFocus(TRUE);
+		// floater did not take focus, so relinquish focus to world
+		if (!child->hasFocus())
+		{
+			gFocusMgr.setKeyboardFocus(NULL);
+		}
+	}
 }
 
 void LLFloaterView::highlightFocusedFloater()
 {
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLFloater *floater = (LLFloater *)(*child_it);
-
-        // skip dependent floaters, as we'll handle them in a batch along with their dependee(?)
-        if (floater->isDependent())
-        {
-            continue;
-        }
-
-        BOOL floater_or_dependent_has_focus = gFocusMgr.childHasKeyboardFocus(floater);
-        for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
-            dependent_it != floater->mDependents.end(); 
-            ++dependent_it)
-        {
-            LLFloater* dependent_floaterp = dependent_it->get();
-            if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp))
-            {
-                floater_or_dependent_has_focus = TRUE;
-            }
-        }
-
-        // now set this floater and all its dependents
-        floater->setForeground(floater_or_dependent_has_focus);
-
-        for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
-            dependent_it != floater->mDependents.end(); )
-        {
-            LLFloater* dependent_floaterp = dependent_it->get();
-            if (dependent_floaterp)
-            {
-                dependent_floaterp->setForeground(floater_or_dependent_has_focus);
-            }
-            ++dependent_it;
-        }
-            
-        floater->cleanupHandles();
-    }
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLFloater *floater = (LLFloater *)(*child_it);
+
+		// skip dependent floaters, as we'll handle them in a batch along with their dependee(?)
+		if (floater->isDependent())
+		{
+			continue;
+		}
+
+		BOOL floater_or_dependent_has_focus = gFocusMgr.childHasKeyboardFocus(floater);
+		for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
+			dependent_it != floater->mDependents.end(); 
+			++dependent_it)
+		{
+			LLFloater* dependent_floaterp = dependent_it->get();
+			if (dependent_floaterp && gFocusMgr.childHasKeyboardFocus(dependent_floaterp))
+			{
+				floater_or_dependent_has_focus = TRUE;
+			}
+		}
+
+		// now set this floater and all its dependents
+		floater->setForeground(floater_or_dependent_has_focus);
+
+		for(LLFloater::handle_set_iter_t dependent_it = floater->mDependents.begin();
+			dependent_it != floater->mDependents.end(); )
+		{
+			LLFloater* dependent_floaterp = dependent_it->get();
+			if (dependent_floaterp)
+			{
+				dependent_floaterp->setForeground(floater_or_dependent_has_focus);
+			}
+			++dependent_it;
+		}
+			
+		floater->cleanupHandles();
+	}
 }
 
 LLFloater* LLFloaterView::getFrontmostClosableFloater()
 {
-    child_list_const_iter_t child_it;
-    LLFloater* frontmost_floater = NULL;
+	child_list_const_iter_t child_it;
+	LLFloater* frontmost_floater = NULL;
 
-    for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        frontmost_floater = (LLFloater *)(*child_it);
+	for ( child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		frontmost_floater = (LLFloater *)(*child_it);
 
-        if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable())
-        {
-            return frontmost_floater;
-        }
-    }
+		if (frontmost_floater->isInVisibleChain() && frontmost_floater->isCloseable())
+		{
+			return frontmost_floater;
+		}
+	}
 
-    return NULL;
+	return NULL;
 }
 
 void LLFloaterView::unhighlightFocusedFloater()
 {
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLFloater *floater = (LLFloater *)(*child_it);
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLFloater *floater = (LLFloater *)(*child_it);
 
-        floater->setForeground(FALSE);
-    }
+		floater->setForeground(FALSE);
+	}
 }
 
 void LLFloaterView::focusFrontFloater()
 {
-    LLFloater* floaterp = getFrontmost();
-    if (floaterp)
-    {
-        floaterp->setFocus(TRUE);
-    }
+	LLFloater* floaterp = getFrontmost();
+	if (floaterp)
+	{
+		floaterp->setFocus(TRUE);
+	}
 }
 
 void LLFloaterView::getMinimizePosition(S32 *left, S32 *bottom)
 {
-    const LLFloater::Params& default_params = LLFloater::getDefaultParams();
-    S32 floater_header_size = default_params.header_height;
-    static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
-    LLRect snap_rect_local = getLocalSnapRect();
-    snap_rect_local.mTop += mMinimizePositionVOffset;
-    for(S32 col = snap_rect_local.mLeft;
-        col < snap_rect_local.getWidth() - minimized_width;
-        col += minimized_width)
-    {   
-        for(S32 row = snap_rect_local.mTop - floater_header_size;
-        row > floater_header_size;
-        row -= floater_header_size ) //loop rows
-        {
-
-            bool foundGap = TRUE;
-            for(child_list_const_iter_t child_it = getChildList()->begin();
-                child_it != getChildList()->end();
-                ++child_it) //loop floaters
-            {
-                // Examine minimized children.
-                LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
-                if(floater->isMinimized()) 
-                {
-                    LLRect r = floater->getRect();
-                    if((r.mBottom < (row + floater_header_size))
-                       && (r.mBottom > (row - floater_header_size))
-                       && (r.mLeft < (col + minimized_width))
-                       && (r.mLeft > (col - minimized_width)))
-                    {
-                        // needs the check for off grid. can't drag,
-                        // but window resize makes them off
-                        foundGap = FALSE;
-                        break;
-                    }
-                }
-            } //done floaters
-            if(foundGap)
-            {
-                *left = col;
-                *bottom = row;
-                return; //done
-            }
-        } //done this col
-    }
-
-    // crude - stack'em all at 0,0 when screen is full of minimized
-    // floaters.
-    *left = snap_rect_local.mLeft;
-    *bottom = snap_rect_local.mBottom;
+	const LLFloater::Params& default_params = LLFloater::getDefaultParams();
+	S32 floater_header_size = default_params.header_height;
+	static LLUICachedControl<S32> minimized_width ("UIMinimizedWidth", 0);
+	LLRect snap_rect_local = getLocalSnapRect();
+	snap_rect_local.mTop += mMinimizePositionVOffset;
+	for(S32 col = snap_rect_local.mLeft;
+		col < snap_rect_local.getWidth() - minimized_width;
+		col += minimized_width)
+	{	
+		for(S32 row = snap_rect_local.mTop - floater_header_size;
+		row > floater_header_size;
+		row -= floater_header_size ) //loop rows
+		{
+
+			bool foundGap = TRUE;
+			for(child_list_const_iter_t child_it = getChildList()->begin();
+				child_it != getChildList()->end();
+				++child_it) //loop floaters
+			{
+				// Examine minimized children.
+				LLFloater* floater = dynamic_cast<LLFloater*>(*child_it);
+				if(floater->isMinimized()) 
+				{
+					LLRect r = floater->getRect();
+					if((r.mBottom < (row + floater_header_size))
+					   && (r.mBottom > (row - floater_header_size))
+					   && (r.mLeft < (col + minimized_width))
+					   && (r.mLeft > (col - minimized_width)))
+					{
+						// needs the check for off grid. can't drag,
+						// but window resize makes them off
+						foundGap = FALSE;
+						break;
+					}
+				}
+			} //done floaters
+			if(foundGap)
+			{
+				*left = col;
+				*bottom = row;
+				return; //done
+			}
+		} //done this col
+	}
+
+	// crude - stack'em all at 0,0 when screen is full of minimized
+	// floaters.
+	*left = snap_rect_local.mLeft;
+	*bottom = snap_rect_local.mBottom;
 }
 
 
 void LLFloaterView::destroyAllChildren()
 {
-    LLView::deleteAllChildren();
+	LLView::deleteAllChildren();
 }
 
 void LLFloaterView::closeAllChildren(bool app_quitting)
 {
-    // iterate over a copy of the list, because closing windows will destroy
-    // some windows on the list.
-    child_list_t child_list = *(getChildList());
-
-    for (child_list_const_iter_t it = child_list.begin(); it != child_list.end(); ++it)
-    {
-        LLView* viewp = *it;
-        child_list_const_iter_t exists = std::find(getChildList()->begin(), getChildList()->end(), viewp);
-        if (exists == getChildList()->end())
-        {
-            // this floater has already been removed
-            continue;
-        }
-
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
-
-        // Attempt to close floater.  This will cause the "do you want to save"
-        // dialogs to appear.
-        // Skip invisible floaters if we're not quitting (STORM-192).
-        if (floaterp->canClose() && !floaterp->isDead() &&
-            (app_quitting || floaterp->getVisible()))
-        {
-            floaterp->closeFloater(app_quitting);
-        }
-    }
+	// iterate over a copy of the list, because closing windows will destroy
+	// some windows on the list.
+	child_list_t child_list = *(getChildList());
+
+	for (child_list_const_iter_t it = child_list.begin(); it != child_list.end(); ++it)
+	{
+		LLView* viewp = *it;
+		child_list_const_iter_t exists = std::find(getChildList()->begin(), getChildList()->end(), viewp);
+		if (exists == getChildList()->end())
+		{
+			// this floater has already been removed
+			continue;
+		}
+
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(viewp);
+
+		// Attempt to close floater.  This will cause the "do you want to save"
+		// dialogs to appear.
+		// Skip invisible floaters if we're not quitting (STORM-192).
+		if (floaterp->canClose() && !floaterp->isDead() &&
+			(app_quitting || floaterp->getVisible()))
+		{
+			floaterp->closeFloater(app_quitting);
+		}
+	}
 }
 
 void LLFloaterView::hiddenFloaterClosed(LLFloater* floater)
 {
-    for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
-        it != end_it;
-        ++it)
-    {
-        if (it->first.get() == floater)
-        {
-            it->second.disconnect();
-            mHiddenFloaters.erase(it);
-            break;
-        }
-    }
+	for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
+		it != end_it;
+		++it)
+	{
+		if (it->first.get() == floater)
+		{
+			it->second.disconnect();
+			mHiddenFloaters.erase(it);
+			break;
+		}
+	}
 }
 
 void LLFloaterView::hideAllFloaters()
 {
-    child_list_t child_list = *(getChildList());
+	child_list_t child_list = *(getChildList());
 
-    for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it)
-    {
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
-        if (floaterp && floaterp->getVisible())
-        {
-            floaterp->setVisible(false);
-            boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp));
-            mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection));
-        }
-    }
+	for (child_list_iter_t it = child_list.begin(); it != child_list.end(); ++it)
+	{
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+		if (floaterp && floaterp->getVisible())
+		{
+			floaterp->setVisible(false);
+			boost::signals2::connection connection = floaterp->mCloseSignal.connect(boost::bind(&LLFloaterView::hiddenFloaterClosed, this, floaterp));
+			mHiddenFloaters.push_back(std::make_pair(floaterp->getHandle(), connection));
+		}
+	}
 }
 
 void LLFloaterView::showHiddenFloaters()
 {
-    for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
-        it != end_it;
-        ++it)
-    {
-        LLFloater* floaterp = it->first.get();
-        if (floaterp)
-        {
-            floaterp->setVisible(true);
-        }
-        it->second.disconnect();
-    }
-    mHiddenFloaters.clear();
+	for (hidden_floaters_t::iterator it = mHiddenFloaters.begin(), end_it = mHiddenFloaters.end();
+		it != end_it;
+		++it)
+	{
+		LLFloater* floaterp = it->first.get();
+		if (floaterp)
+		{
+			floaterp->setVisible(true);
+		}
+		it->second.disconnect();
+	}
+	mHiddenFloaters.clear();
 }
 
 BOOL LLFloaterView::allChildrenClosed()
 {
-    // see if there are any visible floaters (some floaters "close"
-    // by setting themselves invisible)
-    for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
-    {
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+	// see if there are any visible floaters (some floaters "close"
+	// by setting themselves invisible)
+	for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
+	{
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
 
-        if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable())
-        {
-            return false;
-        }
-    }
-    return true;
+		if (floaterp->getVisible() && !floaterp->isDead() && floaterp->isCloseable())
+		{
+			return false;
+		}
+	}
+	return true;
 }
 
 void LLFloaterView::shiftFloaters(S32 x_offset, S32 y_offset)
 {
-    for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
-    {
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
+	for (child_list_const_iter_t it = getChildList()->begin(); it != getChildList()->end(); ++it)
+	{
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(*it);
 
-        if (floaterp && floaterp->isMinimized())
-        {
-            floaterp->translate(x_offset, y_offset);
-        }
-    }
+		if (floaterp && floaterp->isMinimized())
+		{
+			floaterp->translate(x_offset, y_offset);
+		}
+	}
 }
 
 void LLFloaterView::refresh()
 {
-    LLRect snap_rect = getSnapRect();
-    if (snap_rect != mLastSnapRect)
-    {
-        reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
-    }
-
-    // Constrain children to be entirely on the screen
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
-        if (floaterp && floaterp->getVisible() )
-        {
-            // minimized floaters are kept fully onscreen
-            adjustToFitScreen(floaterp, !floaterp->isMinimized());
-        }
-    }
+	LLRect snap_rect = getSnapRect();
+	if (snap_rect != mLastSnapRect)
+	{
+		reshape(getRect().getWidth(), getRect().getHeight(), TRUE);
+	}
+
+	// Constrain children to be entirely on the screen
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+		if (floaterp && floaterp->getVisible() )
+		{
+			// minimized floaters are kept fully onscreen
+			adjustToFitScreen(floaterp, !floaterp->isMinimized());
+		}
+	}
 }
 
 void LLFloaterView::adjustToFitScreen(LLFloater* floater, BOOL allow_partial_outside, BOOL snap_in_toolbars/* = false*/)
 {
-    if (floater->getParent() != this)
-    {
-        // floater is hosted elsewhere, so ignore
-        return;
-    }
-    LLRect::tCoordType screen_width = getSnapRect().getWidth();
-    LLRect::tCoordType screen_height = getSnapRect().getHeight();
-
-    
-    // only automatically resize non-minimized, resizable floaters
-    if( floater->isResizable() && !floater->isMinimized() )
-    {
-        LLRect view_rect = floater->getRect();
-        S32 old_width = view_rect.getWidth();
-        S32 old_height = view_rect.getHeight();
-        S32 min_width;
-        S32 min_height;
-        floater->getResizeLimits( &min_width, &min_height );
-
-        // Make sure floater isn't already smaller than its min height/width?
-        S32 new_width = llmax( min_width, old_width );
-        S32 new_height = llmax( min_height, old_height);
-
-        if((new_width > screen_width) || (new_height > screen_height))
-        {
-            // We have to make this window able to fit on screen
-            new_width = llmin(new_width, screen_width);
-            new_height = llmin(new_height, screen_height);
-
-            // ...while respecting minimum width/height
-            new_width = llmax(new_width, min_width);
-            new_height = llmax(new_height, min_height);
-
-            LLRect new_rect;
-            new_rect.setLeftTopAndSize(view_rect.mLeft,view_rect.mTop,new_width, new_height);
-
-            floater->setShape(new_rect);
-
-            if (floater->followsRight())
-            {
-                floater->translate(old_width - new_width, 0);
-            }
-
-            if (floater->followsTop())
-            {
-                floater->translate(0, old_height - new_height);
-            }
-        }
-    }
-
-    const LLRect& floater_rect = floater->getRect();
-
-    S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0;
-    S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0;
-    S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0;
-
-    // move window fully onscreen
-    if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX ))
-    {
-        floater->clearSnapTarget();
-    }
-    else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom)
-    {
-        floater->translate(delta_left, 0);
-    }
-    else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight)
-    {
-        floater->translate(0, delta_bottom);
-    }
-    else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop  && floater_rect.mBottom > mToolbarRightRect.mBottom)
-    {
-        floater->translate(delta_right, 0);
-    }
+	if (floater->getParent() != this)
+	{
+		// floater is hosted elsewhere, so ignore
+		return;
+	}
+	LLRect::tCoordType screen_width = getSnapRect().getWidth();
+	LLRect::tCoordType screen_height = getSnapRect().getHeight();
+
+	
+	// only automatically resize non-minimized, resizable floaters
+	if( floater->isResizable() && !floater->isMinimized() )
+	{
+		LLRect view_rect = floater->getRect();
+		S32 old_width = view_rect.getWidth();
+		S32 old_height = view_rect.getHeight();
+		S32 min_width;
+		S32 min_height;
+		floater->getResizeLimits( &min_width, &min_height );
+
+		// Make sure floater isn't already smaller than its min height/width?
+		S32 new_width = llmax( min_width, old_width );
+		S32 new_height = llmax( min_height, old_height);
+
+		if((new_width > screen_width) || (new_height > screen_height))
+		{
+			// We have to make this window able to fit on screen
+			new_width = llmin(new_width, screen_width);
+			new_height = llmin(new_height, screen_height);
+
+			// ...while respecting minimum width/height
+			new_width = llmax(new_width, min_width);
+			new_height = llmax(new_height, min_height);
+
+			LLRect new_rect;
+			new_rect.setLeftTopAndSize(view_rect.mLeft,view_rect.mTop,new_width, new_height);
+
+			floater->setShape(new_rect);
+
+			if (floater->followsRight())
+			{
+				floater->translate(old_width - new_width, 0);
+			}
+
+			if (floater->followsTop())
+			{
+				floater->translate(0, old_height - new_height);
+			}
+		}
+	}
+
+	const LLRect& floater_rect = floater->getRect();
+
+	S32 delta_left = mToolbarLeftRect.notEmpty() ? mToolbarLeftRect.mRight - floater_rect.mRight : 0;
+	S32 delta_bottom = mToolbarBottomRect.notEmpty() ? mToolbarBottomRect.mTop - floater_rect.mTop : 0;
+	S32 delta_right = mToolbarRightRect.notEmpty() ? mToolbarRightRect.mLeft - floater_rect.mLeft : 0;
+
+	// move window fully onscreen
+	if (floater->translateIntoRect( snap_in_toolbars ? getSnapRect() : gFloaterView->getRect(), allow_partial_outside ? FLOATER_MIN_VISIBLE_PIXELS : S32_MAX ))
+	{
+		floater->clearSnapTarget();
+	}
+	else if (delta_left > 0 && floater_rect.mTop < mToolbarLeftRect.mTop && floater_rect.mBottom > mToolbarLeftRect.mBottom)
+	{
+		floater->translate(delta_left, 0);
+	}
+	else if (delta_bottom > 0 && floater_rect.mLeft > mToolbarBottomRect.mLeft && floater_rect.mRight < mToolbarBottomRect.mRight)
+	{
+		floater->translate(0, delta_bottom);
+	}
+	else if (delta_right < 0 && floater_rect.mTop < mToolbarRightRect.mTop	&& floater_rect.mBottom > mToolbarRightRect.mBottom)
+	{
+		floater->translate(delta_right, 0);
+	}
 }
 
 void LLFloaterView::draw()
 {
-    refresh();
+	refresh();
 
-    // hide focused floater if in cycle mode, so that it can be drawn on top
-    LLFloater* focused_floater = getFocusedFloater();
+	// hide focused floater if in cycle mode, so that it can be drawn on top
+	LLFloater* focused_floater = getFocusedFloater();
 
-    if (mFocusCycleMode && focused_floater)
-    {
-        child_list_const_iter_t child_it = getChildList()->begin();
-        for (;child_it != getChildList()->end(); ++child_it)
-        {
-            if ((*child_it) != focused_floater)
-            {
-                drawChild(*child_it);
-            }
-        }
+	if (mFocusCycleMode && focused_floater)
+	{
+		child_list_const_iter_t child_it = getChildList()->begin();
+		for (;child_it != getChildList()->end(); ++child_it)
+		{
+			if ((*child_it) != focused_floater)
+			{
+				drawChild(*child_it);
+			}
+		}
 
-        drawChild(focused_floater, -TABBED_FLOATER_OFFSET, TABBED_FLOATER_OFFSET);
-    }
-    else
-    {
-        LLView::draw();
-    }
+		drawChild(focused_floater, -TABBED_FLOATER_OFFSET, TABBED_FLOATER_OFFSET);
+	}
+	else
+	{
+		LLView::draw();
+	}
 }
 
 LLRect LLFloaterView::getSnapRect() const
 {
-    LLRect snap_rect = getLocalRect();
+	LLRect snap_rect = getLocalRect();
 
-    LLView* snap_view = mSnapView.get();
-    if (snap_view)
-    {
-        snap_view->localRectToOtherView(snap_view->getLocalRect(), &snap_rect, this);
-    }
+	LLView* snap_view = mSnapView.get();
+	if (snap_view)
+	{
+		snap_view->localRectToOtherView(snap_view->getLocalRect(), &snap_rect, this);
+	}
 
-    return snap_rect;
+	return snap_rect;
 }
 
 LLFloater *LLFloaterView::getFocusedFloater() const
 {
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        if ((*child_it)->isCtrl())
-        {
-            LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it);
-            if ( ctrlp && ctrlp->hasFocus() )
-            {
-                return ctrlp;
-            }
-        }
-    }
-    return NULL;
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		if ((*child_it)->isCtrl())
+		{
+			LLFloater* ctrlp = dynamic_cast<LLFloater*>(*child_it);
+			if ( ctrlp && ctrlp->hasFocus() )
+			{
+				return ctrlp;
+			}
+		}
+	}
+	return NULL;
 }
 
 LLFloater *LLFloaterView::getFrontmost() const
 {
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLView* viewp = *child_it;
-        if ( viewp->getVisible() && !viewp->isDead())
-        {
-            return (LLFloater *)viewp;
-        }
-    }
-    return NULL;
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLView* viewp = *child_it;
+		if ( viewp->getVisible() && !viewp->isDead())
+		{
+			return (LLFloater *)viewp;
+		}
+	}
+	return NULL;
 }
 
 LLFloater *LLFloaterView::getBackmost() const
 {
-    LLFloater* back_most = NULL;
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLView* viewp = *child_it;
-        if ( viewp->getVisible() )
-        {
-            back_most = (LLFloater *)viewp;
-        }
-    }
-    return back_most;
+	LLFloater* back_most = NULL;
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLView* viewp = *child_it;
+		if ( viewp->getVisible() )
+		{
+			back_most = (LLFloater *)viewp;
+		}
+	}
+	return back_most;
 }
 
 void LLFloaterView::syncFloaterTabOrder()
 {
-    // look for a visible modal dialog, starting from first
-    LLModalDialog* modal_dialog = NULL;
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLModalDialog* dialog = dynamic_cast<LLModalDialog*>(*child_it);
-        if (dialog && dialog->isModal() && dialog->getVisible())
-        {
-            modal_dialog = dialog;
-            break;
-        }
-    }
-
-    if (modal_dialog)
-    {
-        // If we have a visible modal dialog, make sure that it has focus
-        LLUI::addPopup(modal_dialog);
-        
-        if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) )
-        {
-            modal_dialog->setFocus(TRUE);
-        }
-                
-        if( !gFocusMgr.childHasMouseCapture( modal_dialog ) )
-        {
-            gFocusMgr.setMouseCapture( modal_dialog );
-        }
-    }
-    else
-    {
-        // otherwise, make sure the focused floater is in the front of the child list
-        for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it)
-        {
-            LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
-            if (gFocusMgr.childHasKeyboardFocus(floaterp))
-            {
-                bringToFront(floaterp, FALSE);
-                break;
-            }
-        }
-    }
-}
-
-LLFloater*  LLFloaterView::getParentFloater(LLView* viewp) const
-{
-    LLView* parentp = viewp->getParent();
-
-    while(parentp && parentp != this)
-    {
-        viewp = parentp;
-        parentp = parentp->getParent();
-    }
-
-    if (parentp == this)
-    {
-        return dynamic_cast<LLFloater*>(viewp);
-    }
-
-    return NULL;
+	// look for a visible modal dialog, starting from first
+	LLModalDialog* modal_dialog = NULL;
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLModalDialog* dialog = dynamic_cast<LLModalDialog*>(*child_it);
+		if (dialog && dialog->isModal() && dialog->getVisible())
+		{
+			modal_dialog = dialog;
+			break;
+		}
+	}
+
+	if (modal_dialog)
+	{
+		// If we have a visible modal dialog, make sure that it has focus
+		LLUI::addPopup(modal_dialog);
+		
+		if( !gFocusMgr.childHasKeyboardFocus( modal_dialog ) )
+		{
+			modal_dialog->setFocus(TRUE);
+		}
+				
+		if( !gFocusMgr.childHasMouseCapture( modal_dialog ) )
+		{
+			gFocusMgr.setMouseCapture( modal_dialog );
+		}
+	}
+	else
+	{
+		// otherwise, make sure the focused floater is in the front of the child list
+		for ( child_list_const_reverse_iter_t child_it = getChildList()->rbegin(); child_it != getChildList()->rend(); ++child_it)
+		{
+			LLFloater* floaterp = dynamic_cast<LLFloater*>(*child_it);
+			if (gFocusMgr.childHasKeyboardFocus(floaterp))
+			{
+				bringToFront(floaterp, FALSE);
+				break;
+			}
+		}
+	}
+}
+
+LLFloater*	LLFloaterView::getParentFloater(LLView* viewp) const
+{
+	LLView* parentp = viewp->getParent();
+
+	while(parentp && parentp != this)
+	{
+		viewp = parentp;
+		parentp = parentp->getParent();
+	}
+
+	if (parentp == this)
+	{
+		return dynamic_cast<LLFloater*>(viewp);
+	}
+
+	return NULL;
 }
 
 S32 LLFloaterView::getZOrder(LLFloater* child)
 {
-    S32 rv = 0;
-    for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
-    {
-        LLView* viewp = *child_it;
-        if(viewp == child)
-        {
-            break;
-        }
-        ++rv;
-    }
-    return rv;
+	S32 rv = 0;
+	for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it)
+	{
+		LLView* viewp = *child_it;
+		if(viewp == child)
+		{
+			break;
+		}
+		++rv;
+	}
+	return rv;
 }
 
 void LLFloaterView::pushVisibleAll(BOOL visible, const skip_list_t& skip_list)
 {
-    for (child_list_const_iter_t child_iter = getChildList()->begin();
-         child_iter != getChildList()->end(); ++child_iter)
-    {
-        LLView *view = *child_iter;
-        if (skip_list.find(view) == skip_list.end())
-        {
-            view->pushVisible(visible);
-        }
-    }
+	for (child_list_const_iter_t child_iter = getChildList()->begin();
+		 child_iter != getChildList()->end(); ++child_iter)
+	{
+		LLView *view = *child_iter;
+		if (skip_list.find(view) == skip_list.end())
+		{
+			view->pushVisible(visible);
+		}
+	}
 
-    LLFloaterReg::blockShowFloaters(true);
+	LLFloaterReg::blockShowFloaters(true);
 }
 
 void LLFloaterView::popVisibleAll(const skip_list_t& skip_list)
 {
-    // make a copy of the list since some floaters change their
-    // order in the childList when changing visibility.
-    child_list_t child_list_copy = *getChildList();
+	// make a copy of the list since some floaters change their
+	// order in the childList when changing visibility.
+	child_list_t child_list_copy = *getChildList();
 
-    for (child_list_const_iter_t child_iter = child_list_copy.begin();
-         child_iter != child_list_copy.end(); ++child_iter)
-    {
-        LLView *view = *child_iter;
-        if (skip_list.find(view) == skip_list.end())
-        {
-            view->popVisible();
-        }
-    }
+	for (child_list_const_iter_t child_iter = child_list_copy.begin();
+		 child_iter != child_list_copy.end(); ++child_iter)
+	{
+		LLView *view = *child_iter;
+		if (skip_list.find(view) == skip_list.end())
+		{
+			view->popVisible();
+		}
+	}
 
-    LLFloaterReg::blockShowFloaters(false);
+	LLFloaterReg::blockShowFloaters(false);
 }
 
 void LLFloaterView::setToolbarRect(LLToolBarEnums::EToolBarLocation tb, const LLRect& toolbar_rect)
 {
-    switch (tb)
-    {
-    case LLToolBarEnums::TOOLBAR_LEFT:
-        mToolbarLeftRect = toolbar_rect;
-        break;
-    case LLToolBarEnums::TOOLBAR_BOTTOM:
-        mToolbarBottomRect = toolbar_rect;
-        break;
-    case LLToolBarEnums::TOOLBAR_RIGHT:
-        mToolbarRightRect = toolbar_rect;
-        break;
-    default:
-        LL_WARNS() << "setToolbarRect() passed odd toolbar number " << (S32) tb << LL_ENDL;
-        break;
-    }
+	switch (tb)
+	{
+	case LLToolBarEnums::TOOLBAR_LEFT:
+		mToolbarLeftRect = toolbar_rect;
+		break;
+	case LLToolBarEnums::TOOLBAR_BOTTOM:
+		mToolbarBottomRect = toolbar_rect;
+		break;
+	case LLToolBarEnums::TOOLBAR_RIGHT:
+		mToolbarRightRect = toolbar_rect;
+		break;
+	default:
+		LL_WARNS() << "setToolbarRect() passed odd toolbar number " << (S32) tb << LL_ENDL;
+		break;
+	}
 }
 
 void LLFloater::setInstanceName(const std::string& name)
 {
-    if (name != mInstanceName)
-    {
-    llassert_always(mInstanceName.empty());
-    mInstanceName = name;
-    if (!mInstanceName.empty())
-    {
-        std::string ctrl_name = getControlName(mInstanceName, mKey);
-            initRectControl();
-        if (!mVisibilityControl.empty())
-        {
-            mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name);
-        }
-        if(!mDocStateControl.empty())
-        {
-            mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
-        }
-    }
+	if (name != mInstanceName)
+	{
+	llassert_always(mInstanceName.empty());
+	mInstanceName = name;
+	if (!mInstanceName.empty())
+	{
+		std::string ctrl_name = getControlName(mInstanceName, mKey);
+			initRectControl();
+		if (!mVisibilityControl.empty())
+		{
+			mVisibilityControl = LLFloaterReg::declareVisibilityControl(ctrl_name);
+		}
+		if(!mDocStateControl.empty())
+		{
+			mDocStateControl = LLFloaterReg::declareDockStateControl(ctrl_name);
+		}
+	}
 }
 }
 
 void LLFloater::setKey(const LLSD& newkey)
 {
-    // Note: We don't have to do anything special with registration when we change keys
-    mKey = newkey;
+	// Note: We don't have to do anything special with registration when we change keys
+	mKey = newkey;
 }
 
 //static
 void LLFloater::setupParamsForExport(Params& p, LLView* parent)
 {
-    // Do rectangle munging to topleft layout first
-    LLPanel::setupParamsForExport(p, parent);
+	// Do rectangle munging to topleft layout first
+	LLPanel::setupParamsForExport(p, parent);
 
-    // Copy the rectangle out to apply layout constraints
-    LLRect rect = p.rect;
+	// Copy the rectangle out to apply layout constraints
+	LLRect rect = p.rect;
 
-    // Null out other settings
-    p.rect.left.setProvided(false);
-    p.rect.top.setProvided(false);
-    p.rect.right.setProvided(false);
-    p.rect.bottom.setProvided(false);
+	// Null out other settings
+	p.rect.left.setProvided(false);
+	p.rect.top.setProvided(false);
+	p.rect.right.setProvided(false);
+	p.rect.bottom.setProvided(false);
 
-    // Explicitly set width/height
-    p.rect.width.set( rect.getWidth(), true );
-    p.rect.height.set( rect.getHeight(), true );
+	// Explicitly set width/height
+	p.rect.width.set( rect.getWidth(), true );
+	p.rect.height.set( rect.getHeight(), true );
 
-    // If you can't resize this floater, don't export min_height
-    // and min_width
-    bool can_resize = p.can_resize;
-    if (!can_resize)
-    {
-        p.min_height.setProvided(false);
-        p.min_width.setProvided(false);
-    }
+	// If you can't resize this floater, don't export min_height
+	// and min_width
+	bool can_resize = p.can_resize;
+	if (!can_resize)
+	{
+		p.min_height.setProvided(false);
+		p.min_width.setProvided(false);
+	}
 }
 
 void LLFloater::initFromParams(const LLFloater::Params& p)
 {
-    // *NOTE: We have too many classes derived from LLFloater to retrofit them 
-    // all to pass in params via constructors.  So we use this method.
-
-     // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
-    LLPanel::initFromParams(p);
-
-    // override any follows flags
-    if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED)
-    {
-        setFollows(FOLLOWS_NONE);
-    }
-
-    mTitle = p.title;
-    mShortTitle = p.short_title;
-    applyTitle();
-
-    setCanTearOff(p.can_tear_off);
-    setCanMinimize(p.can_minimize);
-    setCanClose(p.can_close);
-    setCanDock(p.can_dock);
-    setCanResize(p.can_resize);
-    setResizeLimits(p.min_width, p.min_height);
-    
-    mDragOnLeft = p.can_drag_on_left;
-    mHeaderHeight = p.header_height;
-    mLegacyHeaderHeight = p.legacy_header_height;
-    mSingleInstance = p.single_instance;
-    mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance;
-
-    mPositioning = p.positioning;
-
-    mSaveRect = p.save_rect;
-    if (p.save_visibility)
-    {
-        mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
-    }
-    if(p.save_dock_state)
-    {
-        mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set
-    }
-    
-    // open callback 
-    if (p.open_callback.isProvided())
-    {
-        setOpenCallback(initCommitCallback(p.open_callback));
-    }
-    // close callback 
-    if (p.close_callback.isProvided())
-    {
-        setCloseCallback(initCommitCallback(p.close_callback));
-    }
-
-    if (mDragHandle)
-    {
-        mDragHandle->setTitleVisible(p.show_title);
-    }
+	// *NOTE: We have too many classes derived from LLFloater to retrofit them 
+	// all to pass in params via constructors.  So we use this method.
+
+	 // control_name, tab_stop, focus_lost_callback, initial_value, rect, enabled, visible
+	LLPanel::initFromParams(p);
+
+	// override any follows flags
+	if (mPositioning != LLFloaterEnums::POSITIONING_SPECIFIED)
+	{
+		setFollows(FOLLOWS_NONE);
+	}
+
+	mTitle = p.title;
+	mShortTitle = p.short_title;
+	applyTitle();
+
+	setCanTearOff(p.can_tear_off);
+	setCanMinimize(p.can_minimize);
+	setCanClose(p.can_close);
+	setCanDock(p.can_dock);
+	setCanResize(p.can_resize);
+	setResizeLimits(p.min_width, p.min_height);
+	
+	mDragOnLeft = p.can_drag_on_left;
+	mHeaderHeight = p.header_height;
+	mLegacyHeaderHeight = p.legacy_header_height;
+	mSingleInstance = p.single_instance;
+	mReuseInstance = p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance;
+
+	mPositioning = p.positioning;
+
+	mSaveRect = p.save_rect;
+	if (p.save_visibility)
+	{
+		mVisibilityControl = "t"; // flag to build mVisibilityControl name once mInstanceName is set
+	}
+	if(p.save_dock_state)
+	{
+		mDocStateControl = "t"; // flag to build mDocStateControl name once mInstanceName is set
+	}
+	
+	// open callback 
+	if (p.open_callback.isProvided())
+	{
+		setOpenCallback(initCommitCallback(p.open_callback));
+	}
+	// close callback 
+	if (p.close_callback.isProvided())
+	{
+		setCloseCallback(initCommitCallback(p.close_callback));
+	}
+
+	if (mDragHandle)
+	{
+		mDragHandle->setTitleVisible(p.show_title);
+	}
 }
 
 boost::signals2::connection LLFloater::setMinimizeCallback( const commit_signal_t::slot_type& cb ) 
 { 
-    if (!mMinimizeSignal) mMinimizeSignal = new commit_signal_t();
-    return mMinimizeSignal->connect(cb); 
+	if (!mMinimizeSignal) mMinimizeSignal = new commit_signal_t();
+	return mMinimizeSignal->connect(cb); 
 }
 
 boost::signals2::connection LLFloater::setOpenCallback( const commit_signal_t::slot_type& cb )
 {
-    return mOpenSignal.connect(cb);
+	return mOpenSignal.connect(cb);
 }
 
 boost::signals2::connection LLFloater::setCloseCallback( const commit_signal_t::slot_type& cb )
 {
-    return mCloseSignal.connect(cb);
+	return mCloseSignal.connect(cb);
 }
 
 LLTrace::BlockTimerStatHandle POST_BUILD("Floater Post Build");
@@ -3181,127 +3181,127 @@ static LLTrace::BlockTimerStatHandle FTM_EXTERNAL_FLOATER_LOAD("Load Extern Floa
 
 bool LLFloater::initFloaterXML(LLXMLNodePtr node, LLView *parent, const std::string& filename, LLXMLNodePtr output_node)
 {
-    Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
-    Params params(default_params);
-
-    LLXUIParser parser;
-    parser.readXUI(node, params, filename); // *TODO: Error checking
-
-    std::string xml_filename = params.filename;
-
-    if (!xml_filename.empty())
-    {
-        LLXMLNodePtr referenced_xml;
-
-        if (output_node)
-        {
-            //if we are exporting, we want to export the current xml
-            //not the referenced xml
-            Params output_params;
-            parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName());
-            setupParamsForExport(output_params, parent);
-            output_node->setName(node->getName()->mString);
-            parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
-            return TRUE;
-        }
-
-        LLUICtrlFactory::instance().pushFileName(xml_filename);
-
-        LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_FLOATER_LOAD);
-        if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
-        {
-            LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL;
-
-            return FALSE;
-        }
-
-        Params referenced_params;
-        parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName());
-        params.fillFrom(referenced_params);
-
-        // add children using dimensions from referenced xml for consistent layout
-        setShape(params.rect);
-        LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
-
-        LLUICtrlFactory::instance().popFileName();
-    }
-
-
-    if (output_node)
-    {
-        Params output_params(params);
-        setupParamsForExport(output_params, parent);
-        output_node->setName(node->getName()->mString);
-        parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
-    }
-
-    // Default floater position to top-left corner of screen
-    // However, some legacy floaters have explicit top or bottom
-    // coordinates set, so respect their wishes.
-    if (!params.rect.top.isProvided() && !params.rect.bottom.isProvided())
-    {
-        params.rect.top.set(0);
-    }
-    if (!params.rect.left.isProvided() && !params.rect.right.isProvided())
-    {
-        params.rect.left.set(0);
-    }
-    params.from_xui = true;
-    applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect());
-    initFromParams(params);
-
-    initFloater(params);
-    
-    LLMultiFloater* last_host = LLFloater::getFloaterHost();
-    if (node->hasName("multi_floater"))
-    {
-        LLFloater::setFloaterHost((LLMultiFloater*) this);
-    }
-
-    LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
-
-    if (node->hasName("multi_floater"))
-    {
-        LLFloater::setFloaterHost(last_host);
-    }
-    
-    // HACK: When we changed the header height to 25 pixels in Viewer 2, rather
-    // than re-layout all the floaters we use this value in pixels to make the
-    // whole floater bigger and change the top-left coordinate for widgets.
-    // The goal is to eventually set mLegacyHeaderHeight to zero, which would
-    // make the top-left corner for widget layout the same as the top-left
-    // corner of the window's content area.  James
-    S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight);
-    if (header_stretch > 0)
-    {
-        // Stretch the floater vertically, don't move widgets
-        LLRect rect = getRect();
-        rect.mTop += header_stretch;
-
-        // This will also update drag handle, title bar, close box, etc.
-        setRect(rect);
-    }
-
-    BOOL result;
-    {
-        LL_RECORD_BLOCK_TIME(POST_BUILD);
-
-        result = postBuild();
-    }
-
-    if (!result)
-    {
-        LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL;
-    }
-
-    applyRectControl(); // If we have a saved rect control, apply it
-    gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen  
-
-    moveResizeHandlesToFront();
-
-    applyDockState();
-
-    return true; // *TODO: Error checking
+	Params default_params(LLUICtrlFactory::getDefaultParams<LLFloater>());
+	Params params(default_params);
+
+	LLXUIParser parser;
+	parser.readXUI(node, params, filename); // *TODO: Error checking
+
+	std::string xml_filename = params.filename;
+
+	if (!xml_filename.empty())
+	{
+		LLXMLNodePtr referenced_xml;
+
+		if (output_node)
+		{
+			//if we are exporting, we want to export the current xml
+			//not the referenced xml
+			Params output_params;
+			parser.readXUI(node, output_params, LLUICtrlFactory::getInstance()->getCurFileName());
+			setupParamsForExport(output_params, parent);
+			output_node->setName(node->getName()->mString);
+			parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
+			return TRUE;
+		}
+
+		LLUICtrlFactory::instance().pushFileName(xml_filename);
+
+		LL_RECORD_BLOCK_TIME(FTM_EXTERNAL_FLOATER_LOAD);
+		if (!LLUICtrlFactory::getLayeredXMLNode(xml_filename, referenced_xml))
+		{
+			LL_WARNS() << "Couldn't parse panel from: " << xml_filename << LL_ENDL;
+
+			return FALSE;
+		}
+
+		Params referenced_params;
+		parser.readXUI(referenced_xml, referenced_params, LLUICtrlFactory::getInstance()->getCurFileName());
+		params.fillFrom(referenced_params);
+
+		// add children using dimensions from referenced xml for consistent layout
+		setShape(params.rect);
+		LLUICtrlFactory::createChildren(this, referenced_xml, child_registry_t::instance());
+
+		LLUICtrlFactory::instance().popFileName();
+	}
+
+
+	if (output_node)
+	{
+		Params output_params(params);
+		setupParamsForExport(output_params, parent);
+		output_node->setName(node->getName()->mString);
+		parser.writeXUI(output_node, output_params, LLInitParam::default_parse_rules(), &default_params);
+	}
+
+	// Default floater position to top-left corner of screen
+	// However, some legacy floaters have explicit top or bottom
+	// coordinates set, so respect their wishes.
+	if (!params.rect.top.isProvided() && !params.rect.bottom.isProvided())
+	{
+		params.rect.top.set(0);
+	}
+	if (!params.rect.left.isProvided() && !params.rect.right.isProvided())
+	{
+		params.rect.left.set(0);
+	}
+	params.from_xui = true;
+	applyXUILayout(params, parent, parent == gFloaterView ? gFloaterView->getSnapRect() : parent->getLocalRect());
+ 	initFromParams(params);
+
+	initFloater(params);
+	
+	LLMultiFloater* last_host = LLFloater::getFloaterHost();
+	if (node->hasName("multi_floater"))
+	{
+		LLFloater::setFloaterHost((LLMultiFloater*) this);
+	}
+
+	LLUICtrlFactory::createChildren(this, node, child_registry_t::instance(), output_node);
+
+	if (node->hasName("multi_floater"))
+	{
+		LLFloater::setFloaterHost(last_host);
+	}
+	
+	// HACK: When we changed the header height to 25 pixels in Viewer 2, rather
+	// than re-layout all the floaters we use this value in pixels to make the
+	// whole floater bigger and change the top-left coordinate for widgets.
+	// The goal is to eventually set mLegacyHeaderHeight to zero, which would
+	// make the top-left corner for widget layout the same as the top-left
+	// corner of the window's content area.  James
+	S32 header_stretch = (mHeaderHeight - mLegacyHeaderHeight);
+	if (header_stretch > 0)
+	{
+		// Stretch the floater vertically, don't move widgets
+		LLRect rect = getRect();
+		rect.mTop += header_stretch;
+
+		// This will also update drag handle, title bar, close box, etc.
+		setRect(rect);
+	}
+
+	BOOL result;
+	{
+		LL_RECORD_BLOCK_TIME(POST_BUILD);
+
+		result = postBuild();
+	}
+
+	if (!result)
+	{
+		LL_ERRS() << "Failed to construct floater " << getName() << LL_ENDL;
+	}
+
+	applyRectControl(); // If we have a saved rect control, apply it
+	gFloaterView->adjustToFitScreen(this, FALSE); // Floaters loaded from XML should all fit on screen	
+
+	moveResizeHandlesToFront();
+
+	applyDockState();
+
+	return true; // *TODO: Error checking
 }
 
 bool LLFloater::isShown() const
@@ -3311,7 +3311,7 @@ bool LLFloater::isShown() const
 
 bool LLFloater::isDetachedAndNotMinimized()
 {
-    return !getHost() && !isMinimized();
+	return !getHost() && !isMinimized();
 }
 
 /* static */
@@ -3336,205 +3336,205 @@ static LLTrace::BlockTimerStatHandle FTM_BUILD_FLOATERS("Build Floaters");
 
 bool LLFloater::buildFromFile(const std::string& filename)
 {
-    LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS);
-    LLXMLNodePtr root;
-
-    if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
-    {
-        LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL;
-        return false;
-    }
-    
-    // root must be called floater
-    if( !(root->hasName("floater") || root->hasName("multi_floater")) )
-    {
-        LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL;
-        return false;
-    }
-    
-    bool res = true;
-    
-    LL_DEBUGS() << "Building floater " << filename << LL_ENDL;
-    LLUICtrlFactory::instance().pushFileName(filename);
-    {
-        if (!getFactoryMap().empty())
-        {
-            LLPanel::sFactoryStack.push_front(&getFactoryMap());
-        }
-
-         // for local registry callbacks; define in constructor, referenced in XUI or postBuild
-        getCommitCallbackRegistrar().pushScope();
-        getEnableCallbackRegistrar().pushScope();
-        
-        res = initFloaterXML(root, getParent(), filename, NULL);
-
-        setXMLFilename(filename);
-        
-        getCommitCallbackRegistrar().popScope();
-        getEnableCallbackRegistrar().popScope();
-        
-        if (!getFactoryMap().empty())
-        {
-            LLPanel::sFactoryStack.pop_front();
-        }
-    }
-    LLUICtrlFactory::instance().popFileName();
-    
-    return res;
+	LL_RECORD_BLOCK_TIME(FTM_BUILD_FLOATERS);
+	LLXMLNodePtr root;
+
+	if (!LLUICtrlFactory::getLayeredXMLNode(filename, root))
+	{
+		LL_WARNS() << "Couldn't find (or parse) floater from: " << filename << LL_ENDL;
+		return false;
+	}
+	
+	// root must be called floater
+	if( !(root->hasName("floater") || root->hasName("multi_floater")) )
+	{
+		LL_WARNS() << "Root node should be named floater in: " << filename << LL_ENDL;
+		return false;
+	}
+	
+	bool res = true;
+	
+	LL_DEBUGS() << "Building floater " << filename << LL_ENDL;
+	LLUICtrlFactory::instance().pushFileName(filename);
+	{
+		if (!getFactoryMap().empty())
+		{
+			LLPanel::sFactoryStack.push_front(&getFactoryMap());
+		}
+
+		 // for local registry callbacks; define in constructor, referenced in XUI or postBuild
+		getCommitCallbackRegistrar().pushScope();
+		getEnableCallbackRegistrar().pushScope();
+		
+		res = initFloaterXML(root, getParent(), filename, NULL);
+
+		setXMLFilename(filename);
+		
+		getCommitCallbackRegistrar().popScope();
+		getEnableCallbackRegistrar().popScope();
+		
+		if (!getFactoryMap().empty())
+		{
+			LLPanel::sFactoryStack.pop_front();
+		}
+	}
+	LLUICtrlFactory::instance().popFileName();
+	
+	return res;
 }
 
 void LLFloater::stackWith(LLFloater& other)
 {
-    static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16);
+	static LLUICachedControl<S32> floater_offset ("UIFloaterOffset", 16);
 
-    LLRect next_rect;
-    if (other.getHost())
-    {
-        next_rect = other.getHost()->getRect();
-    }
-    else
-    {
-        next_rect = other.getRect();
-    }
-    next_rect.translate(floater_offset, -floater_offset);
+	LLRect next_rect;
+	if (other.getHost())
+	{
+		next_rect = other.getHost()->getRect();
+	}
+	else
+	{
+		next_rect = other.getRect();
+	}
+	next_rect.translate(floater_offset, -floater_offset);
 
-    next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight());
-    
-    setShape(next_rect);
+	next_rect.setLeftTopAndSize(next_rect.mLeft, next_rect.mTop, getRect().getWidth(), getRect().getHeight());
+	
+	setShape(next_rect);
 
-    if (!other.getHost())
-    {
-        other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
-        other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
-    }
+	if (!other.getHost())
+	{
+		other.mPositioning = LLFloaterEnums::POSITIONING_CASCADE_GROUP;
+		other.setFollows(FOLLOWS_LEFT | FOLLOWS_TOP);
+	}
 }
 
 void LLFloater::applyRelativePosition()
 {
-    LLRect snap_rect = gFloaterView->getSnapRect();
-    LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
-    snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
-    LLRect floater_screen_rect = calcScreenRect();
+	LLRect snap_rect = gFloaterView->getSnapRect();
+	LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+	snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+	LLRect floater_screen_rect = calcScreenRect();
 
-    LLCoordGL new_center = mPosition.convert();
-    LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY());
-    translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY);
+	LLCoordGL new_center = mPosition.convert();
+	LLCoordGL cur_center(floater_screen_rect.getCenterX(), floater_screen_rect.getCenterY());
+	translate(new_center.mX - cur_center.mX, new_center.mY - cur_center.mY);
 }
 
 
 LLCoordFloater::LLCoordFloater(F32 x, F32 y, LLFloater& floater)
-:   coord_t((S32)x, (S32)y)
+:	coord_t((S32)x, (S32)y)
 {
-    mFloater = floater.getHandle();
+	mFloater = floater.getHandle();
 }
 
 
 LLCoordFloater::LLCoordFloater(const LLCoordCommon& other, LLFloater& floater)
 {
-    mFloater = floater.getHandle();
-    convertFromCommon(other);
+	mFloater = floater.getHandle();
+	convertFromCommon(other);
 }
 
 LLCoordFloater& LLCoordFloater::operator=(const LLCoordFloater& other)
 {
-    mFloater = other.mFloater;
-    coord_t::operator =(other);
-    return *this;
+	mFloater = other.mFloater;
+	coord_t::operator =(other);
+	return *this;
 }
 
 void LLCoordFloater::setFloater(LLFloater& floater)
 {
-    mFloater = floater.getHandle();
+	mFloater = floater.getHandle();
 }
 
 bool LLCoordFloater::operator==(const LLCoordFloater& other) const 
 { 
-    return mX == other.mX && mY == other.mY && mFloater == other.mFloater; 
+	return mX == other.mX && mY == other.mY && mFloater == other.mFloater; 
 }
 
 LLCoordCommon LL_COORD_FLOATER::convertToCommon() const
 {
-    const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
-
-    LLRect snap_rect = gFloaterView->getSnapRect();
-    LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
-    snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
-
-    LLFloater* floaterp = mFloater.get();
-    S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
-    S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
-    LLCoordCommon out;
-    if (self.mX < -0.5f)
-    {
-        out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft));
-    }
-    else if (self.mX > 0.5f)
-    {
-        out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS));
-    }
-    else
-    {
-        out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width));
-    }
-
-    if (self.mY < -0.5f)
-    {
-        out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom));
-    }
-    else if (self.mY > 0.5f)
-    {
-        out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS));
-    }
-    else
-    {
-        out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height));
-    }
-
-    // return center point instead of lower left
-    out.mX += floater_width / 2;
-    out.mY += floater_height / 2;
-
-    return out;
+	const LLCoordFloater& self = static_cast<const LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
+
+	LLRect snap_rect = gFloaterView->getSnapRect();
+	LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+	snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+
+	LLFloater* floaterp = mFloater.get();
+	S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
+	S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
+	LLCoordCommon out;
+	if (self.mX < -0.5f)
+	{
+		out.mX = ll_round(rescale(self.mX, -1.f, -0.5f, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft));
+	}
+	else if (self.mX > 0.5f)
+	{
+		out.mX = ll_round(rescale(self.mX, 0.5f, 1.f, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS));
+	}
+	else
+	{
+		out.mX = ll_round(rescale(self.mX, -0.5f, 0.5f, snap_rect.mLeft, snap_rect.mRight - floater_width));
+	}
+
+	if (self.mY < -0.5f)
+	{
+		out.mY = ll_round(rescale(self.mY, -1.f, -0.5f, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom));
+	}
+	else if (self.mY > 0.5f)
+	{
+		out.mY = ll_round(rescale(self.mY, 0.5f, 1.f, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS));
+	}
+	else
+	{
+		out.mY = ll_round(rescale(self.mY, -0.5f, 0.5f, snap_rect.mBottom, snap_rect.mTop - floater_height));
+	}
+
+	// return center point instead of lower left
+	out.mX += floater_width / 2;
+	out.mY += floater_height / 2;
+
+	return out;
 }
 
 void LL_COORD_FLOATER::convertFromCommon(const LLCoordCommon& from)
 {
-    LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
-    LLRect snap_rect = gFloaterView->getSnapRect();
-    LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
-    snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
-
-
-    LLFloater* floaterp = mFloater.get();
-    S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
-    S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
-
-    S32 from_x = from.mX - floater_width / 2;
-    S32 from_y = from.mY - floater_height / 2;
-
-    if (from_x < snap_rect.mLeft)
-    {
-        self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f);
-    }
-    else if (from_x + floater_width > snap_rect.mRight)
-    {
-        self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
-    }
-    else
-    {
-        self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f);
-    }
-
-    if (from_y < snap_rect.mBottom)
-    {
-        self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f);
-    }
-    else if (from_y + floater_height > snap_rect.mTop)
-    {
-        self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
-    }
-    else
-    {
-        self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f);
-    }
+	LLCoordFloater& self = static_cast<LLCoordFloater&>(LLCoordFloater::getTypedCoords(*this));
+	LLRect snap_rect = gFloaterView->getSnapRect();
+	LLRect floater_view_screen_rect = gFloaterView->calcScreenRect();
+	snap_rect.translate(floater_view_screen_rect.mLeft, floater_view_screen_rect.mBottom);
+
+
+	LLFloater* floaterp = mFloater.get();
+	S32 floater_width = floaterp ? floaterp->getRect().getWidth() : 0;
+	S32 floater_height = floaterp ? floaterp->getRect().getHeight() : 0;
+
+	S32 from_x = from.mX - floater_width / 2;
+	S32 from_y = from.mY - floater_height / 2;
+
+	if (from_x < snap_rect.mLeft)
+	{
+		self.mX = rescale(from_x, snap_rect.mLeft - (floater_width - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mLeft, -1.f, -0.5f);
+	}
+	else if (from_x + floater_width > snap_rect.mRight)
+	{
+		self.mX = rescale(from_x, snap_rect.mRight - floater_width, snap_rect.mRight - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
+	}
+	else
+	{
+		self.mX = rescale(from_x, snap_rect.mLeft, snap_rect.mRight - floater_width, -0.5f, 0.5f);
+	}
+
+	if (from_y < snap_rect.mBottom)
+	{
+		self.mY = rescale(from_y, snap_rect.mBottom - (floater_height - FLOATER_MIN_VISIBLE_PIXELS), snap_rect.mBottom, -1.f, -0.5f);
+	}
+	else if (from_y + floater_height > snap_rect.mTop)
+	{
+		self.mY = rescale(from_y, snap_rect.mTop - floater_height, snap_rect.mTop - FLOATER_MIN_VISIBLE_PIXELS, 0.5f, 1.f);
+	}
+	else
+	{
+		self.mY = rescale(from_y, snap_rect.mBottom, snap_rect.mTop - floater_height, -0.5f, 0.5f);
+	}
 }
diff --git a/indra/llui/lluictrl.h b/indra/llui/lluictrl.h
index 1386f1290a..e53ecd30c2 100644
--- a/indra/llui/lluictrl.h
+++ b/indra/llui/lluictrl.h
@@ -36,298 +36,298 @@
 
 #include "llinitparam.h"
 #include "llview.h"
-#include "llviewmodel.h"        // *TODO move dependency to .cpp file
+#include "llviewmodel.h"		// *TODO move dependency to .cpp file
 
 const BOOL TAKE_FOCUS_YES = TRUE;
 const BOOL TAKE_FOCUS_NO  = FALSE;
 
 class LLUICtrl
-    : public LLView, public boost::signals2::trackable
+	: public LLView, public boost::signals2::trackable
 {
 public:
-    typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t;
-    typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
-    // *TODO: add xml support for this type of signal in the future
-    typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t;
-    
-    typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t;
-    typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t;
-    
-    struct CallbackParam : public LLInitParam::Block<CallbackParam>
-    {
-        Ignored                 name;
-
-        Optional<std::string>   function_name;
-        Optional<LLSD>          parameter;
-
-        Optional<std::string>   control_name;
-        
-        CallbackParam();
-    };
-
-    struct CommitCallbackParam : public LLInitParam::Block<CommitCallbackParam, CallbackParam >
-    {
-        Optional<commit_callback_t> function;
-    };
-
-    // also used for visible callbacks
-    struct EnableCallbackParam : public LLInitParam::Block<EnableCallbackParam, CallbackParam >
-    {
-        Optional<enable_callback_t> function;
-    };
-        
-    struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls>
-    {
-        Alternative<std::string> enabled;
-        Alternative<std::string> disabled;
-        
-        EnableControls();
-    };  
-    struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility>
-    {
-        Alternative<std::string> visible;
-        Alternative<std::string> invisible;
-
-        ControlVisibility();
-    };  
-    struct Params : public LLInitParam::Block<Params, LLView::Params>
-    {
-        Optional<std::string>           label;
-        Optional<bool>                  tab_stop,
-                                        chrome,
-                                        requests_front;
-        Optional<LLSD>                  initial_value;
-
-        Optional<CommitCallbackParam>   init_callback,
-                                        commit_callback;
-        Optional<EnableCallbackParam>   validate_callback;
-        
-        Optional<CommitCallbackParam>   mouseenter_callback,
-                                        mouseleave_callback;
-        
-        Optional<std::string>           control_name;
-        Optional<EnableControls>        enabled_controls;
-        Optional<ControlVisibility>     controls_visibility;
-        
-        // font params
-        Optional<const LLFontGL*>       font;
-        Optional<LLFontGL::HAlign>      font_halign;
-        Optional<LLFontGL::VAlign>      font_valign;
-
-        // cruft from LLXMLNode implementation
-        Ignored                         type,
-                                        length;
-
-        Params();
-    };
-
-    enum ETypeTransparency
-    {
-        TT_DEFAULT,
-        TT_ACTIVE,      // focused floater
-        TT_INACTIVE,    // other floaters
-        TT_FADING,      // fading toast
-    };
-    /*virtual*/ ~LLUICtrl();
-
-    void initFromParams(const Params& p);
+	typedef boost::function<void (LLUICtrl* ctrl, const LLSD& param)> commit_callback_t;
+	typedef boost::signals2::signal<void (LLUICtrl* ctrl, const LLSD& param)> commit_signal_t;
+	// *TODO: add xml support for this type of signal in the future
+	typedef boost::signals2::signal<void (LLUICtrl* ctrl, S32 x, S32 y, MASK mask)> mouse_signal_t;
+	
+	typedef boost::function<bool (LLUICtrl* ctrl, const LLSD& param)> enable_callback_t;
+	typedef boost::signals2::signal<bool (LLUICtrl* ctrl, const LLSD& param), boost_boolean_combiner> enable_signal_t;
+	
+	struct CallbackParam : public LLInitParam::Block<CallbackParam>
+	{
+		Ignored					name;
+
+		Optional<std::string>	function_name;
+		Optional<LLSD>			parameter;
+
+		Optional<std::string>	control_name;
+		
+		CallbackParam();
+	};
+
+	struct CommitCallbackParam : public LLInitParam::Block<CommitCallbackParam, CallbackParam >
+	{
+		Optional<commit_callback_t> function;
+	};
+
+	// also used for visible callbacks
+	struct EnableCallbackParam : public LLInitParam::Block<EnableCallbackParam, CallbackParam >
+	{
+		Optional<enable_callback_t> function;
+	};
+		
+	struct EnableControls : public LLInitParam::ChoiceBlock<EnableControls>
+	{
+		Alternative<std::string> enabled;
+		Alternative<std::string> disabled;
+		
+		EnableControls();
+	};	
+	struct ControlVisibility : public LLInitParam::ChoiceBlock<ControlVisibility>
+	{
+		Alternative<std::string> visible;
+		Alternative<std::string> invisible;
+
+		ControlVisibility();
+	};	
+	struct Params : public LLInitParam::Block<Params, LLView::Params>
+	{
+		Optional<std::string>			label;
+		Optional<bool>					tab_stop,
+										chrome,
+										requests_front;
+		Optional<LLSD>					initial_value;
+
+		Optional<CommitCallbackParam>	init_callback,
+										commit_callback;
+		Optional<EnableCallbackParam>	validate_callback;
+		
+		Optional<CommitCallbackParam>	mouseenter_callback,
+										mouseleave_callback;
+		
+		Optional<std::string>			control_name;
+		Optional<EnableControls>		enabled_controls;
+		Optional<ControlVisibility>		controls_visibility;
+		
+		// font params
+		Optional<const LLFontGL*>		font;
+		Optional<LLFontGL::HAlign>		font_halign;
+		Optional<LLFontGL::VAlign>		font_valign;
+
+		// cruft from LLXMLNode implementation
+		Ignored							type,
+										length;
+
+		Params();
+	};
+
+	enum ETypeTransparency
+	{
+		TT_DEFAULT,
+		TT_ACTIVE,		// focused floater
+		TT_INACTIVE,	// other floaters
+		TT_FADING,		// fading toast
+	};
+	/*virtual*/ ~LLUICtrl();
+
+	void initFromParams(const Params& p);
 protected:
-    friend class LLUICtrlFactory;
-    static const Params& getDefaultParams();
-    LLUICtrl(const Params& p = getDefaultParams(),
+	friend class LLUICtrlFactory;
+	static const Params& getDefaultParams();
+	LLUICtrl(const Params& p = getDefaultParams(),
              const LLViewModelPtr& viewmodel=LLViewModelPtr(new LLViewModel));
-    
-    commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb);
-    enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb);
+	
+	commit_signal_t::slot_type initCommitCallback(const CommitCallbackParam& cb);
+	enable_signal_t::slot_type initEnableCallback(const EnableCallbackParam& cb);
 
-    // We need this virtual so we can override it with derived versions
-    virtual LLViewModel* getViewModel() const;
+	// We need this virtual so we can override it with derived versions
+	virtual LLViewModel* getViewModel() const;
     // We shouldn't ever need to set this directly
     //virtual void    setViewModel(const LLViewModelPtr&);
 
-    virtual BOOL    postBuild();
-    
+	virtual BOOL	postBuild();
+	
 public:
-    // LLView interface
-    /*virtual*/ BOOL    setLabelArg( const std::string& key, const LLStringExplicit& text );
-    /*virtual*/ BOOL    isCtrl() const;
-    /*virtual*/ void    onMouseEnter(S32 x, S32 y, MASK mask);
-    /*virtual*/ void    onMouseLeave(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL    canFocusChildren() const;
-    /*virtual*/ BOOL    handleMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL    handleMouseUp(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL    handleRightMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL    handleRightMouseUp(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL    handleDoubleClick(S32 x, S32 y, MASK mask);
-
-    // From LLFocusableElement
-    /*virtual*/ void    setFocus( BOOL b );
-    /*virtual*/ BOOL    hasFocus() const;
-    
-    // New virtuals
-
-    // Return NULL by default (overrride if the class has the appropriate interface)
-    virtual class LLCtrlSelectionInterface* getSelectionInterface();
-    virtual class LLCtrlListInterface* getListInterface();
-    virtual class LLCtrlScrollInterface* getScrollInterface();
-
-    bool setControlValue(const LLSD& value);
-    void setControlVariable(LLControlVariable* control);
-    virtual void setControlName(const std::string& control, LLView *context = NULL);
-    
-    LLControlVariable* getControlVariable() { return mControlVariable; } 
-    
-    void setEnabledControlVariable(LLControlVariable* control);
-    void setDisabledControlVariable(LLControlVariable* control);
-    void setMakeVisibleControlVariable(LLControlVariable* control);
-    void setMakeInvisibleControlVariable(LLControlVariable* control);
-
-    virtual void    setTentative(BOOL b);
-    virtual BOOL    getTentative() const;
-    virtual void    setValue(const LLSD& value);
-    virtual LLSD    getValue() const;
+	// LLView interface
+	/*virtual*/ BOOL	setLabelArg( const std::string& key, const LLStringExplicit& text );
+	/*virtual*/ BOOL	isCtrl() const;
+	/*virtual*/ void	onMouseEnter(S32 x, S32 y, MASK mask);
+	/*virtual*/ void	onMouseLeave(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	canFocusChildren() const;
+	/*virtual*/ BOOL 	handleMouseDown(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL 	handleMouseUp(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	handleRightMouseDown(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	handleRightMouseUp(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	handleDoubleClick(S32 x, S32 y, MASK mask);
+
+	// From LLFocusableElement
+	/*virtual*/ void	setFocus( BOOL b );
+	/*virtual*/ BOOL	hasFocus() const;
+	
+	// New virtuals
+
+	// Return NULL by default (overrride if the class has the appropriate interface)
+	virtual class LLCtrlSelectionInterface* getSelectionInterface();
+	virtual class LLCtrlListInterface* getListInterface();
+	virtual class LLCtrlScrollInterface* getScrollInterface();
+
+	bool setControlValue(const LLSD& value);
+	void setControlVariable(LLControlVariable* control);
+	virtual void setControlName(const std::string& control, LLView *context = NULL);
+	
+	LLControlVariable* getControlVariable() { return mControlVariable; } 
+	
+	void setEnabledControlVariable(LLControlVariable* control);
+	void setDisabledControlVariable(LLControlVariable* control);
+	void setMakeVisibleControlVariable(LLControlVariable* control);
+	void setMakeInvisibleControlVariable(LLControlVariable* control);
+
+	virtual void	setTentative(BOOL b);
+	virtual BOOL	getTentative() const;
+	virtual void	setValue(const LLSD& value);
+	virtual LLSD	getValue() const;
     /// When two widgets are displaying the same data (e.g. during a skin
     /// change), share their ViewModel.
     virtual void    shareViewModelFrom(const LLUICtrl& other);
 
-    virtual BOOL    setTextArg(  const std::string& key, const LLStringExplicit& text );
-    virtual void    setIsChrome(BOOL is_chrome);
-
-    virtual BOOL    acceptsTextInput() const; // Defaults to false
-
-    // A control is dirty if the user has modified its value.
-    // Editable controls should override this.
-    virtual BOOL    isDirty() const; // Defauls to false
-    virtual void    resetDirty(); //Defaults to no-op
-    
-    // Call appropriate callback
-    virtual void    onCommit();
-    
-    // Default to no-op:
-    virtual void    onTabInto();
-
-    // Clear any user-provided input (text in a text editor, checked checkbox,
-    // selected radio button, etc.).  Defaults to no-op.
-    virtual void    clear();
-
-    virtual void    setColor(const LLColor4& color);
-
-    // Ansariel: Changed to virtual. We might want to change the transparency ourself!
-    virtual F32 getCurrentTransparency();
-
-    void                setTransparencyType(ETypeTransparency type);
-    ETypeTransparency   getTransparencyType() const {return mTransparencyType;}
-
-    BOOL    focusNextItem(BOOL text_entry_only);
-    BOOL    focusPrevItem(BOOL text_entry_only);
-    BOOL    focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE );
-
-    // Non Virtuals
-    LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); }
-    BOOL            getIsChrome() const;
-    
-    void            setTabStop( BOOL b );
-    BOOL            hasTabStop() const;
-
-    LLUICtrl*       getParentUICtrl() const;
-
-    // return true if help topic found by crawling through parents -
-    // topic then put in help_topic_out
-    bool                    findHelpTopic(std::string& help_topic_out);
-
-    boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb);
-    boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb);
-
-    boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
-    boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
-
-    boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb );
-    boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb );
-    
-    boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb );
-    boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb );
-    boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb );
-    boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb );
-    
-    boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb );
-
-    // *TODO: Deprecate; for backwards compatability only:
-    boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data); 
-    boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb );
-
-    LLUICtrl* findRootMostFocusRoot();
-
-    class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
-    {
-        LLSINGLETON_EMPTY_CTOR(LLTextInputFilter);
-        /*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const 
-        {
-            return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
-        }
-    };
-
-    template <typename F, typename DERIVED> class CallbackRegistry : public LLRegistrySingleton<std::string, F, DERIVED >
-    {}; 
-
-    class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry>
-    {
-        LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry);
-    };
-    // the enable callback registry is also used for visiblity callbacks
-    class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry>
-    {
-        LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry);
-    };
-        
+	virtual BOOL	setTextArg(  const std::string& key, const LLStringExplicit& text );
+	virtual void	setIsChrome(BOOL is_chrome);
+
+	virtual BOOL	acceptsTextInput() const; // Defaults to false
+
+	// A control is dirty if the user has modified its value.
+	// Editable controls should override this.
+	virtual BOOL	isDirty() const; // Defauls to false
+	virtual void	resetDirty(); //Defaults to no-op
+	
+	// Call appropriate callback
+	virtual void	onCommit();
+	
+	// Default to no-op:
+	virtual void	onTabInto();
+
+	// Clear any user-provided input (text in a text editor, checked checkbox,
+	// selected radio button, etc.).  Defaults to no-op.
+	virtual void	clear();
+
+	virtual void	setColor(const LLColor4& color);
+
+	// Ansariel: Changed to virtual. We might want to change the transparency ourself!
+	virtual F32	getCurrentTransparency();
+
+	void				setTransparencyType(ETypeTransparency type);
+	ETypeTransparency	getTransparencyType() const {return mTransparencyType;}
+
+	BOOL	focusNextItem(BOOL text_entry_only);
+	BOOL	focusPrevItem(BOOL text_entry_only);
+	BOOL 	focusFirstItem(BOOL prefer_text_fields = FALSE, BOOL focus_flash = TRUE );
+
+	// Non Virtuals
+	LLHandle<LLUICtrl> getHandle() const { return getDerivedHandle<LLUICtrl>(); }
+	BOOL			getIsChrome() const;
+	
+	void			setTabStop( BOOL b );
+	BOOL			hasTabStop() const;
+
+	LLUICtrl*		getParentUICtrl() const;
+
+	// return true if help topic found by crawling through parents -
+	// topic then put in help_topic_out
+	bool                    findHelpTopic(std::string& help_topic_out);
+
+	boost::signals2::connection setCommitCallback(const CommitCallbackParam& cb);
+	boost::signals2::connection setValidateCallback(const EnableCallbackParam& cb);
+
+	boost::signals2::connection setCommitCallback( const commit_signal_t::slot_type& cb );
+	boost::signals2::connection setValidateCallback( const enable_signal_t::slot_type& cb );
+
+	boost::signals2::connection setMouseEnterCallback( const commit_signal_t::slot_type& cb );
+	boost::signals2::connection setMouseLeaveCallback( const commit_signal_t::slot_type& cb );
+	
+	boost::signals2::connection setMouseDownCallback( const mouse_signal_t::slot_type& cb );
+	boost::signals2::connection setMouseUpCallback( const mouse_signal_t::slot_type& cb );
+	boost::signals2::connection setRightMouseDownCallback( const mouse_signal_t::slot_type& cb );
+	boost::signals2::connection setRightMouseUpCallback( const mouse_signal_t::slot_type& cb );
+	
+	boost::signals2::connection setDoubleClickCallback( const mouse_signal_t::slot_type& cb );
+
+	// *TODO: Deprecate; for backwards compatability only:
+	boost::signals2::connection setCommitCallback( boost::function<void (LLUICtrl*,void*)> cb, void* data);	
+	boost::signals2::connection setValidateBeforeCommit( boost::function<bool (const LLSD& data)> cb );
+
+	LLUICtrl* findRootMostFocusRoot();
+
+	class LLTextInputFilter : public LLQueryFilter, public LLSingleton<LLTextInputFilter>
+	{
+		LLSINGLETON_EMPTY_CTOR(LLTextInputFilter);
+		/*virtual*/ filterResult_t operator() (const LLView* const view, const viewList_t & children) const 
+		{
+			return filterResult_t(view->isCtrl() && static_cast<const LLUICtrl *>(view)->acceptsTextInput(), TRUE);
+		}
+	};
+
+	template <typename F, typename DERIVED> class CallbackRegistry : public LLRegistrySingleton<std::string, F, DERIVED >
+	{};	
+
+	class CommitCallbackRegistry : public CallbackRegistry<commit_callback_t, CommitCallbackRegistry>
+	{
+		LLSINGLETON_EMPTY_CTOR(CommitCallbackRegistry);
+	};
+	// the enable callback registry is also used for visiblity callbacks
+	class EnableCallbackRegistry : public CallbackRegistry<enable_callback_t, EnableCallbackRegistry>
+	{
+		LLSINGLETON_EMPTY_CTOR(EnableCallbackRegistry);
+	};
+		
 protected:
 
-    static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type);
+	static bool controlListener(const LLSD& newvalue, LLHandle<LLUICtrl> handle, std::string type);
 
-    commit_signal_t*        mCommitSignal;
-    enable_signal_t*        mValidateSignal;
+	commit_signal_t*		mCommitSignal;
+	enable_signal_t*		mValidateSignal;
 
-    commit_signal_t*        mMouseEnterSignal;
-    commit_signal_t*        mMouseLeaveSignal;
-    
-    mouse_signal_t*     mMouseDownSignal;
-    mouse_signal_t*     mMouseUpSignal;
-    mouse_signal_t*     mRightMouseDownSignal;
-    mouse_signal_t*     mRightMouseUpSignal;
+	commit_signal_t*		mMouseEnterSignal;
+	commit_signal_t*		mMouseLeaveSignal;
+	
+	mouse_signal_t*		mMouseDownSignal;
+	mouse_signal_t*		mMouseUpSignal;
+	mouse_signal_t*		mRightMouseDownSignal;
+	mouse_signal_t*		mRightMouseUpSignal;
 
-    mouse_signal_t*     mDoubleClickSignal;
-    
+	mouse_signal_t*		mDoubleClickSignal;
+	
     LLViewModelPtr  mViewModel;
 
-    LLControlVariable* mControlVariable;
-    boost::signals2::connection mControlConnection;
-    LLControlVariable* mEnabledControlVariable;
-    boost::signals2::connection mEnabledControlConnection;
-    LLControlVariable* mDisabledControlVariable;
-    boost::signals2::connection mDisabledControlConnection;
-    LLControlVariable* mMakeVisibleControlVariable;
-    boost::signals2::connection mMakeVisibleControlConnection;
-    LLControlVariable* mMakeInvisibleControlVariable;
-    boost::signals2::connection mMakeInvisibleControlConnection;
-
-    static F32 sActiveControlTransparency;
-    static F32 sInactiveControlTransparency;
-    
-    virtual void addInfo(LLSD & info);
-    
+	LLControlVariable* mControlVariable;
+	boost::signals2::connection mControlConnection;
+	LLControlVariable* mEnabledControlVariable;
+	boost::signals2::connection mEnabledControlConnection;
+	LLControlVariable* mDisabledControlVariable;
+	boost::signals2::connection mDisabledControlConnection;
+	LLControlVariable* mMakeVisibleControlVariable;
+	boost::signals2::connection mMakeVisibleControlConnection;
+	LLControlVariable* mMakeInvisibleControlVariable;
+	boost::signals2::connection mMakeInvisibleControlConnection;
+
+	static F32 sActiveControlTransparency;
+	static F32 sInactiveControlTransparency;
+	
+	virtual void addInfo(LLSD & info);
+	
 private:
 
-    BOOL            mIsChrome;
-    BOOL            mRequestsFront;
-    BOOL            mTabStop;
-    BOOL            mTentative;
+	BOOL			mIsChrome;
+	BOOL			mRequestsFront;
+	BOOL			mTabStop;
+	BOOL			mTentative;
 
-    ETypeTransparency mTransparencyType;
+	ETypeTransparency mTransparencyType;
 };
 
 // Build time optimization, generate once in .cpp file
 #ifndef LLUICTRL_CPP
 extern template class LLUICtrl* LLView::getChild<class LLUICtrl>(
-    const std::string& name, BOOL recurse) const;
+	const std::string& name, BOOL recurse) const;
 #endif
 
 #endif  // LL_LLUICTRL_H
diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp
index be0ea8bb69..338be1808d 100755
--- a/indra/llui/tests/llurlentry_stub.cpp
+++ b/indra/llui/tests/llurlentry_stub.cpp
@@ -38,13 +38,13 @@
 // Stub for LLAvatarNameCache
 bool LLAvatarNameCache::get(const LLUUID& agent_id, LLAvatarName *av_name)
 {
-    return false;
+	return false;
 }
 
 LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot)
 {
-    callback_connection_t connection;
-    return connection;
+	callback_connection_t connection;
+	return connection;
 }
 
 //
@@ -52,24 +52,24 @@ LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& ag
 //
 BOOL LLCacheName::getFullName(const LLUUID& id, std::string& fullname)
 {
-    fullname = "Lynx Linden";
-    return TRUE;
+	fullname = "Lynx Linden";
+	return TRUE;
 }
 
 BOOL LLCacheName::getGroupName(const LLUUID& id, std::string& group)
 {
-    group = "My Group";
-    return TRUE;
+	group = "My Group";
+	return TRUE;
 }
 
 boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, const LLCacheNameCallback& callback)
 {
-    return boost::signals2::connection();
+	return boost::signals2::connection();
 }
 
 boost::signals2::connection LLCacheName::getGroup(const LLUUID& id, const LLCacheNameCallback& callback)
 {
-    return boost::signals2::connection();
+	return boost::signals2::connection();
 }
 
 LLCacheName* gCacheName = NULL;
@@ -80,12 +80,12 @@ LLCacheName* gCacheName = NULL;
 class LLTrans
 {
 public:
-    static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
+	static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args);
 };
 
 std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args)
 {
-    return std::string();
+	return std::string();
 }
 
 //
@@ -102,65 +102,65 @@ LLStyle::Params::Params()
 
 namespace LLInitParam
 {
-    ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
-    :   super_t(color)
-    {}
-
-    void ParamValue<LLUIColor>::updateValueFromBlock() 
-    {}
-    
-    void ParamValue<LLUIColor>::updateBlockFromValue(bool)
-    {}
-
-    bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
-    {
-        return false;
-    }
-
-    ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
-    :   super_t(fontp)
-    {}
-
-    void ParamValue<const LLFontGL*>::updateValueFromBlock()
-    {}
-    
-    void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
-    {}
-
-    void TypeValues<LLFontGL::HAlign>::declareValues()
-    {}
-
-    void TypeValues<LLFontGL::VAlign>::declareValues()
-    {}
-
-    void TypeValues<LLFontGL::ShadowType>::declareValues()
-    {}
-
-    void ParamValue<LLUIImage*>::updateValueFromBlock()
-    {}
-    
-    void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
-    {}
-
-    
-    bool ParamCompare<LLUIImage*, false>::equals(
-        LLUIImage* const &a,
-        LLUIImage* const &b)
-    {
-        return false;
-    }
-
-    bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
-    {
-        return false;
-    }
+	ParamValue<LLUIColor>::ParamValue(const LLUIColor& color)
+	:	super_t(color)
+	{}
+
+	void ParamValue<LLUIColor>::updateValueFromBlock() 
+	{}
+	
+	void ParamValue<LLUIColor>::updateBlockFromValue(bool)
+	{}
+
+	bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
+	{
+		return false;
+	}
+
+	ParamValue<const LLFontGL*>::ParamValue(const LLFontGL* fontp)
+	:	super_t(fontp)
+	{}
+
+	void ParamValue<const LLFontGL*>::updateValueFromBlock()
+	{}
+	
+	void ParamValue<const LLFontGL*>::updateBlockFromValue(bool)
+	{}
+
+	void TypeValues<LLFontGL::HAlign>::declareValues()
+	{}
+
+	void TypeValues<LLFontGL::VAlign>::declareValues()
+	{}
+
+	void TypeValues<LLFontGL::ShadowType>::declareValues()
+	{}
+
+	void ParamValue<LLUIImage*>::updateValueFromBlock()
+	{}
+	
+	void ParamValue<LLUIImage*>::updateBlockFromValue(bool)
+	{}
+
+	
+	bool ParamCompare<LLUIImage*, false>::equals(
+		LLUIImage* const &a,
+		LLUIImage* const &b)
+	{
+		return false;
+	}
+
+	bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
+	{
+		return false;
+	}
 
 }
 
 //static
 LLFontGL* LLFontGL::getFontDefault()
 {
-    return NULL; 
+	return NULL; 
 }
 
 char const* const _PREHASH_AgentData = (char *)"AgentData";
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 7b395491e6..bbe1354fc3 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -60,8 +60,8 @@ const F32 MIN_ZOOM_FRACTION = 0.25f;
 const F32 INITIAL_ZOOM_FRACTION = 1.f;
 const F32 MAX_ZOOM_FRACTION = 8.f;
 
-const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f;    // seconds
-const F32 FOV_ZOOM_HALF_LIFE = 0.07f;   // seconds
+const F32 CAMERA_ZOOM_HALF_LIFE = 0.07f;	// seconds
+const F32 FOV_ZOOM_HALF_LIFE = 0.07f;	// seconds
 
 const F32 CAMERA_FOCUS_HALF_LIFE = 0.f;//0.02f;
 const F32 CAMERA_LAG_HALF_LIFE = 0.25f;
@@ -107,83 +107,83 @@ LLAgentCamera gAgentCamera;
 // LLAgentCamera()
 //-----------------------------------------------------------------------------
 LLAgentCamera::LLAgentCamera() :
-    mInitialized(false),
-
-    mDrawDistance( DEFAULT_FAR_PLANE ),
-
-    mLookAt(NULL),
-    mPointAt(NULL),
-
-    mHUDTargetZoom(1.f),
-    mHUDCurZoom(1.f),
-
-    mForceMouselook(FALSE),
-
-    mCameraMode( CAMERA_MODE_THIRD_PERSON ),
-    mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
-
-    mCameraPreset(CAMERA_PRESET_REAR_VIEW),
-
-    mCameraAnimating( FALSE ),
-    mAnimationCameraStartGlobal(),
-    mAnimationFocusStartGlobal(),
-    mAnimationTimer(),
-    mAnimationDuration(0.33f),
-    
-    mCameraFOVZoomFactor(0.f),
-    mCameraCurrentFOVZoomFactor(0.f),
-    mCameraFocusOffset(),
-    mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW),
-
-    mCameraCollidePlane(),
-
-    mCurrentCameraDistance(2.f),        // meters, set in init()
-    mTargetCameraDistance(2.f),
-    mCameraZoomFraction(1.f),           // deprecated
-    mThirdPersonHeadOffset(0.f, 0.f, 1.f),
-    mSitCameraEnabled(FALSE),
-    mCameraSmoothingLastPositionGlobal(),
-    mCameraSmoothingLastPositionAgent(),
-    mCameraSmoothingStop(false),
-
-    mCameraUpVector(LLVector3::z_axis), // default is straight up
-
-    mFocusOnAvatar(TRUE),
-    mAllowChangeToFollow(FALSE),
-    mFocusGlobal(),
-    mFocusTargetGlobal(),
-    mFocusObject(NULL),
-    mFocusObjectDist(0.f),
-    mFocusObjectOffset(),
-    mFocusDotRadius( 0.1f ),            // meters
-    mTrackFocusObject(TRUE),
-
-    mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed
-    mWalkKey(0), // like AtKey, but causes less forward thrust
-    mLeftKey(0),
-    mUpKey(0),
-    mYawKey(0.f),
-    mPitchKey(0.f),
-
-    mOrbitLeftKey(0.f),
-    mOrbitRightKey(0.f),
-    mOrbitUpKey(0.f),
-    mOrbitDownKey(0.f),
-    mOrbitInKey(0.f),
-    mOrbitOutKey(0.f),
-
-    mPanUpKey(0.f),
-    mPanDownKey(0.f),
-    mPanLeftKey(0.f),
-    mPanRightKey(0.f),
-    mPanInKey(0.f),
-    mPanOutKey(0.f)
+	mInitialized(false),
+
+	mDrawDistance( DEFAULT_FAR_PLANE ),
+
+	mLookAt(NULL),
+	mPointAt(NULL),
+
+	mHUDTargetZoom(1.f),
+	mHUDCurZoom(1.f),
+
+	mForceMouselook(FALSE),
+
+	mCameraMode( CAMERA_MODE_THIRD_PERSON ),
+	mLastCameraMode( CAMERA_MODE_THIRD_PERSON ),
+
+	mCameraPreset(CAMERA_PRESET_REAR_VIEW),
+
+	mCameraAnimating( FALSE ),
+	mAnimationCameraStartGlobal(),
+	mAnimationFocusStartGlobal(),
+	mAnimationTimer(),
+	mAnimationDuration(0.33f),
+	
+	mCameraFOVZoomFactor(0.f),
+	mCameraCurrentFOVZoomFactor(0.f),
+	mCameraFocusOffset(),
+	mCameraFOVDefault(DEFAULT_FIELD_OF_VIEW),
+
+	mCameraCollidePlane(),
+
+	mCurrentCameraDistance(2.f),		// meters, set in init()
+	mTargetCameraDistance(2.f),
+	mCameraZoomFraction(1.f),			// deprecated
+	mThirdPersonHeadOffset(0.f, 0.f, 1.f),
+	mSitCameraEnabled(FALSE),
+	mCameraSmoothingLastPositionGlobal(),
+	mCameraSmoothingLastPositionAgent(),
+	mCameraSmoothingStop(false),
+
+	mCameraUpVector(LLVector3::z_axis), // default is straight up
+
+	mFocusOnAvatar(TRUE),
+	mAllowChangeToFollow(FALSE),
+	mFocusGlobal(),
+	mFocusTargetGlobal(),
+	mFocusObject(NULL),
+	mFocusObjectDist(0.f),
+	mFocusObjectOffset(),
+	mFocusDotRadius( 0.1f ),			// meters
+	mTrackFocusObject(TRUE),
+
+	mAtKey(0), // Either 1, 0, or -1... indicates that movement-key is pressed
+	mWalkKey(0), // like AtKey, but causes less forward thrust
+	mLeftKey(0),
+	mUpKey(0),
+	mYawKey(0.f),
+	mPitchKey(0.f),
+
+	mOrbitLeftKey(0.f),
+	mOrbitRightKey(0.f),
+	mOrbitUpKey(0.f),
+	mOrbitDownKey(0.f),
+	mOrbitInKey(0.f),
+	mOrbitOutKey(0.f),
+
+	mPanUpKey(0.f),
+	mPanDownKey(0.f),
+	mPanLeftKey(0.f),
+	mPanRightKey(0.f),
+	mPanInKey(0.f),
+	mPanOutKey(0.f)
 {
-    mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
+	mFollowCam.setMaxCameraDistantFromSubject( MAX_CAMERA_DISTANCE_FROM_AGENT );
 
-    clearGeneralKeys();
-    clearOrbitKeys();
-    clearPanKeys();
+	clearGeneralKeys();
+	clearOrbitKeys();
+	clearPanKeys();
 }
 
 // Requires gSavedSettings to be initialized.
@@ -192,36 +192,36 @@ LLAgentCamera::LLAgentCamera() :
 //-----------------------------------------------------------------------------
 void LLAgentCamera::init()
 {
-    // *Note: this is where LLViewerCamera::getInstance() used to be constructed.
+	// *Note: this is where LLViewerCamera::getInstance() used to be constructed.
 
-    mDrawDistance = gSavedSettings.getF32("RenderFarClip");
+	mDrawDistance = gSavedSettings.getF32("RenderFarClip");
 
-    LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW);
-    // Leave at 0.1 meters until we have real near clip management
-    LLViewerCamera::getInstance()->setNear(0.1f);
-    LLViewerCamera::getInstance()->setFar(mDrawDistance);           // if you want to change camera settings, do so in camera.h
-    LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() );       // default, overridden in LLViewerWindow::reshape
-    LLViewerCamera::getInstance()->setViewHeightInPixels(768);          // default, overridden in LLViewerWindow::reshape
+	LLViewerCamera::getInstance()->setView(DEFAULT_FIELD_OF_VIEW);
+	// Leave at 0.1 meters until we have real near clip management
+	LLViewerCamera::getInstance()->setNear(0.1f);
+	LLViewerCamera::getInstance()->setFar(mDrawDistance);			// if you want to change camera settings, do so in camera.h
+	LLViewerCamera::getInstance()->setAspect( gViewerWindow->getWorldViewAspectRatio() );		// default, overridden in LLViewerWindow::reshape
+	LLViewerCamera::getInstance()->setViewHeightInPixels(768);			// default, overridden in LLViewerWindow::reshape
 
-    mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
-    
-    mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
+	mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
+	
+	mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
 
-    mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
-    mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
-    mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
+	mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
+	mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
+	mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
 
-    mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
-    mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
-    mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
+	mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
+	mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
+	mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
 
-    mCameraCollidePlane.clearVec();
-    mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
-    mTargetCameraDistance = mCurrentCameraDistance;
-    mCameraZoomFraction = 1.f;
-    mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
+	mCameraCollidePlane.clearVec();
+	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
+	mTargetCameraDistance = mCurrentCameraDistance;
+	mCameraZoomFraction = 1.f;
+	mTrackFocusObject = gSavedSettings.getBOOL("TrackFocusObject");
 
-    mInitialized = true;
+	mInitialized = true;
 }
 
 //-----------------------------------------------------------------------------
@@ -229,40 +229,40 @@ void LLAgentCamera::init()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cleanup()
 {
-    setSitCamera(LLUUID::null);
-
-    if(mLookAt)
-    {
-        mLookAt->markDead() ;
-        mLookAt = NULL;
-    }
-    if(mPointAt)
-    {
-        mPointAt->markDead() ;
-        mPointAt = NULL;
-    }
-    setFocusObject(NULL);
+	setSitCamera(LLUUID::null);
+
+	if(mLookAt)
+	{
+		mLookAt->markDead() ;
+		mLookAt = NULL;
+	}
+	if(mPointAt)
+	{
+		mPointAt->markDead() ;
+		mPointAt = NULL;
+	}
+	setFocusObject(NULL);
 }
 
 void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar)
 {
-    if (!mLookAt)
-    {
-        mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
-    }
-    if (!mPointAt)
-    {
-        mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
-    }
-    
-    if (!mLookAt.isNull())
-    {
-        mLookAt->setSourceObject(avatar);
-    }
-    if (!mPointAt.isNull())
-    {
-        mPointAt->setSourceObject(avatar);
-    }   
+	if (!mLookAt)
+	{
+		mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
+	}
+	if (!mPointAt)
+	{
+		mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
+	}
+	
+	if (!mLookAt.isNull())
+	{
+		mLookAt->setSourceObject(avatar);
+	}
+	if (!mPointAt.isNull())
+	{
+		mPointAt->setSourceObject(avatar);
+	}	
 }
 
 //-----------------------------------------------------------------------------
@@ -270,9 +270,9 @@ void LLAgentCamera::setAvatarObject(LLVOAvatarSelf* avatar)
 //-----------------------------------------------------------------------------
 LLAgentCamera::~LLAgentCamera()
 {
-    cleanup();
+	cleanup();
 
-    // *Note: this is where LLViewerCamera::getInstance() used to be deleted.
+	// *Note: this is where LLViewerCamera::getInstance() used to be deleted.
 }
 
 // Change camera back to third person, stop the autopilot,
@@ -282,74 +282,74 @@ LLAgentCamera::~LLAgentCamera()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 {
-    if (gAgent.getAutoPilot())
-    {
-        gAgent.stopAutoPilot(TRUE);
-    }
-
-    LLSelectMgr::getInstance()->unhighlightAll();
-
-    // By popular request, keep land selection while walking around. JC
-    // LLViewerParcelMgr::getInstance()->deselectLand();
-
-    // force deselect when walking and attachment is selected
-    // this is so people don't wig out when their avatar moves without animating
-    if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
-    {
-        LLSelectMgr::getInstance()->deselectAll();
-    }
-
-    if (gMenuHolder != NULL)
-    {
-        // Hide all popup menus
-        gMenuHolder->hideMenus();
-    }
-
-    if (change_camera && !gSavedSettings.getBOOL("FreezeTime"))
-    {
-        changeCameraToDefault();
-        
-        if (LLViewerJoystick::getInstance()->getOverrideCamera())
-        {
-            handle_toggle_flycam();
-        }
-
-        // reset avatar mode from eventual residual motion
-        if (LLToolMgr::getInstance()->inBuildMode())
-        {
-            LLViewerJoystick::getInstance()->moveAvatar(true);
-        }
-
-        //Camera Tool is needed for Free Camera Control Mode
-        if (!LLFloaterCamera::inFreeCameraMode())
-        {
-            LLFloaterReg::hideInstance("build");
-
-            // Switch back to basic toolset
-            LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
-        }
-        
-        gViewerWindow->showCursor();
-    }
-
-
-    if (reset_camera && !gSavedSettings.getBOOL("FreezeTime"))
-    {
-        if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson())
-        {
-            // leaving mouse-steer mode
-            LLVector3 agent_at_axis = gAgent.getAtAxis();
-            agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector());
-            agent_at_axis.normalize();
-            gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f)));
-        }
-
-        setFocusOnAvatar(TRUE, ANIMATE);
-
-        mCameraFOVZoomFactor = 0.f;
-    }
-
-    mHUDTargetZoom = 1.f;
+	if (gAgent.getAutoPilot())
+	{
+		gAgent.stopAutoPilot(TRUE);
+	}
+
+	LLSelectMgr::getInstance()->unhighlightAll();
+
+	// By popular request, keep land selection while walking around. JC
+	// LLViewerParcelMgr::getInstance()->deselectLand();
+
+	// force deselect when walking and attachment is selected
+	// this is so people don't wig out when their avatar moves without animating
+	if (LLSelectMgr::getInstance()->getSelection()->isAttachment())
+	{
+		LLSelectMgr::getInstance()->deselectAll();
+	}
+
+	if (gMenuHolder != NULL)
+	{
+		// Hide all popup menus
+		gMenuHolder->hideMenus();
+	}
+
+	if (change_camera && !gSavedSettings.getBOOL("FreezeTime"))
+	{
+		changeCameraToDefault();
+		
+		if (LLViewerJoystick::getInstance()->getOverrideCamera())
+		{
+			handle_toggle_flycam();
+		}
+
+		// reset avatar mode from eventual residual motion
+		if (LLToolMgr::getInstance()->inBuildMode())
+		{
+			LLViewerJoystick::getInstance()->moveAvatar(true);
+		}
+
+		//Camera Tool is needed for Free Camera Control Mode
+		if (!LLFloaterCamera::inFreeCameraMode())
+		{
+			LLFloaterReg::hideInstance("build");
+
+			// Switch back to basic toolset
+			LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
+		}
+		
+		gViewerWindow->showCursor();
+	}
+
+
+	if (reset_camera && !gSavedSettings.getBOOL("FreezeTime"))
+	{
+		if (!gViewerWindow->getLeftMouseDown() && cameraThirdPerson())
+		{
+			// leaving mouse-steer mode
+			LLVector3 agent_at_axis = gAgent.getAtAxis();
+			agent_at_axis -= projected_vec(agent_at_axis, gAgent.getReferenceUpVector());
+			agent_at_axis.normalize();
+			gAgent.resetAxes(lerp(gAgent.getAtAxis(), agent_at_axis, LLSmoothInterpolation::getInterpolant(0.3f)));
+		}
+
+		setFocusOnAvatar(TRUE, ANIMATE);
+
+		mCameraFOVZoomFactor = 0.f;
+	}
+
+	mHUDTargetZoom = 1.f;
 }
 
 // Allow camera to be moved somewhere other than behind avatar.
@@ -358,14 +358,14 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::unlockView()
 {
-    if (getFocusOnAvatar())
-    {
-        if (isAgentAvatarValid())
-        {
-            setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID);
-        }
-        setFocusOnAvatar(FALSE, FALSE); // no animation
-    }
+	if (getFocusOnAvatar())
+	{
+		if (isAgentAvatarValid())
+		{
+			setFocusGlobal(LLVector3d::zero, gAgentAvatarp->mID);
+		}
+		setFocusOnAvatar(FALSE, FALSE);	// no animation
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -373,10 +373,10 @@ void LLAgentCamera::unlockView()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
 {
-    LLVector3 look_at_norm = look_at;
-    look_at_norm.mV[VZ] = 0.f;
-    look_at_norm.normalize();
-    gAgent.resetAxes(look_at_norm);
+	LLVector3 look_at_norm = look_at;
+	look_at_norm.mV[VZ] = 0.f;
+	look_at_norm.normalize();
+	gAgent.resetAxes(look_at_norm);
 }
 
 //-----------------------------------------------------------------------------
@@ -384,169 +384,169 @@ void LLAgentCamera::slamLookAt(const LLVector3 &look_at)
 //-----------------------------------------------------------------------------
 LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 original_focus_point, S32 x, S32 y)
 {
-    LLMatrix4 obj_matrix = object->getRenderMatrix();
-    LLQuaternion obj_rot = object->getRenderRotation();
-    LLVector3 obj_pos = object->getRenderPosition();
-
-    BOOL is_avatar = object->isAvatar();
-    // if is avatar - don't do any funk heuristics to position the focal point
-    // see DEV-30589
-    if (is_avatar)
-    {
-        return original_focus_point - obj_pos;
-    }
-    
-    LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation
-    LLVector3 object_extents = object->getScale();  
-    
-    // make sure they object extents are non-zero
-    object_extents.clamp(0.001f, F32_MAX);
-
-    // obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object
-    LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin();
-    obj_to_cam_ray.rotVec(inv_obj_rot);
-    obj_to_cam_ray.normalize();
-
-    // obj_to_cam_ray_proportions are the (positive) ratios of 
-    // the obj_to_cam_ray x,y,z components with the x,y,z object dimensions.
-    LLVector3 obj_to_cam_ray_proportions;
-    obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]);
-    obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]);
-    obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]);
-
-    // find the largest ratio stored in obj_to_cam_ray_proportions
-    // this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera
-    LLVector3 longest_object_axis;
-    // is x-axis longest?
-    if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] 
-        && obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ])
-    {
-        // then grab it
-        longest_object_axis.setVec(obj_matrix.getFwdRow4());
-    }
-    // is y-axis longest?
-    else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ])
-    {
-        // then grab it
-        longest_object_axis.setVec(obj_matrix.getLeftRow4());
-    }
-    // otherwise, use z axis
-    else
-    {
-        longest_object_axis.setVec(obj_matrix.getUpRow4());
-    }
-
-    // Use this axis as the normal to project mouse click on to plane with that normal, at the object center.
-    // This generates a point behind the mouse cursor that is approximately in the middle of the object in
-    // terms of depth.  
-    // We do this to allow the camera rotation tool to "tumble" the object by rotating the camera.
-    // If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable
-    // eccentricity to the object orientation
-    LLVector3 focus_plane_normal(longest_object_axis);
-    focus_plane_normal.normalize();
-
-    LLVector3d focus_pt_global;
-    gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal);
-    LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global);
-
-    // find vector from camera to focus point in object space
-    LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin();
-    camera_to_focus_vec.rotVec(inv_obj_rot);
-
-    // find vector from object origin to focus point in object coordinates
-    LLVector3 focus_offset_from_object_center = focus_pt - obj_pos;
-    // convert to object-local space
-    focus_offset_from_object_center.rotVec(inv_obj_rot);
-
-    // We need to project the focus point back into the bounding box of the focused object.
-    // Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis
-    LLVector3 clip_fraction;
-
-    // for each axis...
-    for (U32 axis = VX; axis <= VZ; axis++)
-    {
-        //...calculate distance that focus offset sits outside of bounding box along that axis...
-        //NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center 
-        F32 dist_out_of_bounds;
-        if (focus_offset_from_object_center.mV[axis] > 0.f)
-        {
-            dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f));
-        }
-        else
-        {
-            dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f));
-        }
-
-        //...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis
-        if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f)
-        {
-            // don't divide by very small number
-            clip_fraction.mV[axis] = 0.f;
-        }
-        else
-        {
-            clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis];
-        }
-    }
-
-    LLVector3 abs_clip_fraction = clip_fraction;
-    abs_clip_fraction.abs();
-
-    // find axis of focus offset that is *most* outside the bounding box and use that to
-    // rescale focus offset to inside object extents
-    if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY]
-        && abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ])
-    {
-        focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec;
-    }
-    else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ])
-    {
-        focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec;
-    }
-    else
-    {
-        focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec;
-    }
-
-    // convert back to world space
-    focus_offset_from_object_center.rotVec(obj_rot);
-    
-    // now, based on distance of camera from object relative to object size
-    // push the focus point towards the near surface of the object when (relatively) close to the objcet
-    // or keep the focus point in the object middle when (relatively) far
-    // NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars
-    // is almost always "tumble about middle" and not "spin around surface point"
-    if (!is_avatar) 
-    {
-        LLVector3 obj_rel = original_focus_point - object->getRenderPosition();
-        
-        //now that we have the object relative position, we should bias toward the center of the object 
-        //based on the distance of the camera to the focus point vs. the distance of the camera to the focus
-
-        F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis());
-        F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin());
-
-
-        LLBBox obj_bbox = object->getBoundingBoxAgent();
-        F32 bias = 0.f;
-
-        // virtual_camera_pos is the camera position we are simulating by backing the camera off
-        // and adjusting the FOV
-        LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor));
-
-        // if the camera is inside the object (large, hollow objects, for example)
-        // leave focus point all the way to destination depth, away from object center
-        if(!obj_bbox.containsPointAgent(virtual_camera_pos))
-        {
-            // perform magic number biasing of focus point towards surface vs. planar center
-            bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f);
-            obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias);
-        }
-            
-        focus_offset_from_object_center = obj_rel;
-    }
-
-    return focus_offset_from_object_center;
+	LLMatrix4 obj_matrix = object->getRenderMatrix();
+	LLQuaternion obj_rot = object->getRenderRotation();
+	LLVector3 obj_pos = object->getRenderPosition();
+
+	BOOL is_avatar = object->isAvatar();
+	// if is avatar - don't do any funk heuristics to position the focal point
+	// see DEV-30589
+	if (is_avatar)
+	{
+		return original_focus_point - obj_pos;
+	}
+	
+	LLQuaternion inv_obj_rot = ~obj_rot; // get inverse of rotation
+	LLVector3 object_extents = object->getScale();	
+	
+	// make sure they object extents are non-zero
+	object_extents.clamp(0.001f, F32_MAX);
+
+	// obj_to_cam_ray is unit vector pointing from object center to camera, in the coordinate frame of the object
+	LLVector3 obj_to_cam_ray = obj_pos - LLViewerCamera::getInstance()->getOrigin();
+	obj_to_cam_ray.rotVec(inv_obj_rot);
+	obj_to_cam_ray.normalize();
+
+	// obj_to_cam_ray_proportions are the (positive) ratios of 
+	// the obj_to_cam_ray x,y,z components with the x,y,z object dimensions.
+	LLVector3 obj_to_cam_ray_proportions;
+	obj_to_cam_ray_proportions.mV[VX] = llabs(obj_to_cam_ray.mV[VX] / object_extents.mV[VX]);
+	obj_to_cam_ray_proportions.mV[VY] = llabs(obj_to_cam_ray.mV[VY] / object_extents.mV[VY]);
+	obj_to_cam_ray_proportions.mV[VZ] = llabs(obj_to_cam_ray.mV[VZ] / object_extents.mV[VZ]);
+
+	// find the largest ratio stored in obj_to_cam_ray_proportions
+	// this corresponds to the object's local axial plane (XY, YZ, XZ) that is *most* facing the camera
+	LLVector3 longest_object_axis;
+	// is x-axis longest?
+	if (obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VY] 
+		&& obj_to_cam_ray_proportions.mV[VX] > obj_to_cam_ray_proportions.mV[VZ])
+	{
+		// then grab it
+		longest_object_axis.setVec(obj_matrix.getFwdRow4());
+	}
+	// is y-axis longest?
+	else if (obj_to_cam_ray_proportions.mV[VY] > obj_to_cam_ray_proportions.mV[VZ])
+	{
+		// then grab it
+		longest_object_axis.setVec(obj_matrix.getLeftRow4());
+	}
+	// otherwise, use z axis
+	else
+	{
+		longest_object_axis.setVec(obj_matrix.getUpRow4());
+	}
+
+	// Use this axis as the normal to project mouse click on to plane with that normal, at the object center.
+	// This generates a point behind the mouse cursor that is approximately in the middle of the object in
+	// terms of depth.  
+	// We do this to allow the camera rotation tool to "tumble" the object by rotating the camera.
+	// If the focus point were the object surface under the mouse, camera rotation would introduce an undesirable
+	// eccentricity to the object orientation
+	LLVector3 focus_plane_normal(longest_object_axis);
+	focus_plane_normal.normalize();
+
+	LLVector3d focus_pt_global;
+	gViewerWindow->mousePointOnPlaneGlobal(focus_pt_global, x, y, gAgent.getPosGlobalFromAgent(obj_pos), focus_plane_normal);
+	LLVector3 focus_pt = gAgent.getPosAgentFromGlobal(focus_pt_global);
+
+	// find vector from camera to focus point in object space
+	LLVector3 camera_to_focus_vec = focus_pt - LLViewerCamera::getInstance()->getOrigin();
+	camera_to_focus_vec.rotVec(inv_obj_rot);
+
+	// find vector from object origin to focus point in object coordinates
+	LLVector3 focus_offset_from_object_center = focus_pt - obj_pos;
+	// convert to object-local space
+	focus_offset_from_object_center.rotVec(inv_obj_rot);
+
+	// We need to project the focus point back into the bounding box of the focused object.
+	// Do this by calculating the XYZ scale factors needed to get focus offset back in bounds along the camera_focus axis
+	LLVector3 clip_fraction;
+
+	// for each axis...
+	for (U32 axis = VX; axis <= VZ; axis++)
+	{
+		//...calculate distance that focus offset sits outside of bounding box along that axis...
+		//NOTE: dist_out_of_bounds keeps the sign of focus_offset_from_object_center 
+		F32 dist_out_of_bounds;
+		if (focus_offset_from_object_center.mV[axis] > 0.f)
+		{
+			dist_out_of_bounds = llmax(0.f, focus_offset_from_object_center.mV[axis] - (object_extents.mV[axis] * 0.5f));
+		}
+		else
+		{
+			dist_out_of_bounds = llmin(0.f, focus_offset_from_object_center.mV[axis] + (object_extents.mV[axis] * 0.5f));
+		}
+
+		//...then calculate the scale factor needed to push camera_to_focus_vec back in bounds along current axis
+		if (llabs(camera_to_focus_vec.mV[axis]) < 0.0001f)
+		{
+			// don't divide by very small number
+			clip_fraction.mV[axis] = 0.f;
+		}
+		else
+		{
+			clip_fraction.mV[axis] = dist_out_of_bounds / camera_to_focus_vec.mV[axis];
+		}
+	}
+
+	LLVector3 abs_clip_fraction = clip_fraction;
+	abs_clip_fraction.abs();
+
+	// find axis of focus offset that is *most* outside the bounding box and use that to
+	// rescale focus offset to inside object extents
+	if (abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VY]
+		&& abs_clip_fraction.mV[VX] > abs_clip_fraction.mV[VZ])
+	{
+		focus_offset_from_object_center -= clip_fraction.mV[VX] * camera_to_focus_vec;
+	}
+	else if (abs_clip_fraction.mV[VY] > abs_clip_fraction.mV[VZ])
+	{
+		focus_offset_from_object_center -= clip_fraction.mV[VY] * camera_to_focus_vec;
+	}
+	else
+	{
+		focus_offset_from_object_center -= clip_fraction.mV[VZ] * camera_to_focus_vec;
+	}
+
+	// convert back to world space
+	focus_offset_from_object_center.rotVec(obj_rot);
+	
+	// now, based on distance of camera from object relative to object size
+	// push the focus point towards the near surface of the object when (relatively) close to the objcet
+	// or keep the focus point in the object middle when (relatively) far
+	// NOTE: leave focus point in middle of avatars, since the behavior you want when alt-zooming on avatars
+	// is almost always "tumble about middle" and not "spin around surface point"
+	if (!is_avatar) 
+	{
+		LLVector3 obj_rel = original_focus_point - object->getRenderPosition();
+		
+		//now that we have the object relative position, we should bias toward the center of the object 
+		//based on the distance of the camera to the focus point vs. the distance of the camera to the focus
+
+		F32 relDist = llabs(obj_rel * LLViewerCamera::getInstance()->getAtAxis());
+		F32 viewDist = dist_vec(obj_pos + obj_rel, LLViewerCamera::getInstance()->getOrigin());
+
+
+		LLBBox obj_bbox = object->getBoundingBoxAgent();
+		F32 bias = 0.f;
+
+		// virtual_camera_pos is the camera position we are simulating by backing the camera off
+		// and adjusting the FOV
+		LLVector3 virtual_camera_pos = gAgent.getPosAgentFromGlobal(mFocusTargetGlobal + (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor));
+
+		// if the camera is inside the object (large, hollow objects, for example)
+		// leave focus point all the way to destination depth, away from object center
+		if(!obj_bbox.containsPointAgent(virtual_camera_pos))
+		{
+			// perform magic number biasing of focus point towards surface vs. planar center
+			bias = clamp_rescale(relDist/viewDist, 0.1f, 0.7f, 0.0f, 1.0f);
+			obj_rel = lerp(focus_offset_from_object_center, obj_rel, bias);
+		}
+			
+		focus_offset_from_object_center = obj_rel;
+	}
+
+	return focus_offset_from_object_center;
 }
 
 //-----------------------------------------------------------------------------
@@ -554,260 +554,260 @@ LLVector3 LLAgentCamera::calcFocusOffset(LLViewerObject *object, LLVector3 origi
 //-----------------------------------------------------------------------------
 BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
 {
-    BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
-
-    if (!mFocusObject || mFocusObject->isDead() || 
-        mFocusObject->isMesh() ||
-        gSavedSettings.getBOOL("DisableCameraConstraints"))
-    {
-        obj_min_distance = 0.f;
-        return TRUE;
-    }
-
-    if (mFocusObject->mDrawable.isNull())
-    {
+	BOOL soft_limit = FALSE; // is the bounding box to be treated literally (volumes) or as an approximation (avatars)
+
+	if (!mFocusObject || mFocusObject->isDead() || 
+		mFocusObject->isMesh() ||
+		gSavedSettings.getBOOL("DisableCameraConstraints"))
+	{
+		obj_min_distance = 0.f;
+		return TRUE;
+	}
+
+	if (mFocusObject->mDrawable.isNull())
+	{
 #ifdef LL_RELEASE_FOR_DOWNLOAD
-        LL_WARNS() << "Focus object with no drawable!" << LL_ENDL;
+		LL_WARNS() << "Focus object with no drawable!" << LL_ENDL;
 #else
-        mFocusObject->dump();
-        LL_ERRS() << "Focus object with no drawable!" << LL_ENDL;
+		mFocusObject->dump();
+		LL_ERRS() << "Focus object with no drawable!" << LL_ENDL;
 #endif
-        obj_min_distance = 0.f;
-        return TRUE;
-    }
-    
-    LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation();
-    LLVector3 target_offset_origin = mFocusObjectOffset;
-    LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
-
-    // convert offsets into object local space
-    camera_offset_target.rotVec(inv_object_rot);
-    target_offset_origin.rotVec(inv_object_rot);
-
-    // push around object extents based on target offset
-    LLVector3 object_extents = mFocusObject->getScale();
-    if (mFocusObject->isAvatar())
-    {
-        // fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom)
-        object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR;
-        object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR;
-        object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR;
-        soft_limit = TRUE;
-    }
-    LLVector3 abs_target_offset = target_offset_origin;
-    abs_target_offset.abs();
-
-    LLVector3 target_offset_dir = target_offset_origin;
-
-    BOOL target_outside_object_extents = FALSE;
-
-    for (U32 i = VX; i <= VZ; i++)
-    {
-        if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING)
-        {
-            target_outside_object_extents = TRUE;
-        }
-        if (camera_offset_target.mV[i] > 0.f)
-        {
-            object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f;
-        }
-        else
-        {
-            object_extents.mV[i] += target_offset_origin.mV[i] * 2.f;
-        }
-    }
-
-    // don't shrink the object extents so far that the object inverts
-    object_extents.clamp(0.001f, F32_MAX);
-
-    // move into first octant
-    LLVector3 camera_offset_target_abs_norm = camera_offset_target;
-    camera_offset_target_abs_norm.abs();
-    // make sure offset is non-zero
-    camera_offset_target_abs_norm.clamp(0.001f, F32_MAX);
-    camera_offset_target_abs_norm.normalize();
-
-    // find camera position relative to normalized object extents
-    LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm;
-    camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX];
-    camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY];
-    camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ];
-
-    if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && 
-        camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ])
-    {
-        if (camera_offset_target_abs_norm.mV[VX] < 0.001f)
-        {
-            obj_min_distance = object_extents.mV[VX] * 0.5f;
-        }
-        else
-        {
-            obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX];
-        }
-    }
-    else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ])
-    {
-        if (camera_offset_target_abs_norm.mV[VY] < 0.001f)
-        {
-            obj_min_distance = object_extents.mV[VY] * 0.5f;
-        }
-        else
-        {
-            obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY];
-        }
-    }
-    else
-    {
-        if (camera_offset_target_abs_norm.mV[VZ] < 0.001f)
-        {
-            obj_min_distance = object_extents.mV[VZ] * 0.5f;
-        }
-        else
-        {
-            obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ];
-        }
-    }
-
-    LLVector3 object_split_axis;
-    LLVector3 target_offset_scaled = target_offset_origin;
-    target_offset_scaled.abs();
-    target_offset_scaled.normalize();
-    target_offset_scaled.mV[VX] /= object_extents.mV[VX];
-    target_offset_scaled.mV[VY] /= object_extents.mV[VY];
-    target_offset_scaled.mV[VZ] /= object_extents.mV[VZ];
-
-    if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && 
-        target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ])
-    {
-        object_split_axis = LLVector3::x_axis;
-    }
-    else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ])
-    {
-        object_split_axis = LLVector3::y_axis;
-    }
-    else
-    {
-        object_split_axis = LLVector3::z_axis;
-    }
-
-    LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent());
-
-
-    F32 camera_offset_clip = camera_offset_object * object_split_axis;
-    F32 target_offset_clip = target_offset_dir * object_split_axis;
-
-    // target has moved outside of object extents
-    // check to see if camera and target are on same side 
-    if (target_outside_object_extents)
-    {
-        if (camera_offset_clip > 0.f && target_offset_clip > 0.f)
-        {
-            return FALSE;
-        }
-        else if (camera_offset_clip < 0.f && target_offset_clip < 0.f)
-        {
-            return FALSE;
-        }
-    }
-
-    // clamp obj distance to diagonal of 10 by 10 cube
-    obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
-
-    obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
-    
-    return TRUE;
+		obj_min_distance = 0.f;
+		return TRUE;
+	}
+	
+	LLQuaternion inv_object_rot = ~mFocusObject->getRenderRotation();
+	LLVector3 target_offset_origin = mFocusObjectOffset;
+	LLVector3 camera_offset_target(getCameraPositionAgent() - gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+
+	// convert offsets into object local space
+	camera_offset_target.rotVec(inv_object_rot);
+	target_offset_origin.rotVec(inv_object_rot);
+
+	// push around object extents based on target offset
+	LLVector3 object_extents = mFocusObject->getScale();
+	if (mFocusObject->isAvatar())
+	{
+		// fudge factors that lets you zoom in on avatars a bit more (which don't do FOV zoom)
+		object_extents.mV[VX] *= AVATAR_ZOOM_MIN_X_FACTOR;
+		object_extents.mV[VY] *= AVATAR_ZOOM_MIN_Y_FACTOR;
+		object_extents.mV[VZ] *= AVATAR_ZOOM_MIN_Z_FACTOR;
+		soft_limit = TRUE;
+	}
+	LLVector3 abs_target_offset = target_offset_origin;
+	abs_target_offset.abs();
+
+	LLVector3 target_offset_dir = target_offset_origin;
+
+	BOOL target_outside_object_extents = FALSE;
+
+	for (U32 i = VX; i <= VZ; i++)
+	{
+		if (abs_target_offset.mV[i] * 2.f > object_extents.mV[i] + OBJECT_EXTENTS_PADDING)
+		{
+			target_outside_object_extents = TRUE;
+		}
+		if (camera_offset_target.mV[i] > 0.f)
+		{
+			object_extents.mV[i] -= target_offset_origin.mV[i] * 2.f;
+		}
+		else
+		{
+			object_extents.mV[i] += target_offset_origin.mV[i] * 2.f;
+		}
+	}
+
+	// don't shrink the object extents so far that the object inverts
+	object_extents.clamp(0.001f, F32_MAX);
+
+	// move into first octant
+	LLVector3 camera_offset_target_abs_norm = camera_offset_target;
+	camera_offset_target_abs_norm.abs();
+	// make sure offset is non-zero
+	camera_offset_target_abs_norm.clamp(0.001f, F32_MAX);
+	camera_offset_target_abs_norm.normalize();
+
+	// find camera position relative to normalized object extents
+	LLVector3 camera_offset_target_scaled = camera_offset_target_abs_norm;
+	camera_offset_target_scaled.mV[VX] /= object_extents.mV[VX];
+	camera_offset_target_scaled.mV[VY] /= object_extents.mV[VY];
+	camera_offset_target_scaled.mV[VZ] /= object_extents.mV[VZ];
+
+	if (camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VY] && 
+		camera_offset_target_scaled.mV[VX] > camera_offset_target_scaled.mV[VZ])
+	{
+		if (camera_offset_target_abs_norm.mV[VX] < 0.001f)
+		{
+			obj_min_distance = object_extents.mV[VX] * 0.5f;
+		}
+		else
+		{
+			obj_min_distance = object_extents.mV[VX] * 0.5f / camera_offset_target_abs_norm.mV[VX];
+		}
+	}
+	else if (camera_offset_target_scaled.mV[VY] > camera_offset_target_scaled.mV[VZ])
+	{
+		if (camera_offset_target_abs_norm.mV[VY] < 0.001f)
+		{
+			obj_min_distance = object_extents.mV[VY] * 0.5f;
+		}
+		else
+		{
+			obj_min_distance = object_extents.mV[VY] * 0.5f / camera_offset_target_abs_norm.mV[VY];
+		}
+	}
+	else
+	{
+		if (camera_offset_target_abs_norm.mV[VZ] < 0.001f)
+		{
+			obj_min_distance = object_extents.mV[VZ] * 0.5f;
+		}
+		else
+		{
+			obj_min_distance = object_extents.mV[VZ] * 0.5f / camera_offset_target_abs_norm.mV[VZ];
+		}
+	}
+
+	LLVector3 object_split_axis;
+	LLVector3 target_offset_scaled = target_offset_origin;
+	target_offset_scaled.abs();
+	target_offset_scaled.normalize();
+	target_offset_scaled.mV[VX] /= object_extents.mV[VX];
+	target_offset_scaled.mV[VY] /= object_extents.mV[VY];
+	target_offset_scaled.mV[VZ] /= object_extents.mV[VZ];
+
+	if (target_offset_scaled.mV[VX] > target_offset_scaled.mV[VY] && 
+		target_offset_scaled.mV[VX] > target_offset_scaled.mV[VZ])
+	{
+		object_split_axis = LLVector3::x_axis;
+	}
+	else if (target_offset_scaled.mV[VY] > target_offset_scaled.mV[VZ])
+	{
+		object_split_axis = LLVector3::y_axis;
+	}
+	else
+	{
+		object_split_axis = LLVector3::z_axis;
+	}
+
+	LLVector3 camera_offset_object(getCameraPositionAgent() - mFocusObject->getPositionAgent());
+
+
+	F32 camera_offset_clip = camera_offset_object * object_split_axis;
+	F32 target_offset_clip = target_offset_dir * object_split_axis;
+
+	// target has moved outside of object extents
+	// check to see if camera and target are on same side 
+	if (target_outside_object_extents)
+	{
+		if (camera_offset_clip > 0.f && target_offset_clip > 0.f)
+		{
+			return FALSE;
+		}
+		else if (camera_offset_clip < 0.f && target_offset_clip < 0.f)
+		{
+			return FALSE;
+		}
+	}
+
+	// clamp obj distance to diagonal of 10 by 10 cube
+	obj_min_distance = llmin(obj_min_distance, 10.f * F_SQRT3);
+
+	obj_min_distance += LLViewerCamera::getInstance()->getNear() + (soft_limit ? 0.1f : 0.2f);
+	
+	return TRUE;
 }
 
 F32 LLAgentCamera::getCameraZoomFraction()
 {
-    // 0.f -> camera zoomed all the way out
-    // 1.f -> camera zoomed all the way in
-    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-    {
-        // already [0,1]
-        return mHUDTargetZoom;
-    }
-    else if (mFocusOnAvatar && cameraThirdPerson())
-    {
-        return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f);
-    }
-    else if (cameraCustomizeAvatar())
-    {
-        F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
-        return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
-    }
-    else
-    {
-        F32 min_zoom;
-        F32 max_zoom = getCameraMaxZoomDistance();
-
-        F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
-        if (mFocusObject.notNull())
-        {
-            if (mFocusObject->isAvatar())
-            {
-                min_zoom = AVATAR_MIN_ZOOM;
-            }
-            else
-            {
-                min_zoom = OBJECT_MIN_ZOOM;
-            }
-        }
-        else
-        {
-            min_zoom = LAND_MIN_ZOOM;
-        }
-
-        return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
-    }
+	// 0.f -> camera zoomed all the way out
+	// 1.f -> camera zoomed all the way in
+	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+	{
+		// already [0,1]
+		return mHUDTargetZoom;
+	}
+	else if (mFocusOnAvatar && cameraThirdPerson())
+	{
+		return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f);
+	}
+	else if (cameraCustomizeAvatar())
+	{
+		F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
+		return clamp_rescale(distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM, 1.f, 0.f );
+	}
+	else
+	{
+		F32 min_zoom;
+		F32 max_zoom = getCameraMaxZoomDistance();
+
+		F32 distance = (F32)mCameraFocusOffsetTarget.magVec();
+		if (mFocusObject.notNull())
+		{
+			if (mFocusObject->isAvatar())
+			{
+				min_zoom = AVATAR_MIN_ZOOM;
+			}
+			else
+			{
+				min_zoom = OBJECT_MIN_ZOOM;
+			}
+		}
+		else
+		{
+			min_zoom = LAND_MIN_ZOOM;
+		}
+
+		return clamp_rescale(distance, min_zoom, max_zoom, 1.f, 0.f);
+	}
 }
 
 void LLAgentCamera::setCameraZoomFraction(F32 fraction)
 {
-    // 0.f -> camera zoomed all the way out
-    // 1.f -> camera zoomed all the way in
-    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-
-    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-    {
-        mHUDTargetZoom = fraction;
-    }
-    else if (mFocusOnAvatar && cameraThirdPerson())
-    {
-        mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
-    }
-    else if (cameraCustomizeAvatar())
-    {
-        LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
-        camera_offset_dir.normalize();
-        mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM);
-    }
-    else
-    {
-        F32 min_zoom = LAND_MIN_ZOOM;
-        F32 max_zoom = getCameraMaxZoomDistance();
-
-        if (mFocusObject.notNull())
-        {
-            if (mFocusObject.notNull())
-            {
-                if (mFocusObject->isAvatar())
-                {
-                    min_zoom = AVATAR_MIN_ZOOM;
-                }
-                else
-                {
-                    min_zoom = OBJECT_MIN_ZOOM;
-                }
-            }
-        }
-
-        LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
-        camera_offset_dir.normalize();
-        mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
-    }
-    startCameraAnimation();
+	// 0.f -> camera zoomed all the way out
+	// 1.f -> camera zoomed all the way in
+	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+
+	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+	{
+		mHUDTargetZoom = fraction;
+	}
+	else if (mFocusOnAvatar && cameraThirdPerson())
+	{
+		mCameraZoomFraction = rescale(fraction, 0.f, 1.f, MAX_ZOOM_FRACTION, MIN_ZOOM_FRACTION);
+	}
+	else if (cameraCustomizeAvatar())
+	{
+		LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
+		camera_offset_dir.normalize();
+		mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, APPEARANCE_MAX_ZOOM, APPEARANCE_MIN_ZOOM);
+	}
+	else
+	{
+		F32 min_zoom = LAND_MIN_ZOOM;
+		F32 max_zoom = getCameraMaxZoomDistance();
+
+		if (mFocusObject.notNull())
+		{
+			if (mFocusObject.notNull())
+			{
+				if (mFocusObject->isAvatar())
+				{
+					min_zoom = AVATAR_MIN_ZOOM;
+				}
+				else
+				{
+					min_zoom = OBJECT_MIN_ZOOM;
+				}
+			}
+		}
+
+		LLVector3d camera_offset_dir = mCameraFocusOffsetTarget;
+		camera_offset_dir.normalize();
+		mCameraFocusOffsetTarget = camera_offset_dir * rescale(fraction, 0.f, 1.f, max_zoom, min_zoom);
+	}
+	startCameraAnimation();
 }
 
 
@@ -816,21 +816,21 @@ void LLAgentCamera::setCameraZoomFraction(F32 fraction)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraOrbitAround(const F32 radians)
 {
-    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-    {
-        // do nothing for hud selection
-    }
-    else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW))
-    {
-        gAgent.yaw(radians);
-    }
-    else
-    {
-        mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
-        
-        cameraZoomIn(1.f);
-    }
+	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+	{
+		// do nothing for hud selection
+	}
+	else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON || mCameraMode == CAMERA_MODE_FOLLOW))
+	{
+		gAgent.yaw(radians);
+	}
+	else
+	{
+		mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
+		
+		cameraZoomIn(1.f);
+	}
 }
 
 
@@ -839,29 +839,29 @@ void LLAgentCamera::cameraOrbitAround(const F32 radians)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraOrbitOver(const F32 angle)
 {
-    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-    if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-    {
-        // do nothing for hud selection
-    }
-    else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
-    {
-        gAgent.pitch(angle);
-    }
-    else
-    {
-        LLVector3 camera_offset_unit(mCameraFocusOffsetTarget);
-        camera_offset_unit.normalize();
-
-        F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() );
-
-        LLVector3d left_axis;
-        left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
-        F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD);
-        mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis);
-
-        cameraZoomIn(1.f);
-    }
+	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+	if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+	{
+		// do nothing for hud selection
+	}
+	else if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
+	{
+		gAgent.pitch(angle);
+	}
+	else
+	{
+		LLVector3 camera_offset_unit(mCameraFocusOffsetTarget);
+		camera_offset_unit.normalize();
+
+		F32 angle_from_up = acos( camera_offset_unit * gAgent.getReferenceUpVector() );
+
+		LLVector3d left_axis;
+		left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
+		F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD);
+		mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis);
+
+		cameraZoomIn(1.f);
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -869,65 +869,65 @@ void LLAgentCamera::cameraOrbitOver(const F32 angle)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraZoomIn(const F32 fraction)
 {
-    if (gDisconnected)
-    {
-        return;
-    }
-
-    LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-    if (LLToolMgr::getInstance()->inBuildMode() && selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-    {
-        // just update hud zoom level
-        mHUDTargetZoom /= fraction;
-        return;
-    }
-
-
-    LLVector3d  camera_offset_unit(mCameraFocusOffsetTarget);
-    F32 min_zoom = LAND_MIN_ZOOM;
-    F32 current_distance = (F32)camera_offset_unit.normalize();
-    F32 new_distance = current_distance * fraction;
-
-    // Don't move through focus point
-    if (mFocusObject)
-    {
-        LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]);
-
-        if (mFocusObject->isAvatar())
-        {
-            calcCameraMinDistance(min_zoom);
-        }
-        else
-        {
-            min_zoom = OBJECT_MIN_ZOOM;
-        }
-    }
-
-    new_distance = llmax(new_distance, min_zoom); 
-
-    F32 max_distance = getCameraMaxZoomDistance();
+	if (gDisconnected)
+	{
+		return;
+	}
+
+	LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+	if (LLToolMgr::getInstance()->inBuildMode() && selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+	{
+		// just update hud zoom level
+		mHUDTargetZoom /= fraction;
+		return;
+	}
+
+
+	LLVector3d	camera_offset_unit(mCameraFocusOffsetTarget);
+	F32 min_zoom = LAND_MIN_ZOOM;
+	F32 current_distance = (F32)camera_offset_unit.normalize();
+	F32 new_distance = current_distance * fraction;
+
+	// Don't move through focus point
+	if (mFocusObject)
+	{
+		LLVector3 camera_offset_dir((F32)camera_offset_unit.mdV[VX], (F32)camera_offset_unit.mdV[VY], (F32)camera_offset_unit.mdV[VZ]);
+
+		if (mFocusObject->isAvatar())
+		{
+			calcCameraMinDistance(min_zoom);
+		}
+		else
+		{
+			min_zoom = OBJECT_MIN_ZOOM;
+		}
+	}
+
+	new_distance = llmax(new_distance, min_zoom); 
+
+	F32 max_distance = getCameraMaxZoomDistance();
 
     max_distance = llmin(max_distance, current_distance * 4.f); //Scaled max relative to current distance.  MAINT-3154
 
-    if (new_distance > max_distance)
-    {
-        new_distance = max_distance;
-
-        /*
-        // Unless camera is unlocked
-        if (!LLViewerCamera::sDisableCameraConstraints)
-        {
-            return;
-        }
-        */
-    }
-
-    if(cameraCustomizeAvatar())
-    {
-        new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
-    }
-
-    mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
+	if (new_distance > max_distance)
+	{
+		new_distance = max_distance;
+
+		/*
+		// Unless camera is unlocked
+		if (!LLViewerCamera::sDisableCameraConstraints)
+		{
+			return;
+		}
+		*/
+	}
+
+	if(cameraCustomizeAvatar())
+	{
+		new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
+	}
+
+	mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
 }
 
 //-----------------------------------------------------------------------------
@@ -935,62 +935,62 @@ void LLAgentCamera::cameraZoomIn(const F32 fraction)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraOrbitIn(const F32 meters)
 {
-    if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
-    {
-        F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"));
-        
-        mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist;
-
-        if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f)
-        {
-            // No need to animate, camera is already there.
-            changeCameraToMouselook(FALSE);
-        }
-
-        mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION);
-    }
-    else
-    {
-        LLVector3d  camera_offset_unit(mCameraFocusOffsetTarget);
-        F32 current_distance = (F32)camera_offset_unit.normalize();
-        F32 new_distance = current_distance - meters;
-        F32 min_zoom = LAND_MIN_ZOOM;
-        
-        // Don't move through focus point
-        if (mFocusObject.notNull())
-        {
-            if (mFocusObject->isAvatar())
-            {
-                min_zoom = AVATAR_MIN_ZOOM;
-            }
-            else
-            {
-                min_zoom = OBJECT_MIN_ZOOM;
-            }
-        }
-
-        new_distance = llmax(new_distance, min_zoom);
-
-        F32 max_distance = getCameraMaxZoomDistance();
-
-        if (new_distance > max_distance)
-        {
-            // Unless camera is unlocked
-            if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
-            {
-                return;
-            }
-        }
-
-        if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() )
-        {
-            new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
-        }
-
-        // Compute new camera offset
-        mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
-        cameraZoomIn(1.f);
-    }
+	if (mFocusOnAvatar && mCameraMode == CAMERA_MODE_THIRD_PERSON)
+	{
+		F32 camera_offset_dist = llmax(0.001f, getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale"));
+		
+		mCameraZoomFraction = (mTargetCameraDistance - meters) / camera_offset_dist;
+
+		if (!gSavedSettings.getBOOL("FreezeTime") && mCameraZoomFraction < MIN_ZOOM_FRACTION && meters > 0.f)
+		{
+			// No need to animate, camera is already there.
+			changeCameraToMouselook(FALSE);
+		}
+
+		mCameraZoomFraction = llclamp(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION);
+	}
+	else
+	{
+		LLVector3d	camera_offset_unit(mCameraFocusOffsetTarget);
+		F32 current_distance = (F32)camera_offset_unit.normalize();
+		F32 new_distance = current_distance - meters;
+		F32 min_zoom = LAND_MIN_ZOOM;
+		
+		// Don't move through focus point
+		if (mFocusObject.notNull())
+		{
+			if (mFocusObject->isAvatar())
+			{
+				min_zoom = AVATAR_MIN_ZOOM;
+			}
+			else
+			{
+				min_zoom = OBJECT_MIN_ZOOM;
+			}
+		}
+
+		new_distance = llmax(new_distance, min_zoom);
+
+		F32 max_distance = getCameraMaxZoomDistance();
+
+		if (new_distance > max_distance)
+		{
+			// Unless camera is unlocked
+			if (!gSavedSettings.getBOOL("DisableCameraConstraints"))
+			{
+				return;
+			}
+		}
+
+		if( CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode() )
+		{
+			new_distance = llclamp( new_distance, APPEARANCE_MIN_ZOOM, APPEARANCE_MAX_ZOOM );
+		}
+
+		// Compute new camera offset
+		mCameraFocusOffsetTarget = new_distance * camera_offset_unit;
+		cameraZoomIn(1.f);
+	}
 }
 
 
@@ -999,15 +999,15 @@ void LLAgentCamera::cameraOrbitIn(const F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraPanIn(F32 meters)
 {
-    LLVector3d at_axis;
-    at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis());
-
-    mFocusTargetGlobal += meters * at_axis;
-    mFocusGlobal = mFocusTargetGlobal;
-    // don't enforce zoom constraints as this is the only way for users to get past them easily
-    updateFocusOffset();
-    // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
-    mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+	LLVector3d at_axis;
+	at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis());
+
+	mFocusTargetGlobal += meters * at_axis;
+	mFocusGlobal = mFocusTargetGlobal;
+	// don't enforce zoom constraints as this is the only way for users to get past them easily
+	updateFocusOffset();
+	// NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
+	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
 //-----------------------------------------------------------------------------
@@ -1015,19 +1015,19 @@ void LLAgentCamera::cameraPanIn(F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraPanLeft(F32 meters)
 {
-    LLVector3d left_axis;
-    left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
-
-    mFocusTargetGlobal += meters * left_axis;
-    mFocusGlobal = mFocusTargetGlobal;
-
-    // disable smoothing for camera pan, which causes some residents unhappiness
-    mCameraSmoothingStop = true;
-    
-    cameraZoomIn(1.f);
-    updateFocusOffset();
-    // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx
-    mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+	LLVector3d left_axis;
+	left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
+
+	mFocusTargetGlobal += meters * left_axis;
+	mFocusGlobal = mFocusTargetGlobal;
+
+	// disable smoothing for camera pan, which causes some residents unhappiness
+	mCameraSmoothingStop = true;
+	
+	cameraZoomIn(1.f);
+	updateFocusOffset();
+	// NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind - Nyx
+	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
 //-----------------------------------------------------------------------------
@@ -1035,19 +1035,19 @@ void LLAgentCamera::cameraPanLeft(F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::cameraPanUp(F32 meters)
 {
-    LLVector3d up_axis;
-    up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis());
+	LLVector3d up_axis;
+	up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis());
 
-    mFocusTargetGlobal += meters * up_axis;
-    mFocusGlobal = mFocusTargetGlobal;
+	mFocusTargetGlobal += meters * up_axis;
+	mFocusGlobal = mFocusTargetGlobal;
 
-    // disable smoothing for camera pan, which causes some residents unhappiness
-    mCameraSmoothingStop = true;
+	// disable smoothing for camera pan, which causes some residents unhappiness
+	mCameraSmoothingStop = true;
 
-    cameraZoomIn(1.f);
-    updateFocusOffset();
-    // NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
-    mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+	cameraZoomIn(1.f);
+	updateFocusOffset();
+	// NOTE: panning movements expect the camera to move exactly with the focus target, not animated behind -Nyx
+	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
 //-----------------------------------------------------------------------------
@@ -1055,67 +1055,67 @@ void LLAgentCamera::cameraPanUp(F32 meters)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y)
 {
-    static LLVector3 last_at_axis;
-
-    if (!isAgentAvatarValid()) return;
-
-    LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation();
-    LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation();
-
-    if  (LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
-        && (root_at * last_at_axis > 0.95f))
-    {
-        LLVector3 vel = gAgentAvatarp->getVelocity();
-        if (vel.magVecSquared() > 4.f)
-        {
-            setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot);
-        }
-        else
-        {
-            // *FIX: rotate mframeagent by sit object's rotation?
-            LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
-            LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
-            setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset);
-        }
-        last_at_axis = root_at;
-        return;
-    }
-
-    last_at_axis = root_at;
-    
-    if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
-    {
-        setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f));    
-    }
-    else
-    {
-        // Move head based on cursor position
-        ELookAtType lookAtType = LOOKAT_TARGET_NONE;
-        LLVector3 headLookAxis;
-        LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance());
-
-        if (cameraMouselook())
-        {
-            lookAtType = LOOKAT_TARGET_MOUSELOOK;
-        }
-        else if (cameraThirdPerson())
-        {
-            // range from -.5 to .5
-            F32 x_from_center = 
-                ((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f;
-            F32 y_from_center = 
-                ((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f;
-
-            frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD);
-            frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD);
-            lookAtType = LOOKAT_TARGET_FREELOOK;
-        }
-
-        headLookAxis = frameCamera.getAtAxis();
-        // RN: we use world-space offset for mouselook and freelook
-        //headLookAxis = headLookAxis * av_inv_rot;
-        setLookAt(lookAtType, gAgentAvatarp, headLookAxis);
-    }
+	static LLVector3 last_at_axis;
+
+	if (!isAgentAvatarValid()) return;
+
+	LLQuaternion av_inv_rot = ~gAgentAvatarp->mRoot->getWorldRotation();
+	LLVector3 root_at = LLVector3::x_axis * gAgentAvatarp->mRoot->getWorldRotation();
+
+	if 	(LLTrace::get_frame_recording().getLastRecording().getLastValue(*gViewerWindow->getMouseVelocityStat()) < 0.01f
+		&& (root_at * last_at_axis > 0.95f))
+	{
+		LLVector3 vel = gAgentAvatarp->getVelocity();
+		if (vel.magVecSquared() > 4.f)
+		{
+			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, vel * av_inv_rot);
+		}
+		else
+		{
+			// *FIX: rotate mframeagent by sit object's rotation?
+			LLQuaternion look_rotation = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion(); // use camera's current rotation
+			LLVector3 look_offset = LLVector3(2.f, 0.f, 0.f) * look_rotation * av_inv_rot;
+			setLookAt(LOOKAT_TARGET_IDLE, gAgentAvatarp, look_offset);
+		}
+		last_at_axis = root_at;
+		return;
+	}
+
+	last_at_axis = root_at;
+	
+	if (CAMERA_MODE_CUSTOMIZE_AVATAR == getCameraMode())
+	{
+		setLookAt(LOOKAT_TARGET_NONE, gAgentAvatarp, LLVector3(-2.f, 0.f, 0.f));	
+	}
+	else
+	{
+		// Move head based on cursor position
+		ELookAtType lookAtType = LOOKAT_TARGET_NONE;
+		LLVector3 headLookAxis;
+		LLCoordFrame frameCamera = *((LLCoordFrame*)LLViewerCamera::getInstance());
+
+		if (cameraMouselook())
+		{
+			lookAtType = LOOKAT_TARGET_MOUSELOOK;
+		}
+		else if (cameraThirdPerson())
+		{
+			// range from -.5 to .5
+			F32 x_from_center = 
+				((F32) mouse_x / (F32) gViewerWindow->getWorldViewWidthScaled() ) - 0.5f;
+			F32 y_from_center = 
+				((F32) mouse_y / (F32) gViewerWindow->getWorldViewHeightScaled() ) - 0.5f;
+
+			frameCamera.yaw( - x_from_center * gSavedSettings.getF32("YawFromMousePosition") * DEG_TO_RAD);
+			frameCamera.pitch( - y_from_center * gSavedSettings.getF32("PitchFromMousePosition") * DEG_TO_RAD);
+			lookAtType = LOOKAT_TARGET_FREELOOK;
+		}
+
+		headLookAxis = frameCamera.getAtAxis();
+		// RN: we use world-space offset for mouselook and freelook
+		//headLookAxis = headLookAxis * av_inv_rot;
+		setLookAt(lookAtType, gAgentAvatarp, headLookAxis);
+	}
 }
 
 static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera");
@@ -1125,373 +1125,373 @@ static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera");
 //-----------------------------------------------------------------------------
 void LLAgentCamera::updateCamera()
 {
-    LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA);
-
-    // - changed camera_skyward to the new global "mCameraUpVector"
-    mCameraUpVector = LLVector3::z_axis;
-    //LLVector3 camera_skyward(0.f, 0.f, 1.f);
-
-    U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode;
-
-    validateFocusObject();
-
-    if (isAgentAvatarValid() && 
-        gAgentAvatarp->isSitting() &&
-        camera_mode == CAMERA_MODE_MOUSELOOK)
-    {
-        //changed camera_skyward to the new global "mCameraUpVector"
-        mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
-    }
-
-    if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams())
-    {
-        mAllowChangeToFollow = FALSE;
-        mFocusOnAvatar = TRUE;
-        changeCameraToFollow();
-    }
-
-    //NOTE - this needs to be integrated into a general upVector system here within llAgent. 
-    if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar )
-    {
-        mCameraUpVector = mFollowCam.getUpVector();
-    }
-
-    if (mSitCameraEnabled)
-    {
-        if (mSitCameraReferenceObject->isDead())
-        {
-            setSitCamera(LLUUID::null);
-        }
-    }
-
-    // Update UI with our camera inputs
-    LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
-    if (camera_floater)
-    {
-        camera_floater->mRotate->setToggleState(gAgentCamera.getOrbitRightKey() > 0.f,  // left
-                                                gAgentCamera.getOrbitUpKey() > 0.f,     // top
-                                                gAgentCamera.getOrbitLeftKey() > 0.f,   // right
-                                                gAgentCamera.getOrbitDownKey() > 0.f);  // bottom
-        
-        camera_floater->mTrack->setToggleState(gAgentCamera.getPanLeftKey() > 0.f,      // left
-                                               gAgentCamera.getPanUpKey() > 0.f,            // top
-                                               gAgentCamera.getPanRightKey() > 0.f,     // right
-                                               gAgentCamera.getPanDownKey() > 0.f);     // bottom
-    }
-
-    // Handle camera movement based on keyboard.
-    const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD;          // radians per second
-    const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD;        // radians per second
-    const F32 PAN_RATE = 5.f;                               // meters per second
-
-    if (gAgentCamera.getOrbitUpKey() || gAgentCamera.getOrbitDownKey())
-    {
-        F32 input_rate = gAgentCamera.getOrbitUpKey() - gAgentCamera.getOrbitDownKey();
-        cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped );
-    }
-
-    if (gAgentCamera.getOrbitLeftKey() || gAgentCamera.getOrbitRightKey())
-    {
-        F32 input_rate = gAgentCamera.getOrbitLeftKey() - gAgentCamera.getOrbitRightKey();
-        cameraOrbitAround(input_rate * ORBIT_AROUND_RATE / gFPSClamped);
-    }
-
-    if (gAgentCamera.getOrbitInKey() || gAgentCamera.getOrbitOutKey())
-    {
-        F32 input_rate = gAgentCamera.getOrbitInKey() - gAgentCamera.getOrbitOutKey();
-        
-        LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal();
-        F32 distance_to_focus = (F32)to_focus.magVec();
-        // Move at distance (in meters) meters per second
-        cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped );
-    }
-
-    if (gAgentCamera.getPanInKey() || gAgentCamera.getPanOutKey())
-    {
-        F32 input_rate = gAgentCamera.getPanInKey() - gAgentCamera.getPanOutKey();
-        cameraPanIn(input_rate * PAN_RATE / gFPSClamped);
-    }
-
-    if (gAgentCamera.getPanRightKey() || gAgentCamera.getPanLeftKey())
-    {
-        F32 input_rate = gAgentCamera.getPanRightKey() - gAgentCamera.getPanLeftKey();
-        cameraPanLeft(input_rate * -PAN_RATE / gFPSClamped );
-    }
-
-    if (gAgentCamera.getPanUpKey() || gAgentCamera.getPanDownKey())
-    {
-        F32 input_rate = gAgentCamera.getPanUpKey() - gAgentCamera.getPanDownKey();
-        cameraPanUp(input_rate * PAN_RATE / gFPSClamped );
-    }
-
-    // Clear camera keyboard keys.
-    gAgentCamera.clearOrbitKeys();
-    gAgentCamera.clearPanKeys();
-
-    // lerp camera focus offset
-    mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
-
-    if ( mCameraMode == CAMERA_MODE_FOLLOW )
-    {
-        if (isAgentAvatarValid())
-        {
-            //--------------------------------------------------------------------------------
-            // this is where the avatar's position and rotation are given to followCam, and 
-            // where it is updated. All three of its attributes are updated: (1) position, 
-            // (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent.
-            //--------------------------------------------------------------------------------
-            // *TODO: use combined rotation of frameagent and sit object
-            LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
-
-            LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
-            if (current_cam)
-            {
-                mFollowCam.copyParams(*current_cam);
-                mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
-                mFollowCam.update();
-                LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
-            }
-            else
-            {
-                changeCameraToThirdPerson(TRUE);
-            }
-        }
-    }
-
-    BOOL hit_limit;
-    LLVector3d camera_pos_global;
-    LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit);
-    mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global);
-    LLVector3d focus_target_global = calcFocusPositionTargetGlobal();
-
-    // perform field of view correction
-    mCameraFOVZoomFactor = calcCameraFOVZoomFactor();
-    camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor);
-
-    gAgent.setShowAvatar(TRUE); // can see avatar by default
-
-    // Adjust position for animation
-    if (mCameraAnimating)
-    {
-        F32 time = mAnimationTimer.getElapsedTimeF32();
-
-        // yet another instance of critically damped motion, hooray!
-        // F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE);
-
-        // linear interpolation
-        F32 fraction_of_animation = time / mAnimationDuration;
-
-        BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK;
-        BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK;
-        F32 fraction_animation_to_skip;
-
-        if (mAnimationCameraStartGlobal == camera_target_global)
-        {
-            fraction_animation_to_skip = 0.f;
-        }
-        else
-        {
-            LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global;
-            fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec();
-        }
-        F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f;
-        F32 animation_finish_fraction =  (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f;
-    
-        if (fraction_of_animation < animation_finish_fraction)
-        {
-            if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction )
-            {
-                gAgent.setShowAvatar(FALSE);
-            }
-
-            // ...adjust position for animation
-            F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation);
-            camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation);
-            mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation);
-        }
-        else
-        {
-            // ...animation complete
-            mCameraAnimating = FALSE;
-
-            camera_pos_global = camera_target_global;
-            mFocusGlobal = focus_target_global;
-
-            gAgent.endAnimationUpdateUI();
-            gAgent.setShowAvatar(TRUE);
-        }
-
-        if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK))
-        {
-            gAgentAvatarp->updateAttachmentVisibility(mCameraMode);
-        }
-    }
-    else 
-    {
-        camera_pos_global = camera_target_global;
-        mFocusGlobal = focus_target_global;
-        gAgent.setShowAvatar(TRUE);
-    }
-
-    // smoothing
-    if (TRUE)
-    {
-        LLVector3d agent_pos = gAgent.getPositionGlobal();
-        LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
-        // Sitting on what you're manipulating can cause camera jitter with smoothing. 
-        // This turns off smoothing while editing. -MG
-        bool in_build_mode = LLToolMgr::getInstance()->inBuildMode();
-        mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode;
-        
-        if (cameraThirdPerson() && !mCameraSmoothingStop)
-        {
-            const F32 SMOOTHING_HALF_LIFE = 0.02f;
-            
-            F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
-                    
-            if (!mFocusObject)  // we differentiate on avatar mode 
-            {
-                // for avatar-relative focus, we smooth in avatar space -
-                // the avatar moves too jerkily w/r/t global space to smooth there.
-
-                LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent;
-                if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE)  // only smooth over short distances please
-                {
-                    camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing);
-                    camera_pos_global = camera_pos_agent + agent_pos;
-                }
-            }
-            else
-            {
-                LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal;
-                if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
-                {
-                    camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing);
-                }
-            }
-        }
-                                 
-        mCameraSmoothingLastPositionGlobal = camera_pos_global;
-        mCameraSmoothingLastPositionAgent = camera_pos_agent;
-        mCameraSmoothingStop = false;
-    }
-
-    
-    mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE));
-
-//  LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL;
-
-    LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal);
-    
-    mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global);
-
-    // Move the camera
-
-    LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent);
-    //LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent);
-    
-    // Change FOV
-    LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor));
-
-    // follow camera when in customize mode
-    if (cameraCustomizeAvatar())    
-    {
-        setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent);
-    }
-
-    // update the travel distance stat
-    // this isn't directly related to the camera
-    // but this seemed like the best place to do this
-    LLVector3d global_pos = gAgent.getPositionGlobal(); 
-    if (!gAgent.getLastPositionGlobal().isExactlyZero())
-    {
-        LLVector3d delta = global_pos - gAgent.getLastPositionGlobal();
-        gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec());
-    }
-    gAgent.setLastPositionGlobal(global_pos);
-    
-    if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook())
-    {
-        LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + 
-            LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + 
-            LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation();
-        LLVector3 diff = mCameraPositionAgent - head_pos;
-        diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation();
-
-        LLJoint* torso_joint = gAgentAvatarp->mTorsop;
-        LLJoint* chest_joint = gAgentAvatarp->mChestp;
-        LLVector3 torso_scale = torso_joint->getScale();
-        LLVector3 chest_scale = chest_joint->getScale();
-
-        // shorten avatar skeleton to avoid foot interpenetration
-        if (!gAgentAvatarp->mInAir)
-        {
-            LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation();
-            F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f);
-            F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f);
-            torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
-
-            LLJoint* neck_joint = gAgentAvatarp->mNeckp;
-            LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation();
-            scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f);
-            chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
-            diff.mV[VZ] = 0.f;
-        }
-
-        // SL-315
-        gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff);
-
-        gAgentAvatarp->mRoot->updateWorldMatrixChildren();
-
-        for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
-             iter != gAgentAvatarp->mAttachmentPoints.end(); )
-        {
-            LLVOAvatar::attachment_map_t::iterator curiter = iter++;
-            LLViewerJointAttachment* attachment = curiter->second;
-            for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
-                 attachment_iter != attachment->mAttachedObjects.end();
-                 ++attachment_iter)
-            {
-                LLViewerObject *attached_object = (*attachment_iter);
-                if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
-                {
-                    // clear any existing "early" movements of attachment
-                    attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE);
-                    gPipeline.updateMoveNormalAsync(attached_object->mDrawable);
-                    attached_object->updateText();
-                }
-            }
-        }
-
-        torso_joint->setScale(torso_scale);
-        chest_joint->setScale(chest_scale);
-    }
+	LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA);
+
+	// - changed camera_skyward to the new global "mCameraUpVector"
+	mCameraUpVector = LLVector3::z_axis;
+	//LLVector3	camera_skyward(0.f, 0.f, 1.f);
+
+	U32 camera_mode = mCameraAnimating ? mLastCameraMode : mCameraMode;
+
+	validateFocusObject();
+
+	if (isAgentAvatarValid() && 
+		gAgentAvatarp->isSitting() &&
+		camera_mode == CAMERA_MODE_MOUSELOOK)
+	{
+		//changed camera_skyward to the new global "mCameraUpVector"
+		mCameraUpVector = mCameraUpVector * gAgentAvatarp->getRenderRotation();
+	}
+
+	if (cameraThirdPerson() && (mFocusOnAvatar || mAllowChangeToFollow) && LLFollowCamMgr::getActiveFollowCamParams())
+	{
+		mAllowChangeToFollow = FALSE;
+		mFocusOnAvatar = TRUE;
+		changeCameraToFollow();
+	}
+
+	//NOTE - this needs to be integrated into a general upVector system here within llAgent. 
+	if ( camera_mode == CAMERA_MODE_FOLLOW && mFocusOnAvatar )
+	{
+		mCameraUpVector = mFollowCam.getUpVector();
+	}
+
+	if (mSitCameraEnabled)
+	{
+		if (mSitCameraReferenceObject->isDead())
+		{
+			setSitCamera(LLUUID::null);
+		}
+	}
+
+	// Update UI with our camera inputs
+	LLFloaterCamera* camera_floater = LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
+	if (camera_floater)
+	{
+		camera_floater->mRotate->setToggleState(gAgentCamera.getOrbitRightKey() > 0.f,	// left
+												gAgentCamera.getOrbitUpKey() > 0.f,		// top
+												gAgentCamera.getOrbitLeftKey() > 0.f,	// right
+												gAgentCamera.getOrbitDownKey() > 0.f);	// bottom
+		
+		camera_floater->mTrack->setToggleState(gAgentCamera.getPanLeftKey() > 0.f,		// left
+											   gAgentCamera.getPanUpKey() > 0.f,			// top
+											   gAgentCamera.getPanRightKey() > 0.f,		// right
+											   gAgentCamera.getPanDownKey() > 0.f);		// bottom
+	}
+
+	// Handle camera movement based on keyboard.
+	const F32 ORBIT_OVER_RATE = 90.f * DEG_TO_RAD;			// radians per second
+	const F32 ORBIT_AROUND_RATE = 90.f * DEG_TO_RAD;		// radians per second
+	const F32 PAN_RATE = 5.f;								// meters per second
+
+	if (gAgentCamera.getOrbitUpKey() || gAgentCamera.getOrbitDownKey())
+	{
+		F32 input_rate = gAgentCamera.getOrbitUpKey() - gAgentCamera.getOrbitDownKey();
+		cameraOrbitOver( input_rate * ORBIT_OVER_RATE / gFPSClamped );
+	}
+
+	if (gAgentCamera.getOrbitLeftKey() || gAgentCamera.getOrbitRightKey())
+	{
+		F32 input_rate = gAgentCamera.getOrbitLeftKey() - gAgentCamera.getOrbitRightKey();
+		cameraOrbitAround(input_rate * ORBIT_AROUND_RATE / gFPSClamped);
+	}
+
+	if (gAgentCamera.getOrbitInKey() || gAgentCamera.getOrbitOutKey())
+	{
+		F32 input_rate = gAgentCamera.getOrbitInKey() - gAgentCamera.getOrbitOutKey();
+		
+		LLVector3d to_focus = gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin()) - calcFocusPositionTargetGlobal();
+		F32 distance_to_focus = (F32)to_focus.magVec();
+		// Move at distance (in meters) meters per second
+		cameraOrbitIn( input_rate * distance_to_focus / gFPSClamped );
+	}
+
+	if (gAgentCamera.getPanInKey() || gAgentCamera.getPanOutKey())
+	{
+		F32 input_rate = gAgentCamera.getPanInKey() - gAgentCamera.getPanOutKey();
+		cameraPanIn(input_rate * PAN_RATE / gFPSClamped);
+	}
+
+	if (gAgentCamera.getPanRightKey() || gAgentCamera.getPanLeftKey())
+	{
+		F32 input_rate = gAgentCamera.getPanRightKey() - gAgentCamera.getPanLeftKey();
+		cameraPanLeft(input_rate * -PAN_RATE / gFPSClamped );
+	}
+
+	if (gAgentCamera.getPanUpKey() || gAgentCamera.getPanDownKey())
+	{
+		F32 input_rate = gAgentCamera.getPanUpKey() - gAgentCamera.getPanDownKey();
+		cameraPanUp(input_rate * PAN_RATE / gFPSClamped );
+	}
+
+	// Clear camera keyboard keys.
+	gAgentCamera.clearOrbitKeys();
+	gAgentCamera.clearPanKeys();
+
+	// lerp camera focus offset
+	mCameraFocusOffset = lerp(mCameraFocusOffset, mCameraFocusOffsetTarget, LLSmoothInterpolation::getInterpolant(CAMERA_FOCUS_HALF_LIFE));
+
+	if ( mCameraMode == CAMERA_MODE_FOLLOW )
+	{
+		if (isAgentAvatarValid())
+		{
+			//--------------------------------------------------------------------------------
+			// this is where the avatar's position and rotation are given to followCam, and 
+			// where it is updated. All three of its attributes are updated: (1) position, 
+			// (2) focus, and (3) upvector. They can then be queried elsewhere in llAgent.
+			//--------------------------------------------------------------------------------
+			// *TODO: use combined rotation of frameagent and sit object
+			LLQuaternion avatarRotationForFollowCam = gAgentAvatarp->isSitting() ? gAgentAvatarp->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
+
+			LLFollowCamParams* current_cam = LLFollowCamMgr::getActiveFollowCamParams();
+			if (current_cam)
+			{
+				mFollowCam.copyParams(*current_cam);
+				mFollowCam.setSubjectPositionAndRotation( gAgentAvatarp->getRenderPosition(), avatarRotationForFollowCam );
+				mFollowCam.update();
+				LLViewerJoystick::getInstance()->setCameraNeedsUpdate(true);
+			}
+			else
+			{
+				changeCameraToThirdPerson(TRUE);
+			}
+		}
+	}
+
+	BOOL hit_limit;
+	LLVector3d camera_pos_global;
+	LLVector3d camera_target_global = calcCameraPositionTargetGlobal(&hit_limit);
+	mCameraVirtualPositionAgent = gAgent.getPosAgentFromGlobal(camera_target_global);
+	LLVector3d focus_target_global = calcFocusPositionTargetGlobal();
+
+	// perform field of view correction
+	mCameraFOVZoomFactor = calcCameraFOVZoomFactor();
+	camera_target_global = focus_target_global + (camera_target_global - focus_target_global) * (1.f + mCameraFOVZoomFactor);
+
+	gAgent.setShowAvatar(TRUE); // can see avatar by default
+
+	// Adjust position for animation
+	if (mCameraAnimating)
+	{
+		F32 time = mAnimationTimer.getElapsedTimeF32();
+
+		// yet another instance of critically damped motion, hooray!
+		// F32 fraction_of_animation = 1.f - pow(2.f, -time / CAMERA_ZOOM_HALF_LIFE);
+
+		// linear interpolation
+		F32 fraction_of_animation = time / mAnimationDuration;
+
+		BOOL isfirstPerson = mCameraMode == CAMERA_MODE_MOUSELOOK;
+		BOOL wasfirstPerson = mLastCameraMode == CAMERA_MODE_MOUSELOOK;
+		F32 fraction_animation_to_skip;
+
+		if (mAnimationCameraStartGlobal == camera_target_global)
+		{
+			fraction_animation_to_skip = 0.f;
+		}
+		else
+		{
+			LLVector3d cam_delta = mAnimationCameraStartGlobal - camera_target_global;
+			fraction_animation_to_skip = HEAD_BUFFER_SIZE / (F32)cam_delta.magVec();
+		}
+		F32 animation_start_fraction = (wasfirstPerson) ? fraction_animation_to_skip : 0.f;
+		F32 animation_finish_fraction =  (isfirstPerson) ? (1.f - fraction_animation_to_skip) : 1.f;
+	
+		if (fraction_of_animation < animation_finish_fraction)
+		{
+			if (fraction_of_animation < animation_start_fraction || fraction_of_animation > animation_finish_fraction )
+			{
+				gAgent.setShowAvatar(FALSE);
+			}
+
+			// ...adjust position for animation
+			F32 smooth_fraction_of_animation = llsmoothstep(0.0f, 1.0f, fraction_of_animation);
+			camera_pos_global = lerp(mAnimationCameraStartGlobal, camera_target_global, smooth_fraction_of_animation);
+			mFocusGlobal = lerp(mAnimationFocusStartGlobal, focus_target_global, smooth_fraction_of_animation);
+		}
+		else
+		{
+			// ...animation complete
+			mCameraAnimating = FALSE;
+
+			camera_pos_global = camera_target_global;
+			mFocusGlobal = focus_target_global;
+
+			gAgent.endAnimationUpdateUI();
+			gAgent.setShowAvatar(TRUE);
+		}
+
+		if (isAgentAvatarValid() && (mCameraMode != CAMERA_MODE_MOUSELOOK))
+		{
+			gAgentAvatarp->updateAttachmentVisibility(mCameraMode);
+		}
+	}
+	else 
+	{
+		camera_pos_global = camera_target_global;
+		mFocusGlobal = focus_target_global;
+		gAgent.setShowAvatar(TRUE);
+	}
+
+	// smoothing
+	if (TRUE)
+	{
+		LLVector3d agent_pos = gAgent.getPositionGlobal();
+		LLVector3d camera_pos_agent = camera_pos_global - agent_pos;
+		// Sitting on what you're manipulating can cause camera jitter with smoothing. 
+		// This turns off smoothing while editing. -MG
+		bool in_build_mode = LLToolMgr::getInstance()->inBuildMode();
+		mCameraSmoothingStop = mCameraSmoothingStop || in_build_mode;
+		
+		if (cameraThirdPerson() && !mCameraSmoothingStop)
+		{
+			const F32 SMOOTHING_HALF_LIFE = 0.02f;
+			
+			F32 smoothing = LLSmoothInterpolation::getInterpolant(gSavedSettings.getF32("CameraPositionSmoothing") * SMOOTHING_HALF_LIFE, FALSE);
+					
+			if (!mFocusObject)  // we differentiate on avatar mode 
+			{
+				// for avatar-relative focus, we smooth in avatar space -
+				// the avatar moves too jerkily w/r/t global space to smooth there.
+
+				LLVector3d delta = camera_pos_agent - mCameraSmoothingLastPositionAgent;
+				if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE)  // only smooth over short distances please
+				{
+					camera_pos_agent = lerp(mCameraSmoothingLastPositionAgent, camera_pos_agent, smoothing);
+					camera_pos_global = camera_pos_agent + agent_pos;
+				}
+			}
+			else
+			{
+				LLVector3d delta = camera_pos_global - mCameraSmoothingLastPositionGlobal;
+				if (delta.magVec() < MAX_CAMERA_SMOOTH_DISTANCE) // only smooth over short distances please
+				{
+					camera_pos_global = lerp(mCameraSmoothingLastPositionGlobal, camera_pos_global, smoothing);
+				}
+			}
+		}
+								 
+		mCameraSmoothingLastPositionGlobal = camera_pos_global;
+		mCameraSmoothingLastPositionAgent = camera_pos_agent;
+		mCameraSmoothingStop = false;
+	}
+
+	
+	mCameraCurrentFOVZoomFactor = lerp(mCameraCurrentFOVZoomFactor, mCameraFOVZoomFactor, LLSmoothInterpolation::getInterpolant(FOV_ZOOM_HALF_LIFE));
+
+//	LL_INFOS() << "Current FOV Zoom: " << mCameraCurrentFOVZoomFactor << " Target FOV Zoom: " << mCameraFOVZoomFactor << " Object penetration: " << mFocusObjectDist << LL_ENDL;
+
+	LLVector3 focus_agent = gAgent.getPosAgentFromGlobal(mFocusGlobal);
+	
+	mCameraPositionAgent = gAgent.getPosAgentFromGlobal(camera_pos_global);
+
+	// Move the camera
+
+	LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, mCameraUpVector, focus_agent);
+	//LLViewerCamera::getInstance()->updateCameraLocation(mCameraPositionAgent, camera_skyward, focus_agent);
+	
+	// Change FOV
+	LLViewerCamera::getInstance()->setView(LLViewerCamera::getInstance()->getDefaultFOV() / (1.f + mCameraCurrentFOVZoomFactor));
+
+	// follow camera when in customize mode
+	if (cameraCustomizeAvatar())	
+	{
+		setLookAt(LOOKAT_TARGET_FOCUS, NULL, mCameraPositionAgent);
+	}
+
+	// update the travel distance stat
+	// this isn't directly related to the camera
+	// but this seemed like the best place to do this
+	LLVector3d global_pos = gAgent.getPositionGlobal(); 
+	if (!gAgent.getLastPositionGlobal().isExactlyZero())
+	{
+		LLVector3d delta = global_pos - gAgent.getLastPositionGlobal();
+		gAgent.setDistanceTraveled(gAgent.getDistanceTraveled() + delta.magVec());
+	}
+	gAgent.setLastPositionGlobal(global_pos);
+	
+	if (LLVOAvatar::sVisibleInFirstPerson && isAgentAvatarValid() && !gAgentAvatarp->isSitting() && cameraMouselook())
+	{
+		LLVector3 head_pos = gAgentAvatarp->mHeadp->getWorldPosition() + 
+			LLVector3(0.08f, 0.f, 0.05f) * gAgentAvatarp->mHeadp->getWorldRotation() + 
+			LLVector3(0.1f, 0.f, 0.f) * gAgentAvatarp->mPelvisp->getWorldRotation();
+		LLVector3 diff = mCameraPositionAgent - head_pos;
+		diff = diff * ~gAgentAvatarp->mRoot->getWorldRotation();
+
+		LLJoint* torso_joint = gAgentAvatarp->mTorsop;
+		LLJoint* chest_joint = gAgentAvatarp->mChestp;
+		LLVector3 torso_scale = torso_joint->getScale();
+		LLVector3 chest_scale = chest_joint->getScale();
+
+		// shorten avatar skeleton to avoid foot interpenetration
+		if (!gAgentAvatarp->mInAir)
+		{
+			LLVector3 chest_offset = LLVector3(0.f, 0.f, chest_joint->getPosition().mV[VZ]) * torso_joint->getWorldRotation();
+			F32 z_compensate = llclamp(-diff.mV[VZ], -0.2f, 1.f);
+			F32 scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / chest_offset.mV[VZ]), 0.5f, 1.2f);
+			torso_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
+
+			LLJoint* neck_joint = gAgentAvatarp->mNeckp;
+			LLVector3 neck_offset = LLVector3(0.f, 0.f, neck_joint->getPosition().mV[VZ]) * chest_joint->getWorldRotation();
+			scale_factor = llclamp(1.f - ((z_compensate * 0.5f) / neck_offset.mV[VZ]), 0.5f, 1.2f);
+			chest_joint->setScale(LLVector3(1.f, 1.f, scale_factor));
+			diff.mV[VZ] = 0.f;
+		}
+
+		// SL-315
+		gAgentAvatarp->mPelvisp->setPosition(gAgentAvatarp->mPelvisp->getPosition() + diff);
+
+		gAgentAvatarp->mRoot->updateWorldMatrixChildren();
+
+		for (LLVOAvatar::attachment_map_t::iterator iter = gAgentAvatarp->mAttachmentPoints.begin(); 
+			 iter != gAgentAvatarp->mAttachmentPoints.end(); )
+		{
+			LLVOAvatar::attachment_map_t::iterator curiter = iter++;
+			LLViewerJointAttachment* attachment = curiter->second;
+			for (LLViewerJointAttachment::attachedobjs_vec_t::iterator attachment_iter = attachment->mAttachedObjects.begin();
+				 attachment_iter != attachment->mAttachedObjects.end();
+				 ++attachment_iter)
+			{
+				LLViewerObject *attached_object = (*attachment_iter);
+				if (attached_object && !attached_object->isDead() && attached_object->mDrawable.notNull())
+				{
+					// clear any existing "early" movements of attachment
+					attached_object->mDrawable->clearState(LLDrawable::EARLY_MOVE);
+					gPipeline.updateMoveNormalAsync(attached_object->mDrawable);
+					attached_object->updateText();
+				}
+			}
+		}
+
+		torso_joint->setScale(torso_scale);
+		chest_joint->setScale(chest_scale);
+	}
 }
 
 void LLAgentCamera::updateLastCamera()
 {
-    mLastCameraMode = mCameraMode;
+	mLastCameraMode = mCameraMode;
 }
 
 void LLAgentCamera::updateFocusOffset()
 {
-    validateFocusObject();
-    if (mFocusObject.notNull())
-    {
-        LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition());
-        mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos);
-    }
+	validateFocusObject();
+	if (mFocusObject.notNull())
+	{
+		LLVector3d obj_pos = gAgent.getPosGlobalFromAgent(mFocusObject->getRenderPosition());
+		mFocusObjectOffset.setVec(mFocusTargetGlobal - obj_pos);
+	}
 }
 
 void LLAgentCamera::validateFocusObject()
 {
-    if (mFocusObject.notNull() && 
-        mFocusObject->isDead())
-    {
-        mFocusObjectOffset.clearVec();
-        clearFocusObject();
-        mCameraFOVZoomFactor = 0.f;
-    }
+	if (mFocusObject.notNull() && 
+		mFocusObject->isDead())
+	{
+		mFocusObjectOffset.clearVec();
+		clearFocusObject();
+		mCameraFOVZoomFactor = 0.f;
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -1499,124 +1499,124 @@ void LLAgentCamera::validateFocusObject()
 //-----------------------------------------------------------------------------
 LLVector3d LLAgentCamera::calcFocusPositionTargetGlobal()
 {
-    if (mFocusObject.notNull() && mFocusObject->isDead())
-    {
-        clearFocusObject();
-    }
-
-    if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
-    {
-        mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus());
-        return mFocusTargetGlobal;
-    }
-    else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-    {
-        LLVector3d at_axis(1.0, 0.0, 0.0);
-        LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
-        if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-        {
-            LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot();
-            if (!root_object->flagCameraDecoupled())
-            {
-                agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
-            }
-        }
-        at_axis = at_axis * agent_rot;
-        mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis;
-        return mFocusTargetGlobal;
-    }
-    else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
-    {
-        if (mFocusOnAvatar)
-        {
-            LLVector3 focus_target = isAgentAvatarValid()
-                ? gAgentAvatarp->mHeadp->getWorldPosition()
-                : gAgent.getPositionAgent();
-            LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
-            mFocusTargetGlobal = focus_target_global;
-        }
-        return mFocusTargetGlobal;
-    }
-    else if (!mFocusOnAvatar)
-    {
-        if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull())
-        {
-            LLDrawable* drawablep = mFocusObject->mDrawable;
-            
-            if (mTrackFocusObject &&
-                drawablep && 
-                drawablep->isActive())
-            {
-                if (!mFocusObject->isAvatar())
-                {
-                    if (mFocusObject->isSelected())
-                    {
-                        gPipeline.updateMoveNormalAsync(drawablep);
-                    }
-                    else
-                    {
-                        if (drawablep->isState(LLDrawable::MOVE_UNDAMPED))
-                        {
-                            gPipeline.updateMoveNormalAsync(drawablep);
-                        }
-                        else
-                        {
-                            gPipeline.updateMoveDampedAsync(drawablep);
-                        }
-                    }
-                }
-            }
-            // if not tracking object, update offset based on new object position
-            else
-            {
-                updateFocusOffset();
-            }
-            LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset;
-            mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent));
-        }
-        return mFocusTargetGlobal;
-    }
-    else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull())
-    {
-        // sit camera
-        LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
-        LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
-
-        LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot);
-        return gAgent.getPosGlobalFromAgent(target_pos);
-    }
-    else
-    {
-        return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset();
-    }
+	if (mFocusObject.notNull() && mFocusObject->isDead())
+	{
+		clearFocusObject();
+	}
+
+	if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
+	{
+		mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedFocus());
+		return mFocusTargetGlobal;
+	}
+	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+	{
+		LLVector3d at_axis(1.0, 0.0, 0.0);
+		LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
+		if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+		{
+			LLViewerObject* root_object = (LLViewerObject*)gAgentAvatarp->getRoot();
+			if (!root_object->flagCameraDecoupled())
+			{
+				agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
+			}
+		}
+		at_axis = at_axis * agent_rot;
+		mFocusTargetGlobal = calcCameraPositionTargetGlobal() + at_axis;
+		return mFocusTargetGlobal;
+	}
+	else if (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR)
+	{
+		if (mFocusOnAvatar)
+		{
+			LLVector3 focus_target = isAgentAvatarValid()
+				? gAgentAvatarp->mHeadp->getWorldPosition()
+				: gAgent.getPositionAgent();
+			LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
+			mFocusTargetGlobal = focus_target_global;
+		}
+		return mFocusTargetGlobal;
+	}
+	else if (!mFocusOnAvatar)
+	{
+		if (mFocusObject.notNull() && !mFocusObject->isDead() && mFocusObject->mDrawable.notNull())
+		{
+			LLDrawable* drawablep = mFocusObject->mDrawable;
+			
+			if (mTrackFocusObject &&
+				drawablep && 
+				drawablep->isActive())
+			{
+				if (!mFocusObject->isAvatar())
+				{
+					if (mFocusObject->isSelected())
+					{
+						gPipeline.updateMoveNormalAsync(drawablep);
+					}
+					else
+					{
+						if (drawablep->isState(LLDrawable::MOVE_UNDAMPED))
+						{
+							gPipeline.updateMoveNormalAsync(drawablep);
+						}
+						else
+						{
+							gPipeline.updateMoveDampedAsync(drawablep);
+						}
+					}
+				}
+			}
+			// if not tracking object, update offset based on new object position
+			else
+			{
+				updateFocusOffset();
+			}
+			LLVector3 focus_agent = mFocusObject->getRenderPosition() + mFocusObjectOffset;
+			mFocusTargetGlobal.setVec(gAgent.getPosGlobalFromAgent(focus_agent));
+		}
+		return mFocusTargetGlobal;
+	}
+	else if (mSitCameraEnabled && isAgentAvatarValid() && gAgentAvatarp->isSitting() && mSitCameraReferenceObject.notNull())
+	{
+		// sit camera
+		LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
+		LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
+
+		LLVector3 target_pos = object_pos + (mSitCameraFocus * object_rot);
+		return gAgent.getPosGlobalFromAgent(target_pos);
+	}
+	else
+	{
+		return gAgent.getPositionGlobal() + calcThirdPersonFocusOffset();
+	}
 }
 
 LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()
 {
-    // ...offset from avatar
-    LLVector3d focus_offset;
-    LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
-    if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-    {
-        agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
-    }
-
-    focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
-    return focus_offset * agent_rot;
+	// ...offset from avatar
+	LLVector3d focus_offset;
+	LLQuaternion agent_rot = gAgent.getFrameAgent().getQuaternion();
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+	{
+		agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
+	}
+
+	focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
+	return focus_offset * agent_rot;
 }
 
 void LLAgentCamera::setupSitCamera()
 {
-    // agent frame entering this function is in world coordinates
-    if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-    {
-        LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-        // slam agent coordinate frame to proper parent local version
-        LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis();
-        at_axis.mV[VZ] = 0.f;
-        at_axis.normalize();
-        gAgent.resetAxes(at_axis * ~parent_rot);
-    }
+	// agent frame entering this function is in world coordinates
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+	{
+		LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+		// slam agent coordinate frame to proper parent local version
+		LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis();
+		at_axis.mV[VZ] = 0.f;
+		at_axis.normalize();
+		gAgent.resetAxes(at_axis * ~parent_rot);
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -1624,7 +1624,7 @@ void LLAgentCamera::setupSitCamera()
 //-----------------------------------------------------------------------------
 const LLVector3 &LLAgentCamera::getCameraPositionAgent() const
 {
-    return LLViewerCamera::getInstance()->getOrigin();
+	return LLViewerCamera::getInstance()->getOrigin();
 }
 
 //-----------------------------------------------------------------------------
@@ -1632,39 +1632,39 @@ const LLVector3 &LLAgentCamera::getCameraPositionAgent() const
 //-----------------------------------------------------------------------------
 LLVector3d LLAgentCamera::getCameraPositionGlobal() const
 {
-    return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin());
+	return gAgent.getPosGlobalFromAgent(LLViewerCamera::getInstance()->getOrigin());
 }
 
 //-----------------------------------------------------------------------------
 // calcCameraFOVZoomFactor()
 //-----------------------------------------------------------------------------
-F32 LLAgentCamera::calcCameraFOVZoomFactor()
+F32	LLAgentCamera::calcCameraFOVZoomFactor()
 {
-    LLVector3 camera_offset_dir;
-    camera_offset_dir.setVec(mCameraFocusOffset);
-
-    if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-    {
-        return 0.f;
-    }
-    else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar)
-    {
-        // don't FOV zoom on mostly transparent objects
-        F32 obj_min_dist = 0.f;
-        calcCameraMinDistance(obj_min_dist);
-        F32 current_distance = llmax(0.001f, camera_offset_dir.magVec());
-
-        mFocusObjectDist = obj_min_dist - current_distance;
-
-        F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f);
-        return new_fov_zoom;
-    }
-    else // focusing on land or avatar
-    {
-        // keep old field of view until user changes focus explicitly
-        return mCameraFOVZoomFactor;
-        //return 0.f;
-    }
+	LLVector3 camera_offset_dir;
+	camera_offset_dir.setVec(mCameraFocusOffset);
+
+	if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+	{
+		return 0.f;
+	}
+	else if (mFocusObject.notNull() && !mFocusObject->isAvatar() && !mFocusOnAvatar)
+	{
+		// don't FOV zoom on mostly transparent objects
+		F32 obj_min_dist = 0.f;
+		calcCameraMinDistance(obj_min_dist);
+		F32 current_distance = llmax(0.001f, camera_offset_dir.magVec());
+
+		mFocusObjectDist = obj_min_dist - current_distance;
+
+		F32 new_fov_zoom = llclamp(mFocusObjectDist / current_distance, 0.f, 1000.f);
+		return new_fov_zoom;
+	}
+	else // focusing on land or avatar
+	{
+		// keep old field of view until user changes focus explicitly
+		return mCameraFOVZoomFactor;
+		//return 0.f;
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -1672,268 +1672,268 @@ F32 LLAgentCamera::calcCameraFOVZoomFactor()
 //-----------------------------------------------------------------------------
 LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 {
-    // Compute base camera position and look-at points.
-    F32         camera_land_height;
-    LLVector3d  frame_center_global = !isAgentAvatarValid() ? 
-        gAgent.getPositionGlobal() :
-        gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition());
-    
-    BOOL        isConstrained = FALSE;
-    LLVector3d  head_offset;
-    head_offset.setVec(mThirdPersonHeadOffset);
-
-    LLVector3d camera_position_global;
-
-    if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
-    {
-        camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition());
-    }
-    else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-    {
-        if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
-        {
-            LL_WARNS() << "Null avatar drawable!" << LL_ENDL;
-            return LLVector3d::zero;
-        }
-        head_offset.clearVec();
-        if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent())
-        {
-            gAgentAvatarp->updateHeadOffset();
-            head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
-            head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
-            head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
-            const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
-            camera_position_global = gAgent.getPosGlobalFromAgent
-                                ((gAgentAvatarp->getPosition()+
-                                 LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
-        }
-        else
-        {
-            head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ];
-            if (gAgentAvatarp->isSitting())
-            {
-                head_offset.mdV[VZ] += 0.1;
-            }
-            camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global;
-            head_offset = head_offset * gAgentAvatarp->getRenderRotation();
-            camera_position_global = camera_position_global + head_offset;
-        }
-    }
-    else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar)
-    {
-        LLVector3 local_camera_offset;
-        F32 camera_distance = 0.f;
-
-        if (mSitCameraEnabled 
-            && isAgentAvatarValid() 
-            && gAgentAvatarp->isSitting() 
-            && mSitCameraReferenceObject.notNull())
-        {
-            // sit camera
-            LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
-            LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
-
-            LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot);
-
-            camera_position_global = gAgent.getPosGlobalFromAgent(target_pos);
-        }
-        else
-        {
-            local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
-            
-            // are we sitting down?
-            if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-            {
-                LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-                // slam agent coordinate frame to proper parent local version
-                LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot;
-                at_axis.mV[VZ] = 0.f;
-                at_axis.normalize();
-                gAgent.resetAxes(at_axis * ~parent_rot);
-
-                local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
-            }
-            else
-            {
-                local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
-            }
-
-            if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
-            {
-                LLVector3 plane_normal;
-                plane_normal.setVec(mCameraCollidePlane.mV);
-
-                F32 offset_dot_norm = local_camera_offset * plane_normal;
-                if (llabs(offset_dot_norm) < 0.001f)
-                {
-                    offset_dot_norm = 0.001f;
-                }
-                
-                camera_distance = local_camera_offset.normalize();
-
-                F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal;
-                
-                // if agent is outside the colliding half-plane
-                if (pos_dot_norm > mCameraCollidePlane.mV[VW])
-                {
-                    // check to see if camera is on the opposite side (inside) the half-plane
-                    if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW])
-                    {
-                        // diminish offset by factor to push it back outside the half-plane
-                        camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm;
-                    }
-                }
-                else
-                {
-                    if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW])
-                    {
-                        camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm;
-                    }
-                }
-            }
-            else
-            {
-                camera_distance = local_camera_offset.normalize();
-            }
-
-            mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE);
-
-            if (mTargetCameraDistance != mCurrentCameraDistance)
-            {
-                F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE);
-
-                mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt);
-            }
-
-            // Make the camera distance current
-            local_camera_offset *= mCurrentCameraDistance;
-
-            // set the global camera position
-            LLVector3d camera_offset;
-            
-            camera_offset.setVec( local_camera_offset );
-            camera_position_global = frame_center_global + head_offset + camera_offset;
-
-            if (isAgentAvatarValid())
-            {
-                LLVector3d camera_lag_d;
-                F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE);
-                LLVector3 target_lag;
-                LLVector3 vel = gAgent.getVelocity();
-
-                // lag by appropriate amount for flying
-                F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32();
-                if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
-                {
-                    LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
-                    frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector());
-                    frame_at_axis.normalize();
-
-                    //transition smoothly in air mode, to avoid camera pop
-                    F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME;
-                    u = llclamp(u, 0.f, 1.f);
-
-                    lag_interp *= u;
-
-                    if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID())
-                    {
-                        // disable camera lag when using mouse-directed steering
-                        target_lag.clearVec();
-                    }
-                    else
-                    {
-                        target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f;
-                    }
-
-                    mCameraLag = lerp(mCameraLag, target_lag, lag_interp);
-
-                    F32 lag_dist = mCameraLag.magVec();
-                    if (lag_dist > MAX_CAMERA_LAG)
-                    {
-                        mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist;
-                    }
-
-                    // clamp camera lag so that avatar is always in front
-                    F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis;
-                    if (dot < -(MIN_CAMERA_LAG * u))
-                    {
-                        mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis;
-                    }
-                }
-                else
-                {
-                    mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f));
-                }
-
-                camera_lag_d.setVec(mCameraLag);
-                camera_position_global = camera_position_global - camera_lag_d;
-            }
-        }
-    }
-    else
-    {
-        LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal();
-        // camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value
-        camera_position_global = focusPosGlobal + mCameraFocusOffset;
-    }
-
-    if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike())
-    {
-        LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
-        bool constrain = true;
-        if(regionp && regionp->canManageEstate())
-        {
-            constrain = false;
-        }
-        if(constrain)
-        {
-            F32 max_dist = (CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode) ? APPEARANCE_MAX_ZOOM : mDrawDistance;
-
-            LLVector3d camera_offset = camera_position_global - gAgent.getPositionGlobal();
-            F32 camera_distance = (F32)camera_offset.magVec();
-
-            if(camera_distance > max_dist)
-            {
-                camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset;
-                isConstrained = TRUE;
-            }
-        }
+	// Compute base camera position and look-at points.
+	F32			camera_land_height;
+	LLVector3d	frame_center_global = !isAgentAvatarValid() ? 
+		gAgent.getPositionGlobal() :
+		gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition());
+	
+	BOOL		isConstrained = FALSE;
+	LLVector3d	head_offset;
+	head_offset.setVec(mThirdPersonHeadOffset);
+
+	LLVector3d camera_position_global;
+
+	if (mCameraMode == CAMERA_MODE_FOLLOW && mFocusOnAvatar)
+	{
+		camera_position_global = gAgent.getPosGlobalFromAgent(mFollowCam.getSimulatedPosition());
+	}
+	else if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+	{
+		if (!isAgentAvatarValid() || gAgentAvatarp->mDrawable.isNull())
+		{
+			LL_WARNS() << "Null avatar drawable!" << LL_ENDL;
+			return LLVector3d::zero;
+		}
+		head_offset.clearVec();
+		if (gAgentAvatarp->isSitting() && gAgentAvatarp->getParent())
+		{
+			gAgentAvatarp->updateHeadOffset();
+			head_offset.mdV[VX] = gAgentAvatarp->mHeadOffset.mV[VX];
+			head_offset.mdV[VY] = gAgentAvatarp->mHeadOffset.mV[VY];
+			head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ] + 0.1f;
+			const LLMatrix4& mat = ((LLViewerObject*) gAgentAvatarp->getParent())->getRenderMatrix();
+			camera_position_global = gAgent.getPosGlobalFromAgent
+								((gAgentAvatarp->getPosition()+
+								 LLVector3(head_offset)*gAgentAvatarp->getRotation()) * mat);
+		}
+		else
+		{
+			head_offset.mdV[VZ] = gAgentAvatarp->mHeadOffset.mV[VZ];
+			if (gAgentAvatarp->isSitting())
+			{
+				head_offset.mdV[VZ] += 0.1;
+			}
+			camera_position_global = gAgent.getPosGlobalFromAgent(gAgentAvatarp->getRenderPosition());//frame_center_global;
+			head_offset = head_offset * gAgentAvatarp->getRenderRotation();
+			camera_position_global = camera_position_global + head_offset;
+		}
+	}
+	else if (mCameraMode == CAMERA_MODE_THIRD_PERSON && mFocusOnAvatar)
+	{
+		LLVector3 local_camera_offset;
+		F32 camera_distance = 0.f;
+
+		if (mSitCameraEnabled 
+			&& isAgentAvatarValid() 
+			&& gAgentAvatarp->isSitting() 
+			&& mSitCameraReferenceObject.notNull())
+		{
+			// sit camera
+			LLVector3 object_pos = mSitCameraReferenceObject->getRenderPosition();
+			LLQuaternion object_rot = mSitCameraReferenceObject->getRenderRotation();
+
+			LLVector3 target_pos = object_pos + (mSitCameraPos * object_rot);
+
+			camera_position_global = gAgent.getPosGlobalFromAgent(target_pos);
+		}
+		else
+		{
+			local_camera_offset = mCameraZoomFraction * getCameraOffsetInitial() * gSavedSettings.getF32("CameraOffsetScale");
+			
+			// are we sitting down?
+			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+			{
+				LLQuaternion parent_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+				// slam agent coordinate frame to proper parent local version
+				LLVector3 at_axis = gAgent.getFrameAgent().getAtAxis() * parent_rot;
+				at_axis.mV[VZ] = 0.f;
+				at_axis.normalize();
+				gAgent.resetAxes(at_axis * ~parent_rot);
+
+				local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
+			}
+			else
+			{
+				local_camera_offset = gAgent.getFrameAgent().rotateToAbsolute( local_camera_offset );
+			}
+
+			if (!mCameraCollidePlane.isExactlyZero() && (!isAgentAvatarValid() || !gAgentAvatarp->isSitting()))
+			{
+				LLVector3 plane_normal;
+				plane_normal.setVec(mCameraCollidePlane.mV);
+
+				F32 offset_dot_norm = local_camera_offset * plane_normal;
+				if (llabs(offset_dot_norm) < 0.001f)
+				{
+					offset_dot_norm = 0.001f;
+				}
+				
+				camera_distance = local_camera_offset.normalize();
+
+				F32 pos_dot_norm = gAgent.getPosAgentFromGlobal(frame_center_global + head_offset) * plane_normal;
+				
+				// if agent is outside the colliding half-plane
+				if (pos_dot_norm > mCameraCollidePlane.mV[VW])
+				{
+					// check to see if camera is on the opposite side (inside) the half-plane
+					if (offset_dot_norm + pos_dot_norm < mCameraCollidePlane.mV[VW])
+					{
+						// diminish offset by factor to push it back outside the half-plane
+						camera_distance *= (pos_dot_norm - mCameraCollidePlane.mV[VW] - CAMERA_COLLIDE_EPSILON) / -offset_dot_norm;
+					}
+				}
+				else
+				{
+					if (offset_dot_norm + pos_dot_norm > mCameraCollidePlane.mV[VW])
+					{
+						camera_distance *= (mCameraCollidePlane.mV[VW] - pos_dot_norm - CAMERA_COLLIDE_EPSILON) / offset_dot_norm;
+					}
+				}
+			}
+			else
+			{
+				camera_distance = local_camera_offset.normalize();
+			}
+
+			mTargetCameraDistance = llmax(camera_distance, MIN_CAMERA_DISTANCE);
+
+			if (mTargetCameraDistance != mCurrentCameraDistance)
+			{
+				F32 camera_lerp_amt = LLSmoothInterpolation::getInterpolant(CAMERA_ZOOM_HALF_LIFE);
+
+				mCurrentCameraDistance = lerp(mCurrentCameraDistance, mTargetCameraDistance, camera_lerp_amt);
+			}
+
+			// Make the camera distance current
+			local_camera_offset *= mCurrentCameraDistance;
+
+			// set the global camera position
+			LLVector3d camera_offset;
+			
+			camera_offset.setVec( local_camera_offset );
+			camera_position_global = frame_center_global + head_offset + camera_offset;
+
+			if (isAgentAvatarValid())
+			{
+				LLVector3d camera_lag_d;
+				F32 lag_interp = LLSmoothInterpolation::getInterpolant(CAMERA_LAG_HALF_LIFE);
+				LLVector3 target_lag;
+				LLVector3 vel = gAgent.getVelocity();
+
+				// lag by appropriate amount for flying
+				F32 time_in_air = gAgentAvatarp->mTimeInAir.getElapsedTimeF32();
+				if(!mCameraAnimating && gAgentAvatarp->mInAir && time_in_air > GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME)
+				{
+					LLVector3 frame_at_axis = gAgent.getFrameAgent().getAtAxis();
+					frame_at_axis -= projected_vec(frame_at_axis, gAgent.getReferenceUpVector());
+					frame_at_axis.normalize();
+
+					//transition smoothly in air mode, to avoid camera pop
+					F32 u = (time_in_air - GROUND_TO_AIR_CAMERA_TRANSITION_START_TIME) / GROUND_TO_AIR_CAMERA_TRANSITION_TIME;
+					u = llclamp(u, 0.f, 1.f);
+
+					lag_interp *= u;
+
+					if (gViewerWindow->getLeftMouseDown() && gViewerWindow->getLastPick().mObjectID == gAgentAvatarp->getID())
+					{
+						// disable camera lag when using mouse-directed steering
+						target_lag.clearVec();
+					}
+					else
+					{
+						target_lag = vel * gSavedSettings.getF32("DynamicCameraStrength") / 30.f;
+					}
+
+					mCameraLag = lerp(mCameraLag, target_lag, lag_interp);
+
+					F32 lag_dist = mCameraLag.magVec();
+					if (lag_dist > MAX_CAMERA_LAG)
+					{
+						mCameraLag = mCameraLag * MAX_CAMERA_LAG / lag_dist;
+					}
+
+					// clamp camera lag so that avatar is always in front
+					F32 dot = (mCameraLag - (frame_at_axis * (MIN_CAMERA_LAG * u))) * frame_at_axis;
+					if (dot < -(MIN_CAMERA_LAG * u))
+					{
+						mCameraLag -= (dot + (MIN_CAMERA_LAG * u)) * frame_at_axis;
+					}
+				}
+				else
+				{
+					mCameraLag = lerp(mCameraLag, LLVector3::zero, LLSmoothInterpolation::getInterpolant(0.15f));
+				}
+
+				camera_lag_d.setVec(mCameraLag);
+				camera_position_global = camera_position_global - camera_lag_d;
+			}
+		}
+	}
+	else
+	{
+		LLVector3d focusPosGlobal = calcFocusPositionTargetGlobal();
+		// camera gets pushed out later wrt mCameraFOVZoomFactor...this is "raw" value
+		camera_position_global = focusPosGlobal + mCameraFocusOffset;
+	}
+
+	if (!gSavedSettings.getBOOL("DisableCameraConstraints") && !gAgent.isGodlike())
+	{
+		LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
+		bool constrain = true;
+		if(regionp && regionp->canManageEstate())
+		{
+			constrain = false;
+		}
+		if(constrain)
+		{
+			F32 max_dist = (CAMERA_MODE_CUSTOMIZE_AVATAR == mCameraMode) ? APPEARANCE_MAX_ZOOM : mDrawDistance;
+
+			LLVector3d camera_offset = camera_position_global - gAgent.getPositionGlobal();
+			F32 camera_distance = (F32)camera_offset.magVec();
+
+			if(camera_distance > max_dist)
+			{
+				camera_position_global = gAgent.getPositionGlobal() + (max_dist/camera_distance)*camera_offset;
+				isConstrained = TRUE;
+			}
+		}
 
 // JC - Could constrain camera based on parcel stuff here.
-//          LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
-//          
-//          if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global)))
-//          {
-//              camera_position_global = last_position_global;
+//			LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(camera_position_global);
+//			
+//			if (regionp && !regionp->mParcelOverlay->isBuildCameraAllowed(regionp->getPosRegionFromGlobal(camera_position_global)))
+//			{
+//				camera_position_global = last_position_global;
 //
-//              isConstrained = TRUE;
-//          }
-    }
+//				isConstrained = TRUE;
+//			}
+	}
 
-    // Don't let camera go underground
-    F32 camera_min_off_ground = getCameraMinOffGround();
+	// Don't let camera go underground
+	F32 camera_min_off_ground = getCameraMinOffGround();
 
-    camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global);
+	camera_land_height = LLWorld::getInstance()->resolveLandHeightGlobal(camera_position_global);
 
-    if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground)
-    {
-        camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground;
-        isConstrained = TRUE;
-    }
+	if (camera_position_global.mdV[VZ] < camera_land_height + camera_min_off_ground)
+	{
+		camera_position_global.mdV[VZ] = camera_land_height + camera_min_off_ground;
+		isConstrained = TRUE;
+	}
 
 
-    if (hit_limit)
-    {
-        *hit_limit = isConstrained;
-    }
+	if (hit_limit)
+	{
+		*hit_limit = isConstrained;
+	}
 
-    return camera_position_global;
+	return camera_position_global;
 }
 
 
 LLVector3 LLAgentCamera::getCameraOffsetInitial()
 {
-    return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, "");
+	return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, "");
 }
 
 F32 LLAgentCamera::getCameraMaxZoomDistance()
@@ -1949,48 +1949,48 @@ F32 LLAgentCamera::getCameraMaxZoomDistance()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::handleScrollWheel(S32 clicks)
 {
-    if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar())
-    {
-        if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place
-        {
-            mFollowCam.zoom(clicks); 
-            if (mFollowCam.isZoomedToMinimumDistance())
-            {
-                changeCameraToMouselook(FALSE);
-            }
-        }
-    }
-    else
-    {
-        LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
-        const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2);
-
-        // Block if camera is animating
-        if (mCameraAnimating)
-        {
-            return;
-        }
-
-        if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
-        {
-            F32 zoom_factor = (F32)pow(0.8, -clicks);
-            cameraZoomIn(zoom_factor);
-        }
-        else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON))
-        {
-            F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec();
-            
-            F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
-            current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks);
-            
-            cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
-        }
-        else
-        {
-            F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec();
-            cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks)));
-        }
-    }
+	if (mCameraMode == CAMERA_MODE_FOLLOW && getFocusOnAvatar())
+	{
+		if (!mFollowCam.getPositionLocked()) // not if the followCam position is locked in place
+		{
+			mFollowCam.zoom(clicks); 
+			if (mFollowCam.isZoomedToMinimumDistance())
+			{
+				changeCameraToMouselook(FALSE);
+			}
+		}
+	}
+	else
+	{
+		LLObjectSelectionHandle selection = LLSelectMgr::getInstance()->getSelection();
+		const F32 ROOT_ROOT_TWO = sqrt(F_SQRT2);
+
+		// Block if camera is animating
+		if (mCameraAnimating)
+		{
+			return;
+		}
+
+		if (selection->getObjectCount() && selection->getSelectType() == SELECT_TYPE_HUD)
+		{
+			F32 zoom_factor = (F32)pow(0.8, -clicks);
+			cameraZoomIn(zoom_factor);
+		}
+		else if (mFocusOnAvatar && (mCameraMode == CAMERA_MODE_THIRD_PERSON))
+		{
+			F32 camera_offset_initial_mag = getCameraOffsetInitial().magVec();
+			
+			F32 current_zoom_fraction = mTargetCameraDistance / (camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
+			current_zoom_fraction *= 1.f - pow(ROOT_ROOT_TWO, clicks);
+			
+			cameraOrbitIn(current_zoom_fraction * camera_offset_initial_mag * gSavedSettings.getF32("CameraOffsetScale"));
+		}
+		else
+		{
+			F32 current_zoom_fraction = (F32)mCameraFocusOffsetTarget.magVec();
+			cameraOrbitIn(current_zoom_fraction * (1.f - pow(ROOT_ROOT_TWO, clicks)));
+		}
+	}
 }
 
 
@@ -1999,21 +1999,21 @@ void LLAgentCamera::handleScrollWheel(S32 clicks)
 //-----------------------------------------------------------------------------
 F32 LLAgentCamera::getCameraMinOffGround()
 {
-    if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-    {
-        return 0.f;
-    }
-    else
-    {
-        if (gSavedSettings.getBOOL("DisableCameraConstraints"))
-        {
-            return -1000.f;
-        }
-        else
-        {
-            return 0.5f;
-        }
-    }
+	if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+	{
+		return 0.f;
+	}
+	else
+	{
+		if (gSavedSettings.getBOOL("DisableCameraConstraints"))
+		{
+			return -1000.f;
+		}
+		else
+		{
+			return 0.5f;
+		}
+	}
 }
 
 
@@ -2022,15 +2022,15 @@ F32 LLAgentCamera::getCameraMinOffGround()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::resetCamera()
 {
-    // Remove any pitch from the avatar
-    LLVector3 at = gAgent.getFrameAgent().getAtAxis();
-    at.mV[VZ] = 0.f;
-    at.normalize();
-    gAgent.resetAxes(at);
-    // have to explicitly clear field of view zoom now
-    mCameraFOVZoomFactor = 0.f;
-
-    updateCamera();
+	// Remove any pitch from the avatar
+	LLVector3 at = gAgent.getFrameAgent().getAtAxis();
+	at.mV[VZ] = 0.f;
+	at.normalize();
+	gAgent.resetAxes(at);
+	// have to explicitly clear field of view zoom now
+	mCameraFOVZoomFactor = 0.f;
+
+	updateCamera();
 }
 
 //-----------------------------------------------------------------------------
@@ -2038,58 +2038,58 @@ void LLAgentCamera::resetCamera()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 {
-    if (!gSavedSettings.getBOOL("EnableMouselook") 
-        || LLViewerJoystick::getInstance()->getOverrideCamera())
-    {
-        return;
-    }
-    
-    // visibility changes at end of animation
-    gViewerWindow->getWindow()->resetBusyCount();
-
-    // Menus should not remain open on switching to mouselook...
-    LLMenuGL::sMenuContainer->hideMenus();
-    LLUI::clearPopups();
-
-    // unpause avatar animation
-    gAgent.unpauseAnimation();
-
-    LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
-
-    if (isAgentAvatarValid())
-    {
-        gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE);
-        gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT);
-    }
-
-    //gViewerWindow->stopGrab();
-    LLSelectMgr::getInstance()->deselectAll();
-    gViewerWindow->hideCursor();
-    gViewerWindow->moveCursorToCenter();
-
-    if (mCameraMode != CAMERA_MODE_MOUSELOOK)
-    {
-        gFocusMgr.setKeyboardFocus(NULL);
-        
-        updateLastCamera();
-        mCameraMode = CAMERA_MODE_MOUSELOOK;
-        const U32 old_flags = gAgent.getControlFlags();
-        gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK);
-        if (old_flags != gAgent.getControlFlags())
-        {
-            gAgent.setFlagsDirty();
-        }
-
-        if (animate)
-        {
-            startCameraAnimation();
-        }
-        else
-        {
-            mCameraAnimating = FALSE;
-            gAgent.endAnimationUpdateUI();
-        }
-    }
+	if (!gSavedSettings.getBOOL("EnableMouselook") 
+		|| LLViewerJoystick::getInstance()->getOverrideCamera())
+	{
+		return;
+	}
+	
+	// visibility changes at end of animation
+	gViewerWindow->getWindow()->resetBusyCount();
+
+	// Menus should not remain open on switching to mouselook...
+	LLMenuGL::sMenuContainer->hideMenus();
+	LLUI::clearPopups();
+
+	// unpause avatar animation
+	gAgent.unpauseAnimation();
+
+	LLToolMgr::getInstance()->setCurrentToolset(gMouselookToolset);
+
+	if (isAgentAvatarValid())
+	{
+		gAgentAvatarp->stopMotion(ANIM_AGENT_BODY_NOISE);
+		gAgentAvatarp->stopMotion(ANIM_AGENT_BREATHE_ROT);
+	}
+
+	//gViewerWindow->stopGrab();
+	LLSelectMgr::getInstance()->deselectAll();
+	gViewerWindow->hideCursor();
+	gViewerWindow->moveCursorToCenter();
+
+	if (mCameraMode != CAMERA_MODE_MOUSELOOK)
+	{
+		gFocusMgr.setKeyboardFocus(NULL);
+		
+		updateLastCamera();
+		mCameraMode = CAMERA_MODE_MOUSELOOK;
+		const U32 old_flags = gAgent.getControlFlags();
+		gAgent.setControlFlags(AGENT_CONTROL_MOUSELOOK);
+		if (old_flags != gAgent.getControlFlags())
+		{
+			gAgent.setFlagsDirty();
+		}
+
+		if (animate)
+		{
+			startCameraAnimation();
+		}
+		else
+		{
+			mCameraAnimating = FALSE;
+			gAgent.endAnimationUpdateUI();
+		}
+	}
 }
 
 
@@ -2098,24 +2098,24 @@ void LLAgentCamera::changeCameraToMouselook(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToDefault()
 {
-    if (LLViewerJoystick::getInstance()->getOverrideCamera())
-    {
-        return;
-    }
-
-    if (LLFollowCamMgr::getActiveFollowCamParams())
-    {
-        changeCameraToFollow();
-    }
-    else
-    {
-        changeCameraToThirdPerson();
-    }
-    if (gSavedSettings.getBOOL("HideUIControls"))
-    {
-        gViewerWindow->setUIVisibility(false);
-        LLPanelStandStopFlying::getInstance()->setVisible(false);
-    }
+	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	{
+		return;
+	}
+
+	if (LLFollowCamMgr::getActiveFollowCamParams())
+	{
+		changeCameraToFollow();
+	}
+	else
+	{
+		changeCameraToThirdPerson();
+	}
+	if (gSavedSettings.getBOOL("HideUIControls"))
+	{
+		gViewerWindow->setUIVisibility(false);
+		LLPanelStandStopFlying::getInstance()->setVisible(false);
+	}
 }
 
 
@@ -2124,53 +2124,53 @@ void LLAgentCamera::changeCameraToDefault()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToFollow(BOOL animate)
 {
-    if (LLViewerJoystick::getInstance()->getOverrideCamera())
-    {
-        return;
-    }
-
-    if(mCameraMode != CAMERA_MODE_FOLLOW)
-    {
-        if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-        {
-            animate = FALSE;
-        }
-        startCameraAnimation();
-
-        updateLastCamera();
-        mCameraMode = CAMERA_MODE_FOLLOW;
-
-        // bang-in the current focus, position, and up vector of the follow cam
-        mFollowCam.reset(mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis);
-        
-        if (gBasicToolset)
-        {
-            LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
-        }
-
-        if (isAgentAvatarValid())
-        {
-            // SL-315
-            gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
-            gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE );
-            gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT );
-        }
-
-        // unpause avatar animation
-        gAgent.unpauseAnimation();
-
-        gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
-
-        if (animate)
-        {
-            startCameraAnimation();
-        }
-        else
-        {
-            mCameraAnimating = FALSE;
-            gAgent.endAnimationUpdateUI();
-        }
-    }
+	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	{
+		return;
+	}
+
+	if(mCameraMode != CAMERA_MODE_FOLLOW)
+	{
+		if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+		{
+			animate = FALSE;
+		}
+		startCameraAnimation();
+
+		updateLastCamera();
+		mCameraMode = CAMERA_MODE_FOLLOW;
+
+		// bang-in the current focus, position, and up vector of the follow cam
+		mFollowCam.reset(mCameraPositionAgent, LLViewerCamera::getInstance()->getPointOfInterest(), LLVector3::z_axis);
+		
+		if (gBasicToolset)
+		{
+			LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
+		}
+
+		if (isAgentAvatarValid())
+		{
+			// SL-315
+			gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
+			gAgentAvatarp->startMotion( ANIM_AGENT_BODY_NOISE );
+			gAgentAvatarp->startMotion( ANIM_AGENT_BREATHE_ROT );
+		}
+
+		// unpause avatar animation
+		gAgent.unpauseAnimation();
+
+		gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+
+		if (animate)
+		{
+			startCameraAnimation();
+		}
+		else
+		{
+			mCameraAnimating = FALSE;
+			gAgent.endAnimationUpdateUI();
+		}
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -2178,77 +2178,77 @@ void LLAgentCamera::changeCameraToFollow(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 {
-    if (LLViewerJoystick::getInstance()->getOverrideCamera())
-    {
-        return;
-    }
-
-    gViewerWindow->getWindow()->resetBusyCount();
-
-    mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
-
-    if (isAgentAvatarValid())
-    {
-        if (!gAgentAvatarp->isSitting())
-        {
-            // SL-315
-            gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
-        }
-        gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE);
-        gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
-    }
-
-    LLVector3 at_axis;
-
-    // unpause avatar animation
-    gAgent.unpauseAnimation();
-
-    if (mCameraMode != CAMERA_MODE_THIRD_PERSON)
-    {
-        if (gBasicToolset)
-        {
-            LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
-        }
-
-        mCameraLag.clearVec();
-        if (mCameraMode == CAMERA_MODE_MOUSELOOK)
-        {
-            mCurrentCameraDistance = MIN_CAMERA_DISTANCE;
-            mTargetCameraDistance = MIN_CAMERA_DISTANCE;
-            animate = FALSE;
-        }
-        updateLastCamera();
-        mCameraMode = CAMERA_MODE_THIRD_PERSON;
-        gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
-    }
-
-    // Remove any pitch from the avatar
-    if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-    {
-        LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-        at_axis = LLViewerCamera::getInstance()->getAtAxis();
-        at_axis.mV[VZ] = 0.f;
-        at_axis.normalize();
-        gAgent.resetAxes(at_axis * ~obj_rot);
-    }
-    else
-    {
-        at_axis = gAgent.getFrameAgent().getAtAxis();
-        at_axis.mV[VZ] = 0.f;
-        at_axis.normalize();
-        gAgent.resetAxes(at_axis);
-    }
-
-
-    if (animate)
-    {
-        startCameraAnimation();
-    }
-    else
-    {
-        mCameraAnimating = FALSE;
-        gAgent.endAnimationUpdateUI();
-    }
+	if (LLViewerJoystick::getInstance()->getOverrideCamera())
+	{
+		return;
+	}
+
+	gViewerWindow->getWindow()->resetBusyCount();
+
+	mCameraZoomFraction = INITIAL_ZOOM_FRACTION;
+
+	if (isAgentAvatarValid())
+	{
+		if (!gAgentAvatarp->isSitting())
+		{
+			// SL-315
+			gAgentAvatarp->mPelvisp->setPosition(LLVector3::zero);
+		}
+		gAgentAvatarp->startMotion(ANIM_AGENT_BODY_NOISE);
+		gAgentAvatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
+	}
+
+	LLVector3 at_axis;
+
+	// unpause avatar animation
+	gAgent.unpauseAnimation();
+
+	if (mCameraMode != CAMERA_MODE_THIRD_PERSON)
+	{
+		if (gBasicToolset)
+		{
+			LLToolMgr::getInstance()->setCurrentToolset(gBasicToolset);
+		}
+
+		mCameraLag.clearVec();
+		if (mCameraMode == CAMERA_MODE_MOUSELOOK)
+		{
+			mCurrentCameraDistance = MIN_CAMERA_DISTANCE;
+			mTargetCameraDistance = MIN_CAMERA_DISTANCE;
+			animate = FALSE;
+		}
+		updateLastCamera();
+		mCameraMode = CAMERA_MODE_THIRD_PERSON;
+		gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+	}
+
+	// Remove any pitch from the avatar
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+	{
+		LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+		at_axis = LLViewerCamera::getInstance()->getAtAxis();
+		at_axis.mV[VZ] = 0.f;
+		at_axis.normalize();
+		gAgent.resetAxes(at_axis * ~obj_rot);
+	}
+	else
+	{
+		at_axis = gAgent.getFrameAgent().getAtAxis();
+		at_axis.mV[VZ] = 0.f;
+		at_axis.normalize();
+		gAgent.resetAxes(at_axis);
+	}
+
+
+	if (animate)
+	{
+		startCameraAnimation();
+	}
+	else
+	{
+		mCameraAnimating = FALSE;
+		gAgent.endAnimationUpdateUI();
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -2256,81 +2256,81 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::changeCameraToCustomizeAvatar()
 {
-    if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid())
-    {
-        return;
-    }
-
-    gAgent.standUp(); // force stand up
-    gViewerWindow->getWindow()->resetBusyCount();
-
-    if (gFaceEditToolset)
-    {
-        LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
-    }
-
-    startCameraAnimation();
-
-    if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR)
-    {
-        updateLastCamera();
-        mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR;
-        gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
-
-        gFocusMgr.setKeyboardFocus( NULL );
-        gFocusMgr.setMouseCapture( NULL );
-        if( gMorphView )
-        {
-            gMorphView->setVisible( TRUE );
-        }
-        // Remove any pitch or rotation from the avatar
-        LLVector3 at = gAgent.getAtAxis();
-        at.mV[VZ] = 0.f;
-        at.normalize();
-        gAgent.resetAxes(at);
-
-        gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START);
-        gAgent.setCustomAnim(TRUE);
-        gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE);
-        LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE);
-
-        if (turn_motion)
-        {
-            // delay camera animation long enough to play through turn animation
-            setAnimationDuration(turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP);
-        }
-    }
-
-    LLVector3 agent_at = gAgent.getAtAxis();
-    agent_at.mV[VZ] = 0.f;
-    agent_at.normalize();
-
-    // default focus point for customize avatar
-    LLVector3 focus_target = isAgentAvatarValid() 
-        ? gAgentAvatarp->mHeadp->getWorldPosition()
-        : gAgent.getPositionAgent();
-
-    LLVector3d camera_offset(agent_at * -1.0);
-    // push camera up and out from avatar
-    camera_offset.mdV[VZ] = 0.1f; 
-    camera_offset *= CUSTOMIZE_AVATAR_CAMERA_DEFAULT_DIST;
-    LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
-    setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
-    setCameraPosAndFocusGlobal(focus_target_global + camera_offset, focus_target_global, gAgent.getID());
+	if (LLViewerJoystick::getInstance()->getOverrideCamera() || !isAgentAvatarValid())
+	{
+		return;
+	}
+
+	gAgent.standUp(); // force stand up
+	gViewerWindow->getWindow()->resetBusyCount();
+
+	if (gFaceEditToolset)
+	{
+		LLToolMgr::getInstance()->setCurrentToolset(gFaceEditToolset);
+	}
+
+	startCameraAnimation();
+
+	if (mCameraMode != CAMERA_MODE_CUSTOMIZE_AVATAR)
+	{
+		updateLastCamera();
+		mCameraMode = CAMERA_MODE_CUSTOMIZE_AVATAR;
+		gAgent.clearControlFlags(AGENT_CONTROL_MOUSELOOK);
+
+		gFocusMgr.setKeyboardFocus( NULL );
+		gFocusMgr.setMouseCapture( NULL );
+		if( gMorphView )
+		{
+			gMorphView->setVisible( TRUE );
+		}
+		// Remove any pitch or rotation from the avatar
+		LLVector3 at = gAgent.getAtAxis();
+		at.mV[VZ] = 0.f;
+		at.normalize();
+		gAgent.resetAxes(at);
+
+		gAgent.sendAnimationRequest(ANIM_AGENT_CUSTOMIZE, ANIM_REQUEST_START);
+		gAgent.setCustomAnim(TRUE);
+		gAgentAvatarp->startMotion(ANIM_AGENT_CUSTOMIZE);
+		LLMotion* turn_motion = gAgentAvatarp->findMotion(ANIM_AGENT_CUSTOMIZE);
+
+		if (turn_motion)
+		{
+			// delay camera animation long enough to play through turn animation
+			setAnimationDuration(turn_motion->getDuration() + CUSTOMIZE_AVATAR_CAMERA_ANIM_SLOP);
+		}
+	}
+
+	LLVector3 agent_at = gAgent.getAtAxis();
+	agent_at.mV[VZ] = 0.f;
+	agent_at.normalize();
+
+	// default focus point for customize avatar
+	LLVector3 focus_target = isAgentAvatarValid() 
+		? gAgentAvatarp->mHeadp->getWorldPosition()
+		: gAgent.getPositionAgent();
+
+	LLVector3d camera_offset(agent_at * -1.0);
+	// push camera up and out from avatar
+	camera_offset.mdV[VZ] = 0.1f; 
+	camera_offset *= CUSTOMIZE_AVATAR_CAMERA_DEFAULT_DIST;
+	LLVector3d focus_target_global = gAgent.getPosGlobalFromAgent(focus_target);
+	setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
+	setCameraPosAndFocusGlobal(focus_target_global + camera_offset, focus_target_global, gAgent.getID());
 }
 
 
 void LLAgentCamera::switchCameraPreset(ECameraPreset preset)
 {
-    //zoom is supposed to be reset for the front and group views
-    mCameraZoomFraction = 1.f;
+	//zoom is supposed to be reset for the front and group views
+	mCameraZoomFraction = 1.f;
 
-    //focusing on avatar in that case means following him on movements
-    mFocusOnAvatar = TRUE;
+	//focusing on avatar in that case means following him on movements
+	mFocusOnAvatar = TRUE;
 
-    mCameraPreset = preset;
+	mCameraPreset = preset;
 
-    gSavedSettings.setU32("CameraPreset", mCameraPreset);
+	gSavedSettings.setU32("CameraPreset", mCameraPreset);
 }
 
 
@@ -2340,16 +2340,16 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset)
 
 void LLAgentCamera::setAnimationDuration(F32 duration)
 { 
-    if (mCameraAnimating)
-    {
-        // do not cut any existing camera animation short
-        F32 animation_left = llmax(0.f, mAnimationDuration - mAnimationTimer.getElapsedTimeF32());
-        mAnimationDuration = llmax(duration, animation_left);
-    }
-    else
-    {
-        mAnimationDuration = duration; 
-    }
+	if (mCameraAnimating)
+	{
+		// do not cut any existing camera animation short
+		F32 animation_left = llmax(0.f, mAnimationDuration - mAnimationTimer.getElapsedTimeF32());
+		mAnimationDuration = llmax(duration, animation_left);
+	}
+	else
+	{
+		mAnimationDuration = duration; 
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -2357,11 +2357,11 @@ void LLAgentCamera::setAnimationDuration(F32 duration)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::startCameraAnimation()
 {
-    mAnimationCameraStartGlobal = getCameraPositionGlobal();
-    mAnimationFocusStartGlobal = mFocusGlobal;
-    setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
-    mAnimationTimer.reset();
-    mCameraAnimating = TRUE;
+	mAnimationCameraStartGlobal = getCameraPositionGlobal();
+	mAnimationFocusStartGlobal = mFocusGlobal;
+	setAnimationDuration(gSavedSettings.getF32("ZoomTime"));
+	mAnimationTimer.reset();
+	mCameraAnimating = TRUE;
 }
 
 //-----------------------------------------------------------------------------
@@ -2369,23 +2369,23 @@ void LLAgentCamera::startCameraAnimation()
 //-----------------------------------------------------------------------------
 void LLAgentCamera::stopCameraAnimation()
 {
-    mCameraAnimating = FALSE;
+	mCameraAnimating = FALSE;
 }
 
 void LLAgentCamera::clearFocusObject()
 {
-    if (mFocusObject.notNull())
-    {
-        startCameraAnimation();
+	if (mFocusObject.notNull())
+	{
+		startCameraAnimation();
 
-        setFocusObject(NULL);
-        mFocusObjectOffset.clearVec();
-    }
+		setFocusObject(NULL);
+		mFocusObjectOffset.clearVec();
+	}
 }
 
 void LLAgentCamera::setFocusObject(LLViewerObject* object)
 {
-    mFocusObject = object;
+	mFocusObject = object;
 }
 
 // Focus on a point, but try to keep camera position stable.
@@ -2394,104 +2394,104 @@ void LLAgentCamera::setFocusObject(LLViewerObject* object)
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setFocusGlobal(const LLPickInfo& pick)
 {
-    LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
-
-    if (objectp)
-    {
-        // focus on object plus designated offset
-        // which may or may not be same as pick.mPosGlobal
-        setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID);
-    }
-    else
-    {
-        // focus directly on point where user clicked
-        setFocusGlobal(pick.mPosGlobal, pick.mObjectID);
-    }
+	LLViewerObject* objectp = gObjectList.findObject(pick.mObjectID);
+
+	if (objectp)
+	{
+		// focus on object plus designated offset
+		// which may or may not be same as pick.mPosGlobal
+		setFocusGlobal(objectp->getPositionGlobal() + LLVector3d(pick.mObjectOffset), pick.mObjectID);
+	}
+	else
+	{
+		// focus directly on point where user clicked
+		setFocusGlobal(pick.mPosGlobal, pick.mObjectID);
+	}
 }
 
 
 void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object_id)
 {
-    setFocusObject(gObjectList.findObject(object_id));
-    LLVector3d old_focus = mFocusTargetGlobal;
-    LLViewerObject *focus_obj = mFocusObject;
-
-    // if focus has changed
-    if (old_focus != focus)
-    {
-        if (focus.isExactlyZero())
-        {
-            if (isAgentAvatarValid())
-            {
-                mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
-            }
-            else
-            {
-                mFocusTargetGlobal = gAgent.getPositionGlobal();
-            }
-            mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal;
-            mCameraFocusOffset = mCameraFocusOffsetTarget;
-            setLookAt(LOOKAT_TARGET_CLEAR);
-        }
-        else
-        {
-            mFocusTargetGlobal = focus;
-            if (!focus_obj)
-            {
-                mCameraFOVZoomFactor = 0.f;
-            }
-
-            mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal;
-
-            startCameraAnimation();
-
-            if (focus_obj)
-            {
-                if (focus_obj->isAvatar())
-                {
-                    setLookAt(LOOKAT_TARGET_FOCUS, focus_obj);
-                }
-                else
-                {
-                    setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation());
-                }
-            }
-            else
-            {
-                setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
-            }
-        }
-    }
-    else // focus == mFocusTargetGlobal
-    {
-        if (focus.isExactlyZero())
-        {
-            if (isAgentAvatarValid())
-            {
-                mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
-            }
-            else
-            {
-                mFocusTargetGlobal = gAgent.getPositionGlobal();
-            }
-        }
-        mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);;
-        mCameraFocusOffset = mCameraFocusOffsetTarget;
-    }
-
-    if (mFocusObject.notNull())
-    {
-        // for attachments, make offset relative to avatar, not the attachment
-        if (mFocusObject->isAttachment())
-        {
-            while (mFocusObject.notNull() && !mFocusObject->isAvatar())
-            {
-                mFocusObject = (LLViewerObject*) mFocusObject->getParent();
-            }
-            setFocusObject((LLViewerObject*)mFocusObject);
-        }
-        updateFocusOffset();
-    }
+	setFocusObject(gObjectList.findObject(object_id));
+	LLVector3d old_focus = mFocusTargetGlobal;
+	LLViewerObject *focus_obj = mFocusObject;
+
+	// if focus has changed
+	if (old_focus != focus)
+	{
+		if (focus.isExactlyZero())
+		{
+			if (isAgentAvatarValid())
+			{
+				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
+			}
+			else
+			{
+				mFocusTargetGlobal = gAgent.getPositionGlobal();
+			}
+			mCameraFocusOffsetTarget = getCameraPositionGlobal() - mFocusTargetGlobal;
+			mCameraFocusOffset = mCameraFocusOffsetTarget;
+			setLookAt(LOOKAT_TARGET_CLEAR);
+		}
+		else
+		{
+			mFocusTargetGlobal = focus;
+			if (!focus_obj)
+			{
+				mCameraFOVZoomFactor = 0.f;
+			}
+
+			mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(mCameraVirtualPositionAgent) - mFocusTargetGlobal;
+
+			startCameraAnimation();
+
+			if (focus_obj)
+			{
+				if (focus_obj->isAvatar())
+				{
+					setLookAt(LOOKAT_TARGET_FOCUS, focus_obj);
+				}
+				else
+				{
+					setLookAt(LOOKAT_TARGET_FOCUS, focus_obj, (gAgent.getPosAgentFromGlobal(focus) - focus_obj->getRenderPosition()) * ~focus_obj->getRenderRotation());
+				}
+			}
+			else
+			{
+				setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+			}
+		}
+	}
+	else // focus == mFocusTargetGlobal
+	{
+		if (focus.isExactlyZero())
+		{
+			if (isAgentAvatarValid())
+			{
+				mFocusTargetGlobal = gAgent.getPosGlobalFromAgent(gAgentAvatarp->mHeadp->getWorldPosition());
+			}
+			else
+			{
+				mFocusTargetGlobal = gAgent.getPositionGlobal();
+			}
+		}
+		mCameraFocusOffsetTarget = (getCameraPositionGlobal() - mFocusTargetGlobal) / (1.f + mCameraFOVZoomFactor);;
+		mCameraFocusOffset = mCameraFocusOffsetTarget;
+	}
+
+	if (mFocusObject.notNull())
+	{
+		// for attachments, make offset relative to avatar, not the attachment
+		if (mFocusObject->isAttachment())
+		{
+			while (mFocusObject.notNull() && !mFocusObject->isAvatar())
+			{
+				mFocusObject = (LLViewerObject*) mFocusObject->getParent();
+			}
+			setFocusObject((LLViewerObject*)mFocusObject);
+		}
+		updateFocusOffset();
+	}
 }
 
 // Used for avatar customization
@@ -2500,48 +2500,48 @@ void LLAgentCamera::setFocusGlobal(const LLVector3d& focus, const LLUUID &object
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, const LLVector3d& focus, const LLUUID &object_id)
 {
-    LLVector3d old_focus = mFocusTargetGlobal.isExactlyZero() ? focus : mFocusTargetGlobal;
-
-    F64 focus_delta_squared = (old_focus - focus).magVecSquared();
-    const F64 ANIM_EPSILON_SQUARED = 0.0001;
-    if (focus_delta_squared > ANIM_EPSILON_SQUARED)
-    {
-        startCameraAnimation();
-    }
-    
-    //LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) );
-    setFocusObject(gObjectList.findObject(object_id));
-    mFocusTargetGlobal = focus;
-    mCameraFocusOffsetTarget = camera_pos - focus;
-    mCameraFocusOffset = mCameraFocusOffsetTarget;
-
-    if (mFocusObject)
-    {
-        if (mFocusObject->isAvatar())
-        {
-            setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject);
-        }
-        else
-        {
-            setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation());
-        }
-    }
-    else
-    {
-        setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
-    }
-
-    if (mCameraAnimating)
-    {
-        const F64 ANIM_METERS_PER_SECOND = 10.0;
-        const F64 MIN_ANIM_SECONDS = 0.5;
-        const F64 MAX_ANIM_SECONDS = 10.0;
-        F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND );
-        anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS );
-        setAnimationDuration( (F32)anim_duration );
-    }
-
-    updateFocusOffset();
+	LLVector3d old_focus = mFocusTargetGlobal.isExactlyZero() ? focus : mFocusTargetGlobal;
+
+	F64 focus_delta_squared = (old_focus - focus).magVecSquared();
+	const F64 ANIM_EPSILON_SQUARED = 0.0001;
+	if (focus_delta_squared > ANIM_EPSILON_SQUARED)
+	{
+		startCameraAnimation();
+	}
+	
+	//LLViewerCamera::getInstance()->setOrigin( gAgent.getPosAgentFromGlobal( camera_pos ) );
+	setFocusObject(gObjectList.findObject(object_id));
+	mFocusTargetGlobal = focus;
+	mCameraFocusOffsetTarget = camera_pos - focus;
+	mCameraFocusOffset = mCameraFocusOffsetTarget;
+
+	if (mFocusObject)
+	{
+		if (mFocusObject->isAvatar())
+		{
+			setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject);
+		}
+		else
+		{
+			setLookAt(LOOKAT_TARGET_FOCUS, mFocusObject, (gAgent.getPosAgentFromGlobal(focus) - mFocusObject->getRenderPosition()) * ~mFocusObject->getRenderRotation());
+		}
+	}
+	else
+	{
+		setLookAt(LOOKAT_TARGET_FOCUS, NULL, gAgent.getPosAgentFromGlobal(mFocusTargetGlobal));
+	}
+
+	if (mCameraAnimating)
+	{
+		const F64 ANIM_METERS_PER_SECOND = 10.0;
+		const F64 MIN_ANIM_SECONDS = 0.5;
+		const F64 MAX_ANIM_SECONDS = 10.0;
+		F64 anim_duration = llmax( MIN_ANIM_SECONDS, sqrt(focus_delta_squared) / ANIM_METERS_PER_SECOND );
+		anim_duration = llmin( anim_duration, MAX_ANIM_SECONDS );
+		setAnimationDuration( (F32)anim_duration );
+	}
+
+	updateFocusOffset();
 }
 
 //-----------------------------------------------------------------------------
@@ -2549,27 +2549,27 @@ void LLAgentCamera::setCameraPosAndFocusGlobal(const LLVector3d& camera_pos, con
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camera_pos, const LLVector3 &camera_focus)
 {
-    BOOL camera_enabled = !object_id.isNull();
-
-    if (camera_enabled)
-    {
-        LLViewerObject *reference_object = gObjectList.findObject(object_id);
-        if (reference_object)
-        {
-            //convert to root object relative?
-            mSitCameraPos = camera_pos;
-            mSitCameraFocus = camera_focus;
-            mSitCameraReferenceObject = reference_object;
-            mSitCameraEnabled = TRUE;
-        }
-    }
-    else
-    {
-        mSitCameraPos.clearVec();
-        mSitCameraFocus.clearVec();
-        mSitCameraReferenceObject = NULL;
-        mSitCameraEnabled = FALSE;
-    }
+	BOOL camera_enabled = !object_id.isNull();
+
+	if (camera_enabled)
+	{
+		LLViewerObject *reference_object = gObjectList.findObject(object_id);
+		if (reference_object)
+		{
+			//convert to root object relative?
+			mSitCameraPos = camera_pos;
+			mSitCameraFocus = camera_focus;
+			mSitCameraReferenceObject = reference_object;
+			mSitCameraEnabled = TRUE;
+		}
+	}
+	else
+	{
+		mSitCameraPos.clearVec();
+		mSitCameraFocus.clearVec();
+		mSitCameraReferenceObject = NULL;
+		mSitCameraEnabled = FALSE;
+	}
 }
 
 //-----------------------------------------------------------------------------
@@ -2577,80 +2577,80 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer
 //-----------------------------------------------------------------------------
 void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
 {
-    if (focus_on_avatar != mFocusOnAvatar)
-    {
-        if (animate)
-        {
-            startCameraAnimation();
-        }
-        else
-        {
-            stopCameraAnimation();
-        }
-    }
-    
-    //RN: when focused on the avatar, we're not "looking" at it
-    // looking implies intent while focusing on avatar means
-    // you're just walking around with a camera on you...eesh.
-    if (!mFocusOnAvatar && focus_on_avatar)
-    {
-        setFocusGlobal(LLVector3d::zero);
-        mCameraFOVZoomFactor = 0.f;
-        if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
-        {
-            LLVector3 at_axis;
-            if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-            {
-                LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-                at_axis = LLViewerCamera::getInstance()->getAtAxis();
-                at_axis.mV[VZ] = 0.f;
-                at_axis.normalize();
-                gAgent.resetAxes(at_axis * ~obj_rot);
-            }
-            else
-            {
-                at_axis = LLViewerCamera::getInstance()->getAtAxis();
-                at_axis.mV[VZ] = 0.f;
-                at_axis.normalize();
-                gAgent.resetAxes(at_axis);
-            }
-        }
-    }
-    // unlocking camera from avatar
-    else if (mFocusOnAvatar && !focus_on_avatar)
-    {
-        // keep camera focus point consistent, even though it is now unlocked
-        setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
-        mAllowChangeToFollow = FALSE;
-    }
-    
-    mFocusOnAvatar = focus_on_avatar;
+	if (focus_on_avatar != mFocusOnAvatar)
+	{
+		if (animate)
+		{
+			startCameraAnimation();
+		}
+		else
+		{
+			stopCameraAnimation();
+		}
+	}
+	
+	//RN: when focused on the avatar, we're not "looking" at it
+	// looking implies intent while focusing on avatar means
+	// you're just walking around with a camera on you...eesh.
+	if (!mFocusOnAvatar && focus_on_avatar)
+	{
+		setFocusGlobal(LLVector3d::zero);
+		mCameraFOVZoomFactor = 0.f;
+		if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
+		{
+			LLVector3 at_axis;
+			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+			{
+				LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
+				at_axis = LLViewerCamera::getInstance()->getAtAxis();
+				at_axis.mV[VZ] = 0.f;
+				at_axis.normalize();
+				gAgent.resetAxes(at_axis * ~obj_rot);
+			}
+			else
+			{
+				at_axis = LLViewerCamera::getInstance()->getAtAxis();
+				at_axis.mV[VZ] = 0.f;
+				at_axis.normalize();
+				gAgent.resetAxes(at_axis);
+			}
+		}
+	}
+	// unlocking camera from avatar
+	else if (mFocusOnAvatar && !focus_on_avatar)
+	{
+		// keep camera focus point consistent, even though it is now unlocked
+		setFocusGlobal(gAgent.getPositionGlobal() + calcThirdPersonFocusOffset(), gAgent.getID());
+		mAllowChangeToFollow = FALSE;
+	}
+	
+	mFocusOnAvatar = focus_on_avatar;
 }
 
 
 BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, LLVector3 position)
 {
-    if(object && object->isAttachment())
-    {
-        LLViewerObject* parent = object;
-        while(parent)
-        {
-            if (parent == gAgentAvatarp)
-            {
-                // looking at an attachment on ourselves, which we don't want to do
-                object = gAgentAvatarp;
-                position.clearVec();
-            }
-            parent = (LLViewerObject*)parent->getParent();
-        }
-    }
-    if(!mLookAt || mLookAt->isDead())
-    {
-        mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
-        mLookAt->setSourceObject(gAgentAvatarp);
-    }
-
-    return mLookAt->setLookAt(target_type, object, position);
+	if(object && object->isAttachment())
+	{
+		LLViewerObject* parent = object;
+		while(parent)
+		{
+			if (parent == gAgentAvatarp)
+			{
+				// looking at an attachment on ourselves, which we don't want to do
+				object = gAgentAvatarp;
+				position.clearVec();
+			}
+			parent = (LLViewerObject*)parent->getParent();
+		}
+	}
+	if(!mLookAt || mLookAt->isDead())
+	{
+		mLookAt = (LLHUDEffectLookAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_LOOKAT);
+		mLookAt->setSourceObject(gAgentAvatarp);
+	}
+
+	return mLookAt->setLookAt(target_type, object, position);
 }
 
 //-----------------------------------------------------------------------------
@@ -2658,157 +2658,157 @@ BOOL LLAgentCamera::setLookAt(ELookAtType target_type, LLViewerObject *object, L
 //-----------------------------------------------------------------------------
 void LLAgentCamera::lookAtLastChat()
 {
-    // Block if camera is animating or not in normal third person camera mode
-    if (mCameraAnimating || !cameraThirdPerson())
-    {
-        return;
-    }
-
-    LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter());
-    if (!chatter)
-    {
-        return;
-    }
-
-    LLVector3 delta_pos;
-    if (chatter->isAvatar())
-    {
-        LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
-        if (isAgentAvatarValid() && chatter_av->mHeadp)
-        {
-            delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition();
-        }
-        else
-        {
-            delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent();
-        }
-        delta_pos.normalize();
-
-        gAgent.setControlFlags(AGENT_CONTROL_STOP);
-
-        changeCameraToThirdPerson();
-
-        LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
-        LLVector3 left = delta_pos % LLVector3::z_axis;
-        left.normalize();
-        LLVector3 up = left % delta_pos;
-        up.normalize();
-        new_camera_pos -= delta_pos * 0.4f;
-        new_camera_pos += left * 0.3f;
-        new_camera_pos += up * 0.2f;
-
-        setFocusOnAvatar(FALSE, FALSE);
-
-        if (chatter_av->mHeadp)
-        {
-            setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter());
-            mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition());
-        }
-        else
-        {
-            setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
-            mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
-        }
-    }
-    else
-    {
-        delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent();
-        delta_pos.normalize();
-
-        gAgent.setControlFlags(AGENT_CONTROL_STOP);
-
-        changeCameraToThirdPerson();
-
-        LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
-        LLVector3 left = delta_pos % LLVector3::z_axis;
-        left.normalize();
-        LLVector3 up = left % delta_pos;
-        up.normalize();
-        new_camera_pos -= delta_pos * 0.4f;
-        new_camera_pos += left * 0.3f;
-        new_camera_pos += up * 0.2f;
-
-        setFocusOnAvatar(FALSE, FALSE);
-
-        setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
-        mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
-    }
+	// Block if camera is animating or not in normal third person camera mode
+	if (mCameraAnimating || !cameraThirdPerson())
+	{
+		return;
+	}
+
+	LLViewerObject *chatter = gObjectList.findObject(gAgent.getLastChatter());
+	if (!chatter)
+	{
+		return;
+	}
+
+	LLVector3 delta_pos;
+	if (chatter->isAvatar())
+	{
+		LLVOAvatar *chatter_av = (LLVOAvatar*)chatter;
+		if (isAgentAvatarValid() && chatter_av->mHeadp)
+		{
+			delta_pos = chatter_av->mHeadp->getWorldPosition() - gAgentAvatarp->mHeadp->getWorldPosition();
+		}
+		else
+		{
+			delta_pos = chatter->getPositionAgent() - gAgent.getPositionAgent();
+		}
+		delta_pos.normalize();
+
+		gAgent.setControlFlags(AGENT_CONTROL_STOP);
+
+		changeCameraToThirdPerson();
+
+		LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
+		LLVector3 left = delta_pos % LLVector3::z_axis;
+		left.normalize();
+		LLVector3 up = left % delta_pos;
+		up.normalize();
+		new_camera_pos -= delta_pos * 0.4f;
+		new_camera_pos += left * 0.3f;
+		new_camera_pos += up * 0.2f;
+
+		setFocusOnAvatar(FALSE, FALSE);
+
+		if (chatter_av->mHeadp)
+		{
+			setFocusGlobal(gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition()), gAgent.getLastChatter());
+			mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - gAgent.getPosGlobalFromAgent(chatter_av->mHeadp->getWorldPosition());
+		}
+		else
+		{
+			setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
+			mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
+		}
+	}
+	else
+	{
+		delta_pos = chatter->getRenderPosition() - gAgent.getPositionAgent();
+		delta_pos.normalize();
+
+		gAgent.setControlFlags(AGENT_CONTROL_STOP);
+
+		changeCameraToThirdPerson();
+
+		LLVector3 new_camera_pos = gAgentAvatarp->mHeadp->getWorldPosition();
+		LLVector3 left = delta_pos % LLVector3::z_axis;
+		left.normalize();
+		LLVector3 up = left % delta_pos;
+		up.normalize();
+		new_camera_pos -= delta_pos * 0.4f;
+		new_camera_pos += left * 0.3f;
+		new_camera_pos += up * 0.2f;
+
+		setFocusOnAvatar(FALSE, FALSE);
+
+		setFocusGlobal(chatter->getPositionGlobal(), gAgent.getLastChatter());
+		mCameraFocusOffsetTarget = gAgent.getPosGlobalFromAgent(new_camera_pos) - chatter->getPositionGlobal();
+	}
 }
 
 bool LLAgentCamera::isfollowCamLocked()
 {
-    return mFollowCam.getPositionLocked();
+	return mFollowCam.getPositionLocked();
 }
 
 BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object, LLVector3 position)
 {
-    // disallow pointing at attachments and avatars
-    if (object && (object->isAttachment() || object->isAvatar()))
-    {
-        return FALSE;
-    }
-    if (!mPointAt || mPointAt->isDead())
-    {
-        mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
-        mPointAt->setSourceObject(gAgentAvatarp);
-    }
-    return mPointAt->setPointAt(target_type, object, position);
+	// disallow pointing at attachments and avatars
+	if (object && (object->isAttachment() || object->isAvatar()))
+	{
+		return FALSE;
+	}
+	if (!mPointAt || mPointAt->isDead())
+	{
+		mPointAt = (LLHUDEffectPointAt *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINTAT);
+		mPointAt->setSourceObject(gAgentAvatarp);
+	}
+	return mPointAt->setPointAt(target_type, object, position);
 }
 
 ELookAtType LLAgentCamera::getLookAtType()
 {
-    if (mLookAt) 
-    {
-        return mLookAt->getLookAtType();
-    }
-    return LOOKAT_TARGET_NONE;
+	if (mLookAt) 
+	{
+		return mLookAt->getLookAtType();
+	}
+	return LOOKAT_TARGET_NONE;
 }
 
 EPointAtType LLAgentCamera::getPointAtType()
 { 
-    if (mPointAt) 
-    {
-        return mPointAt->getPointAtType();
-    }
-    return POINTAT_TARGET_NONE;
+	if (mPointAt) 
+	{
+		return mPointAt->getPointAtType();
+	}
+	return POINTAT_TARGET_NONE;
 }
 
 void LLAgentCamera::clearGeneralKeys()
 {
-    mAtKey              = 0;
-    mWalkKey            = 0;
-    mLeftKey            = 0;
-    mUpKey              = 0;
-    mYawKey             = 0.f;
-    mPitchKey           = 0.f;
+	mAtKey 				= 0;
+	mWalkKey 			= 0;
+	mLeftKey 			= 0;
+	mUpKey 				= 0;
+	mYawKey 			= 0.f;
+	mPitchKey 			= 0.f;
 }
 
 void LLAgentCamera::clearOrbitKeys()
 {
-    mOrbitLeftKey       = 0.f;
-    mOrbitRightKey      = 0.f;
-    mOrbitUpKey         = 0.f;
-    mOrbitDownKey       = 0.f;
-    mOrbitInKey         = 0.f;
-    mOrbitOutKey        = 0.f;
+	mOrbitLeftKey		= 0.f;
+	mOrbitRightKey		= 0.f;
+	mOrbitUpKey			= 0.f;
+	mOrbitDownKey		= 0.f;
+	mOrbitInKey			= 0.f;
+	mOrbitOutKey		= 0.f;
 }
 
 void LLAgentCamera::clearPanKeys()
 {
-    mPanRightKey        = 0.f;
-    mPanLeftKey         = 0.f;
-    mPanUpKey           = 0.f;
-    mPanDownKey         = 0.f;
-    mPanInKey           = 0.f;
-    mPanOutKey          = 0.f;
+	mPanRightKey		= 0.f;
+	mPanLeftKey			= 0.f;
+	mPanUpKey			= 0.f;
+	mPanDownKey			= 0.f;
+	mPanInKey			= 0.f;
+	mPanOutKey			= 0.f;
 }
 
 // static
 S32 LLAgentCamera::directionToKey(S32 direction)
 {
-    if (direction > 0) return 1;
-    if (direction < 0) return -1;
-    return 0;
+	if (direction > 0) return 1;
+	if (direction < 0) return -1;
+	return 0;
 }
 
 
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 27a9891030..4575c1501a 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -27,9 +27,9 @@
 #ifndef LL_LLAGENTCAMERA_H
 #define LL_LLAGENTCAMERA_H
 
-#include "llfollowcam.h"            // Ventrella
-#include "llhudeffectlookat.h"      // EPointAtType
-#include "llhudeffectpointat.h"     // ELookAtType
+#include "llfollowcam.h" 			// Ventrella
+#include "llhudeffectlookat.h" 		// EPointAtType
+#include "llhudeffectpointat.h" 	// ELookAtType
 
 class LLPickInfo;
 class LLVOAvatarSelf;
@@ -40,26 +40,26 @@ class LLControlVariable;
 //--------------------------------------------------------------------
 enum ECameraMode
 {
-    CAMERA_MODE_THIRD_PERSON,
-    CAMERA_MODE_MOUSELOOK,
-    CAMERA_MODE_CUSTOMIZE_AVATAR,
-    CAMERA_MODE_FOLLOW
+	CAMERA_MODE_THIRD_PERSON,
+	CAMERA_MODE_MOUSELOOK,
+	CAMERA_MODE_CUSTOMIZE_AVATAR,
+	CAMERA_MODE_FOLLOW
 };
 
 /** Camera Presets for CAMERA_MODE_THIRD_PERSON */
 enum ECameraPreset 
 {
-    /** Default preset, what the Third Person Mode actually was */
-    CAMERA_PRESET_REAR_VIEW,
-    
-    /** "Looking at the Avatar from the front" */
-    CAMERA_PRESET_FRONT_VIEW, 
+	/** Default preset, what the Third Person Mode actually was */
+	CAMERA_PRESET_REAR_VIEW,
+	
+	/** "Looking at the Avatar from the front" */
+	CAMERA_PRESET_FRONT_VIEW, 
 
-    /** "Above and to the left, over the shoulder, pulled back a little on the zoom" */
-    CAMERA_PRESET_GROUP_VIEW,
+	/** "Above and to the left, over the shoulder, pulled back a little on the zoom" */
+	CAMERA_PRESET_GROUP_VIEW,
 
-    /** Current view when a preset is saved */
-    CAMERA_PRESET_CUSTOM0
+	/** Current view when a preset is saved */
+	CAMERA_PRESET_CUSTOM0
 };
 
 //------------------------------------------------------------------------
@@ -67,243 +67,243 @@ enum ECameraPreset
 //------------------------------------------------------------------------
 class LLAgentCamera
 {
-    LOG_CLASS(LLAgentCamera);
+	LOG_CLASS(LLAgentCamera);
 
 public:
-    //--------------------------------------------------------------------
-    // Constructors / Destructors
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Constructors / Destructors
+	//--------------------------------------------------------------------
 public:
-    LLAgentCamera();
-    virtual         ~LLAgentCamera();
-    void            init();
-    void            cleanup();
-    void            setAvatarObject(LLVOAvatarSelf* avatar);
-    bool            isInitialized() { return mInitialized; }
+	LLAgentCamera();
+	virtual 		~LLAgentCamera();
+	void			init();
+	void			cleanup();
+	void		    setAvatarObject(LLVOAvatarSelf* avatar);
+	bool			isInitialized() { return mInitialized; }
 private:
-    bool            mInitialized;
+	bool			mInitialized;
 
 
-    //--------------------------------------------------------------------
-    // Mode
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Mode
+	//--------------------------------------------------------------------
 public:
-    void            changeCameraToDefault();
-    void            changeCameraToMouselook(BOOL animate = TRUE);
-    void            changeCameraToThirdPerson(BOOL animate = TRUE);
-    void            changeCameraToCustomizeAvatar(); // Trigger transition animation
-    void            changeCameraToFollow(BOOL animate = TRUE);  // Ventrella
-    BOOL            cameraThirdPerson() const       { return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
-    BOOL            cameraMouselook() const         { return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
-    BOOL            cameraCustomizeAvatar() const   { return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
-    BOOL            cameraFollow() const            { return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
-    ECameraMode     getCameraMode() const           { return mCameraMode; }
-    ECameraMode     getLastCameraMode() const       { return mLastCameraMode; }
-    void            updateCamera();                 // Call once per frame to update camera location/orientation
-    void            resetCamera();                  // Slam camera into its default position
-    void            updateLastCamera();             // Set last camera to current camera
+	void			changeCameraToDefault();
+	void			changeCameraToMouselook(BOOL animate = TRUE);
+	void			changeCameraToThirdPerson(BOOL animate = TRUE);
+	void			changeCameraToCustomizeAvatar(); // Trigger transition animation
+	void			changeCameraToFollow(BOOL animate = TRUE); 	// Ventrella
+	BOOL			cameraThirdPerson() const		{ return (mCameraMode == CAMERA_MODE_THIRD_PERSON && mLastCameraMode == CAMERA_MODE_THIRD_PERSON); }
+	BOOL			cameraMouselook() const			{ return (mCameraMode == CAMERA_MODE_MOUSELOOK && mLastCameraMode == CAMERA_MODE_MOUSELOOK); }
+	BOOL			cameraCustomizeAvatar() const	{ return (mCameraMode == CAMERA_MODE_CUSTOMIZE_AVATAR /*&& !mCameraAnimating*/); }
+	BOOL			cameraFollow() const			{ return (mCameraMode == CAMERA_MODE_FOLLOW && mLastCameraMode == CAMERA_MODE_FOLLOW); }
+	ECameraMode		getCameraMode() const 			{ return mCameraMode; }
+	ECameraMode		getLastCameraMode() const 		{ return mLastCameraMode; }
+	void			updateCamera();					// Call once per frame to update camera location/orientation
+	void			resetCamera(); 					// Slam camera into its default position
+	void			updateLastCamera();				// Set last camera to current camera
 
 private:
-    ECameraMode     mCameraMode;                    // Target mode after transition animation is done
-    ECameraMode     mLastCameraMode;
+	ECameraMode		mCameraMode;					// Target mode after transition animation is done
+	ECameraMode		mLastCameraMode;
 
-    //--------------------------------------------------------------------
-    // Preset
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Preset
+	//--------------------------------------------------------------------
 public:
-    void switchCameraPreset(ECameraPreset preset);
+	void switchCameraPreset(ECameraPreset preset);
 private:
-    /** Determines default camera offset depending on the current camera preset */
-    LLVector3 getCameraOffsetInitial();
-    /** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
-    F32 getCameraMaxZoomDistance();
+	/** Determines default camera offset depending on the current camera preset */
+	LLVector3 getCameraOffsetInitial();
+	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
+	F32 getCameraMaxZoomDistance();
 
-    /** Camera preset in Third Person Mode */
-    ECameraPreset mCameraPreset; 
+	/** Camera preset in Third Person Mode */
+	ECameraPreset mCameraPreset; 
 
-    /** Initial camera offsets */
-    std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial;
+	/** Initial camera offsets */
+	std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial;
 
-    /** Initial focus offsets */
-    std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial;
+	/** Initial focus offsets */
+	std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial;
 
-    //--------------------------------------------------------------------
-    // Position
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Position
+	//--------------------------------------------------------------------
 public:
-    LLVector3d      getCameraPositionGlobal() const;
-    const LLVector3 &getCameraPositionAgent() const;
-    LLVector3d      calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
-    F32             getCameraMinOffGround();        // Minimum height off ground for this mode, meters
-    void            setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; }
-    BOOL            calcCameraMinDistance(F32 &obj_min_distance);
-    F32             getCurrentCameraBuildOffset()   { return (F32)mCameraFocusOffset.length(); }
-    void            clearCameraLag() { mCameraLag.clearVec(); }
+	LLVector3d		getCameraPositionGlobal() const;
+	const LLVector3 &getCameraPositionAgent() const;
+	LLVector3d		calcCameraPositionTargetGlobal(BOOL *hit_limit = NULL); // Calculate the camera position target
+	F32				getCameraMinOffGround(); 		// Minimum height off ground for this mode, meters
+	void			setCameraCollidePlane(const LLVector4 &plane) { mCameraCollidePlane = plane; }
+	BOOL			calcCameraMinDistance(F32 &obj_min_distance);
+	F32				getCurrentCameraBuildOffset() 	{ return (F32)mCameraFocusOffset.length(); }
+	void			clearCameraLag() { mCameraLag.clearVec(); }
 private:
-    F32             mCurrentCameraDistance;         // Current camera offset from avatar
-    F32             mTargetCameraDistance;          // Target camera offset from avatar
-    F32             mCameraFOVZoomFactor;           // Amount of fov zoom applied to camera when zeroing in on an object
-    F32             mCameraCurrentFOVZoomFactor;    // Interpolated fov zoom
-    F32             mCameraFOVDefault;              // Default field of view that is basis for FOV zoom effect
-    LLVector4       mCameraCollidePlane;            // Colliding plane for camera
-    F32             mCameraZoomFraction;            // Mousewheel driven fraction of zoom
-    LLVector3       mCameraPositionAgent;           // Camera position in agent coordinates
-    LLVector3       mCameraVirtualPositionAgent;    // Camera virtual position (target) before performing FOV zoom
-    LLVector3d      mCameraSmoothingLastPositionGlobal;    
-    LLVector3d      mCameraSmoothingLastPositionAgent;
-    bool            mCameraSmoothingStop;
-    LLVector3       mCameraLag;                     // Third person camera lag
-    LLVector3       mCameraUpVector;                // Camera's up direction in world coordinates (determines the 'roll' of the view)
-
-    //--------------------------------------------------------------------
-    // Follow
-    //--------------------------------------------------------------------
+	F32				mCurrentCameraDistance;	 		// Current camera offset from avatar
+	F32				mTargetCameraDistance;			// Target camera offset from avatar
+	F32				mCameraFOVZoomFactor;			// Amount of fov zoom applied to camera when zeroing in on an object
+	F32				mCameraCurrentFOVZoomFactor;	// Interpolated fov zoom
+	F32				mCameraFOVDefault;				// Default field of view that is basis for FOV zoom effect
+	LLVector4		mCameraCollidePlane;			// Colliding plane for camera
+	F32				mCameraZoomFraction;			// Mousewheel driven fraction of zoom
+	LLVector3		mCameraPositionAgent;			// Camera position in agent coordinates
+	LLVector3		mCameraVirtualPositionAgent;	// Camera virtual position (target) before performing FOV zoom
+	LLVector3d      mCameraSmoothingLastPositionGlobal;    
+	LLVector3d      mCameraSmoothingLastPositionAgent;
+	bool            mCameraSmoothingStop;
+	LLVector3		mCameraLag;						// Third person camera lag
+	LLVector3		mCameraUpVector;				// Camera's up direction in world coordinates (determines the 'roll' of the view)
+
+	//--------------------------------------------------------------------
+	// Follow
+	//--------------------------------------------------------------------
 public:
-    void            setUsingFollowCam(bool using_follow_cam);
-    bool            isfollowCamLocked();
+	void			setUsingFollowCam(bool using_follow_cam);
+	bool 			isfollowCamLocked();
 private:
-    LLFollowCam     mFollowCam;             // Ventrella
+	LLFollowCam 	mFollowCam; 			// Ventrella
 
-    //--------------------------------------------------------------------
-    // Sit
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Sit
+	//--------------------------------------------------------------------
 public:
-    void            setupSitCamera();
-    BOOL            sitCameraEnabled()      { return mSitCameraEnabled; }
-    void            setSitCamera(const LLUUID &object_id, 
-                                 const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
+	void			setupSitCamera();
+	BOOL			sitCameraEnabled() 		{ return mSitCameraEnabled; }
+	void			setSitCamera(const LLUUID &object_id, 
+								 const LLVector3 &camera_pos = LLVector3::zero, const LLVector3 &camera_focus = LLVector3::zero);
 private:
-    LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting
-    BOOL            mSitCameraEnabled;      // Use provided camera information when sitting?
-    LLVector3       mSitCameraPos;          // Root relative camera pos when sitting
-    LLVector3       mSitCameraFocus;        // Root relative camera target when sitting
-
-    //--------------------------------------------------------------------
-    // Animation
-    //--------------------------------------------------------------------
+	LLPointer<LLViewerObject> mSitCameraReferenceObject; // Object to which camera is related when sitting
+	BOOL			mSitCameraEnabled;		// Use provided camera information when sitting?
+	LLVector3		mSitCameraPos;			// Root relative camera pos when sitting
+	LLVector3		mSitCameraFocus;		// Root relative camera target when sitting
+
+	//--------------------------------------------------------------------
+	// Animation
+	//--------------------------------------------------------------------
 public:
-    void            setCameraAnimating(BOOL b)          { mCameraAnimating = b; }
-    BOOL            getCameraAnimating()                { return mCameraAnimating; }
-    void            setAnimationDuration(F32 seconds);
-    void            startCameraAnimation();
-    void            stopCameraAnimation();
+	void			setCameraAnimating(BOOL b)			{ mCameraAnimating = b; }
+	BOOL			getCameraAnimating()				{ return mCameraAnimating; }
+	void			setAnimationDuration(F32 seconds);
+	void			startCameraAnimation();
+	void			stopCameraAnimation();
 private:
-    LLFrameTimer    mAnimationTimer;    // Seconds that transition animation has been active
-    F32             mAnimationDuration; // In seconds
-    BOOL            mCameraAnimating;                   // Camera is transitioning from one mode to another
-    LLVector3d      mAnimationCameraStartGlobal;        // Camera start position, global coords
-    LLVector3d      mAnimationFocusStartGlobal;         // Camera focus point, global coords
-
-    //--------------------------------------------------------------------
-    // Focus
-    //--------------------------------------------------------------------
+	LLFrameTimer	mAnimationTimer; 	// Seconds that transition animation has been active
+	F32				mAnimationDuration;	// In seconds
+	BOOL			mCameraAnimating;					// Camera is transitioning from one mode to another
+	LLVector3d		mAnimationCameraStartGlobal;		// Camera start position, global coords
+	LLVector3d		mAnimationFocusStartGlobal;			// Camera focus point, global coords
+
+	//--------------------------------------------------------------------
+	// Focus
+	//--------------------------------------------------------------------
 public:
-    LLVector3d      calcFocusPositionTargetGlobal();
-    LLVector3       calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y);
-    BOOL            getFocusOnAvatar() const        { return mFocusOnAvatar; }
-    LLPointer<LLViewerObject>&  getFocusObject()    { return mFocusObject; }
-    F32             getFocusObjectDist() const      { return mFocusObjectDist; }
-    void            updateFocusOffset();
-    void            validateFocusObject();
-    void            setFocusGlobal(const LLPickInfo& pick);
-    void            setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
-    void            setFocusOnAvatar(BOOL focus, BOOL animate);
-    void            setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
-    void            clearFocusObject();
-    void            setFocusObject(LLViewerObject* object);
-    void            setAllowChangeToFollow(BOOL focus)  { mAllowChangeToFollow = focus; }
-    void            setObjectTracking(BOOL track)   { mTrackFocusObject = track; }
-    const LLVector3d &getFocusGlobal() const        { return mFocusGlobal; }
-    const LLVector3d &getFocusTargetGlobal() const  { return mFocusTargetGlobal; }
+	LLVector3d		calcFocusPositionTargetGlobal();
+	LLVector3		calcFocusOffset(LLViewerObject *object, LLVector3 pos_agent, S32 x, S32 y);
+	BOOL			getFocusOnAvatar() const		{ return mFocusOnAvatar; }
+	LLPointer<LLViewerObject>&	getFocusObject() 	{ return mFocusObject; }
+	F32				getFocusObjectDist() const		{ return mFocusObjectDist; }
+	void			updateFocusOffset();
+	void			validateFocusObject();
+	void			setFocusGlobal(const LLPickInfo& pick);
+	void			setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
+	void			setFocusOnAvatar(BOOL focus, BOOL animate);
+	void			setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
+	void			clearFocusObject();
+	void			setFocusObject(LLViewerObject* object);
+	void			setAllowChangeToFollow(BOOL focus) 	{ mAllowChangeToFollow = focus; }
+	void			setObjectTracking(BOOL track) 	{ mTrackFocusObject = track; }
+	const LLVector3d &getFocusGlobal() const		{ return mFocusGlobal; }
+	const LLVector3d &getFocusTargetGlobal() const	{ return mFocusTargetGlobal; }
 private:
-    LLVector3d      mCameraFocusOffset;             // Offset from focus point in build mode
-    LLVector3d      mCameraFocusOffsetTarget;       // Target towards which we are lerping the camera's focus offset
-    BOOL            mFocusOnAvatar;
-    BOOL            mAllowChangeToFollow;
-    LLVector3d      mFocusGlobal;
-    LLVector3d      mFocusTargetGlobal;
-    LLPointer<LLViewerObject> mFocusObject;
-    F32             mFocusObjectDist;
-    LLVector3       mFocusObjectOffset;
-    F32             mFocusDotRadius;                // Meters
-    BOOL            mTrackFocusObject;
-    
-    //--------------------------------------------------------------------
-    // Lookat / Pointat
-    //--------------------------------------------------------------------
+	LLVector3d		mCameraFocusOffset;				// Offset from focus point in build mode
+	LLVector3d		mCameraFocusOffsetTarget;		// Target towards which we are lerping the camera's focus offset
+	BOOL			mFocusOnAvatar;
+	BOOL			mAllowChangeToFollow;
+	LLVector3d		mFocusGlobal;
+	LLVector3d		mFocusTargetGlobal;
+	LLPointer<LLViewerObject> mFocusObject;
+	F32				mFocusObjectDist;
+	LLVector3		mFocusObjectOffset;
+	F32				mFocusDotRadius; 				// Meters
+	BOOL			mTrackFocusObject;
+	
+	//--------------------------------------------------------------------
+	// Lookat / Pointat
+	//--------------------------------------------------------------------
 public:
-    void            updateLookAt(const S32 mouse_x, const S32 mouse_y);
-    BOOL            setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
-    ELookAtType     getLookAtType();
-    void            lookAtLastChat();
-    void            slamLookAt(const LLVector3 &look_at); // Set the physics data
-    BOOL            setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
-    EPointAtType    getPointAtType();
+	void			updateLookAt(const S32 mouse_x, const S32 mouse_y);
+	BOOL			setLookAt(ELookAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
+	ELookAtType		getLookAtType();
+	void			lookAtLastChat();
+	void 			slamLookAt(const LLVector3 &look_at); // Set the physics data
+	BOOL			setPointAt(EPointAtType target_type, LLViewerObject *object = NULL, LLVector3 position = LLVector3::zero);
+	EPointAtType	getPointAtType();
 public:
-    LLPointer<LLHUDEffectLookAt> mLookAt;
-    LLPointer<LLHUDEffectPointAt> mPointAt;
+	LLPointer<LLHUDEffectLookAt> mLookAt;
+	LLPointer<LLHUDEffectPointAt> mPointAt;
 
-    //--------------------------------------------------------------------
-    // Third person
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Third person
+	//--------------------------------------------------------------------
 public:
-    LLVector3d      calcThirdPersonFocusOffset();
-    void            setThirdPersonHeadOffset(LLVector3 offset)  { mThirdPersonHeadOffset = offset; }    
+	LLVector3d		calcThirdPersonFocusOffset();
+	void			setThirdPersonHeadOffset(LLVector3 offset) 	{ mThirdPersonHeadOffset = offset; }	
 private:
-    LLVector3       mThirdPersonHeadOffset;                     // Head offset for third person camera position
+	LLVector3		mThirdPersonHeadOffset;						// Head offset for third person camera position
 
-    //--------------------------------------------------------------------
-    // Orbit
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Orbit
+	//--------------------------------------------------------------------
 public:
-    void            cameraOrbitAround(const F32 radians);   // Rotate camera CCW radians about build focus point
-    void            cameraOrbitOver(const F32 radians);     // Rotate camera forward radians over build focus point
-    void            cameraOrbitIn(const F32 meters);        // Move camera in toward build focus point
+	void			cameraOrbitAround(const F32 radians);	// Rotate camera CCW radians about build focus point
+	void			cameraOrbitOver(const F32 radians);		// Rotate camera forward radians over build focus point
+	void			cameraOrbitIn(const F32 meters);		// Move camera in toward build focus point
 
-    //--------------------------------------------------------------------
-    // Zoom
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Zoom
+	//--------------------------------------------------------------------
 public:
-    void            handleScrollWheel(S32 clicks);          // Mousewheel driven zoom
-    void            cameraZoomIn(const F32 factor);         // Zoom in by fraction of current distance
-    F32             getCameraZoomFraction();                // Get camera zoom as fraction of minimum and maximum zoom
-    void            setCameraZoomFraction(F32 fraction);    // Set camera zoom as fraction of minimum and maximum zoom
-    F32             calcCameraFOVZoomFactor();
-
-    //--------------------------------------------------------------------
-    // Pan
-    //--------------------------------------------------------------------
+	void			handleScrollWheel(S32 clicks); 			// Mousewheel driven zoom
+	void			cameraZoomIn(const F32 factor);			// Zoom in by fraction of current distance
+	F32				getCameraZoomFraction();				// Get camera zoom as fraction of minimum and maximum zoom
+	void			setCameraZoomFraction(F32 fraction);	// Set camera zoom as fraction of minimum and maximum zoom
+	F32				calcCameraFOVZoomFactor();
+
+	//--------------------------------------------------------------------
+	// Pan
+	//--------------------------------------------------------------------
 public:
-    void            cameraPanIn(const F32 meters);
-    void            cameraPanLeft(const F32 meters);
-    void            cameraPanUp(const F32 meters);
-    
-    //--------------------------------------------------------------------
-    // View
-    //--------------------------------------------------------------------
+	void			cameraPanIn(const F32 meters);
+	void			cameraPanLeft(const F32 meters);
+	void			cameraPanUp(const F32 meters);
+	
+	//--------------------------------------------------------------------
+	// View
+	//--------------------------------------------------------------------
 public:
-    // Called whenever the agent moves.  Puts camera back in default position, deselects items, etc.
-    void            resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE);
-    // Called on camera movement.  Unlocks camera from the default position behind the avatar.
-    void            unlockView();
+	// Called whenever the agent moves.  Puts camera back in default position, deselects items, etc.
+	void			resetView(BOOL reset_camera = TRUE, BOOL change_camera = FALSE);
+	// Called on camera movement.  Unlocks camera from the default position behind the avatar.
+	void			unlockView();
 public:
-    F32             mDrawDistance;
+	F32				mDrawDistance;
 
-    //--------------------------------------------------------------------
-    // Mouselook
-    //--------------------------------------------------------------------
+	//--------------------------------------------------------------------
+	// Mouselook
+	//--------------------------------------------------------------------
 public:
-    BOOL            getForceMouselook() const           { return mForceMouselook; }
-    void            setForceMouselook(BOOL mouselook)   { mForceMouselook = mouselook; }
+	BOOL			getForceMouselook() const 			{ return mForceMouselook; }
+	void			setForceMouselook(BOOL mouselook) 	{ mForceMouselook = mouselook; }
 private:
-    BOOL            mForceMouselook;
-    
-    //--------------------------------------------------------------------
-    // HUD
-    //--------------------------------------------------------------------
+	BOOL			mForceMouselook;
+	
+	//--------------------------------------------------------------------
+	// HUD
+	//--------------------------------------------------------------------
 public:
-    F32             mHUDTargetZoom; // Target zoom level for HUD objects (used when editing)
-    F32             mHUDCurZoom;    // Current animated zoom level for HUD objects
+	F32				mHUDTargetZoom;	// Target zoom level for HUD objects (used when editing)
+	F32				mHUDCurZoom; 	// Current animated zoom level for HUD objects
 
 
 /********************************************************************************
@@ -312,84 +312,84 @@ public:
  **/
 
 public:
-    S32             getAtKey() const        { return mAtKey; }
-    S32             getWalkKey() const      { return mWalkKey; }
-    S32             getLeftKey() const      { return mLeftKey; }
-    S32             getUpKey() const        { return mUpKey; }
-    F32             getYawKey() const       { return mYawKey; }
-    F32             getPitchKey() const     { return mPitchKey; }
-
-    void            setAtKey(S32 mag)       { mAtKey = mag; }
-    void            setWalkKey(S32 mag)     { mWalkKey = mag; }
-    void            setLeftKey(S32 mag)     { mLeftKey = mag; }
-    void            setUpKey(S32 mag)       { mUpKey = mag; }
-    void            setYawKey(F32 mag)      { mYawKey = mag; }
-    void            setPitchKey(F32 mag)    { mPitchKey = mag; }
-
-    void            clearGeneralKeys();
-    static S32      directionToKey(S32 direction); // Changes direction to -1/0/1
+	S32				getAtKey() const		{ return mAtKey; }
+	S32				getWalkKey() const		{ return mWalkKey; }
+	S32				getLeftKey() const		{ return mLeftKey; }
+	S32				getUpKey() const		{ return mUpKey; }
+	F32				getYawKey() const		{ return mYawKey; }
+	F32				getPitchKey() const		{ return mPitchKey; }
+
+	void			setAtKey(S32 mag)		{ mAtKey = mag; }
+	void			setWalkKey(S32 mag)		{ mWalkKey = mag; }
+	void			setLeftKey(S32 mag)		{ mLeftKey = mag; }
+	void			setUpKey(S32 mag)		{ mUpKey = mag; }
+	void			setYawKey(F32 mag)		{ mYawKey = mag; }
+	void			setPitchKey(F32 mag)	{ mPitchKey = mag; }
+
+	void			clearGeneralKeys();
+	static S32		directionToKey(S32 direction); // Changes direction to -1/0/1
 
 private:
-    S32             mAtKey;             // Either 1, 0, or -1. Indicates that movement key is pressed
-    S32             mWalkKey;           // Like AtKey, but causes less forward thrust
-    S32             mLeftKey;
-    S32             mUpKey;
-    F32             mYawKey;
-    F32             mPitchKey;
-
-    //--------------------------------------------------------------------
-    // Orbit
-    //--------------------------------------------------------------------
+	S32 			mAtKey;				// Either 1, 0, or -1. Indicates that movement key is pressed
+	S32				mWalkKey; 			// Like AtKey, but causes less forward thrust
+	S32 			mLeftKey;
+	S32				mUpKey;
+	F32				mYawKey;
+	F32				mPitchKey;
+
+	//--------------------------------------------------------------------
+	// Orbit
+	//--------------------------------------------------------------------
 public:
-    F32             getOrbitLeftKey() const     { return mOrbitLeftKey; }
-    F32             getOrbitRightKey() const    { return mOrbitRightKey; }
-    F32             getOrbitUpKey() const       { return mOrbitUpKey; }
-    F32             getOrbitDownKey() const     { return mOrbitDownKey; }
-    F32             getOrbitInKey() const       { return mOrbitInKey; }
-    F32             getOrbitOutKey() const      { return mOrbitOutKey; }
-
-    void            setOrbitLeftKey(F32 mag)    { mOrbitLeftKey = mag; }
-    void            setOrbitRightKey(F32 mag)   { mOrbitRightKey = mag; }
-    void            setOrbitUpKey(F32 mag)      { mOrbitUpKey = mag; }
-    void            setOrbitDownKey(F32 mag)    { mOrbitDownKey = mag; }
-    void            setOrbitInKey(F32 mag)      { mOrbitInKey = mag; }
-    void            setOrbitOutKey(F32 mag)     { mOrbitOutKey = mag; }
-
-    void            clearOrbitKeys();
+	F32				getOrbitLeftKey() const		{ return mOrbitLeftKey; }
+	F32				getOrbitRightKey() const	{ return mOrbitRightKey; }
+	F32				getOrbitUpKey() const		{ return mOrbitUpKey; }
+	F32				getOrbitDownKey() const		{ return mOrbitDownKey; }
+	F32				getOrbitInKey() const		{ return mOrbitInKey; }
+	F32				getOrbitOutKey() const		{ return mOrbitOutKey; }
+
+	void			setOrbitLeftKey(F32 mag)	{ mOrbitLeftKey = mag; }
+	void			setOrbitRightKey(F32 mag)	{ mOrbitRightKey = mag; }
+	void			setOrbitUpKey(F32 mag)		{ mOrbitUpKey = mag; }
+	void			setOrbitDownKey(F32 mag)	{ mOrbitDownKey = mag; }
+	void			setOrbitInKey(F32 mag)		{ mOrbitInKey = mag; }
+	void			setOrbitOutKey(F32 mag)		{ mOrbitOutKey = mag; }
+
+	void			clearOrbitKeys();
 private:
-    F32             mOrbitLeftKey;
-    F32             mOrbitRightKey;
-    F32             mOrbitUpKey;
-    F32             mOrbitDownKey;
-    F32             mOrbitInKey;
-    F32             mOrbitOutKey;
-
-    //--------------------------------------------------------------------
-    // Pan
-    //--------------------------------------------------------------------
+	F32				mOrbitLeftKey;
+	F32				mOrbitRightKey;
+	F32				mOrbitUpKey;
+	F32				mOrbitDownKey;
+	F32				mOrbitInKey;
+	F32				mOrbitOutKey;
+
+	//--------------------------------------------------------------------
+	// Pan
+	//--------------------------------------------------------------------
 public:
-    F32             getPanLeftKey() const       { return mPanLeftKey; }
-    F32             getPanRightKey() const  { return mPanRightKey; }
-    F32             getPanUpKey() const     { return mPanUpKey; }
-    F32             getPanDownKey() const       { return mPanDownKey; }
-    F32             getPanInKey() const     { return mPanInKey; }
-    F32             getPanOutKey() const        { return mPanOutKey; }
-
-    void            setPanLeftKey(F32 mag)      { mPanLeftKey = mag; }
-    void            setPanRightKey(F32 mag)     { mPanRightKey = mag; }
-    void            setPanUpKey(F32 mag)        { mPanUpKey = mag; }
-    void            setPanDownKey(F32 mag)      { mPanDownKey = mag; }
-    void            setPanInKey(F32 mag)        { mPanInKey = mag; }
-    void            setPanOutKey(F32 mag)       { mPanOutKey = mag; }
-
-    void            clearPanKeys();
+	F32				getPanLeftKey() const		{ return mPanLeftKey; }
+	F32				getPanRightKey() const	{ return mPanRightKey; }
+	F32				getPanUpKey() const		{ return mPanUpKey; }
+	F32				getPanDownKey() const		{ return mPanDownKey; }
+	F32				getPanInKey() const		{ return mPanInKey; }
+	F32				getPanOutKey() const		{ return mPanOutKey; }
+
+	void			setPanLeftKey(F32 mag)		{ mPanLeftKey = mag; }
+	void			setPanRightKey(F32 mag)		{ mPanRightKey = mag; }
+	void			setPanUpKey(F32 mag)		{ mPanUpKey = mag; }
+	void			setPanDownKey(F32 mag)		{ mPanDownKey = mag; }
+	void			setPanInKey(F32 mag)		{ mPanInKey = mag; }
+	void			setPanOutKey(F32 mag)		{ mPanOutKey = mag; }
+
+	void			clearPanKeys();
 private:
-    F32             mPanUpKey;                      
-    F32             mPanDownKey;                    
-    F32             mPanLeftKey;                    
-    F32             mPanRightKey;                   
-    F32             mPanInKey;
-    F32             mPanOutKey;
+	F32				mPanUpKey;						
+	F32				mPanDownKey;					
+	F32				mPanLeftKey;					
+	F32				mPanRightKey;					
+	F32				mPanInKey;
+	F32				mPanOutKey;
 
 /**                    Keys
  **                                                                            **
diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp
index 9848a1af0b..df06ad31e6 100644
--- a/indra/newview/lldrawpoolwater.cpp
+++ b/indra/newview/lldrawpoolwater.cpp
@@ -34,7 +34,7 @@
 #include "m3math.h"
 #include "llrender.h"
 
-#include "llagent.h"        // for gAgent for getRegion for getWaterHeight
+#include "llagent.h"		// for gAgent for getRegion for getWaterHeight
 #include "llcubemap.h"
 #include "lldrawable.h"
 #include "llface.h"
@@ -64,26 +64,26 @@ F32 LLDrawPoolWater::sWaterFogEnd = 0.f;
 LLVector3 LLDrawPoolWater::sLightDir;
 
 LLDrawPoolWater::LLDrawPoolWater() :
-    LLFacePool(POOL_WATER)
+	LLFacePool(POOL_WATER)
 {
-    mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
-    gGL.getTexUnit(0)->bind(mHBTex[0]) ;
-    mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP);
+	mHBTex[0] = LLViewerTextureManager::getFetchedTexture(gSunTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+	gGL.getTexUnit(0)->bind(mHBTex[0]) ;
+	mHBTex[0]->setAddressMode(LLTexUnit::TAM_CLAMP);
 
-    mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
-    gGL.getTexUnit(0)->bind(mHBTex[1]);
-    mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
+	mHBTex[1] = LLViewerTextureManager::getFetchedTexture(gMoonTextureID, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_UI);
+	gGL.getTexUnit(0)->bind(mHBTex[1]);
+	mHBTex[1]->setAddressMode(LLTexUnit::TAM_CLAMP);
 
 
-    mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE);
-    llassert(mWaterImagep);
-    mWaterImagep->setNoDelete();
-    mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
-    llassert(mOpaqueWaterImagep);
-    mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
-    mWaterNormp->setNoDelete();
+	mWaterImagep = LLViewerTextureManager::getFetchedTexture(TRANSPARENT_WATER_TEXTURE);
+	llassert(mWaterImagep);
+	mWaterImagep->setNoDelete();
+	mOpaqueWaterImagep = LLViewerTextureManager::getFetchedTexture(OPAQUE_WATER_TEXTURE);
+	llassert(mOpaqueWaterImagep);
+	mWaterNormp = LLViewerTextureManager::getFetchedTexture(DEFAULT_WATER_NORMAL);
+	mWaterNormp->setNoDelete();
 
-    restoreGL();
+	restoreGL();
 }
 
 LLDrawPoolWater::~LLDrawPoolWater()
@@ -93,48 +93,48 @@ LLDrawPoolWater::~LLDrawPoolWater()
 //static
 void LLDrawPoolWater::restoreGL()
 {
-    
+	
 }
 
 LLDrawPool *LLDrawPoolWater::instancePool()
 {
-    LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL;
-    return NULL;
+	LL_ERRS() << "Should never be calling instancePool on a water pool!" << LL_ENDL;
+	return NULL;
 }
 
 
 void LLDrawPoolWater::prerender()
 {
-    mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ?
-        LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0;
+	mVertexShaderLevel = (gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps) ?
+		LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WATER) : 0;
 
-    // got rid of modulation by light color since it got a little too
-    // green at sunset and sl-57047 (underwater turns black at 8:00)
-    sWaterFogColor = LLWaterParamManager::instance().getFogColor();
-    sWaterFogColor.mV[3] = 0;
+	// got rid of modulation by light color since it got a little too
+	// green at sunset and sl-57047 (underwater turns black at 8:00)
+	sWaterFogColor = LLWaterParamManager::instance().getFogColor();
+	sWaterFogColor.mV[3] = 0;
 
 }
 
 S32 LLDrawPoolWater::getNumPasses()
 {
-    if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f)
-    {
-        return 1;
-    }
+	if (LLViewerCamera::getInstance()->getOrigin().mV[2] < 1024.f)
+	{
+		return 1;
+	}
 
-    return 0;
+	return 0;
 }
 
 void LLDrawPoolWater::beginPostDeferredPass(S32 pass)
 {
-    beginRenderPass(pass);
-    deferred_render = TRUE;
+	beginRenderPass(pass);
+	deferred_render = TRUE;
 }
 
 void LLDrawPoolWater::endPostDeferredPass(S32 pass)
 {
-    endRenderPass(pass);
-    deferred_render = FALSE;
+	endRenderPass(pass);
+	deferred_render = FALSE;
 }
 
 //===============================
@@ -142,591 +142,591 @@ void LLDrawPoolWater::endPostDeferredPass(S32 pass)
 //===============================
 void LLDrawPoolWater::renderDeferred(S32 pass)
 {
-    LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
-    deferred_render = TRUE;
-    shade();
-    deferred_render = FALSE;
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
+	deferred_render = TRUE;
+	shade();
+	deferred_render = FALSE;
 }
 
 //=========================================
 
 void LLDrawPoolWater::render(S32 pass)
 {
-    LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
-    if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
-    {
-        return;
-    }
-
-    //do a quick 'n dirty depth sort
-    for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-             iter != mDrawFace.end(); iter++)
-    {
-        LLFace* facep = *iter;
-        facep->mDistance = -facep->mCenterLocal.mV[2];
-    }
-
-    std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
-
-    // See if we are rendering water as opaque or not
-    if (!gSavedSettings.getBOOL("RenderTransparentWater"))
-    {
-        // render water for low end hardware
-        renderOpaqueLegacyWater();
-        return;
-    }
-
-    LLGLEnable blend(GL_BLEND);
-
-    if ((mVertexShaderLevel > 0) && !sSkipScreenCopy)
-    {
-        shade();
-        return;
-    }
-
-    LLVOSky *voskyp = gSky.mVOSkyp;
-
-    stop_glerror();
-
-    if (!gGLManager.mHasMultitexture)
-    {
-        // Ack!  No multitexture!  Bail!
-        return;
-    }
-
-    LLFace* refl_face = voskyp->getReflFace();
-
-    gPipeline.disableLights();
-    
-    LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
-
-    LLGLDisable cullFace(GL_CULL_FACE);
-    
-    // Set up second pass first
-    mWaterImagep->addTextureStats(1024.f*1024.f);
-    gGL.getTexUnit(1)->activate();
-    gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
-    gGL.getTexUnit(1)->bind(mWaterImagep) ;
-
-    LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
-    F32 up_dot = camera_up * LLVector3::z_axis;
-
-    LLColor4 water_color;
-    if (LLViewerCamera::getInstance()->cameraUnderWater())
-    {
-        water_color.setVec(1.f, 1.f, 1.f, 0.4f);
-    }
-    else
-    {
-        water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
-    }
-
-    gGL.diffuseColor4fv(water_color.mV);
-
-    // Automatically generate texture coords for detail map
-    glEnable(GL_TEXTURE_GEN_S); //texture unit 1
-    glEnable(GL_TEXTURE_GEN_T); //texture unit 1
-    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-    glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-
-    // Slowly move over time.
-    F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f);
-    F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f};
-    F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f};
-    glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
-    glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
-
-    gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
-    gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA);
-
-    gGL.getTexUnit(0)->activate();
-    
-    glClearStencil(1);
-    glClear(GL_STENCIL_BUFFER_BIT);
-    LLGLEnable gls_stencil(GL_STENCIL_TEST);
-    glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP);
-    glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF);
-
-    for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-         iter != mDrawFace.end(); iter++)
-    {
-        LLFace *face = *iter;
-        if (voskyp->isReflFace(face))
-        {
-            continue;
-        }
-        gGL.getTexUnit(0)->bind(face->getTexture());
-        face->renderIndexed();
-    }
-
-    // Now, disable texture coord generation on texture state 1
-    gGL.getTexUnit(1)->activate();
-    gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
-    gGL.getTexUnit(1)->disable();
-    glDisable(GL_TEXTURE_GEN_S); //texture unit 1
-    glDisable(GL_TEXTURE_GEN_T); //texture unit 1
-
-    // Disable texture coordinate and color arrays
-    gGL.getTexUnit(0)->activate();
-    gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
-    stop_glerror();
-    
-    if (gSky.mVOSkyp->getCubeMap())
-    {
-        gSky.mVOSkyp->getCubeMap()->enable(0);
-        gSky.mVOSkyp->getCubeMap()->bind();
-
-        gGL.matrixMode(LLRender::MM_TEXTURE);
-        gGL.loadIdentity();
-        LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
-        LLMatrix4 camera_rot(camera_mat.getMat3());
-        camera_rot.invert();
-
-        gGL.loadMatrix((F32 *)camera_rot.mMatrix);
-
-        gGL.matrixMode(LLRender::MM_MODELVIEW);
-        LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f,  0.5f*up_dot);
-
-        gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
-
-        for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-             iter != mDrawFace.end(); iter++)
-        {
-            LLFace *face = *iter;
-            if (voskyp->isReflFace(face))
-            {
-                //refl_face = face;
-                continue;
-            }
-
-            if (face->getGeomCount() > 0)
-            {                   
-                face->renderIndexed();
-            }
-        }
-
-        gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
-
-        gSky.mVOSkyp->getCubeMap()->disable();
-        
-        gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-        gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
-        gGL.matrixMode(LLRender::MM_TEXTURE);
-        gGL.loadIdentity();
-        gGL.matrixMode(LLRender::MM_MODELVIEW);
-        
-    }
-
-    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+	LL_RECORD_BLOCK_TIME(FTM_RENDER_WATER);
+	if (mDrawFace.empty() || LLDrawable::getCurrentFrame() <= 1)
+	{
+		return;
+	}
+
+	//do a quick 'n dirty depth sort
+	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+			 iter != mDrawFace.end(); iter++)
+	{
+		LLFace* facep = *iter;
+		facep->mDistance = -facep->mCenterLocal.mV[2];
+	}
+
+	std::sort(mDrawFace.begin(), mDrawFace.end(), LLFace::CompareDistanceGreater());
+
+	// See if we are rendering water as opaque or not
+	if (!gSavedSettings.getBOOL("RenderTransparentWater"))
+	{
+		// render water for low end hardware
+		renderOpaqueLegacyWater();
+		return;
+	}
+
+	LLGLEnable blend(GL_BLEND);
+
+	if ((mVertexShaderLevel > 0) && !sSkipScreenCopy)
+	{
+		shade();
+		return;
+	}
+
+	LLVOSky *voskyp = gSky.mVOSkyp;
+
+	stop_glerror();
+
+	if (!gGLManager.mHasMultitexture)
+	{
+		// Ack!  No multitexture!  Bail!
+		return;
+	}
+
+	LLFace* refl_face = voskyp->getReflFace();
+
+	gPipeline.disableLights();
+	
+	LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE);
+
+	LLGLDisable cullFace(GL_CULL_FACE);
+	
+	// Set up second pass first
+	mWaterImagep->addTextureStats(1024.f*1024.f);
+	gGL.getTexUnit(1)->activate();
+	gGL.getTexUnit(1)->enable(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(1)->bind(mWaterImagep) ;
+
+	LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
+	F32 up_dot = camera_up * LLVector3::z_axis;
+
+	LLColor4 water_color;
+	if (LLViewerCamera::getInstance()->cameraUnderWater())
+	{
+		water_color.setVec(1.f, 1.f, 1.f, 0.4f);
+	}
+	else
+	{
+		water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
+	}
+
+	gGL.diffuseColor4fv(water_color.mV);
+
+	// Automatically generate texture coords for detail map
+	glEnable(GL_TEXTURE_GEN_S); //texture unit 1
+	glEnable(GL_TEXTURE_GEN_T); //texture unit 1
+	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+
+	// Slowly move over time.
+	F32 offset = fmod(gFrameTimeSeconds*2.f, 100.f);
+	F32 tp0[4] = {16.f/256.f, 0.0f, 0.0f, offset*0.01f};
+	F32 tp1[4] = {0.0f, 16.f/256.f, 0.0f, offset*0.01f};
+	glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
+	glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
+
+	gGL.getTexUnit(1)->setTextureColorBlend(LLTexUnit::TBO_MULT, LLTexUnit::TBS_TEX_COLOR, LLTexUnit::TBS_PREV_COLOR);
+	gGL.getTexUnit(1)->setTextureAlphaBlend(LLTexUnit::TBO_REPLACE, LLTexUnit::TBS_PREV_ALPHA);
+
+	gGL.getTexUnit(0)->activate();
+	
+	glClearStencil(1);
+	glClear(GL_STENCIL_BUFFER_BIT);
+	LLGLEnable gls_stencil(GL_STENCIL_TEST);
+	glStencilOp(GL_KEEP, GL_REPLACE, GL_KEEP);
+	glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFF);
+
+	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+		 iter != mDrawFace.end(); iter++)
+	{
+		LLFace *face = *iter;
+		if (voskyp->isReflFace(face))
+		{
+			continue;
+		}
+		gGL.getTexUnit(0)->bind(face->getTexture());
+		face->renderIndexed();
+	}
+
+	// Now, disable texture coord generation on texture state 1
+	gGL.getTexUnit(1)->activate();
+	gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(1)->disable();
+	glDisable(GL_TEXTURE_GEN_S); //texture unit 1
+	glDisable(GL_TEXTURE_GEN_T); //texture unit 1
+
+	// Disable texture coordinate and color arrays
+	gGL.getTexUnit(0)->activate();
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+
+	stop_glerror();
+	
+	if (gSky.mVOSkyp->getCubeMap())
+	{
+		gSky.mVOSkyp->getCubeMap()->enable(0);
+		gSky.mVOSkyp->getCubeMap()->bind();
+
+		gGL.matrixMode(LLRender::MM_TEXTURE);
+		gGL.loadIdentity();
+		LLMatrix4 camera_mat = LLViewerCamera::getInstance()->getModelview();
+		LLMatrix4 camera_rot(camera_mat.getMat3());
+		camera_rot.invert();
+
+		gGL.loadMatrix((F32 *)camera_rot.mMatrix);
+
+		gGL.matrixMode(LLRender::MM_MODELVIEW);
+		LLOverrideFaceColor overrid(this, 1.f, 1.f, 1.f,  0.5f*up_dot);
+
+		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+
+		for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+			 iter != mDrawFace.end(); iter++)
+		{
+			LLFace *face = *iter;
+			if (voskyp->isReflFace(face))
+			{
+				//refl_face = face;
+				continue;
+			}
+
+			if (face->getGeomCount() > 0)
+			{					
+				face->renderIndexed();
+			}
+		}
+
+		gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+
+		gSky.mVOSkyp->getCubeMap()->disable();
+		
+		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+		gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+		gGL.matrixMode(LLRender::MM_TEXTURE);
+		gGL.loadIdentity();
+		gGL.matrixMode(LLRender::MM_MODELVIEW);
+		
+	}
+
+	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
 
     if (refl_face)
-    {
-        glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF);
-        renderReflection(refl_face);
-    }
+	{
+		glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFF);
+		renderReflection(refl_face);
+	}
 
-    gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+	gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
 }
 
 // for low end hardware
 void LLDrawPoolWater::renderOpaqueLegacyWater()
 {
-    LLVOSky *voskyp = gSky.mVOSkyp;
-
-    LLGLSLShader* shader = NULL;
-    if (LLGLSLShader::sNoFixedFunction)
-    {
-        if (LLPipeline::sUnderWaterRender)
-        {
-            shader = &gObjectSimpleNonIndexedTexGenWaterProgram;
-        }
-        else
-        {
-            shader = &gObjectSimpleNonIndexedTexGenProgram;
-        }
-
-        shader->bind();
-    }
-
-    stop_glerror();
-
-    // Depth sorting and write to depth buffer
-    // since this is opaque, we should see nothing
-    // behind the water.  No blending because
-    // of no transparency.  And no face culling so
-    // that the underside of the water is also opaque.
-    LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
-    LLGLDisable no_cull(GL_CULL_FACE);
-    LLGLDisable no_blend(GL_BLEND);
-
-    gPipeline.disableLights();
-
-    mOpaqueWaterImagep->addTextureStats(1024.f*1024.f);
-
-    // Activate the texture binding and bind one
-    // texture since all images will have the same texture
-    gGL.getTexUnit(0)->activate();
-    gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
-    gGL.getTexUnit(0)->bind(mOpaqueWaterImagep);
-
-    // Automatically generate texture coords for water texture
-    if (!shader)
-    {
-        glEnable(GL_TEXTURE_GEN_S); //texture unit 0
-        glEnable(GL_TEXTURE_GEN_T); //texture unit 0
-        glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-        glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
-    }
-
-    // Use the fact that we know all water faces are the same size
-    // to save some computation
-
-    // Slowly move texture coordinates over time so the watter appears
-    // to be moving.
-    F32 movement_period_secs = 50.f;
-
-    F32 offset = fmod(gFrameTimeSeconds, movement_period_secs);
-
-    if (movement_period_secs != 0)
-    {
-        offset /= movement_period_secs;
-    }
-    else
-    {
-        offset = 0;
-    }
-
-    F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset };
-    F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset };
-
-    if (!shader)
-    {
-        glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
-        glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
-    }
-    else
-    {
-        shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0);
-        shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1);
-    }
-
-    gGL.diffuseColor3f(1.f, 1.f, 1.f);
-
-    for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-         iter != mDrawFace.end(); iter++)
-    {
-        LLFace *face = *iter;
-        if (voskyp->isReflFace(face))
-        {
-            continue;
-        }
-
-        face->renderIndexed();
-    }
-
-    stop_glerror();
-
-    if (!shader)
-    {
-        // Reset the settings back to expected values
-        glDisable(GL_TEXTURE_GEN_S); //texture unit 0
-        glDisable(GL_TEXTURE_GEN_T); //texture unit 0
-    }
-
-    gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-    gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
+	LLVOSky *voskyp = gSky.mVOSkyp;
+
+	LLGLSLShader* shader = NULL;
+	if (LLGLSLShader::sNoFixedFunction)
+	{
+		if (LLPipeline::sUnderWaterRender)
+		{
+			shader = &gObjectSimpleNonIndexedTexGenWaterProgram;
+		}
+		else
+		{
+			shader = &gObjectSimpleNonIndexedTexGenProgram;
+		}
+
+		shader->bind();
+	}
+
+	stop_glerror();
+
+	// Depth sorting and write to depth buffer
+	// since this is opaque, we should see nothing
+	// behind the water.  No blending because
+	// of no transparency.  And no face culling so
+	// that the underside of the water is also opaque.
+	LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE);
+	LLGLDisable no_cull(GL_CULL_FACE);
+	LLGLDisable no_blend(GL_BLEND);
+
+	gPipeline.disableLights();
+
+	mOpaqueWaterImagep->addTextureStats(1024.f*1024.f);
+
+	// Activate the texture binding and bind one
+	// texture since all images will have the same texture
+	gGL.getTexUnit(0)->activate();
+	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(0)->bind(mOpaqueWaterImagep);
+
+	// Automatically generate texture coords for water texture
+	if (!shader)
+	{
+		glEnable(GL_TEXTURE_GEN_S); //texture unit 0
+		glEnable(GL_TEXTURE_GEN_T); //texture unit 0
+		glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+		glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+	}
+
+	// Use the fact that we know all water faces are the same size
+	// to save some computation
+
+	// Slowly move texture coordinates over time so the watter appears
+	// to be moving.
+	F32 movement_period_secs = 50.f;
+
+	F32 offset = fmod(gFrameTimeSeconds, movement_period_secs);
+
+	if (movement_period_secs != 0)
+	{
+	 	offset /= movement_period_secs;
+	}
+	else
+	{
+		offset = 0;
+	}
+
+	F32 tp0[4] = { 16.f / 256.f, 0.0f, 0.0f, offset };
+	F32 tp1[4] = { 0.0f, 16.f / 256.f, 0.0f, offset };
+
+	if (!shader)
+	{
+		glTexGenfv(GL_S, GL_OBJECT_PLANE, tp0);
+		glTexGenfv(GL_T, GL_OBJECT_PLANE, tp1);
+	}
+	else
+	{
+		shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_S, 1, tp0);
+		shader->uniform4fv(LLShaderMgr::OBJECT_PLANE_T, 1, tp1);
+	}
+
+	gGL.diffuseColor3f(1.f, 1.f, 1.f);
+
+	for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+		 iter != mDrawFace.end(); iter++)
+	{
+		LLFace *face = *iter;
+		if (voskyp->isReflFace(face))
+		{
+			continue;
+		}
+
+		face->renderIndexed();
+	}
+
+	stop_glerror();
+
+	if (!shader)
+	{
+		// Reset the settings back to expected values
+		glDisable(GL_TEXTURE_GEN_S); //texture unit 0
+		glDisable(GL_TEXTURE_GEN_T); //texture unit 0
+	}
+
+	gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
+	gGL.getTexUnit(0)->setTextureBlendType(LLTexUnit::TB_MULT);
 }
 
 
 void LLDrawPoolWater::renderReflection(LLFace* face)
 {
-    LLVOSky *voskyp = gSky.mVOSkyp;
-
-    if (!voskyp)
-    {
-        return;
-    }
-
-    if (!face->getGeomCount())
-    {
-        return;
-    }
-    
-    S8 dr = voskyp->getDrawRefl();
-    if (dr < 0)
-    {
-        return;
-    }
-
-    LLGLSNoFog noFog;
-
-    gGL.getTexUnit(0)->bind(mHBTex[dr]);
-
-    LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV));
-    face->renderIndexed();
+	LLVOSky *voskyp = gSky.mVOSkyp;
+
+	if (!voskyp)
+	{
+		return;
+	}
+
+	if (!face->getGeomCount())
+	{
+		return;
+	}
+	
+	S8 dr = voskyp->getDrawRefl();
+	if (dr < 0)
+	{
+		return;
+	}
+
+	LLGLSNoFog noFog;
+
+	gGL.getTexUnit(0)->bind(mHBTex[dr]);
+
+	LLOverrideFaceColor override(this, LLColor4(face->getFaceColor().mV));
+	face->renderIndexed();
 }
 
 void LLDrawPoolWater::shade()
 {
-    if (!deferred_render)
-    {
-        gGL.setColorMask(true, true);
-    }
-
-    LLVOSky *voskyp = gSky.mVOSkyp;
-
-    if(voskyp == NULL) 
-    {
-        return;
-    }
-
-    LLGLDisable blend(GL_BLEND);
-
-    LLColor3 light_diffuse(0,0,0);
-    F32 light_exp = 0.0f;
-    LLVector3 light_dir;
-    LLColor3 light_color;
-
-    if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS)   
-    {    
-        light_dir  = gSky.getSunDirection();     
-        light_dir.normVec();    
-        light_color = gSky.getSunDiffuseColor();
-        if(gSky.mVOSkyp) {
-            light_diffuse = gSky.mVOSkyp->getSun().getColorCached();     
-            light_diffuse.normVec();     
-        }
-        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0);      
-        light_diffuse *= light_exp + 0.25f;      
-    }    
-    else     
-    {    
-        light_dir       = gSky.getMoonDirection();   
-        light_dir.normVec();     
-        light_color = gSky.getMoonDiffuseColor();
-        light_diffuse   = gSky.mVOSkyp->getMoon().getColorCached();      
-        light_diffuse.normVec();     
-        light_diffuse *= 0.5f;   
-        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0);      
-    }
-
-    light_exp *= light_exp;
-    light_exp *= light_exp;
-    light_exp *= light_exp;
-    light_exp *= light_exp;
-    light_exp *= 256.f;
-    light_exp = light_exp > 32.f ? light_exp : 32.f;
-
-    LLGLSLShader* shader;
-
-    F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight();
-    
-    if (eyedepth < 0.f && LLPipeline::sWaterReflections)
-    {
-    if (deferred_render)
-    {
-            shader = &gDeferredUnderWaterProgram;
-    }
-        else
-    {
-        shader = &gUnderWaterProgram;
-    }
-    }
-    else if (deferred_render)
-    {
-        shader = &gDeferredWaterProgram;
-    }
-    else
-    {
-        shader = &gWaterProgram;
-    }
-
-    if (deferred_render)
-    {
-        gPipeline.bindDeferredShader(*shader);
-    }
-    else
-    {
-        shader->bind();
-    }
-
-    sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f;
-    
-    S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
-        
-    if (reftex > -1)
-    {
-        gGL.getTexUnit(reftex)->activate();
-        gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
-        gGL.getTexUnit(0)->activate();
-    }   
-
-    //bind normal map
-    S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
-
-    LLWaterParamManager * param_mgr = &LLWaterParamManager::instance();
-
-    // change mWaterNormp if needed
-    if (mWaterNormp->getID() != param_mgr->getNormalMapID())
-    {
-        mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID());
-    }
-
-    mWaterNormp->addTextureStats(1024.f*1024.f);
-    gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ;
-    if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
-    {
-        mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
-    }
-    else 
-    {
-        mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT);
-    }
-    
-    S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);    
-        
-    if (screentex > -1)
-    {
-        shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
-        shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, 
-            param_mgr->getFogDensity());
-        gPipeline.mWaterDis.bindTexture(0, screentex);
-    }
-    
-    stop_glerror();
-    
-    gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);  
-
-    if (mVertexShaderLevel == 1)
-    {
-        sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
-        shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
-    }
-
-    F32 screenRes[] = 
-    {
-        1.f/gGLViewport[2],
-        1.f/gGLViewport[3]
-    };
-    shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
-    stop_glerror();
-    
-    S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
-    stop_glerror();
-    
-    light_dir.normVec();
-    sLightDir = light_dir;
-    
-    light_diffuse *= 6.f;
-
-    //shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);
-    shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);
-    shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);
-    shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
-    shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
-    shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
-    shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
-    shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
-    shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
-
-    shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV);
-    shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale());
-    shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset());
-    shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier());
-
-    F32 sunAngle = llmax(0.f, light_dir.mV[2]);
-    F32 scaledAngle = 1.f - sunAngle;
-
-    shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
-    shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
-    shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle);
-
-    LLColor4 water_color;
-    LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
-    F32 up_dot = camera_up * LLVector3::z_axis;
-    if (LLViewerCamera::getInstance()->cameraUnderWater())
-    {
-        water_color.setVec(1.f, 1.f, 1.f, 0.4f);
-        shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
-    }
-    else
-    {
-        water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
-        shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
-    }
-
-    if (water_color.mV[3] > 0.9f)
-    {
-        water_color.mV[3] = 0.9f;
-    }
-
-    {
-        LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0);
-        LLGLDisable cullface(GL_CULL_FACE);
-        for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
-            iter != mDrawFace.end(); iter++)
-        {
-            LLFace *face = *iter;
-
-            if (voskyp->isReflFace(face))
-            {
-                continue;
-            }
-
-            LLVOWater* water = (LLVOWater*) face->getViewerObject();
-            gGL.getTexUnit(diffTex)->bind(face->getTexture());
-
-            sNeedsReflectionUpdate = TRUE;
-            
-            if (water->getUseTexture() || !water->getIsEdgePatch())
-            {
-                sNeedsDistortionUpdate = TRUE;
-                face->renderIndexed();
-            }
-            else if (gGLManager.mHasDepthClamp || deferred_render)
-            {
-                face->renderIndexed();
-            }
-            else
-            {
-                LLGLSquashToFarClip far_clip(glh_get_current_projection());
-                face->renderIndexed();
-            }
-        }
-    }
-    
-    shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
-    shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);   
-    shader->disableTexture(LLShaderMgr::BUMP_MAP);
-    shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
-    shader->disableTexture(LLShaderMgr::WATER_REFTEX);
-    shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
-
-    if (deferred_render)
-    {
-        gPipeline.unbindDeferredShader(*shader);
-    }
-    else
-    {
-        shader->unbind();
-    }
-
-    gGL.getTexUnit(0)->activate();
-    gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
-    if (!deferred_render)
-    {
-        gGL.setColorMask(true, false);
-    }
+	if (!deferred_render)
+	{
+		gGL.setColorMask(true, true);
+	}
+
+	LLVOSky *voskyp = gSky.mVOSkyp;
+
+	if(voskyp == NULL) 
+	{
+		return;
+	}
+
+	LLGLDisable blend(GL_BLEND);
+
+	LLColor3 light_diffuse(0,0,0);
+	F32 light_exp = 0.0f;
+	LLVector3 light_dir;
+	LLColor3 light_color;
+
+	if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) 	 
+    { 	 
+        light_dir  = gSky.getSunDirection(); 	 
+        light_dir.normVec(); 	
+		light_color = gSky.getSunDiffuseColor();
+		if(gSky.mVOSkyp) {
+	        light_diffuse = gSky.mVOSkyp->getSun().getColorCached(); 	 
+			light_diffuse.normVec(); 	 
+		}
+        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	 
+        light_diffuse *= light_exp + 0.25f; 	 
+    } 	 
+    else  	 
+    { 	 
+        light_dir       = gSky.getMoonDirection(); 	 
+        light_dir.normVec(); 	 
+		light_color = gSky.getMoonDiffuseColor();
+        light_diffuse   = gSky.mVOSkyp->getMoon().getColorCached(); 	 
+        light_diffuse.normVec(); 	 
+        light_diffuse *= 0.5f; 	 
+        light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0); 	 
+    }
+
+	light_exp *= light_exp;
+	light_exp *= light_exp;
+	light_exp *= light_exp;
+	light_exp *= light_exp;
+	light_exp *= 256.f;
+	light_exp = light_exp > 32.f ? light_exp : 32.f;
+
+	LLGLSLShader* shader;
+
+	F32 eyedepth = LLViewerCamera::getInstance()->getOrigin().mV[2] - gAgent.getRegion()->getWaterHeight();
+	
+	if (eyedepth < 0.f && LLPipeline::sWaterReflections)
+	{
+	if (deferred_render)
+	{
+			shader = &gDeferredUnderWaterProgram;
+	}
+		else
+	{
+		shader = &gUnderWaterProgram;
+	}
+	}
+	else if (deferred_render)
+	{
+		shader = &gDeferredWaterProgram;
+	}
+	else
+	{
+		shader = &gWaterProgram;
+	}
+
+	if (deferred_render)
+	{
+		gPipeline.bindDeferredShader(*shader);
+	}
+	else
+	{
+		shader->bind();
+	}
+
+	sTime = (F32)LLFrameTimer::getElapsedSeconds()*0.5f;
+	
+	S32 reftex = shader->enableTexture(LLShaderMgr::WATER_REFTEX);
+		
+	if (reftex > -1)
+	{
+		gGL.getTexUnit(reftex)->activate();
+		gGL.getTexUnit(reftex)->bind(&gPipeline.mWaterRef);
+		gGL.getTexUnit(0)->activate();
+	}	
+
+	//bind normal map
+	S32 bumpTex = shader->enableTexture(LLViewerShaderMgr::BUMP_MAP);
+
+	LLWaterParamManager * param_mgr = &LLWaterParamManager::instance();
+
+	// change mWaterNormp if needed
+	if (mWaterNormp->getID() != param_mgr->getNormalMapID())
+	{
+		mWaterNormp = LLViewerTextureManager::getFetchedTexture(param_mgr->getNormalMapID());
+	}
+
+	mWaterNormp->addTextureStats(1024.f*1024.f);
+	gGL.getTexUnit(bumpTex)->bind(mWaterNormp) ;
+	if (gSavedSettings.getBOOL("RenderWaterMipNormal"))
+	{
+		mWaterNormp->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC);
+	}
+	else 
+	{
+		mWaterNormp->setFilteringOption(LLTexUnit::TFO_POINT);
+	}
+	
+	S32 screentex = shader->enableTexture(LLShaderMgr::WATER_SCREENTEX);	
+		
+	if (screentex > -1)
+	{
+		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
+		shader->uniform1f(LLShaderMgr::WATER_FOGDENSITY, 
+			param_mgr->getFogDensity());
+		gPipeline.mWaterDis.bindTexture(0, screentex);
+	}
+	
+	stop_glerror();
+	
+	gGL.getTexUnit(screentex)->bind(&gPipeline.mWaterDis);	
+
+	if (mVertexShaderLevel == 1)
+	{
+		sWaterFogColor.mV[3] = param_mgr->mDensitySliderValue;
+		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, sWaterFogColor.mV);
+	}
+
+	F32 screenRes[] = 
+	{
+		1.f/gGLViewport[2],
+		1.f/gGLViewport[3]
+	};
+	shader->uniform2fv(LLShaderMgr::DEFERRED_SCREEN_RES, 1, screenRes);
+	stop_glerror();
+	
+	S32 diffTex = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP);
+	stop_glerror();
+	
+	light_dir.normVec();
+	sLightDir = light_dir;
+	
+	light_diffuse *= 6.f;
+
+	//shader->uniformMatrix4fv("inverse_ref", 1, GL_FALSE, (GLfloat*) gGLObliqueProjectionInverse.mMatrix);
+	shader->uniform1f(LLShaderMgr::WATER_WATERHEIGHT, eyedepth);
+	shader->uniform1f(LLShaderMgr::WATER_TIME, sTime);
+	shader->uniform3fv(LLShaderMgr::WATER_EYEVEC, 1, LLViewerCamera::getInstance()->getOrigin().mV);
+	shader->uniform3fv(LLShaderMgr::WATER_SPECULAR, 1, light_diffuse.mV);
+	shader->uniform1f(LLShaderMgr::WATER_SPECULAR_EXP, light_exp);
+	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR1, 1, param_mgr->getWave1Dir().mV);
+	shader->uniform2fv(LLShaderMgr::WATER_WAVE_DIR2, 1, param_mgr->getWave2Dir().mV);
+	shader->uniform3fv(LLShaderMgr::WATER_LIGHT_DIR, 1, light_dir.mV);
+
+	shader->uniform3fv(LLShaderMgr::WATER_NORM_SCALE, 1, param_mgr->getNormalScale().mV);
+	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_SCALE, param_mgr->getFresnelScale());
+	shader->uniform1f(LLShaderMgr::WATER_FRESNEL_OFFSET, param_mgr->getFresnelOffset());
+	shader->uniform1f(LLShaderMgr::WATER_BLUR_MULTIPLIER, param_mgr->getBlurMultiplier());
+
+	F32 sunAngle = llmax(0.f, light_dir.mV[2]);
+	F32 scaledAngle = 1.f - sunAngle;
+
+	shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE, sunAngle);
+	shader->uniform1f(LLShaderMgr::WATER_SCALED_ANGLE, scaledAngle);
+	shader->uniform1f(LLShaderMgr::WATER_SUN_ANGLE2, 0.1f + 0.2f*sunAngle);
+
+	LLColor4 water_color;
+	LLVector3 camera_up = LLViewerCamera::getInstance()->getUpAxis();
+	F32 up_dot = camera_up * LLVector3::z_axis;
+	if (LLViewerCamera::getInstance()->cameraUnderWater())
+	{
+		water_color.setVec(1.f, 1.f, 1.f, 0.4f);
+		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleBelow());
+	}
+	else
+	{
+		water_color.setVec(1.f, 1.f, 1.f, 0.5f*(1.f + up_dot));
+		shader->uniform1f(LLShaderMgr::WATER_REFSCALE, param_mgr->getScaleAbove());
+	}
+
+	if (water_color.mV[3] > 0.9f)
+	{
+		water_color.mV[3] = 0.9f;
+	}
+
+	{
+		LLGLEnable depth_clamp(gGLManager.mHasDepthClamp ? GL_DEPTH_CLAMP : 0);
+		LLGLDisable cullface(GL_CULL_FACE);
+		for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
+			iter != mDrawFace.end(); iter++)
+		{
+			LLFace *face = *iter;
+
+			if (voskyp->isReflFace(face))
+			{
+				continue;
+			}
+
+			LLVOWater* water = (LLVOWater*) face->getViewerObject();
+			gGL.getTexUnit(diffTex)->bind(face->getTexture());
+
+			sNeedsReflectionUpdate = TRUE;
+			
+			if (water->getUseTexture() || !water->getIsEdgePatch())
+			{
+				sNeedsDistortionUpdate = TRUE;
+				face->renderIndexed();
+			}
+			else if (gGLManager.mHasDepthClamp || deferred_render)
+			{
+				face->renderIndexed();
+			}
+			else
+			{
+				LLGLSquashToFarClip far_clip(glh_get_current_projection());
+				face->renderIndexed();
+			}
+		}
+	}
+	
+	shader->disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP);
+	shader->disableTexture(LLShaderMgr::WATER_SCREENTEX);	
+	shader->disableTexture(LLShaderMgr::BUMP_MAP);
+	shader->disableTexture(LLShaderMgr::DIFFUSE_MAP);
+	shader->disableTexture(LLShaderMgr::WATER_REFTEX);
+	shader->disableTexture(LLShaderMgr::WATER_SCREENDEPTH);
+
+	if (deferred_render)
+	{
+		gPipeline.unbindDeferredShader(*shader);
+	}
+	else
+	{
+		shader->unbind();
+	}
+
+	gGL.getTexUnit(0)->activate();
+	gGL.getTexUnit(0)->enable(LLTexUnit::TT_TEXTURE);
+	if (!deferred_render)
+	{
+		gGL.setColorMask(true, false);
+	}
 
 }
 
 LLViewerTexture *LLDrawPoolWater::getDebugTexture()
 {
-    return LLViewerFetchedTexture::sSmokeImagep;
+	return LLViewerFetchedTexture::sSmokeImagep;
 }
 
 LLColor3 LLDrawPoolWater::getDebugColor() const
 {
-    return LLColor3(0.f, 1.f, 1.f);
+	return LLColor3(0.f, 1.f, 1.f);
 }
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 2582715dd9..c12ccb386e 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -46,7 +46,7 @@
 
 static LLDefaultChildRegistry::Register<LLPanelCameraItem> r("panel_camera_item");
 
-const F32 NUDGE_TIME = 0.25f;       // in seconds
+const F32 NUDGE_TIME = 0.25f;		// in seconds
 const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed
 
 // constants
@@ -61,94 +61,94 @@ bool LLFloaterCamera::sAppearanceEditing = false;
 
 // Zoom the camera in and out
 class LLPanelCameraZoom
-:   public LLPanel
+:	public LLPanel
 {
-    LOG_CLASS(LLPanelCameraZoom);
+	LOG_CLASS(LLPanelCameraZoom);
 public:
-    LLPanelCameraZoom();
+	LLPanelCameraZoom();
 
-    /* virtual */ BOOL  postBuild();
-    /* virtual */ void  draw();
+	/* virtual */ BOOL	postBuild();
+	/* virtual */ void	draw();
 
 protected:
-    void    onZoomPlusHeldDown();
-    void    onZoomMinusHeldDown();
-    void    onSliderValueChanged();
-    void    onCameraTrack();
-    void    onCameraRotate();
-    F32     getOrbitRate(F32 time);
+	void	onZoomPlusHeldDown();
+	void	onZoomMinusHeldDown();
+	void	onSliderValueChanged();
+	void	onCameraTrack();
+	void	onCameraRotate();
+	F32		getOrbitRate(F32 time);
 
 private:
-    LLButton*   mPlusBtn;
-    LLButton*   mMinusBtn;
-    LLSlider*   mSlider;
+	LLButton*	mPlusBtn;
+	LLButton*	mMinusBtn;
+	LLSlider*	mSlider;
 };
 
 LLPanelCameraItem::Params::Params()
-:   icon_over("icon_over"),
-    icon_selected("icon_selected"),
-    picture("picture"),
-    text("text"),
-    selected_picture("selected_picture"),
-    mousedown_callback("mousedown_callback")
+:	icon_over("icon_over"),
+	icon_selected("icon_selected"),
+	picture("picture"),
+	text("text"),
+	selected_picture("selected_picture"),
+	mousedown_callback("mousedown_callback")
 {
 }
 
 LLPanelCameraItem::LLPanelCameraItem(const LLPanelCameraItem::Params& p)
-:   LLPanel(p)
+:	LLPanel(p)
 {
-    LLIconCtrl::Params icon_params = p.picture;
-    mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-    addChild(mPicture);
+	LLIconCtrl::Params icon_params = p.picture;
+	mPicture = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+	addChild(mPicture);
 
-    icon_params = p.icon_over;
-    mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-    addChild(mIconOver);
+	icon_params = p.icon_over;
+	mIconOver = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+	addChild(mIconOver);
 
-    icon_params = p.icon_selected;
-    mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-    addChild(mIconSelected);
+	icon_params = p.icon_selected;
+	mIconSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+	addChild(mIconSelected);
 
-    icon_params = p.selected_picture;
-    mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
-    addChild(mPictureSelected);
+	icon_params = p.selected_picture;
+	mPictureSelected = LLUICtrlFactory::create<LLIconCtrl>(icon_params);
+	addChild(mPictureSelected);
 
-    LLTextBox::Params text_params = p.text;
-    mText = LLUICtrlFactory::create<LLTextBox>(text_params);
-    addChild(mText);
+	LLTextBox::Params text_params = p.text;
+	mText = LLUICtrlFactory::create<LLTextBox>(text_params);
+	addChild(mText);
 
-    if (p.mousedown_callback.isProvided())
-    {
-        setCommitCallback(initCommitCallback(p.mousedown_callback));
-    }
+	if (p.mousedown_callback.isProvided())
+	{
+		setCommitCallback(initCommitCallback(p.mousedown_callback));
+	}
 }
 
 void set_view_visible(LLView* parent, const std::string& name, bool visible)
 {
-    parent->getChildView(name)->setVisible(visible);
+	parent->getChildView(name)->setVisible(visible);
 }
 
 BOOL LLPanelCameraItem::postBuild()
 {
-    setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true));
-    setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false));
-    setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
-    setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
-    return TRUE;
+	setMouseEnterCallback(boost::bind(set_view_visible, this, "hovered_icon", true));
+	setMouseLeaveCallback(boost::bind(set_view_visible, this, "hovered_icon", false));
+	setMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
+	setRightMouseDownCallback(boost::bind(&LLPanelCameraItem::onAnyMouseClick, this));
+	return TRUE;
 }
 
 void LLPanelCameraItem::onAnyMouseClick()
 {
-    if (mCommitSignal) (*mCommitSignal)(this, LLSD());
+	if (mCommitSignal) (*mCommitSignal)(this, LLSD());
 }
 
 void LLPanelCameraItem::setValue(const LLSD& value)
 {
-    if (!value.isMap()) return;;
-    if (!value.has("selected")) return;
-    getChildView("selected_icon")->setVisible( value["selected"]);
-    getChildView("picture")->setVisible( !value["selected"]);
-    getChildView("selected_picture")->setVisible( value["selected"]);
+	if (!value.isMap()) return;;
+	if (!value.has("selected")) return;
+	getChildView("selected_icon")->setVisible( value["selected"]);
+	getChildView("picture")->setVisible( !value["selected"]);
+	getChildView("selected_picture")->setVisible( value["selected"]);
 }
 
 static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel");
@@ -158,85 +158,85 @@ static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel
 //-------------------------------------------------------------------------------
 
 LLPanelCameraZoom::LLPanelCameraZoom()
-:   mPlusBtn( NULL ),
-    mMinusBtn( NULL ),
-    mSlider( NULL )
+:	mPlusBtn( NULL ),
+	mMinusBtn( NULL ),
+	mSlider( NULL )
 {
-    mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this));
-    mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this));
-    mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this));
-    mCommitCallbackRegistrar.add("Camera.track", boost::bind(&LLPanelCameraZoom::onCameraTrack, this));
-    mCommitCallbackRegistrar.add("Camera.rotate", boost::bind(&LLPanelCameraZoom::onCameraRotate, this));
+	mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this));
+	mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this));
+	mCommitCallbackRegistrar.add("Slider.value_changed", boost::bind(&LLPanelCameraZoom::onSliderValueChanged, this));
+	mCommitCallbackRegistrar.add("Camera.track", boost::bind(&LLPanelCameraZoom::onCameraTrack, this));
+	mCommitCallbackRegistrar.add("Camera.rotate", boost::bind(&LLPanelCameraZoom::onCameraRotate, this));
 }
 
 BOOL LLPanelCameraZoom::postBuild()
 {
-    mPlusBtn  = getChild <LLButton> ("zoom_plus_btn");
-    mMinusBtn = getChild <LLButton> ("zoom_minus_btn");
-    mSlider   = getChild <LLSlider> ("zoom_slider");
-    return LLPanel::postBuild();
+	mPlusBtn  = getChild <LLButton> ("zoom_plus_btn");
+	mMinusBtn = getChild <LLButton> ("zoom_minus_btn");
+	mSlider   = getChild <LLSlider> ("zoom_slider");
+	return LLPanel::postBuild();
 }
 
 void LLPanelCameraZoom::draw()
 {
-    mSlider->setValue(gAgentCamera.getCameraZoomFraction());
-    LLPanel::draw();
+	mSlider->setValue(gAgentCamera.getCameraZoomFraction());
+	LLPanel::draw();
 }
 
 void LLPanelCameraZoom::onZoomPlusHeldDown()
 {
-    F32 val = mSlider->getValueF32();
-    F32 inc = mSlider->getIncrement();
-    mSlider->setValue(val - inc);
-    F32 time = mPlusBtn->getHeldDownTime();
-    gAgentCamera.unlockView();
-    gAgentCamera.setOrbitInKey(getOrbitRate(time));
+	F32 val = mSlider->getValueF32();
+	F32 inc = mSlider->getIncrement();
+	mSlider->setValue(val - inc);
+	F32 time = mPlusBtn->getHeldDownTime();
+	gAgentCamera.unlockView();
+	gAgentCamera.setOrbitInKey(getOrbitRate(time));
 }
 
 void LLPanelCameraZoom::onZoomMinusHeldDown()
 {
-    F32 val = mSlider->getValueF32();
-    F32 inc = mSlider->getIncrement();
-    mSlider->setValue(val + inc);
-    F32 time = mMinusBtn->getHeldDownTime();
-    gAgentCamera.unlockView();
-    gAgentCamera.setOrbitOutKey(getOrbitRate(time));
+	F32 val = mSlider->getValueF32();
+	F32 inc = mSlider->getIncrement();
+	mSlider->setValue(val + inc);
+	F32 time = mMinusBtn->getHeldDownTime();
+	gAgentCamera.unlockView();
+	gAgentCamera.setOrbitOutKey(getOrbitRate(time));
 }
 
 void LLPanelCameraZoom::onCameraTrack()
 {
-    // EXP-202 when camera panning activated, remove the hint
-    LLFirstUse::viewPopup( false );
+	// EXP-202 when camera panning activated, remove the hint
+	LLFirstUse::viewPopup( false );
 }
 
 void LLPanelCameraZoom::onCameraRotate()
 {
-    // EXP-202 when camera rotation activated, remove the hint
-    LLFirstUse::viewPopup( false );
+	// EXP-202 when camera rotation activated, remove the hint
+	LLFirstUse::viewPopup( false );
 }
 
 F32 LLPanelCameraZoom::getOrbitRate(F32 time)
 {
-    if( time < NUDGE_TIME )
-    {
-        F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME;
-        return rate;
-    }
-    else
-    {
-        return 1;
-    }
+	if( time < NUDGE_TIME )
+	{
+		F32 rate = ORBIT_NUDGE_RATE + time * (1 - ORBIT_NUDGE_RATE)/ NUDGE_TIME;
+		return rate;
+	}
+	else
+	{
+		return 1;
+	}
 }
 
 void  LLPanelCameraZoom::onSliderValueChanged()
 {
-    F32 zoom_level = mSlider->getValueF32();
-    gAgentCamera.setCameraZoomFraction(zoom_level);
+	F32 zoom_level = mSlider->getValueF32();
+	gAgentCamera.setCameraZoomFraction(zoom_level);
 }
 
 void activate_camera_tool()
 {
-    LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
+	LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
 };
 
 //
@@ -245,375 +245,375 @@ void activate_camera_tool()
 
 /*static*/ bool LLFloaterCamera::inFreeCameraMode()
 {
-    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-    if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
-    {
-        return true;
-    }
-    return false;
+	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+	if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
+	{
+		return true;
+	}
+	return false;
 }
 
 void LLFloaterCamera::resetCameraMode()
 {
-    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-    if (!floater_camera) return;
-    floater_camera->switchMode(CAMERA_CTRL_MODE_PAN);
+	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+	if (!floater_camera) return;
+	floater_camera->switchMode(CAMERA_CTRL_MODE_PAN);
 }
 
 void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
 {
-    sAppearanceEditing = editing;
-    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-    if (!floater_camera) return;
-    floater_camera->handleAvatarEditingAppearance(editing);
+	sAppearanceEditing = editing;
+	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+	if (!floater_camera) return;
+	floater_camera->handleAvatarEditingAppearance(editing);
 }
 
 void LLFloaterCamera::handleAvatarEditingAppearance(bool editing)
 {
-    //camera presets (rear, front, etc.)
-    getChildView("preset_views_list")->setEnabled(!editing);
-    getChildView("presets_btn")->setEnabled(!editing);
+	//camera presets (rear, front, etc.)
+	getChildView("preset_views_list")->setEnabled(!editing);
+	getChildView("presets_btn")->setEnabled(!editing);
 
-    //camera modes (object view, mouselook view)
-    getChildView("camera_modes_list")->setEnabled(!editing);
-    getChildView("avatarview_btn")->setEnabled(!editing);
+	//camera modes (object view, mouselook view)
+	getChildView("camera_modes_list")->setEnabled(!editing);
+	getChildView("avatarview_btn")->setEnabled(!editing);
 }
 
 void LLFloaterCamera::update()
 {
-    ECameraControlMode mode = determineMode();
-    if (mode != mCurrMode) setMode(mode);
+	ECameraControlMode mode = determineMode();
+	if (mode != mCurrMode) setMode(mode);
 }
 
 
 void LLFloaterCamera::toPrevMode()
 {
-    switchMode(mPrevMode);
+	switchMode(mPrevMode);
 }
 
 /*static*/ void LLFloaterCamera::onLeavingMouseLook()
 {
-    LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
-    if (floater_camera)
-    {
-        floater_camera->updateItemsSelection();
-        if(floater_camera->inFreeCameraMode())
-        {
-            activate_camera_tool();
-        }
-    }
+	LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
+	if (floater_camera)
+	{
+		floater_camera->updateItemsSelection();
+		if(floater_camera->inFreeCameraMode())
+		{
+			activate_camera_tool();
+		}
+	}
 }
 
 LLFloaterCamera* LLFloaterCamera::findInstance()
 {
-    return LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
+	return LLFloaterReg::findTypedInstance<LLFloaterCamera>("camera");
 }
 
 void LLFloaterCamera::onOpen(const LLSD& key)
 {
-    LLFirstUse::viewPopup();
+	LLFirstUse::viewPopup();
 
-    mZoom->onOpen(key);
+	mZoom->onOpen(key);
 
-    // Returns to previous mode, see EXT-2727(View tool should remember state).
-    // In case floater was just hidden and it isn't reset the mode
-    // just update state to current one. Else go to previous.
-    if ( !mClosed )
-        updateState();
-    else
-        toPrevMode();
-    mClosed = FALSE;
+	// Returns to previous mode, see EXT-2727(View tool should remember state).
+	// In case floater was just hidden and it isn't reset the mode
+	// just update state to current one. Else go to previous.
+	if ( !mClosed )
+		updateState();
+	else
+		toPrevMode();
+	mClosed = FALSE;
 }
 
 void LLFloaterCamera::onClose(bool app_quitting)
 {
-    //We don't care of camera mode if app is quitting
-    if(app_quitting)
-        return;
-    // It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so 
-    // to avoid seeing an empty floater when reopening the control.
-    if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA)
-        mCurrMode = CAMERA_CTRL_MODE_PAN;
-    // When mCurrMode is in CAMERA_CTRL_MODE_PAN
-    // switchMode won't modify mPrevMode, so force it here.
-    // It is needed to correctly return to previous mode on open, see EXT-2727.
-    if (mCurrMode == CAMERA_CTRL_MODE_PAN)
-        mPrevMode = CAMERA_CTRL_MODE_PAN;
+	//We don't care of camera mode if app is quitting
+	if(app_quitting)
+		return;
+	// It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so 
+	// to avoid seeing an empty floater when reopening the control.
+	if (mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA)
+		mCurrMode = CAMERA_CTRL_MODE_PAN;
+	// When mCurrMode is in CAMERA_CTRL_MODE_PAN
+	// switchMode won't modify mPrevMode, so force it here.
+	// It is needed to correctly return to previous mode on open, see EXT-2727.
+	if (mCurrMode == CAMERA_CTRL_MODE_PAN)
+		mPrevMode = CAMERA_CTRL_MODE_PAN;
 
-    switchMode(CAMERA_CTRL_MODE_PAN);
-    mClosed = TRUE;
+	switchMode(CAMERA_CTRL_MODE_PAN);
+	mClosed = TRUE;
 
-    gAgent.setMovementLocked(FALSE);
+	gAgent.setMovementLocked(FALSE);
 }
 
 LLFloaterCamera::LLFloaterCamera(const LLSD& val)
-:   LLFloater(val),
-    mClosed(FALSE),
-    mCurrMode(CAMERA_CTRL_MODE_PAN),
-    mPrevMode(CAMERA_CTRL_MODE_PAN)
+:	LLFloater(val),
+	mClosed(FALSE),
+	mCurrMode(CAMERA_CTRL_MODE_PAN),
+	mPrevMode(CAMERA_CTRL_MODE_PAN)
 {
-    LLHints::registerHintTarget("view_popup", getHandle());
-    mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
-    mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2));
+	LLHints::registerHintTarget("view_popup", getHandle());
+	mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
+	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2));
 }
 
 // virtual
 BOOL LLFloaterCamera::postBuild()
 {
-    updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730)
+	updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730)
 
-    mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
-    mZoom = findChild<LLPanelCameraZoom>(ZOOM);
-    mTrack = getChild<LLJoystickCameraTrack>(PAN);
+	mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
+	mZoom = findChild<LLPanelCameraZoom>(ZOOM);
+	mTrack = getChild<LLJoystickCameraTrack>(PAN);
 
-    assignButton2Mode(CAMERA_CTRL_MODE_MODES,           "avatarview_btn");
-    assignButton2Mode(CAMERA_CTRL_MODE_PAN,             "pan_btn");
-    assignButton2Mode(CAMERA_CTRL_MODE_PRESETS,     "presets_btn");
+	assignButton2Mode(CAMERA_CTRL_MODE_MODES,			"avatarview_btn");
+	assignButton2Mode(CAMERA_CTRL_MODE_PAN,				"pan_btn");
+	assignButton2Mode(CAMERA_CTRL_MODE_PRESETS,		"presets_btn");
 
-    update();
+	update();
 
-    // ensure that appearance mode is handled while building. See EXT-7796.
-    handleAvatarEditingAppearance(sAppearanceEditing);
+	// ensure that appearance mode is handled while building. See EXT-7796.
+	handleAvatarEditingAppearance(sAppearanceEditing);
 
-    return LLFloater::postBuild();
+	return LLFloater::postBuild();
 }
 
-F32 LLFloaterCamera::getCurrentTransparency()
+F32	LLFloaterCamera::getCurrentTransparency()
 {
 
-    static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity");
-    static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency");
-    return llmin(camera_opacity(), active_floater_transparency());
+	static LLCachedControl<F32> camera_opacity(gSavedSettings, "CameraOpacity");
+	static LLCachedControl<F32> active_floater_transparency(gSavedSettings, "ActiveFloaterTransparency");
+	return llmin(camera_opacity(), active_floater_transparency());
 
 }
 
 void LLFloaterCamera::onViewButtonClick(const LLSD& user_data)
 {
-    // bring up the prefs floater
-    LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
-    if (prefsfloater)
-    {
-        // grab the 'view' panel from the preferences floater and
-        // bring it the front!
-        LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-        LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
-        if (tabcontainer && graphicspanel)
-        {
-            tabcontainer->selectTabPanel(graphicspanel);
-        }
-    }
+	// bring up the prefs floater
+	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
+	if (prefsfloater)
+	{
+		// grab the 'view' panel from the preferences floater and
+		// bring it the front!
+		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
+		if (tabcontainer && graphicspanel)
+		{
+			tabcontainer->selectTabPanel(graphicspanel);
+		}
+	}
 }
 
 
 void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel)
 {
-    // copying child list and then iterating over a copy, because list itself
-    // is changed in process
-    const child_list_t child_list = *panel->getChildList();
-    child_list_t::const_reverse_iterator iter = child_list.rbegin();
-    child_list_t::const_reverse_iterator end = child_list.rend();
-    for ( ; iter != end; ++iter)
-    {
-        LLView* view = *iter;
-        LLPanel* item = dynamic_cast<LLPanel*>(view);
-        if (panel)
-            list->addItem(item);
-    }
+	// copying child list and then iterating over a copy, because list itself
+	// is changed in process
+	const child_list_t child_list = *panel->getChildList();
+	child_list_t::const_reverse_iterator iter = child_list.rbegin();
+	child_list_t::const_reverse_iterator end = child_list.rend();
+	for ( ; iter != end; ++iter)
+	{
+		LLView* view = *iter;
+		LLPanel* item = dynamic_cast<LLPanel*>(view);
+		if (panel)
+			list->addItem(item);
+	}
 
 }
 
 ECameraControlMode LLFloaterCamera::determineMode()
 {
-    if (sAppearanceEditing)
-    {
-        // this is the only enabled camera mode while editing agent appearance.
-        return CAMERA_CTRL_MODE_PAN;
-    }
+	if (sAppearanceEditing)
+	{
+		// this is the only enabled camera mode while editing agent appearance.
+		return CAMERA_CTRL_MODE_PAN;
+	}
 
-    LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool();
-    if (curr_tool == LLToolCamera::getInstance())
-    {
-        return CAMERA_CTRL_MODE_FREE_CAMERA;
-    } 
+	LLTool* curr_tool = LLToolMgr::getInstance()->getCurrentTool();
+	if (curr_tool == LLToolCamera::getInstance())
+	{
+		return CAMERA_CTRL_MODE_FREE_CAMERA;
+	} 
 
-    if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
-    {
-        return CAMERA_CTRL_MODE_PRESETS;
-    }
+	if (gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK)
+	{
+		return CAMERA_CTRL_MODE_PRESETS;
+	}
 
-    return CAMERA_CTRL_MODE_PAN;
+	return CAMERA_CTRL_MODE_PAN;
 }
 
 
 void clear_camera_tool()
 {
-    LLToolMgr* tool_mgr = LLToolMgr::getInstance();
-    if (tool_mgr->usingTransientTool() && 
-        tool_mgr->getCurrentTool() == LLToolCamera::getInstance())
-    {
-        tool_mgr->clearTransientTool();
-    }
+	LLToolMgr* tool_mgr = LLToolMgr::getInstance();
+	if (tool_mgr->usingTransientTool() && 
+		tool_mgr->getCurrentTool() == LLToolCamera::getInstance())
+	{
+		tool_mgr->clearTransientTool();
+	}
 }
 
 
 void LLFloaterCamera::setMode(ECameraControlMode mode)
 {
-    if (mode != mCurrMode)
-    {
-        mPrevMode = mCurrMode;
-        mCurrMode = mode;
-    }
-    
-    updateState();
+	if (mode != mCurrMode)
+	{
+		mPrevMode = mCurrMode;
+		mCurrMode = mode;
+	}
+	
+	updateState();
 }
 
 void LLFloaterCamera::switchMode(ECameraControlMode mode)
 {
-    setMode(mode);
+	setMode(mode);
 
-    switch (mode)
-    {
-    case CAMERA_CTRL_MODE_MODES:
-        if(sFreeCamera)
-        {
-            switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-        }
-        break;
+	switch (mode)
+	{
+	case CAMERA_CTRL_MODE_MODES:
+		if(sFreeCamera)
+		{
+			switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+		}
+		break;
 
-    case CAMERA_CTRL_MODE_PAN:
-        sFreeCamera = false;
-        clear_camera_tool();
-        break;
+	case CAMERA_CTRL_MODE_PAN:
+		sFreeCamera = false;
+		clear_camera_tool();
+		break;
 
-    case CAMERA_CTRL_MODE_FREE_CAMERA:
-        sFreeCamera = true;
-        activate_camera_tool();
-        break;
+	case CAMERA_CTRL_MODE_FREE_CAMERA:
+		sFreeCamera = true;
+		activate_camera_tool();
+		break;
 
-    case CAMERA_CTRL_MODE_PRESETS:
-        if(sFreeCamera)
-        {
-            switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-        }
-        break;
+	case CAMERA_CTRL_MODE_PRESETS:
+		if(sFreeCamera)
+		{
+			switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+		}
+		break;
 
-    default:
-        //normally we won't occur here
-        llassert_always(FALSE);
-    }
+	default:
+		//normally we won't occur here
+		llassert_always(FALSE);
+	}
 }
 
 
 void LLFloaterCamera::onClickBtn(ECameraControlMode mode)
 {
-    // check for a click on active button
-    if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE);
-    
-    switchMode(mode);
+	// check for a click on active button
+	if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE);
+	
+	switchMode(mode);
 
 }
 
 void LLFloaterCamera::assignButton2Mode(ECameraControlMode mode, const std::string& button_name)
 {
-    LLButton* button = getChild<LLButton>(button_name);
-    
-    button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode));
-    mMode2Button[mode] = button;
+	LLButton* button = getChild<LLButton>(button_name);
+	
+	button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode));
+	mMode2Button[mode] = button;
 }
 
 void LLFloaterCamera::updateState()
 {
-    getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode);
-    
-    bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
-                                                                    && CAMERA_CTRL_MODE_PRESETS == mPrevMode);
-    getChildView(PRESETS)->setVisible(show_presets);
-    
-    bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
-                                                                    && CAMERA_CTRL_MODE_MODES == mPrevMode);
-    getChildView("camera_modes_list")->setVisible( show_camera_modes);
+	getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode);
+	
+	bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
+																	&& CAMERA_CTRL_MODE_PRESETS == mPrevMode);
+	getChildView(PRESETS)->setVisible(show_presets);
+	
+	bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
+																	&& CAMERA_CTRL_MODE_MODES == mPrevMode);
+	getChildView("camera_modes_list")->setVisible( show_camera_modes);
 
-    updateItemsSelection();
+	updateItemsSelection();
 
-    if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode)
-    {
-        return;
-    }
+	if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode)
+	{
+		return;
+	}
 
-    //updating buttons
-    std::map<ECameraControlMode, LLButton*>::const_iterator iter = mMode2Button.begin();
-    for (; iter != mMode2Button.end(); ++iter)
-    {
-        iter->second->setToggleState(iter->first == mCurrMode);
-    }
+	//updating buttons
+	std::map<ECameraControlMode, LLButton*>::const_iterator iter = mMode2Button.begin();
+	for (; iter != mMode2Button.end(); ++iter)
+	{
+		iter->second->setToggleState(iter->first == mCurrMode);
+	}
 }
 
 void LLFloaterCamera::updateItemsSelection()
 {
-    ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
-    LLSD argument;
-    argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW;
-    getChild<LLPanelCameraItem>("rear_view")->setValue(argument);
-    argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW;
-    getChild<LLPanelCameraItem>("group_view")->setValue(argument);
-    argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW;
-    getChild<LLPanelCameraItem>("front_view")->setValue(argument);
-    argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK;
-    getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument);
-    argument["selected"] = mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA;
-    getChild<LLPanelCameraItem>("object_view")->setValue(argument);
+	ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
+	LLSD argument;
+	argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW;
+	getChild<LLPanelCameraItem>("rear_view")->setValue(argument);
+	argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW;
+	getChild<LLPanelCameraItem>("group_view")->setValue(argument);
+	argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW;
+	getChild<LLPanelCameraItem>("front_view")->setValue(argument);
+	argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK;
+	getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument);
+	argument["selected"] = mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA;
+	getChild<LLPanelCameraItem>("object_view")->setValue(argument);
 }
 
 void LLFloaterCamera::onClickCameraItem(const LLSD& param)
 {
-    std::string name = param.asString();
-
-    if ("mouselook_view" == name)
-    {
-        gAgentCamera.changeCameraToMouselook();
-    }
-    else if ("object_view" == name)
-    {
-        LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
-        if (camera_floater)
-        camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-    }
-    else
-    {
-        switchToPreset(name);
-    }
-
-    LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
-    if (camera_floater)
-    {
-        camera_floater->updateItemsSelection();
-        camera_floater->fromFreeToPresets();
-    }
+	std::string name = param.asString();
+
+	if ("mouselook_view" == name)
+	{
+		gAgentCamera.changeCameraToMouselook();
+	}
+	else if ("object_view" == name)
+	{
+		LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
+		if (camera_floater)
+		camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+	}
+	else
+	{
+		switchToPreset(name);
+	}
+
+	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
+	if (camera_floater)
+	{
+		camera_floater->updateItemsSelection();
+		camera_floater->fromFreeToPresets();
+	}
 }
 
 /*static*/
 void LLFloaterCamera::switchToPreset(const std::string& name)
 {
-    sFreeCamera = false;
-    clear_camera_tool();
-    if ("rear_view" == name)
-    {
-        gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
-    }
-    else if ("group_view" == name)
-    {
-        gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
-    }
-    else if ("front_view" == name)
-    {
-        gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
-    }
+	sFreeCamera = false;
+	clear_camera_tool();
+	if ("rear_view" == name)
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+	}
+	else if ("group_view" == name)
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
+	}
+	else if ("front_view" == name)
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
+	}
 }
 
 void LLFloaterCamera::fromFreeToPresets()
 {
-    if (!sFreeCamera && mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && mPrevMode == CAMERA_CTRL_MODE_PRESETS)
-    {
-        switchMode(CAMERA_CTRL_MODE_PRESETS);
-    }
+	if (!sFreeCamera && mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && mPrevMode == CAMERA_CTRL_MODE_PRESETS)
+	{
+		switchMode(CAMERA_CTRL_MODE_PRESETS);
+	}
 }
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 1b24b143bf..481e9aec1b 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -39,95 +39,95 @@ class LLPanelCameraZoom;
 
 enum ECameraControlMode
 {
-    CAMERA_CTRL_MODE_MODES,
-    CAMERA_CTRL_MODE_PAN,
-    CAMERA_CTRL_MODE_FREE_CAMERA,
-    CAMERA_CTRL_MODE_PRESETS
+	CAMERA_CTRL_MODE_MODES,
+	CAMERA_CTRL_MODE_PAN,
+	CAMERA_CTRL_MODE_FREE_CAMERA,
+	CAMERA_CTRL_MODE_PRESETS
 };
 
 class LLFloaterCamera : public LLFloater
 {
-    friend class LLFloaterReg;
-    
+	friend class LLFloaterReg;
+	
 public:
 
-    /* whether in free camera mode */
-    static bool inFreeCameraMode();
-    /* callback for camera items selection changing */
-    static void onClickCameraItem(const LLSD& param);
+	/* whether in free camera mode */
+	static bool inFreeCameraMode();
+	/* callback for camera items selection changing */
+	static void onClickCameraItem(const LLSD& param);
 
-    static void onLeavingMouseLook();
+	static void onLeavingMouseLook();
 
-    /** resets current camera mode to orbit mode */
-    static void resetCameraMode();
+	/** resets current camera mode to orbit mode */
+	static void resetCameraMode();
 
-    /** Called when Avatar is entered/exited editing appearance mode */
-    static void onAvatarEditingAppearance(bool editing);
+	/** Called when Avatar is entered/exited editing appearance mode */
+	static void onAvatarEditingAppearance(bool editing);
 
-    /* determines actual mode and updates ui */
-    void update();
+	/* determines actual mode and updates ui */
+	void update();
 
-    /*switch to one of the camera presets (front, rear, side)*/
-    static void switchToPreset(const std::string& name);
+	/*switch to one of the camera presets (front, rear, side)*/
+	static void switchToPreset(const std::string& name);
 
-    /* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and
-       are not in free camera mode*/
-    void fromFreeToPresets();
+	/* move to CAMERA_CTRL_MODE_PRESETS from CAMERA_CTRL_MODE_FREE_CAMERA if we are on presets panel and
+	   are not in free camera mode*/
+	void fromFreeToPresets();
 
-    virtual void onOpen(const LLSD& key);
-    virtual void onClose(bool app_quitting);
+	virtual void onOpen(const LLSD& key);
+	virtual void onClose(bool app_quitting);
 
-    LLJoystickCameraRotate* mRotate;
-    LLPanelCameraZoom*  mZoom;
-    LLJoystickCameraTrack*  mTrack;
+	LLJoystickCameraRotate* mRotate;
+	LLPanelCameraZoom*	mZoom;
+	LLJoystickCameraTrack*	mTrack;
 
 private:
 
-    LLFloaterCamera(const LLSD& val);
-    ~LLFloaterCamera() {};
+	LLFloaterCamera(const LLSD& val);
+	~LLFloaterCamera() {};
 
-    /* return instance if it exists - created by LLFloaterReg */
-    static LLFloaterCamera* findInstance();
+	/* return instance if it exists - created by LLFloaterReg */
+	static LLFloaterCamera* findInstance();
 
-    /*virtual*/ BOOL postBuild();
+	/*virtual*/ BOOL postBuild();
 
-    F32 getCurrentTransparency();
+	F32 getCurrentTransparency();
 
-    void onViewButtonClick(const LLSD& user_data);
+	void onViewButtonClick(const LLSD& user_data);
 
-    ECameraControlMode determineMode();
+	ECameraControlMode determineMode();
 
-    /* resets to the previous mode */
-    void toPrevMode();
+	/* resets to the previous mode */
+	void toPrevMode();
 
-    /* sets a new mode and performs related actions */
-    void switchMode(ECameraControlMode mode);
+	/* sets a new mode and performs related actions */
+	void switchMode(ECameraControlMode mode);
 
-    /* sets a new mode preserving previous one and updates ui*/
-    void setMode(ECameraControlMode mode);
+	/* sets a new mode preserving previous one and updates ui*/
+	void setMode(ECameraControlMode mode);
 
-    /* updates the state (UI) according to the current mode */
-    void updateState();
+	/* updates the state (UI) according to the current mode */
+	void updateState();
 
-    /* update camera modes items selection and camera preset items selection according to the currently selected preset */
-    void updateItemsSelection();
+	/* update camera modes items selection and camera preset items selection according to the currently selected preset */
+	void updateItemsSelection();
 
-    void onClickBtn(ECameraControlMode mode);
-    void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
-    
-    // fills flatlist with items from given panel
-    void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
+	void onClickBtn(ECameraControlMode mode);
+	void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
+	
+	// fills flatlist with items from given panel
+	void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
 
-    void handleAvatarEditingAppearance(bool editing);
+	void handleAvatarEditingAppearance(bool editing);
 
-    // set to true when free camera mode is selected in modes list
-    // remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
-    static bool sFreeCamera;
-    static bool sAppearanceEditing;
-    BOOL mClosed;
-    ECameraControlMode mPrevMode;
-    ECameraControlMode mCurrMode;
-    std::map<ECameraControlMode, LLButton*> mMode2Button;
+	// set to true when free camera mode is selected in modes list
+	// remains true until preset camera mode is chosen, or pan button is clicked, or escape pressed
+	static bool sFreeCamera;
+	static bool sAppearanceEditing;
+	BOOL mClosed;
+	ECameraControlMode mPrevMode;
+	ECameraControlMode mCurrMode;
+	std::map<ECameraControlMode, LLButton*> mMode2Button;
 };
 
 /**
@@ -138,33 +138,33 @@ private:
  * it's items are used inside of flatlist.
  */
 class LLPanelCameraItem 
-    : public LLPanel
+	: public LLPanel
 {
 public:
-    struct Params : public LLInitParam::Block<Params, LLPanel::Params>
-    {
-        Optional<LLIconCtrl::Params> icon_over;
-        Optional<LLIconCtrl::Params> icon_selected;
-        Optional<LLIconCtrl::Params> picture;
-        Optional<LLIconCtrl::Params> selected_picture;
-
-        Optional<LLTextBox::Params> text;
-        Optional<CommitCallbackParam> mousedown_callback;
-        Params();
-    };
-    /*virtual*/ BOOL postBuild();
-    /** setting on/off background icon to indicate selected state */
-    /*virtual*/ void setValue(const LLSD& value);
-    // sends commit signal
-    void onAnyMouseClick();
+	struct Params :	public LLInitParam::Block<Params, LLPanel::Params>
+	{
+		Optional<LLIconCtrl::Params> icon_over;
+		Optional<LLIconCtrl::Params> icon_selected;
+		Optional<LLIconCtrl::Params> picture;
+		Optional<LLIconCtrl::Params> selected_picture;
+
+		Optional<LLTextBox::Params> text;
+		Optional<CommitCallbackParam> mousedown_callback;
+		Params();
+	};
+	/*virtual*/ BOOL postBuild();
+	/** setting on/off background icon to indicate selected state */
+	/*virtual*/ void setValue(const LLSD& value);
+	// sends commit signal
+	void onAnyMouseClick();
 protected:
-    friend class LLUICtrlFactory;
-    LLPanelCameraItem(const Params&);
-    LLIconCtrl* mIconOver;
-    LLIconCtrl* mIconSelected;
-    LLIconCtrl* mPicture;
-    LLIconCtrl* mPictureSelected;
-    LLTextBox* mText;
+	friend class LLUICtrlFactory;
+	LLPanelCameraItem(const Params&);
+	LLIconCtrl* mIconOver;
+	LLIconCtrl* mIconSelected;
+	LLIconCtrl* mPicture;
+	LLIconCtrl* mPictureSelected;
+	LLTextBox* mText;
 };
 
 #endif
diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp
index dd8117f95f..bd62849b42 100644
--- a/indra/newview/llfloaterdeleteprefpreset.cpp
+++ b/indra/newview/llfloaterdeleteprefpreset.cpp
@@ -37,65 +37,65 @@
 #include "llfloaterreg.h"
 
 LLFloaterDeletePrefPreset::LLFloaterDeletePrefPreset(const LLSD &key)
-:   LLFloater(key)
+:	LLFloater(key)
 {
 }
 
 // virtual
 BOOL LLFloaterDeletePrefPreset::postBuild()
 {
-    LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (preferences)
-    {
-        preferences->addDependentFloater(this);
-    }
-    getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this));
-    getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this));
-    LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this));
-
-    return TRUE;
+	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+	if (preferences)
+	{
+		preferences->addDependentFloater(this);
+	}
+	getChild<LLButton>("delete")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnDelete, this));
+	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterDeletePrefPreset::onBtnCancel, this));
+	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterDeletePrefPreset::onPresetsListChange, this));
+
+	return TRUE;
 }
 
 void LLFloaterDeletePrefPreset::onOpen(const LLSD& key)
 {
-    mSubdirectory = key.asString();
-    std::string floater_title = getString(std::string("title_") + mSubdirectory);
-    setTitle(floater_title);
+	mSubdirectory = key.asString();
+	std::string floater_title = getString(std::string("title_") + mSubdirectory);
+	setTitle(floater_title);
 
-    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-    EDefaultOptions option = DEFAULT_HIDE;
-    bool action;
-    action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+	EDefaultOptions option = DEFAULT_HIDE;
+	bool action;
+	action = LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 
-    LLButton* delete_btn = getChild<LLButton>("delete");
-    delete_btn->setEnabled(action);
+	LLButton* delete_btn = getChild<LLButton>("delete");
+	delete_btn->setEnabled(action);
 }
 
 void LLFloaterDeletePrefPreset::onBtnDelete()
 {
-    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-    std::string name = combo->getSimple();
+	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+	std::string name = combo->getSimple();
 
-    if (!LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name))
-    {
-        LLSD args;
-        args["NAME"] = name;
-        LLNotificationsUtil::add("PresetNotDeleted", args);
-    }
+	if (!LLPresetsManager::getInstance()->deletePreset(mSubdirectory, name))
+	{
+		LLSD args;
+		args["NAME"] = name;
+		LLNotificationsUtil::add("PresetNotDeleted", args);
+	}
 
-    closeFloater();
+	closeFloater();
 }
 
 void LLFloaterDeletePrefPreset::onPresetsListChange()
 {
-    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
 
-    EDefaultOptions option = DEFAULT_HIDE;
+	EDefaultOptions option = DEFAULT_HIDE;
 
-    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterDeletePrefPreset::onBtnCancel()
 {
-    closeFloater();
+	closeFloater();
 }
diff --git a/indra/newview/llfloaterloadprefpreset.cpp b/indra/newview/llfloaterloadprefpreset.cpp
index 0584bf7e09..fa17a9d40e 100644
--- a/indra/newview/llfloaterloadprefpreset.cpp
+++ b/indra/newview/llfloaterloadprefpreset.cpp
@@ -36,57 +36,57 @@
 #include "llviewercontrol.h"
 
 LLFloaterLoadPrefPreset::LLFloaterLoadPrefPreset(const LLSD &key)
-:   LLFloater(key)
+:	LLFloater(key)
 {
 }
 
 // virtual
 BOOL LLFloaterLoadPrefPreset::postBuild()
 {
-    LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (preferences)
-    {
-        preferences->addDependentFloater(this);
-    }
-    getChild<LLButton>("ok")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnOk, this));
-    getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnCancel, this));
-    LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterLoadPrefPreset::onPresetsListChange, this));
-
-    return TRUE;
+	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+	if (preferences)
+	{
+		preferences->addDependentFloater(this);
+	}
+	getChild<LLButton>("ok")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnOk, this));
+	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterLoadPrefPreset::onBtnCancel, this));
+	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterLoadPrefPreset::onPresetsListChange, this));
+
+	return TRUE;
 }
 
 void LLFloaterLoadPrefPreset::onOpen(const LLSD& key)
 {
-    mSubdirectory = key.asString();
-    std::string floater_title = getString(std::string("title_") + mSubdirectory);
+	mSubdirectory = key.asString();
+	std::string floater_title = getString(std::string("title_") + mSubdirectory);
 
-    setTitle(floater_title);
+	setTitle(floater_title);
 
-    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
 
-    EDefaultOptions option = DEFAULT_TOP;
-    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+	EDefaultOptions option = DEFAULT_TOP;
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterLoadPrefPreset::onPresetsListChange()
 {
-    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
 
-    EDefaultOptions option = DEFAULT_TOP;
-    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
+	EDefaultOptions option = DEFAULT_TOP;
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, combo, option);
 }
 
 void LLFloaterLoadPrefPreset::onBtnCancel()
 {
-    closeFloater();
+	closeFloater();
 }
 
 void LLFloaterLoadPrefPreset::onBtnOk()
 {
-    LLComboBox* combo = getChild<LLComboBox>("preset_combo");
-    std::string name = combo->getSimple();
+	LLComboBox* combo = getChild<LLComboBox>("preset_combo");
+	std::string name = combo->getSimple();
 
-    LLPresetsManager::getInstance()->loadPreset(mSubdirectory, name);
+	LLPresetsManager::getInstance()->loadPreset(mSubdirectory, name);
 
-    closeFloater();
+	closeFloater();
 }
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index ee85a46405..6b4e4ceeac 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -139,35 +139,35 @@ static const F32 ARC_LIMIT_MAP_SCALE = (MAX_ARC_LOG - MIN_ARC_LOG) / (MAX_INDIRE
 class LLVoiceSetKeyDialog : public LLModalDialog
 {
 public:
-    LLVoiceSetKeyDialog(const LLSD& key);
-    ~LLVoiceSetKeyDialog();
-    
-    /*virtual*/ BOOL postBuild();
-    
-    void setParent(LLFloaterPreference* parent) { mParent = parent; }
-    
-    BOOL handleKeyHere(KEY key, MASK mask);
-    static void onCancel(void* user_data);
-        
+	LLVoiceSetKeyDialog(const LLSD& key);
+	~LLVoiceSetKeyDialog();
+	
+	/*virtual*/ BOOL postBuild();
+	
+	void setParent(LLFloaterPreference* parent) { mParent = parent; }
+	
+	BOOL handleKeyHere(KEY key, MASK mask);
+	static void onCancel(void* user_data);
+		
 private:
-    LLFloaterPreference* mParent;
+	LLFloaterPreference* mParent;
 };
 
 LLVoiceSetKeyDialog::LLVoiceSetKeyDialog(const LLSD& key)
   : LLModalDialog(key),
-    mParent(NULL)
+	mParent(NULL)
 {
 }
 
 //virtual
 BOOL LLVoiceSetKeyDialog::postBuild()
 {
-    childSetAction("Cancel", onCancel, this);
-    getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
-    
-    gFocusMgr.setKeystrokesOnly(TRUE);
-    
-    return TRUE;
+	childSetAction("Cancel", onCancel, this);
+	getChild<LLUICtrl>("Cancel")->setFocus(TRUE);
+	
+	gFocusMgr.setKeystrokesOnly(TRUE);
+	
+	return TRUE;
 }
 
 LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
@@ -176,25 +176,25 @@ LLVoiceSetKeyDialog::~LLVoiceSetKeyDialog()
 
 BOOL LLVoiceSetKeyDialog::handleKeyHere(KEY key, MASK mask)
 {
-    BOOL result = TRUE;
-    
-    if (key == 'Q' && mask == MASK_CONTROL)
-    {
-        result = FALSE;
-    }
-    else if (mParent)
-    {
-        mParent->setKey(key);
-    }
-    closeFloater();
-    return result;
+	BOOL result = TRUE;
+	
+	if (key == 'Q' && mask == MASK_CONTROL)
+	{
+		result = FALSE;
+	}
+	else if (mParent)
+	{
+		mParent->setKey(key);
+	}
+	closeFloater();
+	return result;
 }
 
 //static
 void LLVoiceSetKeyDialog::onCancel(void* user_data)
 {
-    LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
-    self->closeFloater();
+	LLVoiceSetKeyDialog* self = (LLVoiceSetKeyDialog*)user_data;
+	self->closeFloater();
 }
 
 
@@ -204,8 +204,8 @@ void LLVoiceSetKeyDialog::onCancel(void* user_data)
 // if creating/destroying these is too slow, we'll need to create
 // a static member and update all our static callbacks
 
-void handleNameTagOptionChanged(const LLSD& newvalue);  
-void handleDisplayNamesOptionChanged(const LLSD& newvalue); 
+void handleNameTagOptionChanged(const LLSD& newvalue);	
+void handleDisplayNamesOptionChanged(const LLSD& newvalue);	
 bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response);
 bool callback_clear_cache(const LLSD& notification, const LLSD& response);
 
@@ -216,110 +216,110 @@ void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator);
 
 bool callback_clear_cache(const LLSD& notification, const LLSD& response)
 {
-    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-    if ( option == 0 ) // YES
-    {
-        // flag client texture cache for clearing next time the client runs
-        gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
-        LLNotificationsUtil::add("CacheWillClear");
-    }
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if ( option == 0 ) // YES
+	{
+		// flag client texture cache for clearing next time the client runs
+		gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
+		LLNotificationsUtil::add("CacheWillClear");
+	}
 
-    return false;
+	return false;
 }
 
 bool callback_clear_browser_cache(const LLSD& notification, const LLSD& response)
 {
-    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-    if ( option == 0 ) // YES
-    {
-        // clean web
-        LLViewerMedia::clearAllCaches();
-        LLViewerMedia::clearAllCookies();
-        
-        // clean nav bar history
-        LLNavigationBar::getInstance()->clearHistoryCache();
-        
-        // flag client texture cache for clearing next time the client runs
-        gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
-        LLNotificationsUtil::add("CacheWillClear");
-
-        LLSearchHistory::getInstance()->clearHistory();
-        LLSearchHistory::getInstance()->save();
-        LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
-        search_ctrl->clearHistory();
-
-        LLTeleportHistoryStorage::getInstance()->purgeItems();
-        LLTeleportHistoryStorage::getInstance()->save();
-    }
-    
-    return false;
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if ( option == 0 ) // YES
+	{
+		// clean web
+		LLViewerMedia::clearAllCaches();
+		LLViewerMedia::clearAllCookies();
+		
+		// clean nav bar history
+		LLNavigationBar::getInstance()->clearHistoryCache();
+		
+		// flag client texture cache for clearing next time the client runs
+		gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
+		LLNotificationsUtil::add("CacheWillClear");
+
+		LLSearchHistory::getInstance()->clearHistory();
+		LLSearchHistory::getInstance()->save();
+		LLSearchComboBox* search_ctrl = LLNavigationBar::getInstance()->getChild<LLSearchComboBox>("search_combo_box");
+		search_ctrl->clearHistory();
+
+		LLTeleportHistoryStorage::getInstance()->purgeItems();
+		LLTeleportHistoryStorage::getInstance()->save();
+	}
+	
+	return false;
 }
 
 void handleNameTagOptionChanged(const LLSD& newvalue)
 {
-    LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
-    LLVOAvatar::invalidateNameTags();
+	LLAvatarNameCache::setUseUsernames(gSavedSettings.getBOOL("NameTagShowUsernames"));
+	LLVOAvatar::invalidateNameTags();
 }
 
 void handleDisplayNamesOptionChanged(const LLSD& newvalue)
 {
-    LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean());
-    LLVOAvatar::invalidateNameTags();
+	LLAvatarNameCache::setUseDisplayNames(newvalue.asBoolean());
+	LLVOAvatar::invalidateNameTags();
 }
 
 void handleAppearanceCameraMovementChanged(const LLSD& newvalue)
 {
-    if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
-    {
-        gAgentCamera.changeCameraToDefault();
-        gAgentCamera.resetView();
-    }
+	if(!newvalue.asBoolean() && gAgentCamera.getCameraMode() == CAMERA_MODE_CUSTOMIZE_AVATAR)
+	{
+		gAgentCamera.changeCameraToDefault();
+		gAgentCamera.resetView();
+	}
 }
 
 /*bool callback_skip_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
 {
-    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-    if (0 == option && floater )
-    {
-        if ( floater )
-        {
-            floater->setAllIgnored();
-        //  LLFirstUse::disableFirstUse();
-            floater->buildPopupLists();
-        }
-    }
-    return false;
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if (0 == option && floater )
+	{
+		if ( floater )
+		{
+			floater->setAllIgnored();
+		//	LLFirstUse::disableFirstUse();
+			floater->buildPopupLists();
+		}
+	}
+	return false;
 }
 
 bool callback_reset_dialogs(const LLSD& notification, const LLSD& response, LLFloaterPreference* floater)
 {
-    S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-    if ( 0 == option && floater )
-    {
-        if ( floater )
-        {
-            floater->resetAllIgnored();
-            //LLFirstUse::resetFirstUse();
-            floater->buildPopupLists();
-        }
-    }
-    return false;
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if ( 0 == option && floater )
+	{
+		if ( floater )
+		{
+			floater->resetAllIgnored();
+			//LLFirstUse::resetFirstUse();
+			floater->buildPopupLists();
+		}
+	}
+	return false;
 }
 */
 
 void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
 {
-    numerator = 0;
-    denominator = 0;
-    for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
-    {
-        if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
-        {
-            numerator = ll_round(decimal_val * test_denominator);
-            denominator = ll_round(test_denominator);
-            break;
-        }
-    }
+	numerator = 0;
+	denominator = 0;
+	for (F32 test_denominator = 1.f; test_denominator < 30.f; test_denominator += 1.f)
+	{
+		if (fmodf((decimal_val * test_denominator) + 0.01f, 1.f) < 0.02f)
+		{
+			numerator = ll_round(decimal_val * test_denominator);
+			denominator = ll_round(test_denominator);
+			break;
+		}
+	}
 }
 // static
 std::string LLFloaterPreference::sSkin = "";
@@ -327,1537 +327,1537 @@ std::string LLFloaterPreference::sSkin = "";
 // LLFloaterPreference
 
 LLFloaterPreference::LLFloaterPreference(const LLSD& key)
-    : LLFloater(key),
-    mGotPersonalInfo(false),
-    mOriginalIMViaEmail(false),
-    mLanguageChanged(false),
-    mAvatarDataInitialized(false),
-    mClickActionDirty(false)
-{
-    LLConversationLog::instance().addObserver(this);
-
-    //Build Floater is now Called from  LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
-    
-    static bool registered_dialog = false;
-    if (!registered_dialog)
-    {
-        LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
-        registered_dialog = true;
-    }
-    
-    mCommitCallbackRegistrar.add("Pref.Cancel",             boost::bind(&LLFloaterPreference::onBtnCancel, this, _2));
-    mCommitCallbackRegistrar.add("Pref.OK",                 boost::bind(&LLFloaterPreference::onBtnOK, this, _2));
-    
-    mCommitCallbackRegistrar.add("Pref.ClearCache",             boost::bind(&LLFloaterPreference::onClickClearCache, this));
-    mCommitCallbackRegistrar.add("Pref.WebClearCache",          boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
-    mCommitCallbackRegistrar.add("Pref.SetCache",               boost::bind(&LLFloaterPreference::onClickSetCache, this));
-    mCommitCallbackRegistrar.add("Pref.ResetCache",             boost::bind(&LLFloaterPreference::onClickResetCache, this));
-    mCommitCallbackRegistrar.add("Pref.ClickSkin",              boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2));
-    mCommitCallbackRegistrar.add("Pref.SelectSkin",             boost::bind(&LLFloaterPreference::onSelectSkin, this));
-    mCommitCallbackRegistrar.add("Pref.VoiceSetKey",            boost::bind(&LLFloaterPreference::onClickSetKey, this));
-    mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse",    boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
-    mCommitCallbackRegistrar.add("Pref.SetSounds",              boost::bind(&LLFloaterPreference::onClickSetSounds, this));
-    mCommitCallbackRegistrar.add("Pref.ClickEnablePopup",       boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
-    mCommitCallbackRegistrar.add("Pref.ClickDisablePopup",      boost::bind(&LLFloaterPreference::onClickDisablePopup, this));  
-    mCommitCallbackRegistrar.add("Pref.LogPath",                boost::bind(&LLFloaterPreference::onClickLogPath, this));
-    mCommitCallbackRegistrar.add("Pref.RenderExceptions",       boost::bind(&LLFloaterPreference::onClickRenderExceptions, this));
-    mCommitCallbackRegistrar.add("Pref.HardwareDefaults",       boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
-    mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable",  boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this));
-    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",    boost::bind(&LLFloaterPreference::updateMaxComplexity, this));
-    mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",     boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
-    mCommitCallbackRegistrar.add("Pref.WindowedMod",            boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
-    mCommitCallbackRegistrar.add("Pref.UpdateSliderText",       boost::bind(&LLFloaterPreference::refreshUI,this));
-    mCommitCallbackRegistrar.add("Pref.QualityPerformance",     boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
-    mCommitCallbackRegistrar.add("Pref.applyUIColor",           boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
-    mCommitCallbackRegistrar.add("Pref.getUIColor",             boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
-    mCommitCallbackRegistrar.add("Pref.MaturitySettings",       boost::bind(&LLFloaterPreference::onChangeMaturity, this));
-    mCommitCallbackRegistrar.add("Pref.BlockList",              boost::bind(&LLFloaterPreference::onClickBlockList, this));
-    mCommitCallbackRegistrar.add("Pref.Proxy",                  boost::bind(&LLFloaterPreference::onClickProxySettings, this));
-    mCommitCallbackRegistrar.add("Pref.TranslationSettings",    boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
-    mCommitCallbackRegistrar.add("Pref.AutoReplace",            boost::bind(&LLFloaterPreference::onClickAutoReplace, this));
-    mCommitCallbackRegistrar.add("Pref.PermsDefault",           boost::bind(&LLFloaterPreference::onClickPermsDefault, this));
-    mCommitCallbackRegistrar.add("Pref.SpellChecker",           boost::bind(&LLFloaterPreference::onClickSpellChecker, this));
-    mCommitCallbackRegistrar.add("Pref.Advanced",               boost::bind(&LLFloaterPreference::onClickAdvanced, this));
-
-    sSkin = gSavedSettings.getString("SkinCurrent");
-
-    mCommitCallbackRegistrar.add("Pref.ClickActionChange",      boost::bind(&LLFloaterPreference::onClickActionChange, this));
-
-    gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));   
-    gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2)); 
-    gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged,  _2));
-
-    gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged,  _2));
-
-    LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
-
-    mCommitCallbackRegistrar.add("Pref.ClearLog",               boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance()));
-    mCommitCallbackRegistrar.add("Pref.DeleteTranscripts",      boost::bind(&LLFloaterPreference::onDeleteTranscripts, this));
+	: LLFloater(key),
+	mGotPersonalInfo(false),
+	mOriginalIMViaEmail(false),
+	mLanguageChanged(false),
+	mAvatarDataInitialized(false),
+	mClickActionDirty(false)
+{
+	LLConversationLog::instance().addObserver(this);
+
+	//Build Floater is now Called from 	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
+	
+	static bool registered_dialog = false;
+	if (!registered_dialog)
+	{
+		LLFloaterReg::add("voice_set_key", "floater_select_key.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLVoiceSetKeyDialog>);
+		registered_dialog = true;
+	}
+	
+	mCommitCallbackRegistrar.add("Pref.Cancel",				boost::bind(&LLFloaterPreference::onBtnCancel, this, _2));
+	mCommitCallbackRegistrar.add("Pref.OK",					boost::bind(&LLFloaterPreference::onBtnOK, this, _2));
+	
+	mCommitCallbackRegistrar.add("Pref.ClearCache",				boost::bind(&LLFloaterPreference::onClickClearCache, this));
+	mCommitCallbackRegistrar.add("Pref.WebClearCache",			boost::bind(&LLFloaterPreference::onClickBrowserClearCache, this));
+	mCommitCallbackRegistrar.add("Pref.SetCache",				boost::bind(&LLFloaterPreference::onClickSetCache, this));
+	mCommitCallbackRegistrar.add("Pref.ResetCache",				boost::bind(&LLFloaterPreference::onClickResetCache, this));
+	mCommitCallbackRegistrar.add("Pref.ClickSkin",				boost::bind(&LLFloaterPreference::onClickSkin, this,_1, _2));
+	mCommitCallbackRegistrar.add("Pref.SelectSkin",				boost::bind(&LLFloaterPreference::onSelectSkin, this));
+	mCommitCallbackRegistrar.add("Pref.VoiceSetKey",			boost::bind(&LLFloaterPreference::onClickSetKey, this));
+	mCommitCallbackRegistrar.add("Pref.VoiceSetMiddleMouse",	boost::bind(&LLFloaterPreference::onClickSetMiddleMouse, this));
+	mCommitCallbackRegistrar.add("Pref.SetSounds",				boost::bind(&LLFloaterPreference::onClickSetSounds, this));
+	mCommitCallbackRegistrar.add("Pref.ClickEnablePopup",		boost::bind(&LLFloaterPreference::onClickEnablePopup, this));
+	mCommitCallbackRegistrar.add("Pref.ClickDisablePopup",		boost::bind(&LLFloaterPreference::onClickDisablePopup, this));	
+	mCommitCallbackRegistrar.add("Pref.LogPath",				boost::bind(&LLFloaterPreference::onClickLogPath, this));
+	mCommitCallbackRegistrar.add("Pref.RenderExceptions",       boost::bind(&LLFloaterPreference::onClickRenderExceptions, this));
+	mCommitCallbackRegistrar.add("Pref.HardwareDefaults",		boost::bind(&LLFloaterPreference::setHardwareDefaults, this));
+	mCommitCallbackRegistrar.add("Pref.AvatarImpostorsEnable",	boost::bind(&LLFloaterPreference::onAvatarImpostorsEnable, this));
+	mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",	boost::bind(&LLFloaterPreference::updateMaxComplexity, this));
+	mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",		boost::bind(&LLFloaterPreference::onVertexShaderEnable, this));
+	mCommitCallbackRegistrar.add("Pref.WindowedMod",			boost::bind(&LLFloaterPreference::onCommitWindowedMode, this));
+	mCommitCallbackRegistrar.add("Pref.UpdateSliderText",		boost::bind(&LLFloaterPreference::refreshUI,this));
+	mCommitCallbackRegistrar.add("Pref.QualityPerformance",		boost::bind(&LLFloaterPreference::onChangeQuality, this, _2));
+	mCommitCallbackRegistrar.add("Pref.applyUIColor",			boost::bind(&LLFloaterPreference::applyUIColor, this ,_1, _2));
+	mCommitCallbackRegistrar.add("Pref.getUIColor",				boost::bind(&LLFloaterPreference::getUIColor, this ,_1, _2));
+	mCommitCallbackRegistrar.add("Pref.MaturitySettings",		boost::bind(&LLFloaterPreference::onChangeMaturity, this));
+	mCommitCallbackRegistrar.add("Pref.BlockList",				boost::bind(&LLFloaterPreference::onClickBlockList, this));
+	mCommitCallbackRegistrar.add("Pref.Proxy",					boost::bind(&LLFloaterPreference::onClickProxySettings, this));
+	mCommitCallbackRegistrar.add("Pref.TranslationSettings",	boost::bind(&LLFloaterPreference::onClickTranslationSettings, this));
+	mCommitCallbackRegistrar.add("Pref.AutoReplace",            boost::bind(&LLFloaterPreference::onClickAutoReplace, this));
+	mCommitCallbackRegistrar.add("Pref.PermsDefault",           boost::bind(&LLFloaterPreference::onClickPermsDefault, this));
+	mCommitCallbackRegistrar.add("Pref.SpellChecker",           boost::bind(&LLFloaterPreference::onClickSpellChecker, this));
+	mCommitCallbackRegistrar.add("Pref.Advanced",				boost::bind(&LLFloaterPreference::onClickAdvanced, this));
+
+	sSkin = gSavedSettings.getString("SkinCurrent");
+
+	mCommitCallbackRegistrar.add("Pref.ClickActionChange",		boost::bind(&LLFloaterPreference::onClickActionChange, this));
+
+	gSavedSettings.getControl("NameTagShowUsernames")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));	
+	gSavedSettings.getControl("NameTagShowFriends")->getCommitSignal()->connect(boost::bind(&handleNameTagOptionChanged,  _2));	
+	gSavedSettings.getControl("UseDisplayNames")->getCommitSignal()->connect(boost::bind(&handleDisplayNamesOptionChanged,  _2));
+
+	gSavedSettings.getControl("AppearanceCameraMovement")->getCommitSignal()->connect(boost::bind(&handleAppearanceCameraMovementChanged,  _2));
+
+	LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
+
+	mCommitCallbackRegistrar.add("Pref.ClearLog",				boost::bind(&LLConversationLog::onClearLog, &LLConversationLog::instance()));
+	mCommitCallbackRegistrar.add("Pref.DeleteTranscripts",      boost::bind(&LLFloaterPreference::onDeleteTranscripts, this));
 }
 
 void LLFloaterPreference::processProperties( void* pData, EAvatarProcessorType type )
 {
-    if ( APT_PROPERTIES == type )
-    {
-        const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData );
-        if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null))
-        {
-            storeAvatarProperties( pAvatarData );
-            processProfileProperties( pAvatarData );
-        }
-    }   
+	if ( APT_PROPERTIES == type )
+	{
+		const LLAvatarData* pAvatarData = static_cast<const LLAvatarData*>( pData );
+		if (pAvatarData && (gAgent.getID() == pAvatarData->avatar_id) && (pAvatarData->avatar_id != LLUUID::null))
+		{
+			storeAvatarProperties( pAvatarData );
+			processProfileProperties( pAvatarData );
+		}
+	}	
 }
 
 void LLFloaterPreference::storeAvatarProperties( const LLAvatarData* pAvatarData )
 {
-    if (LLStartUp::getStartupState() == STATE_STARTED)
-    {
-        mAvatarProperties.avatar_id     = pAvatarData->avatar_id;
-        mAvatarProperties.image_id      = pAvatarData->image_id;
-        mAvatarProperties.fl_image_id   = pAvatarData->fl_image_id;
-        mAvatarProperties.about_text    = pAvatarData->about_text;
-        mAvatarProperties.fl_about_text = pAvatarData->fl_about_text;
-        mAvatarProperties.profile_url   = pAvatarData->profile_url;
-        mAvatarProperties.flags         = pAvatarData->flags;
-        mAvatarProperties.allow_publish = pAvatarData->flags & AVATAR_ALLOW_PUBLISH;
-
-        mAvatarDataInitialized = true;
-    }
+	if (LLStartUp::getStartupState() == STATE_STARTED)
+	{
+		mAvatarProperties.avatar_id		= pAvatarData->avatar_id;
+		mAvatarProperties.image_id		= pAvatarData->image_id;
+		mAvatarProperties.fl_image_id   = pAvatarData->fl_image_id;
+		mAvatarProperties.about_text	= pAvatarData->about_text;
+		mAvatarProperties.fl_about_text = pAvatarData->fl_about_text;
+		mAvatarProperties.profile_url   = pAvatarData->profile_url;
+		mAvatarProperties.flags		    = pAvatarData->flags;
+		mAvatarProperties.allow_publish	= pAvatarData->flags & AVATAR_ALLOW_PUBLISH;
+
+		mAvatarDataInitialized = true;
+	}
 }
 
 void LLFloaterPreference::processProfileProperties(const LLAvatarData* pAvatarData )
 {
-    getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) );  
+	getChild<LLUICtrl>("online_searchresults")->setValue( (bool)(pAvatarData->flags & AVATAR_ALLOW_PUBLISH) );	
 }
 
 void LLFloaterPreference::saveAvatarProperties( void )
 {
-    const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue();
+	const BOOL allowPublish = getChild<LLUICtrl>("online_searchresults")->getValue();
 
-    if (allowPublish)
-    {
-        mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH;
-    }
+	if (allowPublish)
+	{
+		mAvatarProperties.flags |= AVATAR_ALLOW_PUBLISH;
+	}
 
-    //
-    // NOTE: We really don't want to send the avatar properties unless we absolutely
-    //       need to so we can avoid the accidental profile reset bug, so, if we're
-    //       logged in, the avatar data has been initialized and we have a state change
-    //       for the "allow publish" flag, then set the flag to its new value and send
-    //       the properties update.
-    //
-    // NOTE: The only reason we can not remove this update altogether is because of the
-    //       "allow publish" flag, the last remaining profile setting in the viewer
-    //       that doesn't exist in the web profile.
-    //
-    if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish))
-    {
-        mAvatarProperties.allow_publish = allowPublish;
+	//
+	// NOTE: We really don't want to send the avatar properties unless we absolutely
+	//       need to so we can avoid the accidental profile reset bug, so, if we're
+	//       logged in, the avatar data has been initialized and we have a state change
+	//       for the "allow publish" flag, then set the flag to its new value and send
+	//       the properties update.
+	//
+	// NOTE: The only reason we can not remove this update altogether is because of the
+	//       "allow publish" flag, the last remaining profile setting in the viewer
+	//       that doesn't exist in the web profile.
+	//
+	if ((LLStartUp::getStartupState() == STATE_STARTED) && mAvatarDataInitialized && (allowPublish != mAvatarProperties.allow_publish))
+	{
+		mAvatarProperties.allow_publish = allowPublish;
 
-        LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties );
-    }
+		LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesUpdate( &mAvatarProperties );
+	}
 }
 
 BOOL LLFloaterPreference::postBuild()
 {
-    gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
+	gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLFloaterIMSessionTab::processChatHistoryStyleUpdate, false));
 
-    gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged));
+	gSavedSettings.getControl("ChatFontSize")->getSignal()->connect(boost::bind(&LLViewerChat::signalChatFontChanged));
 
-    gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2));
+	gSavedSettings.getControl("ChatBubbleOpacity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onNameTagOpacityChange, this, _2));
 
-    gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this));
+	gSavedSettings.getControl("PreferredMaturity")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeMaturity, this));
 
-    gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this));
-    gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this));
-    gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this));
-    gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this));
+	gSavedPerAccountSettings.getControl("ModelUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeModelFolder, this));
+	gSavedPerAccountSettings.getControl("TextureUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeTextureFolder, this));
+	gSavedPerAccountSettings.getControl("SoundUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeSoundFolder, this));
+	gSavedPerAccountSettings.getControl("AnimationUploadFolder")->getSignal()->connect(boost::bind(&LLFloaterPreference::onChangeAnimationFolder, this));
 
-    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-    if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
-        tabcontainer->selectFirstTab();
+	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+	if (!tabcontainer->selectTab(gSavedSettings.getS32("LastPrefTab")))
+		tabcontainer->selectFirstTab();
 
-    getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227)
-    std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
-    setCacheLocation(cache_location);
+	getChild<LLUICtrl>("cache_location")->setEnabled(FALSE); // make it read-only but selectable (STORM-227)
+	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
+	setCacheLocation(cache_location);
 
-    getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable
+	getChild<LLUICtrl>("log_path_string")->setEnabled(FALSE); // make it read-only but selectable
 
-    getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this));
+	getChild<LLComboBox>("language_combobox")->setCommitCallback(boost::bind(&LLFloaterPreference::onLanguageChange, this));
 
-    getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions"));
-    getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions"));
-    getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions"));
-    getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions"));
-    getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions"));
-    getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions"));
+	getChild<LLComboBox>("FriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"FriendIMOptions"));
+	getChild<LLComboBox>("NonFriendIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NonFriendIMOptions"));
+	getChild<LLComboBox>("ConferenceIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ConferenceIMOptions"));
+	getChild<LLComboBox>("GroupChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"GroupChatOptions"));
+	getChild<LLComboBox>("NearbyChatOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"NearbyChatOptions"));
+	getChild<LLComboBox>("ObjectIMOptions")->setCommitCallback(boost::bind(&LLFloaterPreference::onNotificationsChange, this,"ObjectIMOptions"));
 
-    // if floater is opened before login set default localized do not disturb message
-    if (LLStartUp::getStartupState() < STATE_STARTED)
-    {
-        gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
-    }
+	// if floater is opened before login set default localized do not disturb message
+	if (LLStartUp::getStartupState() < STATE_STARTED)
+	{
+		gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
+	}
 
-    // set 'enable' property for 'Clear log...' button
-    changed();
+	// set 'enable' property for 'Clear log...' button
+	changed();
 
-    LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
+	LLLogChat::setSaveHistorySignal(boost::bind(&LLFloaterPreference::onLogChatHistorySaved, this));
 
-    LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
-    fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
-    fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
+	LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
+	fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
+	fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
 
 
-    return TRUE;
+	return TRUE;
 }
 
 void LLFloaterPreference::updateDeleteTranscriptsButton()
 {
-    std::vector<std::string> list_of_transcriptions_file_names;
-    LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names);
-    getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0);
+	std::vector<std::string> list_of_transcriptions_file_names;
+	LLLogChat::getListOfTranscriptFiles(list_of_transcriptions_file_names);
+	getChild<LLButton>("delete_transcripts")->setEnabled(list_of_transcriptions_file_names.size() > 0);
 }
 
 void LLFloaterPreference::onDoNotDisturbResponseChanged()
 {
-    // set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise
-    bool response_changed_flag =
-            LLTrans::getString("DoNotDisturbModeResponseDefault")
-                    != getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString();
+	// set "DoNotDisturbResponseChanged" TRUE if user edited message differs from default, FALSE otherwise
+	bool response_changed_flag =
+			LLTrans::getString("DoNotDisturbModeResponseDefault")
+					!= getChild<LLUICtrl>("do_not_disturb_response")->getValue().asString();
 
-    gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag );
+	gSavedPerAccountSettings.setBOOL("DoNotDisturbResponseChanged", response_changed_flag );
 }
 
 LLFloaterPreference::~LLFloaterPreference()
 {
-    LLConversationLog::instance().removeObserver(this);
+	LLConversationLog::instance().removeObserver(this);
 }
 
 void LLFloaterPreference::draw()
 {
-    BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
-    gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
-    
-    has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
-    gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
-    
-    LLFloater::draw();
+	BOOL has_first_selected = (getChildRef<LLScrollListCtrl>("disabled_popups").getFirstSelected()!=NULL);
+	gSavedSettings.setBOOL("FirstSelectedDisabledPopups", has_first_selected);
+	
+	has_first_selected = (getChildRef<LLScrollListCtrl>("enabled_popups").getFirstSelected()!=NULL);
+	gSavedSettings.setBOOL("FirstSelectedEnabledPopups", has_first_selected);
+	
+	LLFloater::draw();
 }
 
 void LLFloaterPreference::saveSettings()
 {
-    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-    child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-    child_list_t::const_iterator end = tabcontainer->getChildList()->end();
-    for ( ; iter != end; ++iter)
-    {
-        LLView* view = *iter;
-        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-        if (panel)
-            panel->saveSettings();
-    }
-}   
+	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+	child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+	child_list_t::const_iterator end = tabcontainer->getChildList()->end();
+	for ( ; iter != end; ++iter)
+	{
+		LLView* view = *iter;
+		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+		if (panel)
+			panel->saveSettings();
+	}
+}	
 
 void LLFloaterPreference::apply()
 {
-    LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
-    
-    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-    if (sSkin != gSavedSettings.getString("SkinCurrent"))
-    {
-        LLNotificationsUtil::add("ChangeSkin");
-        refreshSkin(this);
-    }
-    // Call apply() on all panels that derive from LLPanelPreference
-    for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-         iter != tabcontainer->getChildList()->end(); ++iter)
-    {
-        LLView* view = *iter;
-        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-        if (panel)
-            panel->apply();
-    }
-    
-    gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
-
-    LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
-    fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
-    fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
-    
-    std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
-    setCacheLocation(cache_location);
-    
-    LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
-    
-    if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE))
-    {
-        bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
-        std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
-        int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
-        LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
-    }
-    
-    if (mGotPersonalInfo)
-    { 
-        bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
-        bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();     
-    
-        if ((new_im_via_email != mOriginalIMViaEmail)
-            ||(new_hide_online != mOriginalHideOnlineStatus))
-        {
-            // This hack is because we are representing several different    
-            // possible strings with a single checkbox. Since most users     
-            // can only select between 2 values, we represent it as a    
-            // checkbox. This breaks down a little bit for liaisons, but     
-            // works out in the end.     
-            if (new_hide_online != mOriginalHideOnlineStatus)
-            {
-                if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
-                else mDirectoryVisibility = VISIBILITY_DEFAULT;
-             //Update showonline value, otherwise multiple applys won't work
-                mOriginalHideOnlineStatus = new_hide_online;
-            }
-            gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
-        }
-    }
-
-    saveAvatarProperties();
-
-    if (mClickActionDirty)
-    {
-        updateClickActionSettings();
-        mClickActionDirty = false;
-    }
+	LLAvatarPropertiesProcessor::getInstance()->addObserver( gAgent.getID(), this );
+	
+	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+	if (sSkin != gSavedSettings.getString("SkinCurrent"))
+	{
+		LLNotificationsUtil::add("ChangeSkin");
+		refreshSkin(this);
+	}
+	// Call apply() on all panels that derive from LLPanelPreference
+	for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+		 iter != tabcontainer->getChildList()->end(); ++iter)
+	{
+		LLView* view = *iter;
+		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+		if (panel)
+			panel->apply();
+	}
+	
+	gViewerWindow->requestResolutionUpdate(); // for UIScaleFactor
+
+	LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
+	fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
+	fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
+	
+	std::string cache_location = gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "");
+	setCacheLocation(cache_location);
+	
+	LLViewerMedia::setCookiesEnabled(getChild<LLUICtrl>("cookies_enabled")->getValue());
+	
+	if (hasChild("web_proxy_enabled", TRUE) &&hasChild("web_proxy_editor", TRUE) && hasChild("web_proxy_port", TRUE))
+	{
+		bool proxy_enable = getChild<LLUICtrl>("web_proxy_enabled")->getValue();
+		std::string proxy_address = getChild<LLUICtrl>("web_proxy_editor")->getValue();
+		int proxy_port = getChild<LLUICtrl>("web_proxy_port")->getValue();
+		LLViewerMedia::setProxyConfig(proxy_enable, proxy_address, proxy_port);
+	}
+	
+	if (mGotPersonalInfo)
+	{ 
+		bool new_im_via_email = getChild<LLUICtrl>("send_im_to_email")->getValue().asBoolean();
+		bool new_hide_online = getChild<LLUICtrl>("online_visibility")->getValue().asBoolean();		
+	
+		if ((new_im_via_email != mOriginalIMViaEmail)
+			||(new_hide_online != mOriginalHideOnlineStatus))
+		{
+			// This hack is because we are representing several different 	 
+			// possible strings with a single checkbox. Since most users 	 
+			// can only select between 2 values, we represent it as a 	 
+			// checkbox. This breaks down a little bit for liaisons, but 	 
+			// works out in the end. 	 
+			if (new_hide_online != mOriginalHideOnlineStatus)
+			{
+				if (new_hide_online) mDirectoryVisibility = VISIBILITY_HIDDEN;
+				else mDirectoryVisibility = VISIBILITY_DEFAULT;
+			 //Update showonline value, otherwise multiple applys won't work
+				mOriginalHideOnlineStatus = new_hide_online;
+			}
+			gAgent.sendAgentUpdateUserInfo(new_im_via_email,mDirectoryVisibility);
+		}
+	}
+
+	saveAvatarProperties();
+
+	if (mClickActionDirty)
+	{
+		updateClickActionSettings();
+		mClickActionDirty = false;
+	}
 }
 
 void LLFloaterPreference::cancel()
 {
-    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-    // Call cancel() on all panels that derive from LLPanelPreference
-    for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-        iter != tabcontainer->getChildList()->end(); ++iter)
-    {
-        LLView* view = *iter;
-        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-        if (panel)
-            panel->cancel();
-    }
-    // hide joystick pref floater
-    LLFloaterReg::hideInstance("pref_joystick");
-
-    // hide translation settings floater
-    LLFloaterReg::hideInstance("prefs_translation");
-    
-    // hide autoreplace settings floater
-    LLFloaterReg::hideInstance("prefs_autoreplace");
-    
-    // hide spellchecker settings folder
-    LLFloaterReg::hideInstance("prefs_spellchecker");
-
-    // hide advanced graphics floater
-    LLFloaterReg::hideInstance("prefs_graphics_advanced");
-    
-    // reverts any changes to current skin
-    gSavedSettings.setString("SkinCurrent", sSkin);
-
-    if (mClickActionDirty)
-    {
-        updateClickActionControls();
-        mClickActionDirty = false;
-    }
-
-    LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy");
-    if (advanced_proxy_settings)
-    {
-        advanced_proxy_settings->cancel();
-    }
-    //Need to reload the navmesh if the pathing console is up
-    LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
-    if ( !pathfindingConsoleHandle.isDead() )
-    {
-        LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
-        pPathfindingConsole->onRegionBoundaryCross();
-    }
-
-    if (!mSavedGraphicsPreset.empty())
-    {
-        gSavedSettings.setString("PresetGraphicActive", mSavedGraphicsPreset);
-        LLPresetsManager::getInstance()->triggerChangeSignal();
-    }
+	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+	// Call cancel() on all panels that derive from LLPanelPreference
+	for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+		iter != tabcontainer->getChildList()->end(); ++iter)
+	{
+		LLView* view = *iter;
+		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+		if (panel)
+			panel->cancel();
+	}
+	// hide joystick pref floater
+	LLFloaterReg::hideInstance("pref_joystick");
+
+	// hide translation settings floater
+	LLFloaterReg::hideInstance("prefs_translation");
+	
+	// hide autoreplace settings floater
+	LLFloaterReg::hideInstance("prefs_autoreplace");
+	
+	// hide spellchecker settings folder
+	LLFloaterReg::hideInstance("prefs_spellchecker");
+
+	// hide advanced graphics floater
+	LLFloaterReg::hideInstance("prefs_graphics_advanced");
+	
+	// reverts any changes to current skin
+	gSavedSettings.setString("SkinCurrent", sSkin);
+
+	if (mClickActionDirty)
+	{
+		updateClickActionControls();
+		mClickActionDirty = false;
+	}
+
+	LLFloaterPreferenceProxy * advanced_proxy_settings = LLFloaterReg::findTypedInstance<LLFloaterPreferenceProxy>("prefs_proxy");
+	if (advanced_proxy_settings)
+	{
+		advanced_proxy_settings->cancel();
+	}
+	//Need to reload the navmesh if the pathing console is up
+	LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
+	if ( !pathfindingConsoleHandle.isDead() )
+	{
+		LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
+		pPathfindingConsole->onRegionBoundaryCross();
+	}
+
+	if (!mSavedGraphicsPreset.empty())
+	{
+		gSavedSettings.setString("PresetGraphicActive", mSavedGraphicsPreset);
+		LLPresetsManager::getInstance()->triggerChangeSignal();
+	}
 }
 
 void LLFloaterPreference::onOpen(const LLSD& key)
 {
 
-    // this variable and if that follows it are used to properly handle do not disturb mode response message
-    static bool initialized = FALSE;
-    // if user is logged in and we haven't initialized do not disturb mode response yet, do it
-    if (!initialized && LLStartUp::getStartupState() == STATE_STARTED)
-    {
-        // Special approach is used for do not disturb response localization, because "DoNotDisturbModeResponse" is
-        // in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized.
-        // To keep track of whether do not disturb response is default or changed by user additional setting DoNotDisturbResponseChanged
-        // was added into per account settings.
-
-        // initialization should happen once,so setting variable to TRUE
-        initialized = TRUE;
-        // this connection is needed to properly set "DoNotDisturbResponseChanged" setting when user makes changes in
-        // do not disturb response message.
-        gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onDoNotDisturbResponseChanged, this));
-    }
-    gAgent.sendAgentUserInfoRequest();
-
-    /////////////////////////// From LLPanelGeneral //////////////////////////
-    // if we have no agent, we can't let them choose anything
-    // if we have an agent, then we only let them choose if they have a choice
-    bool can_choose_maturity =
-        gAgent.getID().notNull() &&
-        (gAgent.isMature() || gAgent.isGodlike());
-    
-    LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox");
-    LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() );
-    if (can_choose_maturity)
-    {       
-        // if they're not adult or a god, they shouldn't see the adult selection, so delete it
-        if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery())
-        {
-            // we're going to remove the adult entry from the combo
-            LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox");
-            if (maturity_list)
-            {
-                maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT));
-            }
-        }
-        getChildView("maturity_desired_combobox")->setEnabled( true);
-        getChildView("maturity_desired_textbox")->setVisible( false);
-    }
-    else
-    {
-        getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel());
-        getChildView("maturity_desired_combobox")->setEnabled( false);
-    }
-
-    // Forget previous language changes.
-    mLanguageChanged = false;
-
-    // Display selected maturity icons.
-    onChangeMaturity();
-
-    onChangeModelFolder();
-    onChangeTextureFolder();
-    onChangeSoundFolder();
-    onChangeAnimationFolder();
-
-    // Load (double-)click to walk/teleport settings.
-    updateClickActionControls();
-    
-    // Enabled/disabled popups, might have been changed by user actions
-    // while preferences floater was closed.
-    buildPopupLists();
-
-
-    //get the options that were checked
-    onNotificationsChange("FriendIMOptions");
-    onNotificationsChange("NonFriendIMOptions");
-    onNotificationsChange("ConferenceIMOptions");
-    onNotificationsChange("GroupChatOptions");
-    onNotificationsChange("NearbyChatOptions");
-    onNotificationsChange("ObjectIMOptions");
-
-    LLPanelLogin::setAlwaysRefresh(true);
-    refresh();
-    
-    // Make sure the current state of prefs are saved away when
-    // when the floater is opened.  That will make cancel do its
-    // job
-    saveSettings();
-
-    // Make sure there is a default preference file
-    LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA);
-    LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC);
-
-    bool started = (LLStartUp::getStartupState() == STATE_STARTED);
-
-    LLButton* load_btn = findChild<LLButton>("PrefLoadButton");
-    LLButton* save_btn = findChild<LLButton>("PrefSaveButton");
-    LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton");
-    LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton");
-
-    if (load_btn && save_btn && delete_btn && exceptions_btn)
-    {
-        load_btn->setEnabled(started);
-        save_btn->setEnabled(started);
-        delete_btn->setEnabled(started);
-        exceptions_btn->setEnabled(started);
-    }
-
-    LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
-    LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton");
-    LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton");
-
-    if (load_camera_btn && save_camera_btn && delete_camera_btn)
-    {
-        load_camera_btn->setEnabled(started);
-        save_camera_btn->setEnabled(started);
-        delete_camera_btn->setEnabled(started);
-    }
+	// this variable and if that follows it are used to properly handle do not disturb mode response message
+	static bool initialized = FALSE;
+	// if user is logged in and we haven't initialized do not disturb mode response yet, do it
+	if (!initialized && LLStartUp::getStartupState() == STATE_STARTED)
+	{
+		// Special approach is used for do not disturb response localization, because "DoNotDisturbModeResponse" is
+		// in non-localizable xml, and also because it may be changed by user and in this case it shouldn't be localized.
+		// To keep track of whether do not disturb response is default or changed by user additional setting DoNotDisturbResponseChanged
+		// was added into per account settings.
+
+		// initialization should happen once,so setting variable to TRUE
+		initialized = TRUE;
+		// this connection is needed to properly set "DoNotDisturbResponseChanged" setting when user makes changes in
+		// do not disturb response message.
+		gSavedPerAccountSettings.getControl("DoNotDisturbModeResponse")->getSignal()->connect(boost::bind(&LLFloaterPreference::onDoNotDisturbResponseChanged, this));
+	}
+	gAgent.sendAgentUserInfoRequest();
+
+	/////////////////////////// From LLPanelGeneral //////////////////////////
+	// if we have no agent, we can't let them choose anything
+	// if we have an agent, then we only let them choose if they have a choice
+	bool can_choose_maturity =
+		gAgent.getID().notNull() &&
+		(gAgent.isMature() || gAgent.isGodlike());
+	
+	LLComboBox* maturity_combo = getChild<LLComboBox>("maturity_desired_combobox");
+	LLAvatarPropertiesProcessor::getInstance()->sendAvatarPropertiesRequest( gAgent.getID() );
+	if (can_choose_maturity)
+	{		
+		// if they're not adult or a god, they shouldn't see the adult selection, so delete it
+		if (!gAgent.isAdult() && !gAgent.isGodlikeWithoutAdminMenuFakery())
+		{
+			// we're going to remove the adult entry from the combo
+			LLScrollListCtrl* maturity_list = maturity_combo->findChild<LLScrollListCtrl>("ComboBox");
+			if (maturity_list)
+			{
+				maturity_list->deleteItems(LLSD(SIM_ACCESS_ADULT));
+			}
+		}
+		getChildView("maturity_desired_combobox")->setEnabled( true);
+		getChildView("maturity_desired_textbox")->setVisible( false);
+	}
+	else
+	{
+		getChild<LLUICtrl>("maturity_desired_textbox")->setValue(maturity_combo->getSelectedItemLabel());
+		getChildView("maturity_desired_combobox")->setEnabled( false);
+	}
+
+	// Forget previous language changes.
+	mLanguageChanged = false;
+
+	// Display selected maturity icons.
+	onChangeMaturity();
+
+	onChangeModelFolder();
+	onChangeTextureFolder();
+	onChangeSoundFolder();
+	onChangeAnimationFolder();
+
+	// Load (double-)click to walk/teleport settings.
+	updateClickActionControls();
+	
+	// Enabled/disabled popups, might have been changed by user actions
+	// while preferences floater was closed.
+	buildPopupLists();
+
+
+	//get the options that were checked
+	onNotificationsChange("FriendIMOptions");
+	onNotificationsChange("NonFriendIMOptions");
+	onNotificationsChange("ConferenceIMOptions");
+	onNotificationsChange("GroupChatOptions");
+	onNotificationsChange("NearbyChatOptions");
+	onNotificationsChange("ObjectIMOptions");
+
+	LLPanelLogin::setAlwaysRefresh(true);
+	refresh();
+	
+	// Make sure the current state of prefs are saved away when
+	// when the floater is opened.  That will make cancel do its
+	// job
+	saveSettings();
+
+	// Make sure there is a default preference file
+	LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA);
+	LLPresetsManager::getInstance()->createMissingDefault(PRESETS_GRAPHIC);
+
+	bool started = (LLStartUp::getStartupState() == STATE_STARTED);
+
+	LLButton* load_btn = findChild<LLButton>("PrefLoadButton");
+	LLButton* save_btn = findChild<LLButton>("PrefSaveButton");
+	LLButton* delete_btn = findChild<LLButton>("PrefDeleteButton");
+	LLButton* exceptions_btn = findChild<LLButton>("RenderExceptionsButton");
+
+	if (load_btn && save_btn && delete_btn && exceptions_btn)
+	{
+		load_btn->setEnabled(started);
+		save_btn->setEnabled(started);
+		delete_btn->setEnabled(started);
+		exceptions_btn->setEnabled(started);
+	}
+
+	LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
+	LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton");
+	LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton");
+
+	if (load_camera_btn && save_camera_btn && delete_camera_btn)
+	{
+		load_camera_btn->setEnabled(started);
+		save_camera_btn->setEnabled(started);
+		delete_camera_btn->setEnabled(started);
+	}
 }
 
 void LLFloaterPreference::onVertexShaderEnable()
 {
-    refreshEnabledGraphics();
+	refreshEnabledGraphics();
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable()
 {
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->refresh();
-    }
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance)
+	{
+		instance->refresh();
+	}
 
-    refreshEnabledGraphics();
+	refreshEnabledGraphics();
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledGraphics()
 {
-    refreshEnabledState();
+	refreshEnabledState();
 }
 
 void LLFloaterPreference::onAvatarImpostorsEnable()
 {
-    refreshEnabledGraphics();
+	refreshEnabledGraphics();
 }
 
 //static
 void LLFloaterPreference::initDoNotDisturbResponse()
-    {
-        if (!gSavedPerAccountSettings.getBOOL("DoNotDisturbResponseChanged"))
-        {
-            //LLTrans::getString("DoNotDisturbModeResponseDefault") is used here for localization (EXT-5885)
-            gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
-        }
-    }
+	{
+		if (!gSavedPerAccountSettings.getBOOL("DoNotDisturbResponseChanged"))
+		{
+			//LLTrans::getString("DoNotDisturbModeResponseDefault") is used here for localization (EXT-5885)
+			gSavedPerAccountSettings.setString("DoNotDisturbModeResponse", LLTrans::getString("DoNotDisturbModeResponseDefault"));
+		}
+	}
 
 //static 
 void LLFloaterPreference::updateShowFavoritesCheckbox(bool val)
 {
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->getChild<LLUICtrl>("favorites_on_login_check")->setValue(val);
-    }   
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance)
+	{
+		instance->getChild<LLUICtrl>("favorites_on_login_check")->setValue(val);
+	}	
 }
 
 void LLFloaterPreference::setHardwareDefaults()
 {
-    std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-    if (!preset_graphic_active.empty())
-    {
-        saveGraphicsPreset(preset_graphic_active);
-        saveSettings(); // save here to be able to return to the previous preset by Cancel
-    }
+	std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+	if (!preset_graphic_active.empty())
+	{
+		saveGraphicsPreset(preset_graphic_active);
+		saveSettings(); // save here to be able to return to the previous preset by Cancel
+	}
 
-    LLFeatureManager::getInstance()->applyRecommendedSettings();
+	LLFeatureManager::getInstance()->applyRecommendedSettings();
 
-    // reset indirects before refresh because we may have changed what they control
-    LLAvatarComplexityControls::setIndirectControls(); 
+	// reset indirects before refresh because we may have changed what they control
+	LLAvatarComplexityControls::setIndirectControls(); 
 
-    refreshEnabledGraphics();
-    gSavedSettings.setString("PresetGraphicActive", "");
-    LLPresetsManager::getInstance()->triggerChangeSignal();
+	refreshEnabledGraphics();
+	gSavedSettings.setString("PresetGraphicActive", "");
+	LLPresetsManager::getInstance()->triggerChangeSignal();
 
-    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-    child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-    child_list_t::const_iterator end = tabcontainer->getChildList()->end();
-    for ( ; iter != end; ++iter)
-    {
-        LLView* view = *iter;
-        LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
-        if (panel)
-        {
-            panel->setHardwareDefaults();
-        }
-    }
+	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+	child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+	child_list_t::const_iterator end = tabcontainer->getChildList()->end();
+	for ( ; iter != end; ++iter)
+	{
+		LLView* view = *iter;
+		LLPanelPreference* panel = dynamic_cast<LLPanelPreference*>(view);
+		if (panel)
+		{
+			panel->setHardwareDefaults();
+		}
+	}
 }
 
 void LLFloaterPreference::getControlNames(std::vector<std::string>& names)
 {
-    LLView* view = findChild<LLView>("display");
-    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-    if (view && advanced)
-    {
-        std::list<LLView*> stack;
-        stack.push_back(view);
-        stack.push_back(advanced);
-        while(!stack.empty())
-        {
-            // Process view on top of the stack
-            LLView* curview = stack.front();
-            stack.pop_front();
-
-            LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-            if (ctrl)
-            {
-                LLControlVariable* control = ctrl->getControlVariable();
-                if (control)
-                {
-                    std::string control_name = control->getName();
-                    if (std::find(names.begin(), names.end(), control_name) == names.end())
-                    {
-                        names.push_back(control_name);
-                    }
-                }
-            }
-
-            for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-                iter != curview->getChildList()->end(); ++iter)
-            {
-                stack.push_back(*iter);
-            }
-        }
-    }
+	LLView* view = findChild<LLView>("display");
+	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+	if (view && advanced)
+	{
+		std::list<LLView*> stack;
+		stack.push_back(view);
+		stack.push_back(advanced);
+		while(!stack.empty())
+		{
+			// Process view on top of the stack
+			LLView* curview = stack.front();
+			stack.pop_front();
+
+			LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+			if (ctrl)
+			{
+				LLControlVariable* control = ctrl->getControlVariable();
+				if (control)
+				{
+					std::string control_name = control->getName();
+					if (std::find(names.begin(), names.end(), control_name) == names.end())
+					{
+						names.push_back(control_name);
+					}
+				}
+			}
+
+			for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+				iter != curview->getChildList()->end(); ++iter)
+			{
+				stack.push_back(*iter);
+			}
+		}
+	}
 }
 
 //virtual
 void LLFloaterPreference::onClose(bool app_quitting)
 {
-    gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
-    LLPanelLogin::setAlwaysRefresh(false);
-    if (!app_quitting)
-    {
-        cancel();
-    }
+	gSavedSettings.setS32("LastPrefTab", getChild<LLTabContainer>("pref core")->getCurrentPanelIndex());
+	LLPanelLogin::setAlwaysRefresh(false);
+	if (!app_quitting)
+	{
+		cancel();
+	}
 }
 
 // static 
 void LLFloaterPreference::onBtnOK(const LLSD& userdata)
 {
-    // commit any outstanding text entry
-    if (hasFocus())
-    {
-        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-        if (cur_focus && cur_focus->acceptsTextInput())
-        {
-            cur_focus->onCommit();
-        }
-    }
-
-    if (canClose())
-    {
-        saveSettings();
-        apply();
-        
-        if (userdata.asString() == "closeadvanced")
-        {
-            LLFloaterReg::hideInstance("prefs_graphics_advanced");
-        }
-        else
-        {
-            closeFloater(false);
-        }
-
-        //Conversation transcript and log path changed so reload conversations based on new location
-        if(mPriorInstantMessageLogPath.length())
-        {
-            if(moveTranscriptsAndLog())
-            {
-                //When floaters are empty but have a chat history files, reload chat history into them
-                LLFloaterIMSessionTab::reloadEmptyFloaters();
-            }
-            //Couldn't move files so restore the old path and show a notification
-            else
-            {
-                gSavedPerAccountSettings.setString("InstantMessageLogPath", mPriorInstantMessageLogPath);
-                LLNotificationsUtil::add("PreferenceChatPathChanged");
-            }
-            mPriorInstantMessageLogPath.clear();
-        }
-
-        LLUIColorTable::instance().saveUserSettings();
-        gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
-        
-        //Only save once logged in and loaded per account settings
-        if(mGotPersonalInfo)
-        {
-            gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
-    }
-    }
-    else
-    {
-        // Show beep, pop up dialog, etc.
-        LL_INFOS() << "Can't close preferences!" << LL_ENDL;
-    }
-
-    LLPanelLogin::updateLocationSelectorsVisibility();  
-    //Need to reload the navmesh if the pathing console is up
-    LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
-    if ( !pathfindingConsoleHandle.isDead() )
-    {
-        LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
-        pPathfindingConsole->onRegionBoundaryCross();
-    }
+	// commit any outstanding text entry
+	if (hasFocus())
+	{
+		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+		if (cur_focus && cur_focus->acceptsTextInput())
+		{
+			cur_focus->onCommit();
+		}
+	}
+
+	if (canClose())
+	{
+		saveSettings();
+		apply();
+		
+		if (userdata.asString() == "closeadvanced")
+		{
+			LLFloaterReg::hideInstance("prefs_graphics_advanced");
+		}
+		else
+		{
+			closeFloater(false);
+		}
+
+		//Conversation transcript and log path changed so reload conversations based on new location
+		if(mPriorInstantMessageLogPath.length())
+		{
+			if(moveTranscriptsAndLog())
+			{
+				//When floaters are empty but have a chat history files, reload chat history into them
+				LLFloaterIMSessionTab::reloadEmptyFloaters();
+			}
+			//Couldn't move files so restore the old path and show a notification
+			else
+			{
+				gSavedPerAccountSettings.setString("InstantMessageLogPath", mPriorInstantMessageLogPath);
+				LLNotificationsUtil::add("PreferenceChatPathChanged");
+			}
+			mPriorInstantMessageLogPath.clear();
+		}
+
+		LLUIColorTable::instance().saveUserSettings();
+		gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
+		
+		//Only save once logged in and loaded per account settings
+		if(mGotPersonalInfo)
+		{
+			gSavedPerAccountSettings.saveToFile(gSavedSettings.getString("PerAccountSettingsFile"), TRUE);
+	}
+	}
+	else
+	{
+		// Show beep, pop up dialog, etc.
+		LL_INFOS() << "Can't close preferences!" << LL_ENDL;
+	}
+
+	LLPanelLogin::updateLocationSelectorsVisibility();	
+	//Need to reload the navmesh if the pathing console is up
+	LLHandle<LLFloaterPathfindingConsole> pathfindingConsoleHandle = LLFloaterPathfindingConsole::getInstanceHandle();
+	if ( !pathfindingConsoleHandle.isDead() )
+	{
+		LLFloaterPathfindingConsole* pPathfindingConsole = pathfindingConsoleHandle.get();
+		pPathfindingConsole->onRegionBoundaryCross();
+	}
 }
 
 // static 
 void LLFloaterPreference::onBtnCancel(const LLSD& userdata)
 {
-    if (hasFocus())
-    {
-        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-        if (cur_focus && cur_focus->acceptsTextInput())
-        {
-            cur_focus->onCommit();
-        }
-        refresh();
-    }
-    cancel();
-
-    if (userdata.asString() == "closeadvanced")
-    {
-        LLFloaterReg::hideInstance("prefs_graphics_advanced");
-    }
-    else
-    {
-        closeFloater();
-    }
+	if (hasFocus())
+	{
+		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+		if (cur_focus && cur_focus->acceptsTextInput())
+		{
+			cur_focus->onCommit();
+		}
+		refresh();
+	}
+	cancel();
+
+	if (userdata.asString() == "closeadvanced")
+	{
+		LLFloaterReg::hideInstance("prefs_graphics_advanced");
+	}
+	else
+	{
+		closeFloater();
+	}
 }
 
 // static 
 void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email)
 {
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance)
+	{
         instance->setPersonalInfo(visibility, im_via_email, is_verified_email);
-    }
+	}
 }
 
 void LLFloaterPreference::refreshEnabledGraphics()
 {
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->refresh();
-    }
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance)
+	{
+		instance->refresh();
+	}
 
-    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-    if (advanced)
-    {
-        advanced->refresh();
-    }
+	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+	if (advanced)
+	{
+		advanced->refresh();
+	}
 }
 
 void LLFloaterPreference::onClickClearCache()
 {
-    LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache);
+	LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache);
 }
 
 void LLFloaterPreference::onClickBrowserClearCache()
 {
-    LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache);
+	LLNotificationsUtil::add("ConfirmClearBrowserCache", LLSD(), LLSD(), callback_clear_browser_cache);
 }
 
 // Called when user changes language via the combobox.
 void LLFloaterPreference::onLanguageChange()
 {
-    // Let the user know that the change will only take effect after restart.
-    // Do it only once so that we're not too irritating.
-    if (!mLanguageChanged)
-    {
-        LLNotificationsUtil::add("ChangeLanguage");
-        mLanguageChanged = true;
-    }
+	// Let the user know that the change will only take effect after restart.
+	// Do it only once so that we're not too irritating.
+	if (!mLanguageChanged)
+	{
+		LLNotificationsUtil::add("ChangeLanguage");
+		mLanguageChanged = true;
+	}
 }
 
 void LLFloaterPreference::onNotificationsChange(const std::string& OptionName)
 {
-    mNotificationOptions[OptionName] = getChild<LLComboBox>(OptionName)->getSelectedItemLabel();
+	mNotificationOptions[OptionName] = getChild<LLComboBox>(OptionName)->getSelectedItemLabel();
 
-    bool show_notifications_alert = true;
-    for (notifications_map::iterator it_notification = mNotificationOptions.begin(); it_notification != mNotificationOptions.end(); it_notification++)
-    {
-        if(it_notification->second != "No action")
-        {
-            show_notifications_alert = false;
-            break;
-        }
-    }
+	bool show_notifications_alert = true;
+	for (notifications_map::iterator it_notification = mNotificationOptions.begin(); it_notification != mNotificationOptions.end(); it_notification++)
+	{
+		if(it_notification->second != "No action")
+		{
+			show_notifications_alert = false;
+			break;
+		}
+	}
 
-    getChild<LLTextBox>("notifications_alert")->setVisible(show_notifications_alert);
+	getChild<LLTextBox>("notifications_alert")->setVisible(show_notifications_alert);
 }
 
 void LLFloaterPreference::onNameTagOpacityChange(const LLSD& newvalue)
 {
-    LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background");
-    if (color_swatch)
-    {
-        LLColor4 new_color = color_swatch->get();
-        color_swatch->set( new_color.setAlpha(newvalue.asReal()) );
-    }
+	LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>("background");
+	if (color_swatch)
+	{
+		LLColor4 new_color = color_swatch->get();
+		color_swatch->set( new_color.setAlpha(newvalue.asReal()) );
+	}
 }
 
 void LLFloaterPreference::onClickSetCache()
 {
-    std::string cur_name(gSavedSettings.getString("CacheLocation"));
-//  std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name));
-    
-    std::string proposed_name(cur_name);
+	std::string cur_name(gSavedSettings.getString("CacheLocation"));
+//	std::string cur_top_folder(gDirUtilp->getBaseFileName(cur_name));
+	
+	std::string proposed_name(cur_name);
 
-    (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeCachePath, this, _1, _2), proposed_name))->getFile();
+	(new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeCachePath, this, _1, _2), proposed_name))->getFile();
 }
 
 void LLFloaterPreference::changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name)
 {
-    std::string dir_name = filenames[0];
-    if (!dir_name.empty() && dir_name != proposed_name)
-    {
-        std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name));
-        LLNotificationsUtil::add("CacheWillBeMoved");
-        gSavedSettings.setString("NewCacheLocation", dir_name);
-        gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder);
-    }
-    else
-    {
-        std::string cache_location = gDirUtilp->getCacheDir();
-        gSavedSettings.setString("CacheLocation", cache_location);
-        std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
-        gSavedSettings.setString("CacheLocationTopFolder", top_folder);
-    }
+	std::string dir_name = filenames[0];
+	if (!dir_name.empty() && dir_name != proposed_name)
+	{
+		std::string new_top_folder(gDirUtilp->getBaseFileName(dir_name));
+		LLNotificationsUtil::add("CacheWillBeMoved");
+		gSavedSettings.setString("NewCacheLocation", dir_name);
+		gSavedSettings.setString("NewCacheLocationTopFolder", new_top_folder);
+	}
+	else
+	{
+		std::string cache_location = gDirUtilp->getCacheDir();
+		gSavedSettings.setString("CacheLocation", cache_location);
+		std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
+		gSavedSettings.setString("CacheLocationTopFolder", top_folder);
+	}
 }
 
 void LLFloaterPreference::onClickResetCache()
 {
-    if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true))
-    {
-        // The cache location was already the default.
-        return;
-    }
-    gSavedSettings.setString("NewCacheLocation", "");
-    gSavedSettings.setString("NewCacheLocationTopFolder", "");
-    LLNotificationsUtil::add("CacheWillBeMoved");
-    std::string cache_location = gDirUtilp->getCacheDir(false);
-    gSavedSettings.setString("CacheLocation", cache_location);
-    std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
-    gSavedSettings.setString("CacheLocationTopFolder", top_folder);
+	if (gDirUtilp->getCacheDir(false) == gDirUtilp->getCacheDir(true))
+	{
+		// The cache location was already the default.
+		return;
+	}
+	gSavedSettings.setString("NewCacheLocation", "");
+	gSavedSettings.setString("NewCacheLocationTopFolder", "");
+	LLNotificationsUtil::add("CacheWillBeMoved");
+	std::string cache_location = gDirUtilp->getCacheDir(false);
+	gSavedSettings.setString("CacheLocation", cache_location);
+	std::string top_folder(gDirUtilp->getBaseFileName(cache_location));
+	gSavedSettings.setString("CacheLocationTopFolder", top_folder);
 }
 
 void LLFloaterPreference::onClickSkin(LLUICtrl* ctrl, const LLSD& userdata)
 {
-    gSavedSettings.setString("SkinCurrent", userdata.asString());
-    ctrl->setValue(userdata.asString());
+	gSavedSettings.setString("SkinCurrent", userdata.asString());
+	ctrl->setValue(userdata.asString());
 }
 
 void LLFloaterPreference::onSelectSkin()
 {
-    std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString();
-    gSavedSettings.setString("SkinCurrent", skin_selection);
+	std::string skin_selection = getChild<LLRadioGroup>("skin_selection")->getValue().asString();
+	gSavedSettings.setString("SkinCurrent", skin_selection);
 }
 
 void LLFloaterPreference::refreshSkin(void* data)
 {
-    LLPanel*self = (LLPanel*)data;
-    sSkin = gSavedSettings.getString("SkinCurrent");
-    self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin);
+	LLPanel*self = (LLPanel*)data;
+	sSkin = gSavedSettings.getString("SkinCurrent");
+	self->getChild<LLRadioGroup>("skin_selection", true)->setValue(sSkin);
 }
 
 void LLFloaterPreference::buildPopupLists()
 {
-    LLScrollListCtrl& disabled_popups =
-        getChildRef<LLScrollListCtrl>("disabled_popups");
-    LLScrollListCtrl& enabled_popups =
-        getChildRef<LLScrollListCtrl>("enabled_popups");
-    
-    disabled_popups.deleteAllItems();
-    enabled_popups.deleteAllItems();
-    
-    for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
-         iter != LLNotifications::instance().templatesEnd();
-         ++iter)
-    {
-        LLNotificationTemplatePtr templatep = iter->second;
-        LLNotificationFormPtr formp = templatep->mForm;
-        
-        LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType();
-        if (ignore == LLNotificationForm::IGNORE_NO)
-            continue;
-        
-        LLSD row;
-        row["columns"][0]["value"] = formp->getIgnoreMessage();
-        row["columns"][0]["font"] = "SANSSERIF_SMALL";
-        row["columns"][0]["width"] = 400;
-        
-        LLScrollListItem* item = NULL;
-        
-        bool show_popup = !formp->getIgnored();
-        if (!show_popup)
-        {
-            if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
-            {
-                LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
-                if (!last_response.isUndefined())
-                {
-                    for (LLSD::map_const_iterator it = last_response.beginMap();
-                         it != last_response.endMap();
-                         ++it)
-                    {
-                        if (it->second.asBoolean())
-                        {
-                            row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString();
-                            break;
-                        }
-                    }
-                }
-                row["columns"][1]["font"] = "SANSSERIF_SMALL";
-                row["columns"][1]["width"] = 360;
-            }
-            item = disabled_popups.addElement(row);
-        }
-        else
-        {
-            item = enabled_popups.addElement(row);
-        }
-        
-        if (item)
-        {
-            item->setUserdata((void*)&iter->first);
-        }
-    }
+	LLScrollListCtrl& disabled_popups =
+		getChildRef<LLScrollListCtrl>("disabled_popups");
+	LLScrollListCtrl& enabled_popups =
+		getChildRef<LLScrollListCtrl>("enabled_popups");
+	
+	disabled_popups.deleteAllItems();
+	enabled_popups.deleteAllItems();
+	
+	for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
+		 iter != LLNotifications::instance().templatesEnd();
+		 ++iter)
+	{
+		LLNotificationTemplatePtr templatep = iter->second;
+		LLNotificationFormPtr formp = templatep->mForm;
+		
+		LLNotificationForm::EIgnoreType ignore = formp->getIgnoreType();
+		if (ignore == LLNotificationForm::IGNORE_NO)
+			continue;
+		
+		LLSD row;
+		row["columns"][0]["value"] = formp->getIgnoreMessage();
+		row["columns"][0]["font"] = "SANSSERIF_SMALL";
+		row["columns"][0]["width"] = 400;
+		
+		LLScrollListItem* item = NULL;
+		
+		bool show_popup = !formp->getIgnored();
+		if (!show_popup)
+		{
+			if (ignore == LLNotificationForm::IGNORE_WITH_LAST_RESPONSE)
+			{
+				LLSD last_response = LLUI::sSettingGroups["config"]->getLLSD("Default" + templatep->mName);
+				if (!last_response.isUndefined())
+				{
+					for (LLSD::map_const_iterator it = last_response.beginMap();
+						 it != last_response.endMap();
+						 ++it)
+					{
+						if (it->second.asBoolean())
+						{
+							row["columns"][1]["value"] = formp->getElement(it->first)["ignore"].asString();
+							break;
+						}
+					}
+				}
+				row["columns"][1]["font"] = "SANSSERIF_SMALL";
+				row["columns"][1]["width"] = 360;
+			}
+			item = disabled_popups.addElement(row);
+		}
+		else
+		{
+			item = enabled_popups.addElement(row);
+		}
+		
+		if (item)
+		{
+			item->setUserdata((void*)&iter->first);
+		}
+	}
 }
 
 void LLFloaterPreference::refreshEnabledState()
 {
-    LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
 
-    // if vertex shaders off, disable all shader related products
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") ||
-        !LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
-    {
-        ctrl_wind_light->setEnabled(FALSE);
-        ctrl_wind_light->setValue(FALSE);
-    }
-    else
-    {
-        ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable"));
-    }
+	// if vertex shaders off, disable all shader related products
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable") ||
+		!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
+	{
+		ctrl_wind_light->setEnabled(FALSE);
+		ctrl_wind_light->setValue(FALSE);
+	}
+	else
+	{
+		ctrl_wind_light->setEnabled(gSavedSettings.getBOOL("VertexShaderEnable"));
+	}
 
-    //Deferred/SSAO/Shadows
-    BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump");
-    BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable");
-    BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-                        bumpshiny &&
-                        shaders && 
-                        gGLManager.mHasFramebufferObject &&
-                        gSavedSettings.getBOOL("RenderAvatarVP") &&
-                        (ctrl_wind_light->get()) ? TRUE : FALSE;
+	//Deferred/SSAO/Shadows
+	BOOL bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump") && gSavedSettings.getBOOL("RenderObjectBump");
+	BOOL shaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders") && gSavedSettings.getBOOL("VertexShaderEnable");
+	BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+						bumpshiny &&
+						shaders && 
+						gGLManager.mHasFramebufferObject &&
+						gSavedSettings.getBOOL("RenderAvatarVP") &&
+						(ctrl_wind_light->get()) ? TRUE : FALSE;
 
-    ctrl_deferred->setEnabled(enabled);
+	ctrl_deferred->setEnabled(enabled);
 
-    // Cannot have floater active until caps have been received
-    getChild<LLButton>("default_creation_permissions")->setEnabled(LLStartUp::getStartupState() < STATE_STARTED ? false : true);
+	// Cannot have floater active until caps have been received
+	getChild<LLButton>("default_creation_permissions")->setEnabled(LLStartUp::getStartupState() < STATE_STARTED ? false : true);
 
-    getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess());
+	getChildView("block_list")->setEnabled(LLLoginInstance::getInstance()->authSuccess());
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState()
 {
-    LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
-    LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
-
-    // Reflections
-    BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") 
-        && gGLManager.mHasCubeMap
-        && LLCubeMap::sUseCubeMaps;
-    ctrl_reflections->setEnabled(reflections);
-    reflections_text->setEnabled(reflections);
-    
-    // Bump & Shiny 
-    LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny");
-    bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
-    bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE);
-    
-    // Avatar Mode
-    // Enable Avatar Shaders
-    LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
-    // Avatar Render Mode
-    LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
+	LLComboBox* ctrl_reflections = getChild<LLComboBox>("Reflections");
+	LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
+
+	// Reflections
+	BOOL reflections = gSavedSettings.getBOOL("VertexShaderEnable") 
+		&& gGLManager.mHasCubeMap
+		&& LLCubeMap::sUseCubeMaps;
+	ctrl_reflections->setEnabled(reflections);
+	reflections_text->setEnabled(reflections);
+	
+	// Bump & Shiny	
+	LLCheckBoxCtrl* bumpshiny_ctrl = getChild<LLCheckBoxCtrl>("BumpShiny");
+	bool bumpshiny = gGLManager.mHasCubeMap && LLCubeMap::sUseCubeMaps && LLFeatureManager::getInstance()->isFeatureAvailable("RenderObjectBump");
+	bumpshiny_ctrl->setEnabled(bumpshiny ? TRUE : FALSE);
     
-    bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP");
-    if (LLViewerShaderMgr::sInitialized)
-    {
-        S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
-        avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE;
-    }
-
-    ctrl_avatar_vp->setEnabled(avatar_vp_enabled);
-    
-    if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || 
-        gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
-    {
-        ctrl_avatar_cloth->setEnabled(FALSE);
-    } 
-    else
-    {
-        ctrl_avatar_cloth->setEnabled(TRUE);
-    }
-    
-    // Vertex Shaders
-    // Global Shader Enable
-    LLCheckBoxCtrl* ctrl_shader_enable   = getChild<LLCheckBoxCtrl>("BasicShaders");
-    LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail");   // can be linked with control var
-    LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText");
-
-    ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"));
-    
-    BOOL shaders = ctrl_shader_enable->get();
-    if (shaders)
-    {
-        terrain_detail->setEnabled(FALSE);
-        terrain_text->setEnabled(FALSE);
-    }
-    else
-    {
-        terrain_detail->setEnabled(TRUE);
-        terrain_text->setEnabled(TRUE);
-    }
-    
-    // WindLight
-    LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-    LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
-    LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
-
-    // *HACK just checks to see if we can use shaders... 
-    // maybe some cards that use shaders, but don't support windlight
-    ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
-
-    sky->setEnabled(ctrl_wind_light->get() && shaders);
-    sky_text->setEnabled(ctrl_wind_light->get() && shaders);
-
-    //Deferred/SSAO/Shadows
-    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
-    
-    BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
-                        ((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) &&
-                        shaders && 
-                        gGLManager.mHasFramebufferObject &&
-                        gSavedSettings.getBOOL("RenderAvatarVP") &&
-                        (ctrl_wind_light->get()) ? TRUE : FALSE;
-
-    ctrl_deferred->setEnabled(enabled);
-
-    LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
-    LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
-    LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
-    LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText");
-
-    // note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it
-    enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
-    
-    ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred"));
-
-    ctrl_ssao->setEnabled(enabled);
-    ctrl_dof->setEnabled(enabled);
-
-    enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
-
-    ctrl_shadow->setEnabled(enabled);
-    shadow_text->setEnabled(enabled);
-
-    // Hardware settings
-    F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
-    S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
-    S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier);
-    getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value());
-    getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value());
-
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
-        !gGLManager.mHasVertexBufferObject)
-    {
-        getChildView("vbo")->setEnabled(FALSE);
-    }
-
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") ||
-        !gGLManager.mHasVertexBufferObject)
-    {
-        getChildView("texture compression")->setEnabled(FALSE);
-    }
-
-    // if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
-    LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma");
-    gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
-    getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
-    getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
-    getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"));
-
-    // now turn off any features that are unavailable
-    disableUnavailableSettings();
+	// Avatar Mode
+	// Enable Avatar Shaders
+	LLCheckBoxCtrl* ctrl_avatar_vp = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
+	// Avatar Render Mode
+	LLCheckBoxCtrl* ctrl_avatar_cloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
+	
+	bool avatar_vp_enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP");
+	if (LLViewerShaderMgr::sInitialized)
+	{
+		S32 max_avatar_shader = LLViewerShaderMgr::instance()->mMaxAvatarShaderLevel;
+		avatar_vp_enabled = (max_avatar_shader > 0) ? TRUE : FALSE;
+	}
+
+	ctrl_avatar_vp->setEnabled(avatar_vp_enabled);
+	
+	if (gSavedSettings.getBOOL("VertexShaderEnable") == FALSE || 
+		gSavedSettings.getBOOL("RenderAvatarVP") == FALSE)
+	{
+		ctrl_avatar_cloth->setEnabled(FALSE);
+	} 
+	else
+	{
+		ctrl_avatar_cloth->setEnabled(TRUE);
+	}
+	
+	// Vertex Shaders
+	// Global Shader Enable
+	LLCheckBoxCtrl* ctrl_shader_enable   = getChild<LLCheckBoxCtrl>("BasicShaders");
+	LLSliderCtrl* terrain_detail = getChild<LLSliderCtrl>("TerrainDetail");   // can be linked with control var
+	LLTextBox* terrain_text = getChild<LLTextBox>("TerrainDetailText");
+
+	ctrl_shader_enable->setEnabled(LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"));
+	
+	BOOL shaders = ctrl_shader_enable->get();
+	if (shaders)
+	{
+		terrain_detail->setEnabled(FALSE);
+		terrain_text->setEnabled(FALSE);
+	}
+	else
+	{
+		terrain_detail->setEnabled(TRUE);
+		terrain_text->setEnabled(TRUE);
+	}
+	
+	// WindLight
+	LLCheckBoxCtrl* ctrl_wind_light = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
+	LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
+	LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
+
+	// *HACK just checks to see if we can use shaders... 
+	// maybe some cards that use shaders, but don't support windlight
+	ctrl_wind_light->setEnabled(ctrl_shader_enable->getEnabled() && shaders);
+
+	sky->setEnabled(ctrl_wind_light->get() && shaders);
+	sky_text->setEnabled(ctrl_wind_light->get() && shaders);
+
+	//Deferred/SSAO/Shadows
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	
+	BOOL enabled = LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") &&
+						((bumpshiny_ctrl && bumpshiny_ctrl->get()) ? TRUE : FALSE) &&
+						shaders && 
+						gGLManager.mHasFramebufferObject &&
+						gSavedSettings.getBOOL("RenderAvatarVP") &&
+						(ctrl_wind_light->get()) ? TRUE : FALSE;
+
+	ctrl_deferred->setEnabled(enabled);
+
+	LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
+	LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
+	LLComboBox* ctrl_shadow = getChild<LLComboBox>("ShadowDetail");
+	LLTextBox* shadow_text = getChild<LLTextBox>("RenderShadowDetailText");
+
+	// note, okay here to get from ctrl_deferred as it's twin, ctrl_deferred2 will alway match it
+	enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO") && (ctrl_deferred->get() ? TRUE : FALSE);
+	
+	ctrl_deferred->set(gSavedSettings.getBOOL("RenderDeferred"));
+
+	ctrl_ssao->setEnabled(enabled);
+	ctrl_dof->setEnabled(enabled);
+
+	enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail");
+
+	ctrl_shadow->setEnabled(enabled);
+	shadow_text->setEnabled(enabled);
+
+	// Hardware settings
+	F32 mem_multiplier = gSavedSettings.getF32("RenderTextureMemoryMultiple");
+	S32Megabytes min_tex_mem = LLViewerTextureList::getMinVideoRamSetting();
+	S32Megabytes max_tex_mem = LLViewerTextureList::getMaxVideoRamSetting(false, mem_multiplier);
+	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMinValue(min_tex_mem.value());
+	getChild<LLSliderCtrl>("GraphicsCardTextureMemory")->setMaxValue(max_tex_mem.value());
+
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderVBOEnable") ||
+		!gGLManager.mHasVertexBufferObject)
+	{
+		getChildView("vbo")->setEnabled(FALSE);
+	}
+
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderCompressTextures") ||
+		!gGLManager.mHasVertexBufferObject)
+	{
+		getChildView("texture compression")->setEnabled(FALSE);
+	}
+
+	// if no windlight shaders, turn off nighttime brightness, gamma, and fog distance
+	LLUICtrl* gamma_ctrl = getChild<LLUICtrl>("gamma");
+	gamma_ctrl->setEnabled(!gPipeline.canUseWindLightShaders());
+	getChildView("(brightness, lower is brighter)")->setEnabled(!gPipeline.canUseWindLightShaders());
+	getChildView("fog")->setEnabled(!gPipeline.canUseWindLightShaders());
+	getChildView("antialiasing restart")->setVisible(!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred"));
+
+	// now turn off any features that are unavailable
+	disableUnavailableSettings();
 }
 
 // static
 void LLAvatarComplexityControls::setIndirectControls()
 {
-    /*
-     * We have controls that have an indirect relationship between the control
-     * values and adjacent text and the underlying setting they influence.
-     * In each case, the control and its associated setting are named Indirect<something>
-     * This method interrogates the controlled setting and establishes the
-     * appropriate value for the indirect control. It must be called whenever the
-     * underlying setting may have changed other than through the indirect control,
-     * such as when the 'Reset all to recommended settings' button is used...
-     */
-    setIndirectMaxNonImpostors();
-    setIndirectMaxArc();
+	/*
+	 * We have controls that have an indirect relationship between the control
+	 * values and adjacent text and the underlying setting they influence.
+	 * In each case, the control and its associated setting are named Indirect<something>
+	 * This method interrogates the controlled setting and establishes the
+	 * appropriate value for the indirect control. It must be called whenever the
+	 * underlying setting may have changed other than through the indirect control,
+	 * such as when the 'Reset all to recommended settings' button is used...
+	 */
+	setIndirectMaxNonImpostors();
+	setIndirectMaxArc();
 }
 
 // static
 void LLAvatarComplexityControls::setIndirectMaxNonImpostors()
 {
-    U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors");
-    // for this one, we just need to make zero, which means off, the max value of the slider
-    U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors;
-    gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors);
+	U32 max_non_impostors = gSavedSettings.getU32("RenderAvatarMaxNonImpostors");
+	// for this one, we just need to make zero, which means off, the max value of the slider
+	U32 indirect_max_non_impostors = (0 == max_non_impostors) ? LLVOAvatar::IMPOSTORS_OFF : max_non_impostors;
+	gSavedSettings.setU32("IndirectMaxNonImpostors", indirect_max_non_impostors);
 }
 
 void LLAvatarComplexityControls::setIndirectMaxArc()
 {
-    U32 max_arc = gSavedSettings.getU32("RenderAvatarMaxComplexity");
-    U32 indirect_max_arc;
-    if (0 == max_arc)
-    {
-        // the off position is all the way to the right, so set to control max
-        indirect_max_arc = INDIRECT_MAX_ARC_OFF;
-    }
-    else
-    {
-        // This is the inverse of the calculation in updateMaxComplexity
-        indirect_max_arc = (U32)ll_round(((log(F32(max_arc)) - MIN_ARC_LOG) / ARC_LIMIT_MAP_SCALE)) + MIN_INDIRECT_ARC_LIMIT;
-    }
-    gSavedSettings.setU32("IndirectMaxComplexity", indirect_max_arc);
+	U32 max_arc = gSavedSettings.getU32("RenderAvatarMaxComplexity");
+	U32 indirect_max_arc;
+	if (0 == max_arc)
+	{
+		// the off position is all the way to the right, so set to control max
+		indirect_max_arc = INDIRECT_MAX_ARC_OFF;
+	}
+	else
+	{
+		// This is the inverse of the calculation in updateMaxComplexity
+		indirect_max_arc = (U32)ll_round(((log(F32(max_arc)) - MIN_ARC_LOG) / ARC_LIMIT_MAP_SCALE)) + MIN_INDIRECT_ARC_LIMIT;
+	}
+	gSavedSettings.setU32("IndirectMaxComplexity", indirect_max_arc);
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::disableUnavailableSettings()
-{   
-    LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
-    LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
-    LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
-    LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
-    LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
-    LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
-    LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
-    LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
-    LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText");
-    LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
-    LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
-    LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
-    LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
-
-    // if vertex shaders off, disable all shader related products
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
-    {
-        ctrl_shader_enable->setEnabled(FALSE);
-        ctrl_shader_enable->setValue(FALSE);
-        
-        ctrl_wind_light->setEnabled(FALSE);
-        ctrl_wind_light->setValue(FALSE);
-
-        sky->setEnabled(FALSE);
-        sky_text->setEnabled(FALSE);
-
-        ctrl_reflections->setEnabled(FALSE);
-        ctrl_reflections->setValue(0);
-        reflections_text->setEnabled(FALSE);
-        
-        ctrl_avatar_vp->setEnabled(FALSE);
-        ctrl_avatar_vp->setValue(FALSE);
-        
-        ctrl_avatar_cloth->setEnabled(FALSE);
-        ctrl_avatar_cloth->setValue(FALSE);
-
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-        
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-    
-    // disabled windlight
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
-    {
-        ctrl_wind_light->setEnabled(FALSE);
-        ctrl_wind_light->setValue(FALSE);
-
-        sky->setEnabled(FALSE);
-        sky_text->setEnabled(FALSE);
-
-        //deferred needs windlight, disable deferred
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-        
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-
-    // disabled deferred
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") ||
-        !gGLManager.mHasFramebufferObject)
-    {
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-        
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-    
-    // disabled deferred SSAO
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
-    {
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-    }
-    
-    // disabled deferred shadows
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
-    {
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-    }
-
-    // disabled reflections
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
-    {
-        ctrl_reflections->setEnabled(FALSE);
-        ctrl_reflections->setValue(FALSE);
-        reflections_text->setEnabled(FALSE);
-    }
-    
-    // disabled av
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
-    {
-        ctrl_avatar_vp->setEnabled(FALSE);
-        ctrl_avatar_vp->setValue(FALSE);
-        
-        ctrl_avatar_cloth->setEnabled(FALSE);
-        ctrl_avatar_cloth->setValue(FALSE);
-
-        //deferred needs AvatarVP, disable deferred
-        ctrl_shadows->setEnabled(FALSE);
-        ctrl_shadows->setValue(0);
-        shadows_text->setEnabled(FALSE);
-        
-        ctrl_ssao->setEnabled(FALSE);
-        ctrl_ssao->setValue(FALSE);
-
-        ctrl_dof->setEnabled(FALSE);
-        ctrl_dof->setValue(FALSE);
-
-        ctrl_deferred->setEnabled(FALSE);
-        ctrl_deferred->setValue(FALSE);
-    }
-
-    // disabled cloth
-    if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
-    {
-        ctrl_avatar_cloth->setEnabled(FALSE);
-        ctrl_avatar_cloth->setValue(FALSE);
-    }
+{	
+	LLComboBox* ctrl_reflections   = getChild<LLComboBox>("Reflections");
+	LLTextBox* reflections_text = getChild<LLTextBox>("ReflectionsText");
+	LLCheckBoxCtrl* ctrl_avatar_vp     = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
+	LLCheckBoxCtrl* ctrl_avatar_cloth  = getChild<LLCheckBoxCtrl>("AvatarCloth");
+	LLCheckBoxCtrl* ctrl_shader_enable = getChild<LLCheckBoxCtrl>("BasicShaders");
+	LLCheckBoxCtrl* ctrl_wind_light    = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
+	LLCheckBoxCtrl* ctrl_deferred = getChild<LLCheckBoxCtrl>("UseLightShaders");
+	LLComboBox* ctrl_shadows = getChild<LLComboBox>("ShadowDetail");
+	LLTextBox* shadows_text = getChild<LLTextBox>("RenderShadowDetailText");
+	LLCheckBoxCtrl* ctrl_ssao = getChild<LLCheckBoxCtrl>("UseSSAO");
+	LLCheckBoxCtrl* ctrl_dof = getChild<LLCheckBoxCtrl>("UseDoF");
+	LLSliderCtrl* sky = getChild<LLSliderCtrl>("SkyMeshDetail");
+	LLTextBox* sky_text = getChild<LLTextBox>("SkyMeshDetailText");
+
+	// if vertex shaders off, disable all shader related products
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("VertexShaderEnable"))
+	{
+		ctrl_shader_enable->setEnabled(FALSE);
+		ctrl_shader_enable->setValue(FALSE);
+		
+		ctrl_wind_light->setEnabled(FALSE);
+		ctrl_wind_light->setValue(FALSE);
+
+		sky->setEnabled(FALSE);
+		sky_text->setEnabled(FALSE);
+
+		ctrl_reflections->setEnabled(FALSE);
+		ctrl_reflections->setValue(0);
+		reflections_text->setEnabled(FALSE);
+		
+		ctrl_avatar_vp->setEnabled(FALSE);
+		ctrl_avatar_vp->setValue(FALSE);
+		
+		ctrl_avatar_cloth->setEnabled(FALSE);
+		ctrl_avatar_cloth->setValue(FALSE);
+
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		shadows_text->setEnabled(FALSE);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_dof->setEnabled(FALSE);
+		ctrl_dof->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
+	}
+	
+	// disabled windlight
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"))
+	{
+		ctrl_wind_light->setEnabled(FALSE);
+		ctrl_wind_light->setValue(FALSE);
+
+		sky->setEnabled(FALSE);
+		sky_text->setEnabled(FALSE);
+
+		//deferred needs windlight, disable deferred
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		shadows_text->setEnabled(FALSE);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_dof->setEnabled(FALSE);
+		ctrl_dof->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
+	}
+
+	// disabled deferred
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferred") ||
+		!gGLManager.mHasFramebufferObject)
+	{
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		shadows_text->setEnabled(FALSE);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_dof->setEnabled(FALSE);
+		ctrl_dof->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
+	}
+	
+	// disabled deferred SSAO
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderDeferredSSAO"))
+	{
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+	}
+	
+	// disabled deferred shadows
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"))
+	{
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		shadows_text->setEnabled(FALSE);
+	}
+
+	// disabled reflections
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderReflectionDetail"))
+	{
+		ctrl_reflections->setEnabled(FALSE);
+		ctrl_reflections->setValue(FALSE);
+		reflections_text->setEnabled(FALSE);
+	}
+	
+	// disabled av
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarVP"))
+	{
+		ctrl_avatar_vp->setEnabled(FALSE);
+		ctrl_avatar_vp->setValue(FALSE);
+		
+		ctrl_avatar_cloth->setEnabled(FALSE);
+		ctrl_avatar_cloth->setValue(FALSE);
+
+		//deferred needs AvatarVP, disable deferred
+		ctrl_shadows->setEnabled(FALSE);
+		ctrl_shadows->setValue(0);
+		shadows_text->setEnabled(FALSE);
+		
+		ctrl_ssao->setEnabled(FALSE);
+		ctrl_ssao->setValue(FALSE);
+
+		ctrl_dof->setEnabled(FALSE);
+		ctrl_dof->setValue(FALSE);
+
+		ctrl_deferred->setEnabled(FALSE);
+		ctrl_deferred->setValue(FALSE);
+	}
+
+	// disabled cloth
+	if (!LLFeatureManager::getInstance()->isFeatureAvailable("RenderAvatarCloth"))
+	{
+		ctrl_avatar_cloth->setEnabled(FALSE);
+		ctrl_avatar_cloth->setValue(FALSE);
+	}
 }
 
 void LLFloaterPreference::refresh()
 {
-    LLPanel::refresh();
+	LLPanel::refresh();
     LLAvatarComplexityControls::setText(
         gSavedSettings.getU32("RenderAvatarMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText", true));
-    refreshEnabledState();
-    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-    if (advanced)
-    {
-        advanced->refresh();
-    }
+	refreshEnabledState();
+	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+	if (advanced)
+	{
+		advanced->refresh();
+	}
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::refresh()
 {
-    getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer)  gSavedSettings.getU32("RenderFSAASamples"));
-
-    // sliders and their text boxes
-    //  mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
-    // slider text boxes
-    updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail",     true), getChild<LLTextBox>("ObjectMeshDetailText",      true));
-    updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail",   true), getChild<LLTextBox>("FlexibleMeshDetailText",    true));
-    updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail",       true), getChild<LLTextBox>("TreeMeshDetailText",        true));
-    updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail",     true), getChild<LLTextBox>("AvatarMeshDetailText",      true));
-    updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail",  true), getChild<LLTextBox>("AvatarPhysicsDetailText",       true));
-    updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail",    true), getChild<LLTextBox>("TerrainMeshDetailText",     true));
-    updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess",    true), getChild<LLTextBox>("PostProcessText",           true));
-    updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail",        true), getChild<LLTextBox>("SkyMeshDetailText",         true));
-    updateSliderText(getChild<LLSliderCtrl>("TerrainDetail",        true), getChild<LLTextBox>("TerrainDetailText",         true)); 
+	getChild<LLUICtrl>("fsaa")->setValue((LLSD::Integer)  gSavedSettings.getU32("RenderFSAASamples"));
+
+	// sliders and their text boxes
+	//	mPostProcess = gSavedSettings.getS32("RenderGlowResolutionPow");
+	// slider text boxes
+	updateSliderText(getChild<LLSliderCtrl>("ObjectMeshDetail",		true), getChild<LLTextBox>("ObjectMeshDetailText",		true));
+	updateSliderText(getChild<LLSliderCtrl>("FlexibleMeshDetail",	true), getChild<LLTextBox>("FlexibleMeshDetailText",	true));
+	updateSliderText(getChild<LLSliderCtrl>("TreeMeshDetail",		true), getChild<LLTextBox>("TreeMeshDetailText",		true));
+	updateSliderText(getChild<LLSliderCtrl>("AvatarMeshDetail",		true), getChild<LLTextBox>("AvatarMeshDetailText",		true));
+	updateSliderText(getChild<LLSliderCtrl>("AvatarPhysicsDetail",	true), getChild<LLTextBox>("AvatarPhysicsDetailText",		true));
+	updateSliderText(getChild<LLSliderCtrl>("TerrainMeshDetail",	true), getChild<LLTextBox>("TerrainMeshDetailText",		true));
+	updateSliderText(getChild<LLSliderCtrl>("RenderPostProcess",	true), getChild<LLTextBox>("PostProcessText",			true));
+	updateSliderText(getChild<LLSliderCtrl>("SkyMeshDetail",		true), getChild<LLTextBox>("SkyMeshDetailText",			true));
+	updateSliderText(getChild<LLSliderCtrl>("TerrainDetail",		true), getChild<LLTextBox>("TerrainDetailText",			true));	
     LLAvatarComplexityControls::setIndirectControls();
-    setMaxNonImpostorsText(
+	setMaxNonImpostorsText(
         gSavedSettings.getU32("RenderAvatarMaxNonImpostors"),
         getChild<LLTextBox>("IndirectMaxNonImpostorsText", true));
     LLAvatarComplexityControls::setText(
         gSavedSettings.getU32("RenderAvatarMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText", true));
-    refreshEnabledState();
+	refreshEnabledState();
 }
 
 void LLFloaterPreference::onCommitWindowedMode()
 {
-    refresh();
+	refresh();
 }
 
 void LLFloaterPreference::onChangeQuality(const LLSD& data)
 {
-    U32 level = (U32)(data.asReal());
-    LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
-    refreshEnabledGraphics();
-    refresh();
+	U32 level = (U32)(data.asReal());
+	LLFeatureManager::getInstance()->setGraphicsLevel(level, true);
+	refreshEnabledGraphics();
+	refresh();
 }
 
 void LLFloaterPreference::onClickSetKey()
 {
-    LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
-    if (dialog)
-    {
-        dialog->setParent(this);
-    }
+	LLVoiceSetKeyDialog* dialog = LLFloaterReg::showTypedInstance<LLVoiceSetKeyDialog>("voice_set_key", LLSD(), TRUE);
+	if (dialog)
+	{
+		dialog->setParent(this);
+	}
 }
 
 void LLFloaterPreference::setKey(KEY key)
 {
-    getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key));
-    // update the control right away since we no longer wait for apply
-    getChild<LLUICtrl>("modifier_combo")->onCommit();
+	getChild<LLUICtrl>("modifier_combo")->setValue(LLKeyboard::stringFromKey(key));
+	// update the control right away since we no longer wait for apply
+	getChild<LLUICtrl>("modifier_combo")->onCommit();
 }
 
 void LLFloaterPreference::onClickSetMiddleMouse()
 {
-    LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo");
+	LLUICtrl* p2t_line_editor = getChild<LLUICtrl>("modifier_combo");
 
-    // update the control right away since we no longer wait for apply
-    p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV);
+	// update the control right away since we no longer wait for apply
+	p2t_line_editor->setControlValue(MIDDLE_MOUSE_CV);
 
-    //push2talk button "middle mouse" control value is in English, need to localize it for presentation
-    LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent());
-    if (advanced_preferences)
-    {
-        p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse"));
-    }
+	//push2talk button "middle mouse" control value is in English, need to localize it for presentation
+	LLPanel* advanced_preferences = dynamic_cast<LLPanel*>(p2t_line_editor->getParent());
+	if (advanced_preferences)
+	{
+		p2t_line_editor->setValue(advanced_preferences->getString("middle_mouse"));
+	}
 }
 
 void LLFloaterPreference::onClickSetSounds()
 {
-    // Disable Enable gesture sounds checkbox if the master sound is disabled 
-    // or if sound effects are disabled.
-    getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds"));
+	// Disable Enable gesture sounds checkbox if the master sound is disabled 
+	// or if sound effects are disabled.
+	getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds"));
 }
 
 /*
 void LLFloaterPreference::onClickSkipDialogs()
 {
-    LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this));
+	LLNotificationsUtil::add("SkipShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_skip_dialogs, _1, _2, this));
 }
 
 void LLFloaterPreference::onClickResetDialogs()
 {
-    LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this));
+	LLNotificationsUtil::add("ResetShowNextTimeDialogs", LLSD(), LLSD(), boost::bind(&callback_reset_dialogs, _1, _2, this));
 }
  */
 
 void LLFloaterPreference::onClickEnablePopup()
-{   
-    LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups");
-    
-    std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected();
-    std::vector<LLScrollListItem*>::iterator itor;
-    for (itor = items.begin(); itor != items.end(); ++itor)
-    {
-        LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
-        //gSavedSettings.setWarning(templatep->mName, TRUE);
-        std::string notification_name = templatep->mName;
-        LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
-    }
-    
-    buildPopupLists();
+{	
+	LLScrollListCtrl& disabled_popups = getChildRef<LLScrollListCtrl>("disabled_popups");
+	
+	std::vector<LLScrollListItem*> items = disabled_popups.getAllSelected();
+	std::vector<LLScrollListItem*>::iterator itor;
+	for (itor = items.begin(); itor != items.end(); ++itor)
+	{
+		LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
+		//gSavedSettings.setWarning(templatep->mName, TRUE);
+		std::string notification_name = templatep->mName;
+		LLUI::sSettingGroups["ignores"]->setBOOL(notification_name, TRUE);
+	}
+	
+	buildPopupLists();
 }
 
 void LLFloaterPreference::onClickDisablePopup()
-{   
-    LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups");
-    
-    std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected();
-    std::vector<LLScrollListItem*>::iterator itor;
-    for (itor = items.begin(); itor != items.end(); ++itor)
-    {
-        LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
-        templatep->mForm->setIgnored(true);
-    }
-    
-    buildPopupLists();
+{	
+	LLScrollListCtrl& enabled_popups = getChildRef<LLScrollListCtrl>("enabled_popups");
+	
+	std::vector<LLScrollListItem*> items = enabled_popups.getAllSelected();
+	std::vector<LLScrollListItem*>::iterator itor;
+	for (itor = items.begin(); itor != items.end(); ++itor)
+	{
+		LLNotificationTemplatePtr templatep = LLNotifications::instance().getTemplate(*(std::string*)((*itor)->getUserdata()));
+		templatep->mForm->setIgnored(true);
+	}
+	
+	buildPopupLists();
 }
 
 void LLFloaterPreference::resetAllIgnored()
 {
-    for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
-         iter != LLNotifications::instance().templatesEnd();
-         ++iter)
-    {
-        if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
-        {
-            iter->second->mForm->setIgnored(false);
-        }
-    }
+	for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
+		 iter != LLNotifications::instance().templatesEnd();
+		 ++iter)
+	{
+		if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
+		{
+			iter->second->mForm->setIgnored(false);
+		}
+	}
 }
 
 void LLFloaterPreference::setAllIgnored()
 {
-    for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
-         iter != LLNotifications::instance().templatesEnd();
-         ++iter)
-    {
-        if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
-        {
-            iter->second->mForm->setIgnored(true);
-        }
-    }
+	for (LLNotifications::TemplateMap::const_iterator iter = LLNotifications::instance().templatesBegin();
+		 iter != LLNotifications::instance().templatesEnd();
+		 ++iter)
+	{
+		if (iter->second->mForm->getIgnoreType() != LLNotificationForm::IGNORE_NO)
+		{
+			iter->second->mForm->setIgnored(true);
+		}
+	}
 }
 
 void LLFloaterPreference::onClickLogPath()
 {
-    std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath"));  
-    mPriorInstantMessageLogPath.clear();
-    
+	std::string proposed_name(gSavedPerAccountSettings.getString("InstantMessageLogPath"));	 
+	mPriorInstantMessageLogPath.clear();
+	
 
-    (new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeLogPath, this, _1, _2), proposed_name))->getFile();
+	(new LLDirPickerThread(boost::bind(&LLFloaterPreference::changeLogPath, this, _1, _2), proposed_name))->getFile();
 }
 
 void LLFloaterPreference::changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name)
 {
-    //Path changed
-    if (proposed_name != filenames[0])
-    {
-        gSavedPerAccountSettings.setString("InstantMessageLogPath", filenames[0]);
-        mPriorInstantMessageLogPath = proposed_name;
+	//Path changed
+	if (proposed_name != filenames[0])
+	{
+		gSavedPerAccountSettings.setString("InstantMessageLogPath", filenames[0]);
+		mPriorInstantMessageLogPath = proposed_name;
 
-        // enable/disable 'Delete transcripts button
-        updateDeleteTranscriptsButton();
-    }
+		// enable/disable 'Delete transcripts button
+		updateDeleteTranscriptsButton();
+	}
 }
 
 bool LLFloaterPreference::moveTranscriptsAndLog()
 {
-    std::string instantMessageLogPath(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
-    std::string chatLogPath = gDirUtilp->add(instantMessageLogPath, gDirUtilp->getUserName());
-
-    bool madeDirectory = false;
-
-    //Does the directory really exist, if not then make it
-    if(!LLFile::isdir(chatLogPath))
-    {
-        //mkdir success is defined as zero
-        if(LLFile::mkdir(chatLogPath) != 0)
-        {
-            return false;
-        }
-        madeDirectory = true;
-    }
-    
-    std::string originalConversationLogDir = LLConversationLog::instance().getFileName();
-    std::string targetConversationLogDir = gDirUtilp->add(chatLogPath, "conversation.log");
-    //Try to move the conversation log
-    if(!LLConversationLog::instance().moveLog(originalConversationLogDir, targetConversationLogDir))
-    {
-        //Couldn't move the log and created a new directory so remove the new directory
-        if(madeDirectory)
-        {
-            LLFile::rmdir(chatLogPath);
-        }
-        return false;
-    }
-
-    //Attempt to move transcripts
-    std::vector<std::string> listOfTranscripts;
-    std::vector<std::string> listOfFilesMoved;
-
-    LLLogChat::getListOfTranscriptFiles(listOfTranscripts);
-
-    if(!LLLogChat::moveTranscripts(gDirUtilp->getChatLogsDir(), 
-                                    instantMessageLogPath, 
-                                    listOfTranscripts,
-                                    listOfFilesMoved))
-    {
-        //Couldn't move all the transcripts so restore those that moved back to their old location
-        LLLogChat::moveTranscripts(instantMessageLogPath, 
-            gDirUtilp->getChatLogsDir(), 
-            listOfFilesMoved);
-
-        //Move the conversation log back
-        LLConversationLog::instance().moveLog(targetConversationLogDir, originalConversationLogDir);
-
-        if(madeDirectory)
-        {
-            LLFile::rmdir(chatLogPath);
-        }
-
-        return false;
-    }
-
-    gDirUtilp->setChatLogsDir(instantMessageLogPath);
-    gDirUtilp->updatePerAccountChatLogsDir();
-
-    return true;
+	std::string instantMessageLogPath(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
+	std::string chatLogPath = gDirUtilp->add(instantMessageLogPath, gDirUtilp->getUserName());
+
+	bool madeDirectory = false;
+
+	//Does the directory really exist, if not then make it
+	if(!LLFile::isdir(chatLogPath))
+	{
+		//mkdir success is defined as zero
+		if(LLFile::mkdir(chatLogPath) != 0)
+		{
+			return false;
+		}
+		madeDirectory = true;
+	}
+	
+	std::string originalConversationLogDir = LLConversationLog::instance().getFileName();
+	std::string targetConversationLogDir = gDirUtilp->add(chatLogPath, "conversation.log");
+	//Try to move the conversation log
+	if(!LLConversationLog::instance().moveLog(originalConversationLogDir, targetConversationLogDir))
+	{
+		//Couldn't move the log and created a new directory so remove the new directory
+		if(madeDirectory)
+		{
+			LLFile::rmdir(chatLogPath);
+		}
+		return false;
+	}
+
+	//Attempt to move transcripts
+	std::vector<std::string> listOfTranscripts;
+	std::vector<std::string> listOfFilesMoved;
+
+	LLLogChat::getListOfTranscriptFiles(listOfTranscripts);
+
+	if(!LLLogChat::moveTranscripts(gDirUtilp->getChatLogsDir(), 
+									instantMessageLogPath, 
+									listOfTranscripts,
+									listOfFilesMoved))
+	{
+		//Couldn't move all the transcripts so restore those that moved back to their old location
+		LLLogChat::moveTranscripts(instantMessageLogPath, 
+			gDirUtilp->getChatLogsDir(), 
+			listOfFilesMoved);
+
+		//Move the conversation log back
+		LLConversationLog::instance().moveLog(targetConversationLogDir, originalConversationLogDir);
+
+		if(madeDirectory)
+		{
+			LLFile::rmdir(chatLogPath);
+		}
+
+		return false;
+	}
+
+	gDirUtilp->setChatLogsDir(instantMessageLogPath);
+	gDirUtilp->updatePerAccountChatLogsDir();
+
+	return true;
 }
 
 void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email)
 {
-    mGotPersonalInfo = true;
-    mOriginalIMViaEmail = im_via_email;
-    mDirectoryVisibility = visibility;
-    
-    if (visibility == VISIBILITY_DEFAULT)
-    {
-        mOriginalHideOnlineStatus = false;
-        getChildView("online_visibility")->setEnabled(TRUE);     
-    }
-    else if (visibility == VISIBILITY_HIDDEN)
-    {
-        mOriginalHideOnlineStatus = true;
-        getChildView("online_visibility")->setEnabled(TRUE);     
-    }
-    else
-    {
-        mOriginalHideOnlineStatus = true;
-    }
-    
-    getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE);
-    getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
-    getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus);    
-    getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
-    getChildView("send_im_to_email")->setEnabled(is_verified_email);
+	mGotPersonalInfo = true;
+	mOriginalIMViaEmail = im_via_email;
+	mDirectoryVisibility = visibility;
+	
+	if (visibility == VISIBILITY_DEFAULT)
+	{
+		mOriginalHideOnlineStatus = false;
+		getChildView("online_visibility")->setEnabled(TRUE); 	 
+	}
+	else if (visibility == VISIBILITY_HIDDEN)
+	{
+		mOriginalHideOnlineStatus = true;
+		getChildView("online_visibility")->setEnabled(TRUE); 	 
+	}
+	else
+	{
+		mOriginalHideOnlineStatus = true;
+	}
+	
+	getChild<LLUICtrl>("online_searchresults")->setEnabled(TRUE);
+	getChildView("friends_online_notify_checkbox")->setEnabled(TRUE);
+	getChild<LLUICtrl>("online_visibility")->setValue(mOriginalHideOnlineStatus); 	 
+	getChild<LLUICtrl>("online_visibility")->setLabelArg("[DIR_VIS]", mDirectoryVisibility);
+	getChildView("send_im_to_email")->setEnabled(is_verified_email);
 
     std::string tooltip;
     if (!is_verified_email)
@@ -1867,115 +1867,115 @@ void LLFloaterPreference::setPersonalInfo(const std::string& visibility, bool im
 
     // *TODO: Show or hide verify email text here based on is_verified_email
     getChild<LLUICtrl>("send_im_to_email")->setValue(im_via_email);
-    getChildView("favorites_on_login_check")->setEnabled(TRUE);
-    getChildView("log_path_button")->setEnabled(TRUE);
-    getChildView("chat_font_size")->setEnabled(TRUE);
-    getChildView("conversation_log_combo")->setEnabled(TRUE);
+	getChildView("favorites_on_login_check")->setEnabled(TRUE);
+	getChildView("log_path_button")->setEnabled(TRUE);
+	getChildView("chat_font_size")->setEnabled(TRUE);
+	getChildView("conversation_log_combo")->setEnabled(TRUE);
 }
 
 
 void LLFloaterPreference::refreshUI()
 {
-    refresh();
+	refresh();
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box)
 {
-    if (text_box == NULL || ctrl== NULL)
-        return;
-
-    // get range and points when text should change
-    F32 value = (F32)ctrl->getValue().asReal();
-    F32 min = ctrl->getMinValue();
-    F32 max = ctrl->getMaxValue();
-    F32 range = max - min;
-    llassert(range > 0);
-    F32 midPoint = min + range / 3.0f;
-    F32 highPoint = min + (2.0f * range / 3.0f);
-
-    // choose the right text
-    if (value < midPoint)
-    {
-        text_box->setText(LLTrans::getString("GraphicsQualityLow"));
-    } 
-    else if (value < highPoint)
-    {
-        text_box->setText(LLTrans::getString("GraphicsQualityMid"));
-    }
-    else
-    {
-        text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
-    }
+	if (text_box == NULL || ctrl== NULL)
+		return;
+
+	// get range and points when text should change
+	F32 value = (F32)ctrl->getValue().asReal();
+	F32 min = ctrl->getMinValue();
+	F32 max = ctrl->getMaxValue();
+	F32 range = max - min;
+	llassert(range > 0);
+	F32 midPoint = min + range / 3.0f;
+	F32 highPoint = min + (2.0f * range / 3.0f);
+
+	// choose the right text
+	if (value < midPoint)
+	{
+		text_box->setText(LLTrans::getString("GraphicsQualityLow"));
+	} 
+	else if (value < highPoint)
+	{
+		text_box->setText(LLTrans::getString("GraphicsQualityMid"));
+	}
+	else
+	{
+		text_box->setText(LLTrans::getString("GraphicsQualityHigh"));
+	}
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors()
 {
-    // Called when the IndirectMaxNonImpostors control changes
-    // Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors
-    LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true);
-    U32 value = ctrl->getValue().asInteger();
+	// Called when the IndirectMaxNonImpostors control changes
+	// Responsible for fixing the slider label (IndirectMaxNonImpostorsText) and setting RenderAvatarMaxNonImpostors
+	LLSliderCtrl* ctrl = getChild<LLSliderCtrl>("IndirectMaxNonImpostors",true);
+	U32 value = ctrl->getValue().asInteger();
 
-    if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value)
-    {
-        value=0;
-    }
-    gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value);
-    LLVOAvatar::updateImpostorRendering(value); // make it effective immediately
-    setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText"));
+	if (0 == value || LLVOAvatar::IMPOSTORS_OFF <= value)
+	{
+		value=0;
+	}
+	gSavedSettings.setU32("RenderAvatarMaxNonImpostors", value);
+	LLVOAvatar::updateImpostorRendering(value); // make it effective immediately
+	setMaxNonImpostorsText(value, getChild<LLTextBox>("IndirectMaxNonImpostorsText"));
 }
 
 void LLFloaterPreferenceGraphicsAdvanced::setMaxNonImpostorsText(U32 value, LLTextBox* text_box)
 {
-    if (0 == value)
-    {
-        text_box->setText(LLTrans::getString("no_limit"));
-    }
-    else
-    {
-        text_box->setText(llformat("%d", value));
-    }
+	if (0 == value)
+	{
+		text_box->setText(LLTrans::getString("no_limit"));
+	}
+	else
+	{
+		text_box->setText(llformat("%d", value));
+	}
 }
 
 void LLAvatarComplexityControls::updateMax(LLSliderCtrl* slider, LLTextBox* value_label)
 {
-    // Called when the IndirectMaxComplexity control changes
-    // Responsible for fixing the slider label (IndirectMaxComplexityText) and setting RenderAvatarMaxComplexity
-    U32 indirect_value = slider->getValue().asInteger();
-    U32 max_arc;
-    
-    if (INDIRECT_MAX_ARC_OFF == indirect_value)
-    {
-        // The 'off' position is when the slider is all the way to the right, 
-        // which is a value of INDIRECT_MAX_ARC_OFF,
-        // so it is necessary to set max_arc to 0 disable muted avatars.
-        max_arc = 0;
-    }
-    else
-    {
-        // if this is changed, the inverse calculation in setIndirectMaxArc
-        // must be changed to match
-        max_arc = (U32)ll_round(exp(MIN_ARC_LOG + (ARC_LIMIT_MAP_SCALE * (indirect_value - MIN_INDIRECT_ARC_LIMIT))));
-    }
-
-    gSavedSettings.setU32("RenderAvatarMaxComplexity", (U32)max_arc);
-    setText(max_arc, value_label);
+	// Called when the IndirectMaxComplexity control changes
+	// Responsible for fixing the slider label (IndirectMaxComplexityText) and setting RenderAvatarMaxComplexity
+	U32 indirect_value = slider->getValue().asInteger();
+	U32 max_arc;
+	
+	if (INDIRECT_MAX_ARC_OFF == indirect_value)
+	{
+		// The 'off' position is when the slider is all the way to the right, 
+		// which is a value of INDIRECT_MAX_ARC_OFF,
+		// so it is necessary to set max_arc to 0 disable muted avatars.
+		max_arc = 0;
+	}
+	else
+	{
+		// if this is changed, the inverse calculation in setIndirectMaxArc
+		// must be changed to match
+		max_arc = (U32)ll_round(exp(MIN_ARC_LOG + (ARC_LIMIT_MAP_SCALE * (indirect_value - MIN_INDIRECT_ARC_LIMIT))));
+	}
+
+	gSavedSettings.setU32("RenderAvatarMaxComplexity", (U32)max_arc);
+	setText(max_arc, value_label);
 }
 
 void LLAvatarComplexityControls::setText(U32 value, LLTextBox* text_box)
 {
-    if (0 == value)
-    {
-        text_box->setText(LLTrans::getString("no_limit"));
-    }
-    else
-    {
-        text_box->setText(llformat("%d", value));
-    }
+	if (0 == value)
+	{
+		text_box->setText(LLTrans::getString("no_limit"));
+	}
+	else
+	{
+		text_box->setText(llformat("%d", value));
+	}
 }
 
 void LLFloaterPreference::updateMaxComplexity()
 {
-    // Called when the IndirectMaxComplexity control changes
+	// Called when the IndirectMaxComplexity control changes
     LLAvatarComplexityControls::updateMax(
         getChild<LLSliderCtrl>("IndirectMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText"));
@@ -1983,7 +1983,7 @@ void LLFloaterPreference::updateMaxComplexity()
 
 void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity()
 {
-    // Called when the IndirectMaxComplexity control changes
+	// Called when the IndirectMaxComplexity control changes
     LLAvatarComplexityControls::updateMax(
         getChild<LLSliderCtrl>("IndirectMaxComplexity"),
         getChild<LLTextBox>("IndirectMaxComplexityText"));
@@ -1991,16 +1991,16 @@ void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity()
 
 void LLFloaterPreference::onChangeMaturity()
 {
-    U8 sim_access = gSavedSettings.getU32("PreferredMaturity");
+	U8 sim_access = gSavedSettings.getU32("PreferredMaturity");
 
-    getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG
-                                                            || sim_access == SIM_ACCESS_MATURE
-                                                            || sim_access == SIM_ACCESS_ADULT);
+	getChild<LLIconCtrl>("rating_icon_general")->setVisible(sim_access == SIM_ACCESS_PG
+															|| sim_access == SIM_ACCESS_MATURE
+															|| sim_access == SIM_ACCESS_ADULT);
 
-    getChild<LLIconCtrl>("rating_icon_moderate")->setVisible(sim_access == SIM_ACCESS_MATURE
-                                                            || sim_access == SIM_ACCESS_ADULT);
+	getChild<LLIconCtrl>("rating_icon_moderate")->setVisible(sim_access == SIM_ACCESS_MATURE
+															|| sim_access == SIM_ACCESS_ADULT);
 
-    getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT);
+	getChild<LLIconCtrl>("rating_icon_adult")->setVisible(sim_access == SIM_ACCESS_ADULT);
 }
 
 std::string get_category_path(LLUUID cat_id)
@@ -2064,23 +2064,23 @@ void LLFloaterPreference::onChangeAnimationFolder()
 // but the UI for this will still be enabled
 void LLFloaterPreference::onClickBlockList()
 {
-    LLFloaterSidePanelContainer::showPanel("people", "panel_people",
-        LLSD().with("people_panel_tab_name", "blocked_panel"));
+	LLFloaterSidePanelContainer::showPanel("people", "panel_people",
+		LLSD().with("people_panel_tab_name", "blocked_panel"));
 }
 
 void LLFloaterPreference::onClickProxySettings()
 {
-    LLFloaterReg::showInstance("prefs_proxy");
+	LLFloaterReg::showInstance("prefs_proxy");
 }
 
 void LLFloaterPreference::onClickTranslationSettings()
 {
-    LLFloaterReg::showInstance("prefs_translation");
+	LLFloaterReg::showInstance("prefs_translation");
 }
 
 void LLFloaterPreference::onClickAutoReplace()
 {
-    LLFloaterReg::showInstance("prefs_autoreplace");
+	LLFloaterReg::showInstance("prefs_autoreplace");
 }
 
 void LLFloaterPreference::onClickSpellChecker()
@@ -2095,141 +2095,141 @@ void LLFloaterPreference::onClickRenderExceptions()
 
 void LLFloaterPreference::onClickAdvanced()
 {
-    LLFloaterReg::showInstance("prefs_graphics_advanced");
+	LLFloaterReg::showInstance("prefs_graphics_advanced");
 
-    LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
-    for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
-         iter != tabcontainer->getChildList()->end(); ++iter)
-    {
-        LLView* view = *iter;
-        LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view);
-        if (panel)
-        {
-            panel->resetDirtyChilds();
-        }
-    }
+	LLTabContainer* tabcontainer = getChild<LLTabContainer>("pref core");
+	for (child_list_t::const_iterator iter = tabcontainer->getChildList()->begin();
+		 iter != tabcontainer->getChildList()->end(); ++iter)
+	{
+		LLView* view = *iter;
+		LLPanelPreferenceGraphics* panel = dynamic_cast<LLPanelPreferenceGraphics*>(view);
+		if (panel)
+		{
+			panel->resetDirtyChilds();
+		}
+	}
 }
 
 void LLFloaterPreference::onClickActionChange()
 {
-    mClickActionDirty = true;
+	mClickActionDirty = true;
 }
 
 void LLFloaterPreference::onClickPermsDefault()
 {
-    LLFloaterReg::showInstance("perms_default");
+	LLFloaterReg::showInstance("perms_default");
 }
 
 void LLFloaterPreference::onDeleteTranscripts()
 {
-    LLSD args;
-    args["FOLDER"] = gDirUtilp->getUserName();
+	LLSD args;
+	args["FOLDER"] = gDirUtilp->getUserName();
 
-    LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2));
+	LLNotificationsUtil::add("PreferenceChatDeleteTranscripts", args, LLSD(), boost::bind(&LLFloaterPreference::onDeleteTranscriptsResponse, this, _1, _2));
 }
 
 void LLFloaterPreference::onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response)
 {
-    if (0 == LLNotificationsUtil::getSelectedOption(notification, response))
-    {
-        LLLogChat::deleteTranscripts();
-        updateDeleteTranscriptsButton();
-    }
+	if (0 == LLNotificationsUtil::getSelectedOption(notification, response))
+	{
+		LLLogChat::deleteTranscripts();
+		updateDeleteTranscriptsButton();
+	}
 }
 
 void LLFloaterPreference::onLogChatHistorySaved()
 {
-    LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts");
+	LLButton * delete_transcripts_buttonp = getChild<LLButton>("delete_transcripts");
 
-    if (!delete_transcripts_buttonp->getEnabled())
-    {
-        delete_transcripts_buttonp->setEnabled(true);
-    }
+	if (!delete_transcripts_buttonp->getEnabled())
+	{
+		delete_transcripts_buttonp->setEnabled(true);
+	}
 }
 
 void LLFloaterPreference::updateClickActionSettings()
 {
-    const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger();
-    const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger();
+	const int single_clk_action = getChild<LLComboBox>("single_click_action_combo")->getValue().asInteger();
+	const int double_clk_action = getChild<LLComboBox>("double_click_action_combo")->getValue().asInteger();
 
-    gSavedSettings.setBOOL("ClickToWalk",           single_clk_action == 1);
-    gSavedSettings.setBOOL("DoubleClickAutoPilot",  double_clk_action == 1);
-    gSavedSettings.setBOOL("DoubleClickTeleport",   double_clk_action == 2);
+	gSavedSettings.setBOOL("ClickToWalk",			single_clk_action == 1);
+	gSavedSettings.setBOOL("DoubleClickAutoPilot",	double_clk_action == 1);
+	gSavedSettings.setBOOL("DoubleClickTeleport",	double_clk_action == 2);
 }
 
 void LLFloaterPreference::updateClickActionControls()
 {
-    const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk");
-    const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot");
-    const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport");
+	const bool click_to_walk = gSavedSettings.getBOOL("ClickToWalk");
+	const bool dbl_click_to_walk = gSavedSettings.getBOOL("DoubleClickAutoPilot");
+	const bool dbl_click_to_teleport = gSavedSettings.getBOOL("DoubleClickTeleport");
 
-    getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk);
-    getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk);
+	getChild<LLComboBox>("single_click_action_combo")->setValue((int)click_to_walk);
+	getChild<LLComboBox>("double_click_action_combo")->setValue(dbl_click_to_teleport ? 2 : (int)dbl_click_to_walk);
 }
 
 void LLFloaterPreference::applyUIColor(LLUICtrl* ctrl, const LLSD& param)
 {
-    LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue()));
+	LLUIColorTable::instance().setColor(param.asString(), LLColor4(ctrl->getValue()));
 }
 
 void LLFloaterPreference::getUIColor(LLUICtrl* ctrl, const LLSD& param)
 {
-    LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl;
-    color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString()));
+	LLColorSwatchCtrl* color_swatch = (LLColorSwatchCtrl*) ctrl;
+	color_swatch->setOriginal(LLUIColorTable::instance().getColor(param.asString()));
 }
 
 void LLFloaterPreference::setCacheLocation(const LLStringExplicit& location)
 {
-    LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location");
-    cache_location_editor->setValue(location);
-    cache_location_editor->setToolTip(location);
+	LLUICtrl* cache_location_editor = getChild<LLUICtrl>("cache_location");
+	cache_location_editor->setValue(location);
+	cache_location_editor->setToolTip(location);
 }
 
 void LLFloaterPreference::selectPanel(const LLSD& name)
 {
-    LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");
-    LLPanel * panel = tab_containerp->getPanelByName(name);
-    if (NULL != panel)
-    {
-        tab_containerp->selectTabPanel(panel);
-    }
+	LLTabContainer * tab_containerp = getChild<LLTabContainer>("pref core");
+	LLPanel * panel = tab_containerp->getPanelByName(name);
+	if (NULL != panel)
+	{
+		tab_containerp->selectTabPanel(panel);
+	}
 }
 
 void LLFloaterPreference::selectPrivacyPanel()
 {
-    selectPanel("im");
+	selectPanel("im");
 }
 
 void LLFloaterPreference::selectChatPanel()
 {
-    selectPanel("chat");
+	selectPanel("chat");
 }
 
 void LLFloaterPreference::changed()
 {
-    getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0);
+	getChild<LLButton>("clear_log")->setEnabled(LLConversationLog::instance().getConversations().size() > 0);
 
-    // set 'enable' property for 'Delete transcripts...' button
-    updateDeleteTranscriptsButton();
+	// set 'enable' property for 'Delete transcripts...' button
+	updateDeleteTranscriptsButton();
 
 }
 
 void LLFloaterPreference::saveCameraPreset(std::string& preset)
 {
-    mSavedCameraPreset = preset;
+	mSavedCameraPreset = preset;
 }
 
 void LLFloaterPreference::saveGraphicsPreset(std::string& preset)
 {
-    mSavedGraphicsPreset = preset;
+	mSavedGraphicsPreset = preset;
 }
 
 //------------------------------Updater---------------------------------------
 
 static bool handleBandwidthChanged(const LLSD& newvalue)
 {
-    gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
-    return true;
+	gViewerThrottle.setMaxBandwidth((F32) newvalue.asReal());
+	return true;
 }
 
 class LLPanelPreference::Updater : public LLEventTimer
@@ -2237,37 +2237,37 @@ class LLPanelPreference::Updater : public LLEventTimer
 
 public:
 
-    typedef boost::function<bool(const LLSD&)> callback_t;
+	typedef boost::function<bool(const LLSD&)> callback_t;
 
-    Updater(callback_t cb, F32 period)
-    :LLEventTimer(period),
-     mCallback(cb)
-    {
-        mEventTimer.stop();
-    }
+	Updater(callback_t cb, F32 period)
+	:LLEventTimer(period),
+	 mCallback(cb)
+	{
+		mEventTimer.stop();
+	}
 
-    virtual ~Updater(){}
+	virtual ~Updater(){}
 
-    void update(const LLSD& new_value)
-    {
-        mNewValue = new_value;
-        mEventTimer.start();
-    }
+	void update(const LLSD& new_value)
+	{
+		mNewValue = new_value;
+		mEventTimer.start();
+	}
 
 protected:
 
-    BOOL tick()
-    {
-        mCallback(mNewValue);
-        mEventTimer.stop();
+	BOOL tick()
+	{
+		mCallback(mNewValue);
+		mEventTimer.stop();
 
-        return FALSE;
-    }
+		return FALSE;
+	}
 
 private:
 
-    LLSD mNewValue;
-    callback_t mCallback;
+	LLSD mNewValue;
+	callback_t mCallback;
 };
 //----------------------------------------------------------------------------
 static LLPanelInjector<LLPanelPreference> t_places("panel_preference");
@@ -2275,169 +2275,169 @@ LLPanelPreference::LLPanelPreference()
 : LLPanel(),
   mBandWidthUpdater(NULL)
 {
-    mCommitCallbackRegistrar.add("Pref.setControlFalse",    boost::bind(&LLPanelPreference::setControlFalse,this, _2));
-    mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox",    boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1));
-    mCommitCallbackRegistrar.add("Pref.PrefDelete", boost::bind(&LLPanelPreference::deletePreset, this, _2));
-    mCommitCallbackRegistrar.add("Pref.PrefSave",   boost::bind(&LLPanelPreference::savePreset, this, _2));
-    mCommitCallbackRegistrar.add("Pref.PrefLoad",   boost::bind(&LLPanelPreference::loadPreset, this, _2));
+	mCommitCallbackRegistrar.add("Pref.setControlFalse",	boost::bind(&LLPanelPreference::setControlFalse,this, _2));
+	mCommitCallbackRegistrar.add("Pref.updateMediaAutoPlayCheckbox",	boost::bind(&LLPanelPreference::updateMediaAutoPlayCheckbox, this, _1));
+	mCommitCallbackRegistrar.add("Pref.PrefDelete",	boost::bind(&LLPanelPreference::deletePreset, this, _2));
+	mCommitCallbackRegistrar.add("Pref.PrefSave",	boost::bind(&LLPanelPreference::savePreset, this, _2));
+	mCommitCallbackRegistrar.add("Pref.PrefLoad",	boost::bind(&LLPanelPreference::loadPreset, this, _2));
 }
 
 //virtual
 BOOL LLPanelPreference::postBuild()
 {
-    ////////////////////// PanelGeneral ///////////////////
-    if (hasChild("display_names_check", TRUE))
-    {
-        BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI");
-        LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check");
-        ctrl_display_name->setEnabled(use_people_api);
-        if (!use_people_api)
-        {
-            ctrl_display_name->setValue(FALSE);
-        }
-    }
-
-    ////////////////////// PanelVoice ///////////////////
-    if (hasChild("voice_unavailable", TRUE))
-    {
-        BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
-        getChildView("voice_unavailable")->setVisible( voice_disabled);
-        getChildView("enable_voice_check")->setVisible( !voice_disabled);
-    }
-    
-    //////////////////////PanelSkins ///////////////////
-    
-    if (hasChild("skin_selection", TRUE))
-    {
-        LLFloaterPreference::refreshSkin(this);
-
-        // if skin is set to a skin that no longer exists (silver) set back to default
-        if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0)
-        {
-            gSavedSettings.setString("SkinCurrent", "default");
-            LLFloaterPreference::refreshSkin(this);
-        }
-
-    }
-
-    //////////////////////PanelPrivacy ///////////////////
-    if (hasChild("media_enabled", TRUE))
-    {
-        bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
-        
-        getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
-        getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
-    }
-    if (hasChild("music_enabled", TRUE))
-    {
-        getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
-    }
-    if (hasChild("voice_call_friends_only_check", TRUE))
-    {
-        getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
-    }
-    if (hasChild("allow_multiple_viewer_check", TRUE))
-    {
-        getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2));
-    }
-    if (hasChild("favorites_on_login_check", TRUE))
-    {
-        getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
-        bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
-        getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
-    }
-    if (hasChild("mute_chb_label", TRUE))
-    {
-        getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false);
-        getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized));
-    }
-
-    //////////////////////PanelAdvanced ///////////////////
-    if (hasChild("modifier_combo", TRUE))
-    {
-        //localizing if push2talk button is set to middle mouse
-        if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString())
-        {
-            getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse"));
-        }
-    }
-
-    //////////////////////PanelSetup ///////////////////
-    if (hasChild("max_bandwidth"), TRUE)
-    {
-        mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT);
-        gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2));
-    }
+	////////////////////// PanelGeneral ///////////////////
+	if (hasChild("display_names_check", TRUE))
+	{
+		BOOL use_people_api = gSavedSettings.getBOOL("UsePeopleAPI");
+		LLCheckBoxCtrl* ctrl_display_name = getChild<LLCheckBoxCtrl>("display_names_check");
+		ctrl_display_name->setEnabled(use_people_api);
+		if (!use_people_api)
+		{
+			ctrl_display_name->setValue(FALSE);
+		}
+	}
+
+	////////////////////// PanelVoice ///////////////////
+	if (hasChild("voice_unavailable", TRUE))
+	{
+		BOOL voice_disabled = gSavedSettings.getBOOL("CmdLineDisableVoice");
+		getChildView("voice_unavailable")->setVisible( voice_disabled);
+		getChildView("enable_voice_check")->setVisible( !voice_disabled);
+	}
+	
+	//////////////////////PanelSkins ///////////////////
+	
+	if (hasChild("skin_selection", TRUE))
+	{
+		LLFloaterPreference::refreshSkin(this);
+
+		// if skin is set to a skin that no longer exists (silver) set back to default
+		if (getChild<LLRadioGroup>("skin_selection")->getSelectedIndex() < 0)
+		{
+			gSavedSettings.setString("SkinCurrent", "default");
+			LLFloaterPreference::refreshSkin(this);
+		}
+
+	}
+
+	//////////////////////PanelPrivacy ///////////////////
+	if (hasChild("media_enabled", TRUE))
+	{
+		bool media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
+		
+		getChild<LLCheckBoxCtrl>("media_enabled")->set(media_enabled);
+		getChild<LLCheckBoxCtrl>("autoplay_enabled")->setEnabled(media_enabled);
+	}
+	if (hasChild("music_enabled", TRUE))
+	{
+		getChild<LLCheckBoxCtrl>("music_enabled")->set(gSavedSettings.getBOOL("AudioStreamingMusic"));
+	}
+	if (hasChild("voice_call_friends_only_check", TRUE))
+	{
+		getChild<LLCheckBoxCtrl>("voice_call_friends_only_check")->setCommitCallback(boost::bind(&showFriendsOnlyWarning, _1, _2));
+	}
+	if (hasChild("allow_multiple_viewer_check", TRUE))
+	{
+		getChild<LLCheckBoxCtrl>("allow_multiple_viewer_check")->setCommitCallback(boost::bind(&showMultipleViewersWarning, _1, _2));
+	}
+	if (hasChild("favorites_on_login_check", TRUE))
+	{
+		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setCommitCallback(boost::bind(&handleFavoritesOnLoginChanged, _1, _2));
+		bool show_favorites_at_login = LLPanelLogin::getShowFavorites();
+		getChild<LLCheckBoxCtrl>("favorites_on_login_check")->setValue(show_favorites_at_login);
+	}
+	if (hasChild("mute_chb_label", TRUE))
+	{
+		getChild<LLTextBox>("mute_chb_label")->setShowCursorHand(false);
+		getChild<LLTextBox>("mute_chb_label")->setClickedCallback(boost::bind(&toggleMuteWhenMinimized));
+	}
+
+	//////////////////////PanelAdvanced ///////////////////
+	if (hasChild("modifier_combo", TRUE))
+	{
+		//localizing if push2talk button is set to middle mouse
+		if (MIDDLE_MOUSE_CV == getChild<LLUICtrl>("modifier_combo")->getValue().asString())
+		{
+			getChild<LLUICtrl>("modifier_combo")->setValue(getString("middle_mouse"));
+		}
+	}
+
+	//////////////////////PanelSetup ///////////////////
+	if (hasChild("max_bandwidth"), TRUE)
+	{
+		mBandWidthUpdater = new LLPanelPreference::Updater(boost::bind(&handleBandwidthChanged, _1), BANDWIDTH_UPDATER_TIMEOUT);
+		gSavedSettings.getControl("ThrottleBandwidthKBPS")->getSignal()->connect(boost::bind(&LLPanelPreference::Updater::update, mBandWidthUpdater, _2));
+	}
 
 #ifdef EXTERNAL_TOS
-    LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior");
-    if (ext_browser_settings)
-    {
-        // turn off ability to set external/internal browser
-        ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true);
-        ext_browser_settings->setEnabled(false);
-    }
+	LLRadioGroup* ext_browser_settings = getChild<LLRadioGroup>("preferred_browser_behavior");
+	if (ext_browser_settings)
+	{
+		// turn off ability to set external/internal browser
+		ext_browser_settings->setSelectedByValue(LLWeb::BROWSER_EXTERNAL_ONLY, true);
+		ext_browser_settings->setEnabled(false);
+	}
 #endif
 
-    apply();
-    return true;
+	apply();
+	return true;
 }
 
 LLPanelPreference::~LLPanelPreference()
 {
-    if (mBandWidthUpdater)
-    {
-        delete mBandWidthUpdater;
-    }
+	if (mBandWidthUpdater)
+	{
+		delete mBandWidthUpdater;
+	}
 }
 void LLPanelPreference::apply()
 {
-    // no-op
+	// no-op
 }
 
 void LLPanelPreference::saveSettings()
 {
-    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-
-    // Save the value of all controls in the hierarchy
-    mSavedValues.clear();
-    std::list<LLView*> view_stack;
-    view_stack.push_back(this);
-    if (advanced)
-    {
-        view_stack.push_back(advanced);
-    }
-    while(!view_stack.empty())
-    {
-        // Process view on top of the stack
-        LLView* curview = view_stack.front();
-        view_stack.pop_front();
-
-        LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
-        if (color_swatch)
-        {
-            mSavedColors[color_swatch->getName()] = color_swatch->get();
-        }
-        else
-        {
-            LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-            if (ctrl)
-            {
-                LLControlVariable* control = ctrl->getControlVariable();
-                if (control)
-                {
-                    mSavedValues[control] = control->getValue();
-                }
-            }
-        }
-            
-        // Push children onto the end of the work stack
-        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-             iter != curview->getChildList()->end(); ++iter)
-        {
-            view_stack.push_back(*iter);
-        }
-    }   
+	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+
+	// Save the value of all controls in the hierarchy
+	mSavedValues.clear();
+	std::list<LLView*> view_stack;
+	view_stack.push_back(this);
+	if (advanced)
+	{
+		view_stack.push_back(advanced);
+	}
+	while(!view_stack.empty())
+	{
+		// Process view on top of the stack
+		LLView* curview = view_stack.front();
+		view_stack.pop_front();
+
+		LLColorSwatchCtrl* color_swatch = dynamic_cast<LLColorSwatchCtrl *>(curview);
+		if (color_swatch)
+		{
+			mSavedColors[color_swatch->getName()] = color_swatch->get();
+		}
+		else
+		{
+			LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+			if (ctrl)
+			{
+				LLControlVariable* control = ctrl->getControlVariable();
+				if (control)
+				{
+					mSavedValues[control] = control->getValue();
+				}
+			}
+		}
+			
+		// Push children onto the end of the work stack
+		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+			 iter != curview->getChildList()->end(); ++iter)
+		{
+			view_stack.push_back(*iter);
+		}
+	}	
 }
 
 void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLSD& value)
@@ -2450,104 +2450,104 @@ void LLPanelPreference::showMultipleViewersWarning(LLUICtrl* checkbox, const LLS
 
 void LLPanelPreference::showFriendsOnlyWarning(LLUICtrl* checkbox, const LLSD& value)
 {
-    if (checkbox && checkbox->getValue())
-    {
-        LLNotificationsUtil::add("FriendsAndGroupsOnly");
-    }
+	if (checkbox && checkbox->getValue())
+	{
+		LLNotificationsUtil::add("FriendsAndGroupsOnly");
+	}
 }
 
 void LLPanelPreference::handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value)
 {
-    if (checkbox)
-    {
-        LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
-        if(checkbox->getValue())
-        {
-            LLNotificationsUtil::add("FavoritesOnLogin");
-        }
-    }
+	if (checkbox)
+	{
+		LLFavoritesOrderStorage::instance().showFavoritesOnLoginChanged(checkbox->getValue().asBoolean());
+		if(checkbox->getValue())
+		{
+			LLNotificationsUtil::add("FavoritesOnLogin");
+		}
+	}
 }
 
 void LLPanelPreference::toggleMuteWhenMinimized()
 {
-    std::string mute("MuteWhenMinimized");
-    gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute));
+	std::string mute("MuteWhenMinimized");
+	gSavedSettings.setBOOL(mute, !gSavedSettings.getBOOL(mute));
 }
 
 void LLPanelPreference::cancel()
 {
-    for (control_values_map_t::iterator iter =  mSavedValues.begin();
-         iter !=  mSavedValues.end(); ++iter)
-    {
-        LLControlVariable* control = iter->first;
-        LLSD ctrl_value = iter->second;
+	for (control_values_map_t::iterator iter =  mSavedValues.begin();
+		 iter !=  mSavedValues.end(); ++iter)
+	{
+		LLControlVariable* control = iter->first;
+		LLSD ctrl_value = iter->second;
 
-        if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == ""))
-        {
-            continue;
-        }
+		if((control->getName() == "InstantMessageLogPath") && (ctrl_value.asString() == ""))
+		{
+			continue;
+		}
 
-        control->set(ctrl_value);
-    }
+		control->set(ctrl_value);
+	}
 
-    for (string_color_map_t::iterator iter = mSavedColors.begin();
-         iter != mSavedColors.end(); ++iter)
-    {
-        LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
-        if (color_swatch)
-        {
-            color_swatch->set(iter->second);
-            color_swatch->onCommit();
-        }
-    }
+	for (string_color_map_t::iterator iter = mSavedColors.begin();
+		 iter != mSavedColors.end(); ++iter)
+	{
+		LLColorSwatchCtrl* color_swatch = findChild<LLColorSwatchCtrl>(iter->first);
+		if (color_swatch)
+		{
+			color_swatch->set(iter->second);
+			color_swatch->onCommit();
+		}
+	}
 }
 
 void LLPanelPreference::setControlFalse(const LLSD& user_data)
 {
-    std::string control_name = user_data.asString();
-    LLControlVariable* control = findControl(control_name);
-    
-    if (control)
-        control->set(LLSD(FALSE));
+	std::string control_name = user_data.asString();
+	LLControlVariable* control = findControl(control_name);
+	
+	if (control)
+		control->set(LLSD(FALSE));
 }
 
 void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
 {
-    std::string name = ctrl->getName();
+	std::string name = ctrl->getName();
 
-    // Disable "Allow Media to auto play" only when both
-    // "Streaming Music" and "Media" are unchecked. STORM-513.
-    if ((name == "enable_music") || (name == "enable_media"))
-    {
-        bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
-        bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
+	// Disable "Allow Media to auto play" only when both
+	// "Streaming Music" and "Media" are unchecked. STORM-513.
+	if ((name == "enable_music") || (name == "enable_media"))
+	{
+		bool music_enabled = getChild<LLCheckBoxCtrl>("enable_music")->get();
+		bool media_enabled = getChild<LLCheckBoxCtrl>("enable_media")->get();
 
-        getChild<LLCheckBoxCtrl>("media_auto_play_btn")->setEnabled(music_enabled || media_enabled);
-    }
+		getChild<LLCheckBoxCtrl>("media_auto_play_btn")->setEnabled(music_enabled || media_enabled);
+	}
 }
 
 void LLPanelPreference::deletePreset(const LLSD& user_data)
 {
-    std::string subdirectory = user_data.asString();
-    LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
-    LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
-    LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
+	std::string subdirectory = user_data.asString();
+	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
+	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
+	LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::savePreset(const LLSD& user_data)
 {
-    std::string subdirectory = user_data.asString();
-    LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
-    LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
-    LLFloaterReg::showInstance("save_pref_preset", subdirectory);
+	std::string subdirectory = user_data.asString();
+	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
+	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
+	LLFloaterReg::showInstance("save_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::loadPreset(const LLSD& user_data)
 {
-    std::string subdirectory = user_data.asString();
-    LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
-    LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
-    LLFloaterReg::showInstance("load_pref_preset", subdirectory);
+	std::string subdirectory = user_data.asString();
+	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
+	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
+	LLFloaterReg::showInstance("load_pref_preset", subdirectory);
 }
 
 void LLPanelPreference::setHardwareDefaults()
@@ -2557,39 +2557,39 @@ void LLPanelPreference::setHardwareDefaults()
 class LLPanelPreferencePrivacy : public LLPanelPreference
 {
 public:
-    LLPanelPreferencePrivacy()
-    {
-        mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly");
-        mAccountIndependentSettings.push_back("AutoDisengageMic");
-    }
-
-    /*virtual*/ void saveSettings()
-    {
-        LLPanelPreference::saveSettings();
-
-        // Don't save (=erase from the saved values map) per-account privacy settings
-        // if we're not logged in, otherwise they will be reset to defaults on log off.
-        if (LLStartUp::getStartupState() != STATE_STARTED)
-        {
-            // Erase only common settings, assuming there are no color settings on Privacy page.
-            for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); )
-            {
-                const std::string setting = it->first->getName();
-                if (find(mAccountIndependentSettings.begin(),
-                    mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end())
-                {
-                    mSavedValues.erase(it++);
-                }
-                else
-                {
-                    ++it;
-                }
-            }
-        }
-    }
+	LLPanelPreferencePrivacy()
+	{
+		mAccountIndependentSettings.push_back("VoiceCallsFriendsOnly");
+		mAccountIndependentSettings.push_back("AutoDisengageMic");
+	}
+
+	/*virtual*/ void saveSettings()
+	{
+		LLPanelPreference::saveSettings();
+
+		// Don't save (=erase from the saved values map) per-account privacy settings
+		// if we're not logged in, otherwise they will be reset to defaults on log off.
+		if (LLStartUp::getStartupState() != STATE_STARTED)
+		{
+			// Erase only common settings, assuming there are no color settings on Privacy page.
+			for (control_values_map_t::iterator it = mSavedValues.begin(); it != mSavedValues.end(); )
+			{
+				const std::string setting = it->first->getName();
+				if (find(mAccountIndependentSettings.begin(),
+					mAccountIndependentSettings.end(), setting) == mAccountIndependentSettings.end())
+				{
+					mSavedValues.erase(it++);
+				}
+				else
+				{
+					++it;
+				}
+			}
+		}
+	}
 
 private:
-    std::list<std::string> mAccountIndependentSettings;
+	std::list<std::string> mAccountIndependentSettings;
 };
 
 static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
@@ -2598,253 +2598,253 @@ static LLPanelInjector<LLPanelPreferenceView> t_pref_view("panel_preference_view
 
 BOOL LLPanelPreferenceView::postBuild()
 {
-    setPresetText();
+	setPresetText();
 
-    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-    if (presetsMgr)
-    {
-        presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this));
-        presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok
-    }
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this));
+		presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok
+	}
 
-    return LLPanelPreference::postBuild();
+	return LLPanelPreference::postBuild();
 }
 
 void LLPanelPreferenceView::onPresetsListChangeCamera()
 {
-    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-    if (presetsMgr)
-    {
-        presetsMgr->setCameraDirty(false);
-    }
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		presetsMgr->setCameraDirty(false);
+	}
 
-    setPresetText();
+	setPresetText();
 
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance && !gSavedSettings.getString("PresetCameraActive").empty())
-    {
-        instance->saveSettings(); //make cancel work correctly after changing the preset
-    }
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance && !gSavedSettings.getString("PresetCameraActive").empty())
+	{
+		instance->saveSettings(); //make cancel work correctly after changing the preset
+	}
 }
 
 void LLPanelPreferenceView::draw()
 {
-    setPresetText();
-    LLPanelPreference::draw();
+	setPresetText();
+	LLPanelPreference::draw();
 }
 
 void LLPanelPreferenceView::setPresetText()
 {
-    LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text");
-
-    std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive");
-
-    if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText())
-    {
-        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-        if (instance)
-        {
-            instance->saveCameraPreset(preset_camera_active);
-        }
-    }
-
-    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-    if (presetsMgr)
-    {
-        if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
-        {
-            preset_camera_active.clear();
-        }
-    }
-
-    if (!preset_camera_active.empty())
-    {
-        if (preset_camera_active == PRESETS_DEFAULT)
-        {
-            preset_camera_active = LLTrans::getString(PRESETS_DEFAULT);
-        }
-        preset_text->setText(preset_camera_active);
-    }
-    else
-    {
-        preset_text->setText(LLTrans::getString("none_paren_cap"));
-    }
+	LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text");
+
+	std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive");
+
+	if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText())
+	{
+		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+		if (instance)
+		{
+			instance->saveCameraPreset(preset_camera_active);
+		}
+	}
+
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
+		{
+			preset_camera_active.clear();
+		}
+	}
+
+	if (!preset_camera_active.empty())
+	{
+		if (preset_camera_active == PRESETS_DEFAULT)
+		{
+			preset_camera_active = LLTrans::getString(PRESETS_DEFAULT);
+		}
+		preset_text->setText(preset_camera_active);
+	}
+	else
+	{
+		preset_text->setText(LLTrans::getString("none_paren_cap"));
+	}
 }
 
 BOOL LLPanelPreferenceGraphics::postBuild()
 {
-    LLFloaterReg::showInstance("prefs_graphics_advanced");
-    LLFloaterReg::hideInstance("prefs_graphics_advanced");
+	LLFloaterReg::showInstance("prefs_graphics_advanced");
+	LLFloaterReg::hideInstance("prefs_graphics_advanced");
 
-    resetDirtyChilds();
-    setPresetText();
+	resetDirtyChilds();
+	setPresetText();
 
-    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
     presetsMgr->setPresetListChangeCallback(boost::bind(&LLPanelPreferenceGraphics::onPresetsListChange, this));
     presetsMgr->createMissingDefault(PRESETS_GRAPHIC); // a no-op after the first time, but that's ok
     
-    return LLPanelPreference::postBuild();
+	return LLPanelPreference::postBuild();
 }
 
 void LLPanelPreferenceGraphics::draw()
 {
-    setPresetText();
-    LLPanelPreference::draw();
+	setPresetText();
+	LLPanelPreference::draw();
 }
 
 void LLPanelPreferenceGraphics::onPresetsListChange()
 {
-    resetDirtyChilds();
-    setPresetText();
+	resetDirtyChilds();
+	setPresetText();
 
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance && !gSavedSettings.getString("PresetGraphicActive").empty())
-    {
-        instance->saveSettings(); //make cancel work correctly after changing the preset
-    }
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance && !gSavedSettings.getString("PresetGraphicActive").empty())
+	{
+		instance->saveSettings(); //make cancel work correctly after changing the preset
+	}
 }
 
 void LLPanelPreferenceGraphics::setPresetText()
 {
-    LLTextBox* preset_text = getChild<LLTextBox>("preset_text");
-
-    std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-
-    if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText())
-    {
-        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-        if (instance)
-        {
-            instance->saveGraphicsPreset(preset_graphic_active);
-        }
-    }
-
-    if (hasDirtyChilds() && !preset_graphic_active.empty())
-    {
-        gSavedSettings.setString("PresetGraphicActive", "");
-        preset_graphic_active.clear();
-        // This doesn't seem to cause an infinite recursion.  This trigger is needed to cause the pulldown
-        // panel to update.
-        LLPresetsManager::getInstance()->triggerChangeSignal();
-    }
-
-    if (!preset_graphic_active.empty())
-    {
-        if (preset_graphic_active == PRESETS_DEFAULT)
-        {
-            preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT);
-        }
-        preset_text->setText(preset_graphic_active);
-    }
-    else
-    {
-        preset_text->setText(LLTrans::getString("none_paren_cap"));
-    }
-
-    preset_text->resetDirty();
+	LLTextBox* preset_text = getChild<LLTextBox>("preset_text");
+
+	std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+
+	if (!preset_graphic_active.empty() && preset_graphic_active != preset_text->getText())
+	{
+		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+		if (instance)
+		{
+			instance->saveGraphicsPreset(preset_graphic_active);
+		}
+	}
+
+	if (hasDirtyChilds() && !preset_graphic_active.empty())
+	{
+		gSavedSettings.setString("PresetGraphicActive", "");
+		preset_graphic_active.clear();
+		// This doesn't seem to cause an infinite recursion.  This trigger is needed to cause the pulldown
+		// panel to update.
+		LLPresetsManager::getInstance()->triggerChangeSignal();
+	}
+
+	if (!preset_graphic_active.empty())
+	{
+		if (preset_graphic_active == PRESETS_DEFAULT)
+		{
+			preset_graphic_active = LLTrans::getString(PRESETS_DEFAULT);
+		}
+		preset_text->setText(preset_graphic_active);
+	}
+	else
+	{
+		preset_text->setText(LLTrans::getString("none_paren_cap"));
+	}
+
+	preset_text->resetDirty();
 }
 
 bool LLPanelPreferenceGraphics::hasDirtyChilds()
 {
-    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-    std::list<LLView*> view_stack;
-    view_stack.push_back(this);
-    if (advanced)
-    {
-        view_stack.push_back(advanced);
-    }
-    while(!view_stack.empty())
-    {
-        // Process view on top of the stack
-        LLView* curview = view_stack.front();
-        view_stack.pop_front();
-
-        LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-        if (ctrl)
-        {
-            if (ctrl->isDirty())
-            {
-                LLControlVariable* control = ctrl->getControlVariable();
-                if (control)
-                {
-                    std::string control_name = control->getName();
-                    if (!control_name.empty())
-                    {
-                        return true;
-                    }
-                }
-            }
-        }
-        // Push children onto the end of the work stack
-        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-             iter != curview->getChildList()->end(); ++iter)
-        {
-            view_stack.push_back(*iter);
-        }
-    }
-
-    return false;
+	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+	std::list<LLView*> view_stack;
+	view_stack.push_back(this);
+	if (advanced)
+	{
+		view_stack.push_back(advanced);
+	}
+	while(!view_stack.empty())
+	{
+		// Process view on top of the stack
+		LLView* curview = view_stack.front();
+		view_stack.pop_front();
+
+		LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+		if (ctrl)
+		{
+			if (ctrl->isDirty())
+			{
+				LLControlVariable* control = ctrl->getControlVariable();
+				if (control)
+				{
+					std::string control_name = control->getName();
+					if (!control_name.empty())
+					{
+						return true;
+					}
+				}
+			}
+		}
+		// Push children onto the end of the work stack
+		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+			 iter != curview->getChildList()->end(); ++iter)
+		{
+			view_stack.push_back(*iter);
+		}
+	}
+
+	return false;
 }
 
 void LLPanelPreferenceGraphics::resetDirtyChilds()
 {
-    LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
-    std::list<LLView*> view_stack;
-    view_stack.push_back(this);
-    if (advanced)
-    {
-        view_stack.push_back(advanced);
-    }
-    while(!view_stack.empty())
-    {
-        // Process view on top of the stack
-        LLView* curview = view_stack.front();
-        view_stack.pop_front();
-
-        LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-        if (ctrl)
-        {
-            ctrl->resetDirty();
-        }
-        // Push children onto the end of the work stack
-        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-             iter != curview->getChildList()->end(); ++iter)
-        {
-            view_stack.push_back(*iter);
-        }
-    }   
+	LLFloater* advanced = LLFloaterReg::findTypedInstance<LLFloater>("prefs_graphics_advanced");
+	std::list<LLView*> view_stack;
+	view_stack.push_back(this);
+	if (advanced)
+	{
+		view_stack.push_back(advanced);
+	}
+	while(!view_stack.empty())
+	{
+		// Process view on top of the stack
+		LLView* curview = view_stack.front();
+		view_stack.pop_front();
+
+		LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+		if (ctrl)
+		{
+			ctrl->resetDirty();
+		}
+		// Push children onto the end of the work stack
+		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+			 iter != curview->getChildList()->end(); ++iter)
+		{
+			view_stack.push_back(*iter);
+		}
+	}	
 }
 
 void LLPanelPreferenceGraphics::cancel()
 {
-    LLPanelPreference::cancel();
+	LLPanelPreference::cancel();
 }
 void LLPanelPreferenceGraphics::saveSettings()
 {
-    resetDirtyChilds();
-    std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-    if (preset_graphic_active.empty())
-    {
-        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-        if (instance)
-        {
-            //don't restore previous preset after closing Preferences
-            instance->saveGraphicsPreset(preset_graphic_active);
-        }
-    }
-    LLPanelPreference::saveSettings();
+	resetDirtyChilds();
+	std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+	if (preset_graphic_active.empty())
+	{
+		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+		if (instance)
+		{
+			//don't restore previous preset after closing Preferences
+			instance->saveGraphicsPreset(preset_graphic_active);
+		}
+	}
+	LLPanelPreference::saveSettings();
 }
 void LLPanelPreferenceGraphics::setHardwareDefaults()
 {
-    resetDirtyChilds();
+	resetDirtyChilds();
 }
 
 LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key)
-    : LLFloater(key)
+	: LLFloater(key)
 {
-    mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",     boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this));
-    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this));
-    mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",   boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this));
+	mCommitCallbackRegistrar.add("Pref.VertexShaderEnable",		boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this));
+	mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this));
+	mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity",   boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this));
 }
 
 LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced()
@@ -2852,12 +2852,12 @@ LLFloaterPreferenceGraphicsAdvanced::~LLFloaterPreferenceGraphicsAdvanced()
 }
 
 LLFloaterPreferenceProxy::LLFloaterPreferenceProxy(const LLSD& key)
-    : LLFloater(key),
-      mSocksSettingsDirty(false)
+	: LLFloater(key),
+	  mSocksSettingsDirty(false)
 {
-    mCommitCallbackRegistrar.add("Proxy.OK",                boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this));
-    mCommitCallbackRegistrar.add("Proxy.Cancel",            boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this));
-    mCommitCallbackRegistrar.add("Proxy.Change",            boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this));
+	mCommitCallbackRegistrar.add("Proxy.OK",                boost::bind(&LLFloaterPreferenceProxy::onBtnOk, this));
+	mCommitCallbackRegistrar.add("Proxy.Cancel",            boost::bind(&LLFloaterPreferenceProxy::onBtnCancel, this));
+	mCommitCallbackRegistrar.add("Proxy.Change",            boost::bind(&LLFloaterPreferenceProxy::onChangeSocksSettings, this));
 }
 
 BOOL LLFloaterPreferenceGraphicsAdvanced::postBuild()
@@ -2884,11 +2884,11 @@ void LLFloaterPreferenceGraphicsAdvanced::onOpen(const LLSD& key)
 
 void LLFloaterPreferenceGraphicsAdvanced::onClickCloseBtn(bool app_quitting)
 {
-    LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-    if (instance)
-    {
-        instance->cancel();
-    }
+	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+	if (instance)
+	{
+		instance->cancel();
+	}
 }
 
 LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy()
@@ -2897,182 +2897,182 @@ LLFloaterPreferenceProxy::~LLFloaterPreferenceProxy()
 
 BOOL LLFloaterPreferenceProxy::postBuild()
 {
-    LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
-    if (!socksAuth)
-    {
-        return FALSE;
-    }
-    if (socksAuth->getSelectedValue().asString() == "None")
-    {
-        getChild<LLLineEditor>("socks5_username")->setEnabled(false);
-        getChild<LLLineEditor>("socks5_password")->setEnabled(false);
-    }
-    else
-    {
-        // Populate the SOCKS 5 credential fields with protected values.
-        LLPointer<LLCredential> socks_cred = gSecAPIHandler->loadCredential("SOCKS5");
-        getChild<LLLineEditor>("socks5_username")->setValue(socks_cred->getIdentifier()["username"].asString());
-        getChild<LLLineEditor>("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString());
-    }
-
-    return TRUE;
+	LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+	if (!socksAuth)
+	{
+		return FALSE;
+	}
+	if (socksAuth->getSelectedValue().asString() == "None")
+	{
+		getChild<LLLineEditor>("socks5_username")->setEnabled(false);
+		getChild<LLLineEditor>("socks5_password")->setEnabled(false);
+	}
+	else
+	{
+		// Populate the SOCKS 5 credential fields with protected values.
+		LLPointer<LLCredential> socks_cred = gSecAPIHandler->loadCredential("SOCKS5");
+		getChild<LLLineEditor>("socks5_username")->setValue(socks_cred->getIdentifier()["username"].asString());
+		getChild<LLLineEditor>("socks5_password")->setValue(socks_cred->getAuthenticator()["creds"].asString());
+	}
+
+	return TRUE;
 }
 
 void LLFloaterPreferenceProxy::onOpen(const LLSD& key)
 {
-    saveSettings();
+	saveSettings();
 }
 
 void LLFloaterPreferenceProxy::onClose(bool app_quitting)
 {
-    if(app_quitting)
-    {
-        cancel();
-    }
+	if(app_quitting)
+	{
+		cancel();
+	}
 
-    if (mSocksSettingsDirty)
-    {
+	if (mSocksSettingsDirty)
+	{
 
-        // If the user plays with the Socks proxy settings after login, it's only fair we let them know
-        // it will not be updated until next restart.
-        if (LLStartUp::getStartupState()>STATE_LOGIN_WAIT)
-        {
-            LLNotifications::instance().add("ChangeProxySettings", LLSD(), LLSD());
-            mSocksSettingsDirty = false; // we have notified the user now be quiet again
-        }
-    }
+		// If the user plays with the Socks proxy settings after login, it's only fair we let them know
+		// it will not be updated until next restart.
+		if (LLStartUp::getStartupState()>STATE_LOGIN_WAIT)
+		{
+			LLNotifications::instance().add("ChangeProxySettings", LLSD(), LLSD());
+			mSocksSettingsDirty = false; // we have notified the user now be quiet again
+		}
+	}
 }
 
 void LLFloaterPreferenceProxy::saveSettings()
 {
-    // Save the value of all controls in the hierarchy
-    mSavedValues.clear();
-    std::list<LLView*> view_stack;
-    view_stack.push_back(this);
-    while(!view_stack.empty())
-    {
-        // Process view on top of the stack
-        LLView* curview = view_stack.front();
-        view_stack.pop_front();
-
-        LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
-        if (ctrl)
-        {
-            LLControlVariable* control = ctrl->getControlVariable();
-            if (control)
-            {
-                mSavedValues[control] = control->getValue();
-            }
-        }
-
-        // Push children onto the end of the work stack
-        for (child_list_t::const_iterator iter = curview->getChildList()->begin();
-                iter != curview->getChildList()->end(); ++iter)
-        {
-            view_stack.push_back(*iter);
-        }
-    }
+	// Save the value of all controls in the hierarchy
+	mSavedValues.clear();
+	std::list<LLView*> view_stack;
+	view_stack.push_back(this);
+	while(!view_stack.empty())
+	{
+		// Process view on top of the stack
+		LLView* curview = view_stack.front();
+		view_stack.pop_front();
+
+		LLUICtrl* ctrl = dynamic_cast<LLUICtrl*>(curview);
+		if (ctrl)
+		{
+			LLControlVariable* control = ctrl->getControlVariable();
+			if (control)
+			{
+				mSavedValues[control] = control->getValue();
+			}
+		}
+
+		// Push children onto the end of the work stack
+		for (child_list_t::const_iterator iter = curview->getChildList()->begin();
+				iter != curview->getChildList()->end(); ++iter)
+		{
+			view_stack.push_back(*iter);
+		}
+	}
 }
 
 void LLFloaterPreferenceProxy::onBtnOk()
 {
-    // commit any outstanding text entry
-    if (hasFocus())
-    {
-        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-        if (cur_focus && cur_focus->acceptsTextInput())
-        {
-            cur_focus->onCommit();
-        }
-    }
-
-    // Save SOCKS proxy credentials securely if password auth is enabled
-    LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
-    if (socksAuth->getSelectedValue().asString() == "UserPass")
-    {
-        LLSD socks_id = LLSD::emptyMap();
-        socks_id["type"] = "SOCKS5";
-        socks_id["username"] = getChild<LLLineEditor>("socks5_username")->getValue().asString();
-
-        LLSD socks_authenticator = LLSD::emptyMap();
-        socks_authenticator["type"] = "SOCKS5";
-        socks_authenticator["creds"] = getChild<LLLineEditor>("socks5_password")->getValue().asString();
-
-        // Using "SOCKS5" as the "grid" argument since the same proxy
-        // settings will be used for all grids and because there is no
-        // way to specify the type of credential.
-        LLPointer<LLCredential> socks_cred = gSecAPIHandler->createCredential("SOCKS5", socks_id, socks_authenticator);
-        gSecAPIHandler->saveCredential(socks_cred, true);
-    }
-    else
-    {
-        // Clear SOCKS5 credentials since they are no longer needed.
-        LLPointer<LLCredential> socks_cred = new LLCredential("SOCKS5");
-        gSecAPIHandler->deleteCredential(socks_cred);
-    }
-
-    closeFloater(false);
+	// commit any outstanding text entry
+	if (hasFocus())
+	{
+		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+		if (cur_focus && cur_focus->acceptsTextInput())
+		{
+			cur_focus->onCommit();
+		}
+	}
+
+	// Save SOCKS proxy credentials securely if password auth is enabled
+	LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+	if (socksAuth->getSelectedValue().asString() == "UserPass")
+	{
+		LLSD socks_id = LLSD::emptyMap();
+		socks_id["type"] = "SOCKS5";
+		socks_id["username"] = getChild<LLLineEditor>("socks5_username")->getValue().asString();
+
+		LLSD socks_authenticator = LLSD::emptyMap();
+		socks_authenticator["type"] = "SOCKS5";
+		socks_authenticator["creds"] = getChild<LLLineEditor>("socks5_password")->getValue().asString();
+
+		// Using "SOCKS5" as the "grid" argument since the same proxy
+		// settings will be used for all grids and because there is no
+		// way to specify the type of credential.
+		LLPointer<LLCredential> socks_cred = gSecAPIHandler->createCredential("SOCKS5", socks_id, socks_authenticator);
+		gSecAPIHandler->saveCredential(socks_cred, true);
+	}
+	else
+	{
+		// Clear SOCKS5 credentials since they are no longer needed.
+		LLPointer<LLCredential> socks_cred = new LLCredential("SOCKS5");
+		gSecAPIHandler->deleteCredential(socks_cred);
+	}
+
+	closeFloater(false);
 }
 
 void LLFloaterPreferenceProxy::onBtnCancel()
 {
-    if (hasFocus())
-    {
-        LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
-        if (cur_focus && cur_focus->acceptsTextInput())
-        {
-            cur_focus->onCommit();
-        }
-        refresh();
-    }
+	if (hasFocus())
+	{
+		LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
+		if (cur_focus && cur_focus->acceptsTextInput())
+		{
+			cur_focus->onCommit();
+		}
+		refresh();
+	}
 
-    cancel();
+	cancel();
 }
 
 void LLFloaterPreferenceProxy::onClickCloseBtn(bool app_quitting)
 {
-    cancel();
+	cancel();
 }
 
 void LLFloaterPreferenceProxy::cancel()
 {
 
-    for (control_values_map_t::iterator iter =  mSavedValues.begin();
-            iter !=  mSavedValues.end(); ++iter)
-    {
-        LLControlVariable* control = iter->first;
-        LLSD ctrl_value = iter->second;
-        control->set(ctrl_value);
-    }
-    mSocksSettingsDirty = false;
-    closeFloater();
+	for (control_values_map_t::iterator iter =  mSavedValues.begin();
+			iter !=  mSavedValues.end(); ++iter)
+	{
+		LLControlVariable* control = iter->first;
+		LLSD ctrl_value = iter->second;
+		control->set(ctrl_value);
+	}
+	mSocksSettingsDirty = false;
+	closeFloater();
 }
 
 void LLFloaterPreferenceProxy::onChangeSocksSettings() 
 {
-    mSocksSettingsDirty = true;
-
-    LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
-    if (socksAuth->getSelectedValue().asString() == "None")
-    {
-        getChild<LLLineEditor>("socks5_username")->setEnabled(false);
-        getChild<LLLineEditor>("socks5_password")->setEnabled(false);
-    }
-    else
-    {
-        getChild<LLLineEditor>("socks5_username")->setEnabled(true);
-        getChild<LLLineEditor>("socks5_password")->setEnabled(true);
-    }
-
-    // Check for invalid states for the other HTTP proxy radio
-    LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_type");
-    if ((otherHttpProxy->getSelectedValue().asString() == "Socks" &&
-            getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||(
-                    otherHttpProxy->getSelectedValue().asString() == "Web" &&
-                    getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) )
-    {
-        otherHttpProxy->selectFirstItem();
-    }
+	mSocksSettingsDirty = true;
+
+	LLRadioGroup* socksAuth = getChild<LLRadioGroup>("socks5_auth_type");
+	if (socksAuth->getSelectedValue().asString() == "None")
+	{
+		getChild<LLLineEditor>("socks5_username")->setEnabled(false);
+		getChild<LLLineEditor>("socks5_password")->setEnabled(false);
+	}
+	else
+	{
+		getChild<LLLineEditor>("socks5_username")->setEnabled(true);
+		getChild<LLLineEditor>("socks5_password")->setEnabled(true);
+	}
+
+	// Check for invalid states for the other HTTP proxy radio
+	LLRadioGroup* otherHttpProxy = getChild<LLRadioGroup>("other_http_proxy_type");
+	if ((otherHttpProxy->getSelectedValue().asString() == "Socks" &&
+			getChild<LLCheckBoxCtrl>("socks_proxy_enabled")->get() == FALSE )||(
+					otherHttpProxy->getSelectedValue().asString() == "Web" &&
+					getChild<LLCheckBoxCtrl>("web_proxy_enabled")->get() == FALSE ) )
+	{
+		otherHttpProxy->selectFirstItem();
+	}
 
 }
 
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 0d383c1da0..da96e68f5e 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -50,308 +50,308 @@ class LLTextBox;
 typedef std::map<std::string, std::string> notifications_map;
 
 typedef enum
-    {
-        GS_LOW_GRAPHICS,
-        GS_MID_GRAPHICS,
-        GS_HIGH_GRAPHICS,
-        GS_ULTRA_GRAPHICS
-        
-    } EGraphicsSettings;
+	{
+		GS_LOW_GRAPHICS,
+		GS_MID_GRAPHICS,
+		GS_HIGH_GRAPHICS,
+		GS_ULTRA_GRAPHICS
+		
+	} EGraphicsSettings;
 
 // Floater to control preferences (display, audio, bandwidth, general.
 class LLFloaterPreference : public LLFloater, public LLAvatarPropertiesObserver, public LLConversationLogObserver
 {
 public: 
-    LLFloaterPreference(const LLSD& key);
-    ~LLFloaterPreference();
-
-    void apply();
-    void cancel();
-    /*virtual*/ void draw();
-    /*virtual*/ BOOL postBuild();
-    /*virtual*/ void onOpen(const LLSD& key);
-    /*virtual*/ void onClose(bool app_quitting);
-    /*virtual*/ void changed();
-    /*virtual*/ void changed(const LLUUID& session_id, U32 mask) {};
-
-    // static data update, called from message handler
-    static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
-
-    // refresh all the graphics preferences menus
-    static void refreshEnabledGraphics();
-    
-    // translate user's do not disturb response message according to current locale if message is default, otherwise do nothing
-    static void initDoNotDisturbResponse();
-
-    // update Show Favorites checkbox
-    static void updateShowFavoritesCheckbox(bool val);
-
-    void processProperties( void* pData, EAvatarProcessorType type );
-    void processProfileProperties(const LLAvatarData* pAvatarData );
-    void storeAvatarProperties( const LLAvatarData* pAvatarData );
-    void saveAvatarProperties( void );
-    void selectPrivacyPanel();
-    void selectChatPanel();
-    void getControlNames(std::vector<std::string>& names);
-
-protected:  
-    void        onBtnOK(const LLSD& userdata);
-    void        onBtnCancel(const LLSD& userdata);
-
-    void        onClickClearCache();            // Clear viewer texture cache, vfs, and VO cache on next startup
-    void        onClickBrowserClearCache();     // Clear web history and caches as well as viewer caches above
-    void        onLanguageChange();
-    void        onNotificationsChange(const std::string& OptionName);
-    void        onNameTagOpacityChange(const LLSD& newvalue);
-
-    // set value of "DoNotDisturbResponseChanged" in account settings depending on whether do not disturb response
-    // string differs from default after user changes.
-    void onDoNotDisturbResponseChanged();
-    // if the custom settings box is clicked
-    void onChangeCustom();
-    void updateMeterText(LLUICtrl* ctrl);
-    // callback for defaults
-    void setHardwareDefaults();
-    void setRecommended();
-    // callback for when client turns on shaders
-    void onVertexShaderEnable();
-    // callback for when client turns on impostors
-    void onAvatarImpostorsEnable();
-
-    // callback for commit in the "Single click on land" and "Double click on land" comboboxes.
-    void onClickActionChange();
-    // updates click/double-click action settings depending on controls values
-    void updateClickActionSettings();
-    // updates click/double-click action controls depending on values from settings.xml
-    void updateClickActionControls();
+	LLFloaterPreference(const LLSD& key);
+	~LLFloaterPreference();
+
+	void apply();
+	void cancel();
+	/*virtual*/ void draw();
+	/*virtual*/ BOOL postBuild();
+	/*virtual*/ void onOpen(const LLSD& key);
+	/*virtual*/	void onClose(bool app_quitting);
+	/*virtual*/ void changed();
+	/*virtual*/ void changed(const LLUUID& session_id, U32 mask) {};
+
+	// static data update, called from message handler
+	static void updateUserInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
+
+	// refresh all the graphics preferences menus
+	static void refreshEnabledGraphics();
+	
+	// translate user's do not disturb response message according to current locale if message is default, otherwise do nothing
+	static void initDoNotDisturbResponse();
+
+	// update Show Favorites checkbox
+	static void updateShowFavoritesCheckbox(bool val);
+
+	void processProperties( void* pData, EAvatarProcessorType type );
+	void processProfileProperties(const LLAvatarData* pAvatarData );
+	void storeAvatarProperties( const LLAvatarData* pAvatarData );
+	void saveAvatarProperties( void );
+	void selectPrivacyPanel();
+	void selectChatPanel();
+	void getControlNames(std::vector<std::string>& names);
+
+protected:	
+	void		onBtnOK(const LLSD& userdata);
+	void		onBtnCancel(const LLSD& userdata);
+
+	void		onClickClearCache();			// Clear viewer texture cache, vfs, and VO cache on next startup
+	void		onClickBrowserClearCache();		// Clear web history and caches as well as viewer caches above
+	void		onLanguageChange();
+	void		onNotificationsChange(const std::string& OptionName);
+	void		onNameTagOpacityChange(const LLSD& newvalue);
+
+	// set value of "DoNotDisturbResponseChanged" in account settings depending on whether do not disturb response
+	// string differs from default after user changes.
+	void onDoNotDisturbResponseChanged();
+	// if the custom settings box is clicked
+	void onChangeCustom();
+	void updateMeterText(LLUICtrl* ctrl);
+	// callback for defaults
+	void setHardwareDefaults();
+	void setRecommended();
+	// callback for when client turns on shaders
+	void onVertexShaderEnable();
+	// callback for when client turns on impostors
+	void onAvatarImpostorsEnable();
+
+	// callback for commit in the "Single click on land" and "Double click on land" comboboxes.
+	void onClickActionChange();
+	// updates click/double-click action settings depending on controls values
+	void updateClickActionSettings();
+	// updates click/double-click action controls depending on values from settings.xml
+	void updateClickActionControls();
 
 public:
-    // This function squirrels away the current values of the controls so that
-    // cancel() can restore them.   
-    void saveSettings();
-
-    void setCacheLocation(const LLStringExplicit& location);
-
-    void onClickSetCache();
-    void changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name);
-    void onClickResetCache();
-    void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata);
-    void onSelectSkin();
-    void onClickSetKey();
-    void setKey(KEY key);
-    void onClickSetMiddleMouse();
-    void onClickSetSounds();
-    void onClickEnablePopup();
-    void onClickDisablePopup(); 
-    void resetAllIgnored();
-    void setAllIgnored();
-    void onClickLogPath();
-    void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name);
-    bool moveTranscriptsAndLog();
-    void enableHistory();
-    void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
-    void refreshEnabledState();
-    void onCommitWindowedMode();
-    void refresh(); // Refresh enable/disable
-    // if the quality radio buttons are changed
-    void onChangeQuality(const LLSD& data);
-    
-    void refreshUI();
-
-    void onCommitParcelMediaAutoPlayEnable();
-    void onCommitMediaEnabled();
-    void onCommitMusicEnabled();
-    void applyResolution();
-    void onChangeMaturity();
-    void onChangeModelFolder();
-    void onChangeTextureFolder();
-    void onChangeSoundFolder();
-    void onChangeAnimationFolder();
-    void onClickBlockList();
-    void onClickProxySettings();
-    void onClickTranslationSettings();
-    void onClickPermsDefault();
-    void onClickAutoReplace();
-    void onClickSpellChecker();
-    void onClickRenderExceptions();
-    void onClickAdvanced();
-    void applyUIColor(LLUICtrl* ctrl, const LLSD& param);
-    void getUIColor(LLUICtrl* ctrl, const LLSD& param);
-    void onLogChatHistorySaved();   
-    void buildPopupLists();
-    static void refreshSkin(void* data);
-    void selectPanel(const LLSD& name);
-    void saveCameraPreset(std::string& preset);
-    void saveGraphicsPreset(std::string& preset);
+	// This function squirrels away the current values of the controls so that
+	// cancel() can restore them.	
+	void saveSettings();
+
+	void setCacheLocation(const LLStringExplicit& location);
+
+	void onClickSetCache();
+	void changeCachePath(const std::vector<std::string>& filenames, std::string proposed_name);
+	void onClickResetCache();
+	void onClickSkin(LLUICtrl* ctrl,const LLSD& userdata);
+	void onSelectSkin();
+	void onClickSetKey();
+	void setKey(KEY key);
+	void onClickSetMiddleMouse();
+	void onClickSetSounds();
+	void onClickEnablePopup();
+	void onClickDisablePopup();	
+	void resetAllIgnored();
+	void setAllIgnored();
+	void onClickLogPath();
+	void changeLogPath(const std::vector<std::string>& filenames, std::string proposed_name);
+	bool moveTranscriptsAndLog();
+	void enableHistory();
+	void setPersonalInfo(const std::string& visibility, bool im_via_email, bool is_verified_email);
+	void refreshEnabledState();
+	void onCommitWindowedMode();
+	void refresh();	// Refresh enable/disable
+	// if the quality radio buttons are changed
+	void onChangeQuality(const LLSD& data);
+	
+	void refreshUI();
+
+	void onCommitParcelMediaAutoPlayEnable();
+	void onCommitMediaEnabled();
+	void onCommitMusicEnabled();
+	void applyResolution();
+	void onChangeMaturity();
+	void onChangeModelFolder();
+	void onChangeTextureFolder();
+	void onChangeSoundFolder();
+	void onChangeAnimationFolder();
+	void onClickBlockList();
+	void onClickProxySettings();
+	void onClickTranslationSettings();
+	void onClickPermsDefault();
+	void onClickAutoReplace();
+	void onClickSpellChecker();
+	void onClickRenderExceptions();
+	void onClickAdvanced();
+	void applyUIColor(LLUICtrl* ctrl, const LLSD& param);
+	void getUIColor(LLUICtrl* ctrl, const LLSD& param);
+	void onLogChatHistorySaved();	
+	void buildPopupLists();
+	static void refreshSkin(void* data);
+	void selectPanel(const LLSD& name);
+	void saveCameraPreset(std::string& preset);
+	void saveGraphicsPreset(std::string& preset);
 
 private:
 
-    void onDeleteTranscripts();
-    void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response);
-    void updateDeleteTranscriptsButton();
-    void updateMaxComplexity();
-
-    static std::string sSkin;
-    notifications_map mNotificationOptions;
-    bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user.
-    bool mGotPersonalInfo;
-    bool mOriginalIMViaEmail;
-    bool mLanguageChanged;
-    bool mAvatarDataInitialized;
-    std::string mPriorInstantMessageLogPath;
-    
-    bool mOriginalHideOnlineStatus;
-    std::string mDirectoryVisibility;
-    
-    LLAvatarData mAvatarProperties;
-    std::string mSavedCameraPreset;
-    std::string mSavedGraphicsPreset;
-    LOG_CLASS(LLFloaterPreference);
+	void onDeleteTranscripts();
+	void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response);
+	void updateDeleteTranscriptsButton();
+	void updateMaxComplexity();
+
+	static std::string sSkin;
+	notifications_map mNotificationOptions;
+	bool mClickActionDirty; ///< Set to true when the click/double-click options get changed by user.
+	bool mGotPersonalInfo;
+	bool mOriginalIMViaEmail;
+	bool mLanguageChanged;
+	bool mAvatarDataInitialized;
+	std::string mPriorInstantMessageLogPath;
+	
+	bool mOriginalHideOnlineStatus;
+	std::string mDirectoryVisibility;
+	
+	LLAvatarData mAvatarProperties;
+	std::string mSavedCameraPreset;
+	std::string mSavedGraphicsPreset;
+	LOG_CLASS(LLFloaterPreference);
 };
 
 class LLPanelPreference : public LLPanel
 {
 public:
-    LLPanelPreference();
-    /*virtual*/ BOOL postBuild();
-    
-    virtual ~LLPanelPreference();
+	LLPanelPreference();
+	/*virtual*/ BOOL postBuild();
+	
+	virtual ~LLPanelPreference();
 
-    virtual void apply();
-    virtual void cancel();
-    void setControlFalse(const LLSD& user_data);
-    virtual void setHardwareDefaults();
+	virtual void apply();
+	virtual void cancel();
+	void setControlFalse(const LLSD& user_data);
+	virtual void setHardwareDefaults();
 
-    // Disables "Allow Media to auto play" check box only when both
-    // "Streaming Music" and "Media" are unchecked. Otherwise enables it.
-    void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl);
+	// Disables "Allow Media to auto play" check box only when both
+	// "Streaming Music" and "Media" are unchecked. Otherwise enables it.
+	void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl);
 
-    // This function squirrels away the current values of the controls so that
-    // cancel() can restore them.
-    virtual void saveSettings();
+	// This function squirrels away the current values of the controls so that
+	// cancel() can restore them.
+	virtual void saveSettings();
 
-    void deletePreset(const LLSD& user_data);
-    void savePreset(const LLSD& user_data);
-    void loadPreset(const LLSD& user_data);
+	void deletePreset(const LLSD& user_data);
+	void savePreset(const LLSD& user_data);
+	void loadPreset(const LLSD& user_data);
 
-    class Updater;
+	class Updater;
 
 protected:
-    typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
-    control_values_map_t mSavedValues;
+	typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
+	control_values_map_t mSavedValues;
 
 private:
-    //for "Only friends and groups can call or IM me"
-    static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&);
+	//for "Only friends and groups can call or IM me"
+	static void showFriendsOnlyWarning(LLUICtrl*, const LLSD&);
     //for  "Allow Multiple Viewers"
     static void showMultipleViewersWarning(LLUICtrl*, const LLSD&);
-    //for "Show my Favorite Landmarks at Login"
-    static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value);
+	//for "Show my Favorite Landmarks at Login"
+	static void handleFavoritesOnLoginChanged(LLUICtrl* checkbox, const LLSD& value);
 
-    static void toggleMuteWhenMinimized();
-    typedef std::map<std::string, LLColor4> string_color_map_t;
-    string_color_map_t mSavedColors;
+	static void toggleMuteWhenMinimized();
+	typedef std::map<std::string, LLColor4> string_color_map_t;
+	string_color_map_t mSavedColors;
 
-    Updater* mBandWidthUpdater;
-    LOG_CLASS(LLPanelPreference);
+	Updater* mBandWidthUpdater;
+	LOG_CLASS(LLPanelPreference);
 };
 
 class LLPanelPreferenceView : public LLPanelPreference
 {
 public:
-    BOOL postBuild();
-    void draw();
-    void setPresetText();
+	BOOL postBuild();
+	void draw();
+	void setPresetText();
 
 private:
-    void onPresetsListChangeCamera();
-    LOG_CLASS(LLPanelPreferenceView);
+	void onPresetsListChangeCamera();
+	LOG_CLASS(LLPanelPreferenceView);
 };
 
 class LLPanelPreferenceGraphics : public LLPanelPreference
 {
 public:
-    BOOL postBuild();
-    void draw();
-    void cancel();
-    void saveSettings();
-    void resetDirtyChilds();
-    void setHardwareDefaults();
-    void setPresetText();
+	BOOL postBuild();
+	void draw();
+	void cancel();
+	void saveSettings();
+	void resetDirtyChilds();
+	void setHardwareDefaults();
+	void setPresetText();
 
-    static const std::string getPresetsPath();
+	static const std::string getPresetsPath();
 
 protected:
-    bool hasDirtyChilds();
+	bool hasDirtyChilds();
 
 private:
-    void onPresetsListChange();
-    LOG_CLASS(LLPanelPreferenceGraphics);
+	void onPresetsListChange();
+	LOG_CLASS(LLPanelPreferenceGraphics);
 };
 
 class LLFloaterPreferenceGraphicsAdvanced : public LLFloater
 {
   public: 
-    LLFloaterPreferenceGraphicsAdvanced(const LLSD& key);
-    ~LLFloaterPreferenceGraphicsAdvanced();
-    /*virtual*/ BOOL postBuild();
-    void onOpen(const LLSD& key);
-    void onClickCloseBtn(bool app_quitting);
-    void disableUnavailableSettings();
-    void refreshEnabledGraphics();
-    void refreshEnabledState();
-    void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box);
-    void updateMaxNonImpostors();
-    void setMaxNonImpostorsText(U32 value, LLTextBox* text_box);
-    void updateMaxComplexity();
-    void setMaxComplexityText(U32 value, LLTextBox* text_box);
-    static void setIndirectControls();
-    static void setIndirectMaxNonImpostors();
-    static void setIndirectMaxArc();
-    void refresh();
-    // callback for when client turns on shaders
-    void onVertexShaderEnable();
-    LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced);
+	LLFloaterPreferenceGraphicsAdvanced(const LLSD& key);
+	~LLFloaterPreferenceGraphicsAdvanced();
+	/*virtual*/ BOOL postBuild();
+	void onOpen(const LLSD& key);
+	void onClickCloseBtn(bool app_quitting);
+	void disableUnavailableSettings();
+	void refreshEnabledGraphics();
+	void refreshEnabledState();
+	void updateSliderText(LLSliderCtrl* ctrl, LLTextBox* text_box);
+	void updateMaxNonImpostors();
+	void setMaxNonImpostorsText(U32 value, LLTextBox* text_box);
+	void updateMaxComplexity();
+	void setMaxComplexityText(U32 value, LLTextBox* text_box);
+	static void setIndirectControls();
+	static void setIndirectMaxNonImpostors();
+	static void setIndirectMaxArc();
+	void refresh();
+	// callback for when client turns on shaders
+	void onVertexShaderEnable();
+	LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced);
 };
 
 class LLAvatarComplexityControls
 {
   public: 
-    static void updateMax(LLSliderCtrl* slider, LLTextBox* value_label);
-    static void setText(U32 value, LLTextBox* text_box);
-    static void setIndirectControls();
-    static void setIndirectMaxNonImpostors();
-    static void setIndirectMaxArc();
-    LOG_CLASS(LLAvatarComplexityControls);
+	static void updateMax(LLSliderCtrl* slider, LLTextBox* value_label);
+	static void setText(U32 value, LLTextBox* text_box);
+	static void setIndirectControls();
+	static void setIndirectMaxNonImpostors();
+	static void setIndirectMaxArc();
+	LOG_CLASS(LLAvatarComplexityControls);
 };
 
 class LLFloaterPreferenceProxy : public LLFloater
 {
 public: 
-    LLFloaterPreferenceProxy(const LLSD& key);
-    ~LLFloaterPreferenceProxy();
+	LLFloaterPreferenceProxy(const LLSD& key);
+	~LLFloaterPreferenceProxy();
 
-    /// show off our menu
-    static void show();
-    void cancel();
-    
+	/// show off our menu
+	static void show();
+	void cancel();
+	
 protected:
-    BOOL postBuild();
-    void onOpen(const LLSD& key);
-    void onClose(bool app_quitting);
-    void saveSettings();
-    void onBtnOk();
-    void onBtnCancel();
-    void onClickCloseBtn(bool app_quitting = false);
+	BOOL postBuild();
+	void onOpen(const LLSD& key);
+	void onClose(bool app_quitting);
+	void saveSettings();
+	void onBtnOk();
+	void onBtnCancel();
+	void onClickCloseBtn(bool app_quitting = false);
 
-    void onChangeSocksSettings();
+	void onChangeSocksSettings();
 
 private:
-    
-    bool mSocksSettingsDirty;
-    typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
-    control_values_map_t mSavedValues;
-    LOG_CLASS(LLFloaterPreferenceProxy);
+	
+	bool mSocksSettingsDirty;
+	typedef std::map<LLControlVariable*, LLSD> control_values_map_t;
+	control_values_map_t mSavedValues;
+	LOG_CLASS(LLFloaterPreferenceProxy);
 };
 
 
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
index e740a3a9cf..791ff79d87 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -34,11 +34,11 @@
 
 
 LLFloaterPreferenceViewAdvanced::LLFloaterPreferenceViewAdvanced(const LLSD& key) 
-:   LLFloater(key)
+:	LLFloater(key)
 {
-    mCommitCallbackRegistrar.add("Cancel",  boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this));
-    mCommitCallbackRegistrar.add("CommitSettings",  boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
-    mCommitCallbackRegistrar.add("Ok",  boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this));
+	mCommitCallbackRegistrar.add("Cancel",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this));
+	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
+	mCommitCallbackRegistrar.add("Ok",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this));
 
 }
 
@@ -47,66 +47,66 @@ LLFloaterPreferenceViewAdvanced::~LLFloaterPreferenceViewAdvanced()
 
 void LLFloaterPreferenceViewAdvanced::onClickOk()
 {
-    closeFloater();
+	closeFloater();
 }
 
 void LLFloaterPreferenceViewAdvanced::onClickCancel()
 {
-    gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
-    gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
+	gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
+	gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
 
-    updateCameraControl(mCameraSaved);
-    updateFocusControl(mFocusSaved);
+	updateCameraControl(mCameraSaved);
+	updateFocusControl(mFocusSaved);
 }
 
 BOOL LLFloaterPreferenceViewAdvanced::postBuild()
 {
-    mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
-    mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
+	mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
+	mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
 
-    updateCameraControl(mCameraSaved);
-    updateFocusControl(mFocusSaved);
+	updateCameraControl(mCameraSaved);
+	updateFocusControl(mFocusSaved);
 
-    return TRUE;
+	return TRUE;
 }
 
 void LLFloaterPreferenceViewAdvanced::updateCameraControl(const LLVector3& vector)
 {
-    getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
-    getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]);
-    getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]);
+	getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
+	getChild<LLSpinCtrl>("camera_y")->setValue(vector[VY]);
+	getChild<LLSpinCtrl>("camera_z")->setValue(vector[VZ]);
 }
 
 void LLFloaterPreferenceViewAdvanced::updateFocusControl(const LLVector3d& vector3d)
 {
-    getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]);
-    getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]);
-    getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]);
+	getChild<LLSpinCtrl>("focus_x")->setValue(vector3d[VX]);
+	getChild<LLSpinCtrl>("focus_y")->setValue(vector3d[VY]);
+	getChild<LLSpinCtrl>("focus_z")->setValue(vector3d[VZ]);
 }
 
  void LLFloaterPreferenceViewAdvanced::draw()
 {
-    static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView");
-    static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView");
+	static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView");
+	static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView");
 
-    updateCameraControl(camera);
-    updateFocusControl(focus);
+	updateCameraControl(camera);
+	updateFocusControl(focus);
 
-    LLFloater::draw();
+	LLFloater::draw();
 }
 
 void LLFloaterPreferenceViewAdvanced::onCommitSettings()
 {
-    LLVector3 vector;
-    LLVector3d vector3d;
-
-    vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
-    vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
-    vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
-    gSavedSettings.setVector3("CameraOffsetRearView", vector);
-
-    vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
-    vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
-    vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
-    gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
+	LLVector3 vector;
+	LLVector3d vector3d;
+
+	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
+	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
+	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
+	gSavedSettings.setVector3("CameraOffsetRearView", vector);
+
+	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
+	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
+	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
+	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
 }
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h
index 9113949273..8f4b594605 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.h
+++ b/indra/newview/llfloaterpreferenceviewadvanced.h
@@ -31,27 +31,27 @@
 #include "llfloater.h"
 
 class LLFloaterPreferenceViewAdvanced
-:   public LLFloater
+:	public LLFloater
 {
-    friend class LLFloaterReg;
+	friend class LLFloaterReg;
 
 public:
-    LLFloaterPreferenceViewAdvanced(const LLSD& key);
-    virtual BOOL postBuild();
-    virtual void draw();
+	LLFloaterPreferenceViewAdvanced(const LLSD& key);
+	virtual BOOL postBuild();
+	virtual void draw();
 
-    void onCommitSettings();
-    void onClickCancel();
-    void onClickOk();
-    void updateCameraControl(const LLVector3& vector);
-    void updateFocusControl(const LLVector3d& vector3d);
+	void onCommitSettings();
+	void onClickCancel();
+	void onClickOk();
+	void updateCameraControl(const LLVector3& vector);
+	void updateFocusControl(const LLVector3d& vector3d);
 
 private:
-    virtual ~LLFloaterPreferenceViewAdvanced();
+	virtual ~LLFloaterPreferenceViewAdvanced();
 
-    LLVector3   mCameraSaved;
-    LLVector3d  mFocusSaved;
-    
+	LLVector3	mCameraSaved;
+	LLVector3d	mFocusSaved;
+	
 };
 
 #endif //LLFLOATERPREFERENCEVIEWADVANCED_H
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index 149451c8c4..bae7602566 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -37,78 +37,78 @@
 #include "lltrans.h"
 
 LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key)
-:   LLFloater(key)
+:	LLFloater(key)
 {
 }
 
 // virtual
 BOOL LLFloaterSavePrefPreset::postBuild()
 {
-    LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
-    if (preferences)
-    {
-        preferences->addDependentFloater(this);
-    }
-    getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
-    getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
-    getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
-    getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
-
-    LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
-
-    mSaveButton = getChild<LLButton>("save");
-    mPresetCombo = getChild<LLComboBox>("preset_combo");
-
-    return TRUE;
+	LLFloaterPreference* preferences = LLFloaterReg::getTypedInstance<LLFloaterPreference>("preferences");
+	if (preferences)
+	{
+		preferences->addDependentFloater(this);
+	}
+	getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
+	getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
+	getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
+	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
+
+	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
+
+	mSaveButton = getChild<LLButton>("save");
+	mPresetCombo = getChild<LLComboBox>("preset_combo");
+
+	return TRUE;
 }
 
 void LLFloaterSavePrefPreset::onPresetNameEdited()
 {
-    // Disable saving a preset having empty name.
-    std::string name = mPresetCombo->getSimple();
+	// Disable saving a preset having empty name.
+	std::string name = mPresetCombo->getSimple();
 
-    mSaveButton->setEnabled(!name.empty());
+	mSaveButton->setEnabled(!name.empty());
 }
 
 void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 {
-    mSubdirectory = key.asString();
+	mSubdirectory = key.asString();
 
-    std::string floater_title = getString(std::string("title_") + mSubdirectory);
+	std::string floater_title = getString(std::string("title_") + mSubdirectory);
 
-    setTitle(floater_title);
+	setTitle(floater_title);
 
-    EDefaultOptions option = DEFAULT_HIDE;
-    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
+	EDefaultOptions option = DEFAULT_HIDE;
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 
-    onPresetNameEdited();
+	onPresetNameEdited();
 }
 
 void LLFloaterSavePrefPreset::onBtnSave()
 {
-    std::string name = mPresetCombo->getSimple();
-
-    if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
-    {
-        LLNotificationsUtil::add("DefaultPresetNotSaved");
-    }
-    else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
-    {
-        LLSD args;
-        args["NAME"] = name;
-        LLNotificationsUtil::add("PresetNotSaved", args);
-    }
-
-    closeFloater();
+	std::string name = mPresetCombo->getSimple();
+
+	if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
+	{
+		LLNotificationsUtil::add("DefaultPresetNotSaved");
+	}
+	else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
+	{
+		LLSD args;
+		args["NAME"] = name;
+		LLNotificationsUtil::add("PresetNotSaved", args);
+	}
+
+	closeFloater();
 }
 
 void LLFloaterSavePrefPreset::onPresetsListChange()
 {
-    EDefaultOptions option = DEFAULT_HIDE;
-    LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
+	EDefaultOptions option = DEFAULT_HIDE;
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 }
 
 void LLFloaterSavePrefPreset::onBtnCancel()
 {
-    closeFloater();
+	closeFloater();
 }
diff --git a/indra/newview/llnavigationbar.h b/indra/newview/llnavigationbar.h
index a9d0f1a82e..a44c6dd699 100755
--- a/indra/newview/llnavigationbar.h
+++ b/indra/newview/llnavigationbar.h
@@ -47,113 +47,113 @@ class LLSearchComboBox;
 
 class LLPullButton: public LLButton
 {
-    LOG_CLASS(LLPullButton);
+	LOG_CLASS(LLPullButton);
 
 public:
-    struct Params: public LLInitParam::Block<Params, LLButton::Params>
-    {
-        Optional<std::string> direction; // left, right, down, up
+	struct Params: public LLInitParam::Block<Params, LLButton::Params>
+	{
+		Optional<std::string> direction; // left, right, down, up
 
-        Params() 
-        :   direction("direction", "down")
-        {
-        }
-    };
-    
-    /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+		Params() 
+		:	direction("direction", "down")
+		{
+		}
+	};
+	
+	/*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
 
-    /*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL handleMouseUp(S32 x, S32 y, MASK mask);
 
-    /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
 
-    boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
+	boost::signals2::connection setClickDraggingCallback(const commit_signal_t::slot_type& cb);
 
 protected:
-    friend class LLUICtrlFactory;
-    // convert string name into direction vector
-    void setDirectionFromName(const std::string& name);
-    LLPullButton(const LLPullButton::Params& params);
-
-    commit_signal_t mClickDraggingSignal;
-    LLVector2 mLastMouseDown;
-    LLVector2 mDraggingDirection;
+	friend class LLUICtrlFactory;
+	// convert string name into direction vector
+	void setDirectionFromName(const std::string& name);
+	LLPullButton(const LLPullButton::Params& params);
+
+	commit_signal_t mClickDraggingSignal;
+	LLVector2 mLastMouseDown;
+	LLVector2 mDraggingDirection;
 };
 
 /**
  * Web browser-like navigation bar.
  */ 
 class LLNavigationBar
-    :   public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar>
+	:	public LLPanel, public LLSingleton<LLNavigationBar>, private LLDestroyClass<LLNavigationBar>
 {
-    LLSINGLETON(LLNavigationBar);
-    virtual ~LLNavigationBar();
-    LOG_CLASS(LLNavigationBar);
-    friend class LLDestroyClass<LLNavigationBar>;
+	LLSINGLETON(LLNavigationBar);
+	virtual ~LLNavigationBar();
+	LOG_CLASS(LLNavigationBar);
+	friend class LLDestroyClass<LLNavigationBar>;
 
 public:
-    
-    /*virtual*/ void    draw();
-    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL    postBuild();
-    /*virtual*/ void    setVisible(BOOL visible);
-
-    void handleLoginComplete();
-    void clearHistoryCache();
-
-    int getDefNavBarHeight();
-    int getDefFavBarHeight();
-    
+	
+	/*virtual*/ void	draw();
+	/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL	postBuild();
+	/*virtual*/ void	setVisible(BOOL visible);
+
+	void handleLoginComplete();
+	void clearHistoryCache();
+
+	int getDefNavBarHeight();
+	int getDefFavBarHeight();
+	
 private:
-    // the distance between navigation panel and favorites panel in pixels
-    const static S32 FAVBAR_TOP_PADDING = 10;
-
-    void rebuildTeleportHistoryMenu();
-    void showTeleportHistoryMenu(LLUICtrl* btn_ctrl);
-    void invokeSearch(std::string search_text);
-    void resizeLayoutPanel();
-    // callbacks
-    void onTeleportHistoryMenuItemClicked(const LLSD& userdata);
-    void onTeleportHistoryChanged();
-    void onBackButtonClicked();
-    void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param);
-    void onNavigationButtonHeldUp(LLButton* nav_button);
-    void onForwardButtonClicked();
-    void onHomeButtonClicked();
-    void onLocationSelection();
-    void onLocationPrearrange(const LLSD& data);
-    void onTeleportFinished(const LLVector3d& global_agent_pos);
-    void onTeleportFailed();
-    void onNavbarResized();
-    void onRegionNameResponse(
-            std::string typed_location,
-            std::string region_name,
-            LLVector3 local_coords,
-            U64 region_handle, const std::string& url,
-            const LLUUID& snapshot_id, bool teleport);
-
-    static void destroyClass()
-    {
-        if (LLNavigationBar::instanceExists())
-        {
-            LLNavigationBar::getInstance()->setEnabled(FALSE);
-        }
-    }
-
-    S32                         mNavPanWidth;
-    LLMenuGL*                   mTeleportHistoryMenu;
-    LLPullButton*               mBtnBack;
-    LLPullButton*               mBtnForward;
-    LLButton*                   mBtnHome;
-    LLLocationInputCtrl*        mCmbLocation;
-    LLRect                      mDefaultNbRect;
-    LLRect                      mDefaultFpRect;
-    LLLayoutPanel*              mNavigationPanel;
-    LLLayoutPanel*              mFavoritePanel;
-    boost::signals2::connection mTeleportFailedConnection;
-    boost::signals2::connection mTeleportFinishConnection;
-    boost::signals2::connection mHistoryMenuConnection;
-    // if true, save location to location history when teleport finishes
-    bool                        mSaveToLocationHistory;
+	// the distance between navigation panel and favorites panel in pixels
+	const static S32 FAVBAR_TOP_PADDING = 10;
+
+	void rebuildTeleportHistoryMenu();
+	void showTeleportHistoryMenu(LLUICtrl* btn_ctrl);
+	void invokeSearch(std::string search_text);
+	void resizeLayoutPanel();
+	// callbacks
+	void onTeleportHistoryMenuItemClicked(const LLSD& userdata);
+	void onTeleportHistoryChanged();
+	void onBackButtonClicked();
+	void onBackOrForwardButtonHeldDown(LLUICtrl* ctrl, const LLSD& param);
+	void onNavigationButtonHeldUp(LLButton* nav_button);
+	void onForwardButtonClicked();
+	void onHomeButtonClicked();
+	void onLocationSelection();
+	void onLocationPrearrange(const LLSD& data);
+	void onTeleportFinished(const LLVector3d& global_agent_pos);
+	void onTeleportFailed();
+	void onNavbarResized();
+	void onRegionNameResponse(
+			std::string typed_location,
+			std::string region_name,
+			LLVector3 local_coords,
+			U64 region_handle, const std::string& url,
+			const LLUUID& snapshot_id, bool teleport);
+
+	static void destroyClass()
+	{
+		if (LLNavigationBar::instanceExists())
+		{
+			LLNavigationBar::getInstance()->setEnabled(FALSE);
+		}
+	}
+
+	S32							mNavPanWidth;
+	LLMenuGL*					mTeleportHistoryMenu;
+	LLPullButton*				mBtnBack;
+	LLPullButton*				mBtnForward;
+	LLButton*					mBtnHome;
+	LLLocationInputCtrl*		mCmbLocation;
+	LLRect						mDefaultNbRect;
+	LLRect						mDefaultFpRect;
+	LLLayoutPanel* 				mNavigationPanel;
+	LLLayoutPanel* 				mFavoritePanel;
+	boost::signals2::connection	mTeleportFailedConnection;
+	boost::signals2::connection	mTeleportFinishConnection;
+	boost::signals2::connection	mHistoryMenuConnection;
+	// if true, save location to location history when teleport finishes
+	bool						mSaveToLocationHistory;
 };
 
 #endif
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index 7cdb91388a..7612c428d9 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -50,85 +50,85 @@
 // Default constructor
 LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown()
 {
-    mHoverTimer.stop();
+	mHoverTimer.stop();
 
-    mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
-    mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
+	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
+	mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
 
-    buildFromFile( "panel_presets_camera_pulldown.xml");
+	buildFromFile( "panel_presets_camera_pulldown.xml");
 }
 
 BOOL LLPanelPresetsCameraPulldown::postBuild()
 {
-    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-    if (presetsMgr)
-    {
-        // Make sure there is a default preference file
-        presetsMgr->createMissingDefault(PRESETS_CAMERA);
+	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+	if (presetsMgr)
+	{
+		// Make sure there is a default preference file
+		presetsMgr->createMissingDefault(PRESETS_CAMERA);
 
-        presetsMgr->startWatching(PRESETS_CAMERA);
+		presetsMgr->startWatching(PRESETS_CAMERA);
 
-        presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
-    }
+		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPresetsCameraPulldown::populatePanel, this));
+	}
 
-    populatePanel();
+	populatePanel();
 
-    return LLPanel::postBuild();
+	return LLPanel::postBuild();
 }
 
 void LLPanelPresetsCameraPulldown::populatePanel()
 {
-    std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
-    LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
+	std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
+	LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
 
-    LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
+	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
 
-    if (scroll && mPresetNames.begin() != mPresetNames.end())
-    {
-        scroll->clearRows();
+	if (scroll && mPresetNames.begin() != mPresetNames.end())
+	{
+		scroll->clearRows();
 
-        std::string active_preset = gSavedSettings.getString("PresetCameraActive");
-        if (active_preset == PRESETS_DEFAULT)
-        {
-            active_preset = LLTrans::getString(PRESETS_DEFAULT);
-        }
+		std::string active_preset = gSavedSettings.getString("PresetCameraActive");
+		if (active_preset == PRESETS_DEFAULT)
+		{
+			active_preset = LLTrans::getString(PRESETS_DEFAULT);
+		}
 
-        for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it)
-        {
-            const std::string& name = *it;
+		for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it)
+		{
+			const std::string& name = *it;
             LL_DEBUGS() << "adding '" << name << "'" << LL_ENDL;
             
-            LLSD row;
-            row["columns"][0]["column"] = "preset_name";
-            row["columns"][0]["value"] = name;
-
-            bool is_selected_preset = false;
-            if (name == active_preset)
-            {
-                row["columns"][1]["column"] = "icon";
-                row["columns"][1]["type"] = "icon";
-                row["columns"][1]["value"] = "Check_Mark";
-
-                is_selected_preset = true;
-            }
-
-            LLScrollListItem* new_item = scroll->addElement(row);
-            new_item->setSelected(is_selected_preset);
-        }
-    }
+			LLSD row;
+			row["columns"][0]["column"] = "preset_name";
+			row["columns"][0]["value"] = name;
+
+			bool is_selected_preset = false;
+			if (name == active_preset)
+			{
+				row["columns"][1]["column"] = "icon";
+				row["columns"][1]["type"] = "icon";
+				row["columns"][1]["value"] = "Check_Mark";
+
+				is_selected_preset = true;
+			}
+
+			LLScrollListItem* new_item = scroll->addElement(row);
+			new_item->setSelected(is_selected_preset);
+		}
+	}
 }
 
 /*virtual*/
 void LLPanelPresetsCameraPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
 {
-    mHoverTimer.stop();
-    LLPanel::onMouseEnter(x,y,mask);
+	mHoverTimer.stop();
+	LLPanel::onMouseEnter(x,y,mask);
 }
 
 /*virtual*/
 void LLPanelPresetsCameraPulldown::onTopLost()
 {
-    setVisible(FALSE);
+	setVisible(FALSE);
 }
 
 /*virtual*/
@@ -155,45 +155,45 @@ BOOL LLPanelPresetsCameraPulldown::handleDoubleClick(S32 x, S32 y, MASK mask)
 /*virtual*/
 void LLPanelPresetsCameraPulldown::onMouseLeave(S32 x, S32 y, MASK mask)
 {
-    mHoverTimer.start();
-    LLPanel::onMouseLeave(x,y,mask);
+	mHoverTimer.start();
+	LLPanel::onMouseLeave(x,y,mask);
 }
 
 /*virtual*/ 
 void LLPanelPresetsCameraPulldown::onVisibilityChange ( BOOL new_visibility )
 {
-    if (new_visibility) 
-    {
-        mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-    }
-    else
-    {
-        mHoverTimer.stop();
-
-    }
+	if (new_visibility)	
+	{
+		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
+	}
+	else
+	{
+		mHoverTimer.stop();
+
+	}
 }
 
 void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
 {
-    LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
+	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
 
-    if (scroll)
-    {
-        LLScrollListItem* item = scroll->getFirstSelected();
-        if (item)
-        {
-            std::string name = item->getColumn(1)->getValue().asString();
+	if (scroll)
+	{
+		LLScrollListItem* item = scroll->getFirstSelected();
+		if (item)
+		{
+			std::string name = item->getColumn(1)->getValue().asString();
 
             LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL;
-            LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
+			LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
 
-            setVisible(FALSE);
-        }
+			setVisible(FALSE);
+		}
         else
         {
             LL_DEBUGS() << "none selected" << LL_ENDL;
         }
-    }
+	}
     else
     {
         LL_DEBUGS() << "no scroll" << LL_ENDL;
@@ -202,36 +202,36 @@ void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
 
 void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data)
 {
-    // close the minicontrol, we're bringing up the big one
-    setVisible(FALSE);
-
-    // bring up the prefs floater
-    LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
-    if (prefsfloater)
-    {
-        // grab the 'view' panel from the preferences floater and
-        // bring it the front!
-        LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-        LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
-        if (tabcontainer && graphicspanel)
-        {
-            tabcontainer->selectTabPanel(graphicspanel);
-        }
-    }
+	// close the minicontrol, we're bringing up the big one
+	setVisible(FALSE);
+
+	// bring up the prefs floater
+	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
+	if (prefsfloater)
+	{
+		// grab the 'view' panel from the preferences floater and
+		// bring it the front!
+		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
+		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
+		if (tabcontainer && graphicspanel)
+		{
+			tabcontainer->selectTabPanel(graphicspanel);
+		}
+	}
 }
 
 //virtual
 void LLPanelPresetsCameraPulldown::draw()
 {
-    F32 alpha = mHoverTimer.getStarted() 
-        ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
-        : 1.0f;
-    LLViewDrawContext context(alpha);
+	F32 alpha = mHoverTimer.getStarted() 
+		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
+		: 1.0f;
+	LLViewDrawContext context(alpha);
 
-    LLPanel::draw();
+	LLPanel::draw();
 
-    if (alpha == 0.f)
-    {
-        setVisible(FALSE);
-    }
+	if (alpha == 0.f)
+	{
+		setVisible(FALSE);
+	}
 }
diff --git a/indra/newview/llpanelpresetscamerapulldown.h b/indra/newview/llpanelpresetscamerapulldown.h
index 069d587086..12d9bc26ec 100644
--- a/indra/newview/llpanelpresetscamerapulldown.h
+++ b/indra/newview/llpanelpresetscamerapulldown.h
@@ -36,26 +36,26 @@ class LLFrameTimer;
 class LLPanelPresetsCameraPulldown : public LLPanel
 {
  public:
-    LLPanelPresetsCameraPulldown();
-    /*virtual*/ void draw();
-    /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-    /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+	LLPanelPresetsCameraPulldown();
+	/*virtual*/ void draw();
+	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
+	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
     /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
     /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
     /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
-    /*virtual*/ void onTopLost();
-    /*virtual*/ void onVisibilityChange ( BOOL new_visibility );
-    /*virtual*/ BOOL postBuild();
-    void populatePanel();
-    
+	/*virtual*/ void onTopLost();
+	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
+	/*virtual*/ BOOL postBuild();
+	void populatePanel();
+	
  private:
-    void onViewButtonClick(const LLSD& user_data);
-    void onRowClick(const LLSD& user_data);
+	void onViewButtonClick(const LLSD& user_data);
+	void onRowClick(const LLSD& user_data);
 
-    std::list<std::string> mPresetNames;
-    LLFrameTimer mHoverTimer;
-    static const F32 sAutoCloseFadeStartTimeSec;
-    static const F32 sAutoCloseTotalTimeSec;
+	std::list<std::string> mPresetNames;
+	LLFrameTimer mHoverTimer;
+	static const F32 sAutoCloseFadeStartTimeSec;
+	static const F32 sAutoCloseTotalTimeSec;
     LOG_CLASS(LLPanelPresetsCameraPulldown);
 };
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index fb36c5875d..c1702b4132 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -48,35 +48,35 @@ LLPresetsManager::LLPresetsManager()
 
 LLPresetsManager::~LLPresetsManager()
 {
-    mCameraChangedSignal.disconnect();
+	mCameraChangedSignal.disconnect();
 }
 
 void LLPresetsManager::triggerChangeCameraSignal()
 {
-    mPresetListChangeCameraSignal();
+	mPresetListChangeCameraSignal();
 }
 
 void LLPresetsManager::triggerChangeSignal()
 {
-    mPresetListChangeSignal();
+	mPresetListChangeSignal();
 }
 
 void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 {
-    if(gDirUtilp->getLindenUserDir().empty())
-    {
-        return;
-    }
-
-    std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
-                                                              subdirectory, PRESETS_DEFAULT + ".xml");
-    if (!gDirUtilp->fileExists(default_file))
-    {
-        LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
-
-        // Write current settings as the default
+	if(gDirUtilp->getLindenUserDir().empty())
+	{
+		return;
+	}
+
+	std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
+															  subdirectory, PRESETS_DEFAULT + ".xml");
+	if (!gDirUtilp->fileExists(default_file))
+	{
+		LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
+
+		// Write current settings as the default
         savePreset(subdirectory, PRESETS_DEFAULT, true);
-    }
+	}
     else
     {
         LL_DEBUGS() << "default preset exists; no-op" << LL_ENDL;
@@ -85,330 +85,330 @@ void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 
 void LLPresetsManager::startWatching(const std::string& subdirectory)
 {
-    if (PRESETS_CAMERA == subdirectory)
-    {
-        std::vector<std::string> name_list;
-        getControlNames(name_list);
-
-        for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
-        {
-            std::string ctrl_name = *it;
-            if (gSavedSettings.controlExists(ctrl_name))
-            {
-                LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
-                if (cntrl_ptr.isNull())
-                {
-                    LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
-                                    << "'" << LL_ENDL;
-                }
-                else
-                {
-                    mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged));
-                }
-            }
-        }
-    }
+	if (PRESETS_CAMERA == subdirectory)
+	{
+		std::vector<std::string> name_list;
+		getControlNames(name_list);
+
+		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+		{
+			std::string ctrl_name = *it;
+			if (gSavedSettings.controlExists(ctrl_name))
+			{
+				LLPointer<LLControlVariable> cntrl_ptr = gSavedSettings.getControl(ctrl_name);
+				if (cntrl_ptr.isNull())
+				{
+					LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
+									<< "'" << LL_ENDL;
+				}
+				else
+				{
+					mCameraChangedSignal = cntrl_ptr->getCommitSignal()->connect(boost::bind(&settingChanged));
+				}
+			}
+		}
+	}
 }
 
 std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 {
-    std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR);
-
-    LLFile::mkdir(presets_path);
-
-    std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory);
-    if (!gDirUtilp->fileExists(dest_path))
-        LLFile::mkdir(dest_path);
-
-        if (PRESETS_CAMERA == subdirectory)
-        {
-            std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
-            LLDirIterator dir_iter(source_dir, "*.xml");
-            bool found = true;
-            while (found)
-            {
-                std::string file;
-                found = dir_iter.next(file);
-
-                if (found)
-                {
-                    std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
-                    file = LLURI::escape(file);
-                    std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
-                    LLFile::copy(source, dest);
-                }
-            }
-        }
-
-    return dest_path;
+	std::string presets_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR);
+
+	LLFile::mkdir(presets_path);
+
+	std::string dest_path = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, subdirectory);
+	if (!gDirUtilp->fileExists(dest_path))
+		LLFile::mkdir(dest_path);
+
+		if (PRESETS_CAMERA == subdirectory)
+		{
+			std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
+			LLDirIterator dir_iter(source_dir, "*.xml");
+			bool found = true;
+			while (found)
+			{
+				std::string file;
+				found = dir_iter.next(file);
+
+				if (found)
+				{
+					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
+					file = LLURI::escape(file);
+					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
+					LLFile::copy(source, dest);
+				}
+			}
+		}
+
+	return dest_path;
 }
 
 void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option)
 {
-    LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL;
+	LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL;
 
-    mPresetNames.clear();
+	mPresetNames.clear();
 
-    LLDirIterator dir_iter(dir, "*.xml");
-    bool found = true;
-    while (found)
-    {
-        std::string file;
-        found = dir_iter.next(file);
+	LLDirIterator dir_iter(dir, "*.xml");
+	bool found = true;
+	while (found)
+	{
+		std::string file;
+		found = dir_iter.next(file);
 
-        if (found)
-        {
-            std::string path = gDirUtilp->add(dir, file);
-            std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
+		if (found)
+		{
+			std::string path = gDirUtilp->add(dir, file);
+			std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
             LL_DEBUGS() << "  Found preset '" << name << "'" << LL_ENDL;
 
-            if (PRESETS_DEFAULT != name)
-            {
-                mPresetNames.push_back(name);
-            }
-            else
-            {
-                switch (default_option)
-                {
-                    case DEFAULT_SHOW:
-                        mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT));
-                        break;
-
-                    case DEFAULT_TOP:
-                        mPresetNames.push_front(LLTrans::getString(PRESETS_DEFAULT));
-                        break;
-
-                    case DEFAULT_HIDE:
-                    default:
-                        break;
-                }
-            }
-        }
-    }
-
-    presets = mPresetNames;
+			if (PRESETS_DEFAULT != name)
+			{
+				mPresetNames.push_back(name);
+			}
+			else
+			{
+				switch (default_option)
+				{
+					case DEFAULT_SHOW:
+						mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT));
+						break;
+
+					case DEFAULT_TOP:
+						mPresetNames.push_front(LLTrans::getString(PRESETS_DEFAULT));
+						break;
+
+					case DEFAULT_HIDE:
+					default:
+						break;
+				}
+			}
+		}
+	}
+
+	presets = mPresetNames;
 }
 
 bool LLPresetsManager::mCameraDirty = false;
 
 void LLPresetsManager::setCameraDirty(bool dirty)
 {
-    mCameraDirty = dirty;
+	mCameraDirty = dirty;
 }
 
 bool LLPresetsManager::isCameraDirty()
 {
-    return mCameraDirty;
+	return mCameraDirty;
 }
 
 void LLPresetsManager::settingChanged()
 {
-    setCameraDirty(true);
+	setCameraDirty(true);
 
-    gSavedSettings.setString("PresetCameraActive", "");
+	gSavedSettings.setString("PresetCameraActive", "");
 
 // Hack call because this is a static routine
-    LLPresetsManager::getInstance()->triggerChangeCameraSignal();
+	LLPresetsManager::getInstance()->triggerChangeCameraSignal();
 
 }
 
 void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 {
-    const std::vector<std::string> camera_controls = boost::assign::list_of
-        // From panel_preferences_move.xml
-        ("CameraAngle")
-        ("CameraOffsetScale")
-        ("EditCameraMovement")
-        ("AppearanceCameraMovement")
-        // From llagentcamera.cpp
-        ("CameraOffsetBuild")
-        ("CameraOffsetRearView")
-        ("FocusOffsetRearView")
-        ("CameraOffsetScale")
-        ("TrackFocusObject")
+	const std::vector<std::string> camera_controls = boost::assign::list_of
+		// From panel_preferences_move.xml
+		("CameraAngle")
+		("CameraOffsetScale")
+		("EditCameraMovement")
+		("AppearanceCameraMovement")
+		// From llagentcamera.cpp
+		("CameraOffsetBuild")
+		("CameraOffsetRearView")
+		("FocusOffsetRearView")
+		("CameraOffsetScale")
+		("TrackFocusObject")
         ;
     names = camera_controls;
 }
 
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
 {
-    if (LLTrans::getString(PRESETS_DEFAULT) == name)
-    {
-        name = PRESETS_DEFAULT;
-    }
-    if (!createDefault && name == PRESETS_DEFAULT)
-    {
-        LL_WARNS() << "Should not overwrite default" << LL_ENDL;
-        return false;
-    }
-
-    bool saved = false;
-    std::vector<std::string> name_list;
-
-    if(PRESETS_GRAPHIC == subdirectory)
-    {
-        LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-        if (instance && !createDefault)
-        {
-            gSavedSettings.setString("PresetGraphicActive", name);
-            instance->getControlNames(name_list);
-            LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
-            name_list.push_back("PresetGraphicActive");
-        }
-        else
+	if (LLTrans::getString(PRESETS_DEFAULT) == name)
+	{
+		name = PRESETS_DEFAULT;
+	}
+	if (!createDefault && name == PRESETS_DEFAULT)
+	{
+		LL_WARNS() << "Should not overwrite default" << LL_ENDL;
+		return false;
+	}
+
+	bool saved = false;
+	std::vector<std::string> name_list;
+
+	if(PRESETS_GRAPHIC == subdirectory)
+	{
+		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+		if (instance && !createDefault)
+		{
+			gSavedSettings.setString("PresetGraphicActive", name);
+			instance->getControlNames(name_list);
+			LL_DEBUGS() << "saving preset '" << name << "'; " << name_list.size() << " names" << LL_ENDL;
+			name_list.push_back("PresetGraphicActive");
+		}
+		else
         {
-            LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL;
-        }
-    }
-    else if(PRESETS_CAMERA == subdirectory)
-    {
-        gSavedSettings.setString("PresetGraphicActive", name);
-
-        name_list.clear();
-        getControlNames(name_list);
-        name_list.push_back("PresetCameraActive");
-    }
-    else
-    {
-        LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
-    }
+			LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL;
+		}
+	}
+	else if(PRESETS_CAMERA == subdirectory)
+	{
+		gSavedSettings.setString("PresetGraphicActive", name);
+
+		name_list.clear();
+		getControlNames(name_list);
+		name_list.push_back("PresetCameraActive");
+	}
+	else
+	{
+		LL_ERRS() << "Invalid presets directory '" << subdirectory << "'" << LL_ENDL;
+	}
  
-    // make an empty llsd
-    LLSD paramsData(LLSD::emptyMap());
-
-    // Create a default graphics preset from hw recommended settings 
-    if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)
-    {
-        paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
-        if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
-        {
-            // use the recommended setting as an initial one (MAINT-6435)
-            gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
-        }
-    }
-    else
-    {
-        for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
-        {
-            std::string ctrl_name = *it;
-            LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
-            std::string comment = ctrl->getComment();
-            std::string type = LLControlGroup::typeEnumToString(ctrl->type());
-            LLSD value = ctrl->getValue();
-
-            paramsData[ctrl_name]["Comment"] = comment;
-            paramsData[ctrl_name]["Persist"] = 1;
-            paramsData[ctrl_name]["Type"] = type;
-            paramsData[ctrl_name]["Value"] = value;
-        }
-    }
-
-    std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
+	// make an empty llsd
+	LLSD paramsData(LLSD::emptyMap());
+
+	// Create a default graphics preset from hw recommended settings 
+	if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)
+	{
+		paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
+		if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
+		{
+			// use the recommended setting as an initial one (MAINT-6435)
+			gSavedSettings.setU32("RenderAvatarMaxComplexity", paramsData["RenderAvatarMaxComplexity"]["Value"].asInteger());
+		}
+	}
+	else
+	{
+		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
+		{
+			std::string ctrl_name = *it;
+			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
+			std::string comment = ctrl->getComment();
+			std::string type = LLControlGroup::typeEnumToString(ctrl->type());
+			LLSD value = ctrl->getValue();
+
+			paramsData[ctrl_name]["Comment"] = comment;
+			paramsData[ctrl_name]["Persist"] = 1;
+			paramsData[ctrl_name]["Type"] = type;
+			paramsData[ctrl_name]["Value"] = value;
+		}
+	}
+
+	std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
 
  // If the active preset name is the only thing in the list, don't save the list
-    if (paramsData.size() > 1)
-    {
-        // write to file
-        llofstream presetsXML(pathName.c_str());
-        if (presetsXML.is_open())
-        {
-            LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
-            formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
-            presetsXML.close();
-            saved = true;
+	if (paramsData.size() > 1)
+	{
+		// write to file
+		llofstream presetsXML(pathName.c_str());
+		if (presetsXML.is_open())
+		{
+			LLPointer<LLSDFormatter> formatter = new LLSDXMLFormatter();
+			formatter->format(paramsData, presetsXML, LLSDFormatter::OPTIONS_PRETTY);
+			presetsXML.close();
+			saved = true;
             
-            LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
-
-            if (subdirectory == PRESETS_GRAPHIC)
-            {
-                gSavedSettings.setString("PresetGraphicActive", name);
-                // signal interested parties
-                triggerChangeSignal();
-            }
-
-            if (subdirectory == PRESETS_CAMERA)
-            {
-                gSavedSettings.setString("PresetCameraActive", name);
-                setCameraDirty(false);
-                // signal interested parties
-                triggerChangeCameraSignal();
-            }
-        }
-        else
-        {
-            LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
-        }
-    }
+			LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
+
+			if (subdirectory == PRESETS_GRAPHIC)
+			{
+				gSavedSettings.setString("PresetGraphicActive", name);
+				// signal interested parties
+				triggerChangeSignal();
+			}
+
+			if (subdirectory == PRESETS_CAMERA)
+			{
+				gSavedSettings.setString("PresetCameraActive", name);
+				setCameraDirty(false);
+				// signal interested parties
+				triggerChangeCameraSignal();
+			}
+		}
+		else
+		{
+			LL_WARNS("Presets") << "Cannot open for output preset file " << pathName << LL_ENDL;
+		}
+	}
     else
-    {
-        LL_INFOS() << "No settings available to be saved" << LL_ENDL;
-    }
+	{
+		LL_INFOS() << "No settings available to be saved" << LL_ENDL;
+	}
     
-    return saved;
+	return saved;
 }
 
 bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option)
 {
-    bool sts = true;
-
-    combo->clearRows();
-
-    std::string presets_dir = getPresetsDir(subdirectory);
-
-    if (!presets_dir.empty())
-    {
-        std::list<std::string> preset_names;
-        loadPresetNamesFromDir(presets_dir, preset_names, default_option);
-
-        std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-
-        if (preset_names.begin() != preset_names.end())
-        {
-            for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
-            {
-                const std::string& name = *it;
-                combo->add(name, LLSD().with(0, name));
-            }
-        }
-        else
-        {
-            combo->setLabel(LLTrans::getString("preset_combo_label"));
-            sts = false;
-        }
-    }
-    return sts;
+	bool sts = true;
+
+	combo->clearRows();
+
+	std::string presets_dir = getPresetsDir(subdirectory);
+
+	if (!presets_dir.empty())
+	{
+		std::list<std::string> preset_names;
+		loadPresetNamesFromDir(presets_dir, preset_names, default_option);
+
+		std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
+
+		if (preset_names.begin() != preset_names.end())
+		{
+			for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
+			{
+				const std::string& name = *it;
+				combo->add(name, LLSD().with(0, name));
+			}
+		}
+		else
+		{
+			combo->setLabel(LLTrans::getString("preset_combo_label"));
+			sts = false;
+		}
+	}
+	return sts;
 }
 
 void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string name)
 {
-    if (LLTrans::getString(PRESETS_DEFAULT) == name)
-    {
-        name = PRESETS_DEFAULT;
-    }
+	if (LLTrans::getString(PRESETS_DEFAULT) == name)
+	{
+		name = PRESETS_DEFAULT;
+	}
 
-    std::string full_path(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
+	std::string full_path(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
 
     LL_DEBUGS() << "attempting to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
 
-    if(gSavedSettings.loadFromFile(full_path, false, true) > 0)
-    {
-        if(PRESETS_GRAPHIC == subdirectory)
-        {
-            gSavedSettings.setString("PresetGraphicActive", name);
-
-            LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-            if (instance)
-            {
-                instance->refreshEnabledGraphics();
-            }
-            triggerChangeSignal();
-        }
-        if(PRESETS_CAMERA == subdirectory)
-        {
-            gSavedSettings.setString("PresetCameraActive", name);
-            triggerChangeCameraSignal();
-        }
-    }
+	if(gSavedSettings.loadFromFile(full_path, false, true) > 0)
+	{
+		if(PRESETS_GRAPHIC == subdirectory)
+		{
+			gSavedSettings.setString("PresetGraphicActive", name);
+
+			LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+			if (instance)
+			{
+				instance->refreshEnabledGraphics();
+			}
+			triggerChangeSignal();
+		}
+		if(PRESETS_CAMERA == subdirectory)
+		{
+			gSavedSettings.setString("PresetCameraActive", name);
+			triggerChangeCameraSignal();
+		}
+	}
     else
     {
         LL_WARNS("Presets") << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
@@ -417,56 +417,56 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n
 
 bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string name)
 {
-    if (LLTrans::getString(PRESETS_DEFAULT) == name)
-    {
-        name = PRESETS_DEFAULT;
-    }
-
-    bool sts = true;
-
-    if (PRESETS_DEFAULT == name)
-    {
-        // This code should never execute
-        LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL;
-        sts = false;
-    }
-
-    if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1)
-    {
-        LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL;
-        sts = false;
-    }
-
-    // If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded.
-    if(PRESETS_GRAPHIC == subdirectory)
-    {
-        if (gSavedSettings.getString("PresetGraphicActive") == name)
-        {
-            gSavedSettings.setString("PresetGraphicActive", "");
-        }
-        // signal interested parties
-        triggerChangeSignal();
-    }
-
-    if(PRESETS_CAMERA == subdirectory)
-    {
-        if (gSavedSettings.getString("PresetCameraActive") == name)
-        {
-            gSavedSettings.setString("PresetCameraActive", "");
-        }
-        // signal interested parties
-        triggerChangeCameraSignal();
-    }
-
-    return sts;
+	if (LLTrans::getString(PRESETS_DEFAULT) == name)
+	{
+		name = PRESETS_DEFAULT;
+	}
+
+	bool sts = true;
+
+	if (PRESETS_DEFAULT == name)
+	{
+		// This code should never execute
+		LL_WARNS("Presets") << "You are not allowed to delete the default preset." << LL_ENDL;
+		sts = false;
+	}
+
+	if (gDirUtilp->deleteFilesInDir(getPresetsDir(subdirectory), LLURI::escape(name) + ".xml") < 1)
+	{
+		LL_WARNS("Presets") << "Error removing preset " << name << " from disk" << LL_ENDL;
+		sts = false;
+	}
+
+	// If you delete the preset that is currently marked as loaded then also indicate that no preset is loaded.
+	if(PRESETS_GRAPHIC == subdirectory)
+	{
+		if (gSavedSettings.getString("PresetGraphicActive") == name)
+		{
+			gSavedSettings.setString("PresetGraphicActive", "");
+		}
+		// signal interested parties
+		triggerChangeSignal();
+	}
+
+	if(PRESETS_CAMERA == subdirectory)
+	{
+		if (gSavedSettings.getString("PresetCameraActive") == name)
+		{
+			gSavedSettings.setString("PresetCameraActive", "");
+		}
+		// signal interested parties
+		triggerChangeCameraSignal();
+	}
+
+	return sts;
 }
 
 boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
 {
-    return mPresetListChangeCameraSignal.connect(cb);
+	return mPresetListChangeCameraSignal.connect(cb);
 }
 
 boost::signals2::connection LLPresetsManager::setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb)
 {
-    return mPresetListChangeSignal.connect(cb);
+	return mPresetListChangeSignal.connect(cb);
 }
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index c3a6c0795c..7370e0a3b1 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -39,54 +39,54 @@ static const std::string PRESETS_CAMERA = "camera";
 
 enum EDefaultOptions
 {
-    DEFAULT_SHOW,
-    DEFAULT_TOP,
-    DEFAULT_HIDE                // Do not display "Default" in a list
+	DEFAULT_SHOW,
+	DEFAULT_TOP,
+	DEFAULT_HIDE				// Do not display "Default" in a list
 };
 
 class LLPresetsManager : public LLSingleton<LLPresetsManager>
 {
-    LLSINGLETON(LLPresetsManager);
-    ~LLPresetsManager();
+	LLSINGLETON(LLPresetsManager);
+	~LLPresetsManager();
 
 public:
 
-    typedef std::list<std::string> preset_name_list_t;
-    typedef boost::signals2::signal<void()> preset_list_signal_t;
+	typedef std::list<std::string> preset_name_list_t;
+	typedef boost::signals2::signal<void()> preset_list_signal_t;
 
-    void createMissingDefault(const std::string& subdirectory);
-    void startWatching(const std::string& subdirectory);
-    void triggerChangeCameraSignal();
-    void triggerChangeSignal();
-    static std::string getPresetsDir(const std::string& subdirectory);
-    bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
-    void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
-    bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
-    void loadPreset(const std::string& subdirectory, std::string name);
-    bool deletePreset(const std::string& subdirectory, std::string name);
-    bool isCameraDirty();
-    static void setCameraDirty(bool dirty);
+	void createMissingDefault(const std::string& subdirectory);
+	void startWatching(const std::string& subdirectory);
+	void triggerChangeCameraSignal();
+	void triggerChangeSignal();
+	static std::string getPresetsDir(const std::string& subdirectory);
+	bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
+	void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
+	bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
+	void loadPreset(const std::string& subdirectory, std::string name);
+	bool deletePreset(const std::string& subdirectory, std::string name);
+	bool isCameraDirty();
+	static void setCameraDirty(bool dirty);
 
-    // Emitted when a preset gets loaded, deleted, or saved.
-    boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
-    boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
+	// Emitted when a preset gets loaded, deleted, or saved.
+	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
+	boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
 
-    // Emitted when a preset gets loaded or saved.
+	// Emitted when a preset gets loaded or saved.
 
-    preset_name_list_t mPresetNames;
+	preset_name_list_t mPresetNames;
 
-    preset_list_signal_t mPresetListChangeCameraSignal;
-    preset_list_signal_t mPresetListChangeSignal;
+	preset_list_signal_t mPresetListChangeCameraSignal;
+	preset_list_signal_t mPresetListChangeSignal;
 
   private:
-    LOG_CLASS(LLPresetsManager);
+	LOG_CLASS(LLPresetsManager);
 
-    void getControlNames(std::vector<std::string>& names);
-    static void settingChanged();
+	void getControlNames(std::vector<std::string>& names);
+	static void settingChanged();
 
-    boost::signals2::connection mCameraChangedSignal;
+	boost::signals2::connection	mCameraChangedSignal;
 
-    static bool mCameraDirty;
+	static bool	mCameraDirty;
 };
 
 #endif // LL_PRESETSMANAGER_H
diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index da495cbf21..398ec953d7 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -63,7 +63,7 @@
 #include "llworld.h"
 #include "llstatgraph.h"
 #include "llviewermedia.h"
-#include "llviewermenu.h"   // for gMenuBarView
+#include "llviewermenu.h"	// for gMenuBarView
 #include "llviewerparcelmgr.h"
 #include "llviewerthrottle.h"
 #include "lluictrlfactory.h"
@@ -100,42 +100,42 @@ const S32 SIM_STAT_WIDTH = 8;
 const LLColor4 SIM_OK_COLOR(0.f, 1.f, 0.f, 1.f);
 const LLColor4 SIM_WARN_COLOR(1.f, 1.f, 0.f, 1.f);
 const LLColor4 SIM_FULL_COLOR(1.f, 0.f, 0.f, 1.f);
-const F32 ICON_TIMER_EXPIRY     = 3.f; // How long the balance and health icons should flash after a change.
+const F32 ICON_TIMER_EXPIRY		= 3.f; // How long the balance and health icons should flash after a change.
 
 static void onClickVolume(void*);
 
 LLStatusBar::LLStatusBar(const LLRect& rect)
-:   LLPanel(),
-    mTextTime(NULL),
-    mSGBandwidth(NULL),
-    mSGPacketLoss(NULL),
-    mBtnVolume(NULL),
-    mBoxBalance(NULL),
-    mBalance(0),
-    mHealth(100),
-    mSquareMetersCredit(0),
-    mSquareMetersCommitted(0)
+:	LLPanel(),
+	mTextTime(NULL),
+	mSGBandwidth(NULL),
+	mSGPacketLoss(NULL),
+	mBtnVolume(NULL),
+	mBoxBalance(NULL),
+	mBalance(0),
+	mHealth(100),
+	mSquareMetersCredit(0),
+	mSquareMetersCommitted(0)
 {
-    setRect(rect);
-    
-    // status bar can possible overlay menus?
-    setMouseOpaque(FALSE);
+	setRect(rect);
+	
+	// status bar can possible overlay menus?
+	setMouseOpaque(FALSE);
 
-    mBalanceTimer = new LLFrameTimer();
-    mHealthTimer = new LLFrameTimer();
+	mBalanceTimer = new LLFrameTimer();
+	mHealthTimer = new LLFrameTimer();
 
-    buildFromFile("panel_status_bar.xml");
+	buildFromFile("panel_status_bar.xml");
 }
 
 LLStatusBar::~LLStatusBar()
 {
-    delete mBalanceTimer;
-    mBalanceTimer = NULL;
+	delete mBalanceTimer;
+	mBalanceTimer = NULL;
 
-    delete mHealthTimer;
-    mHealthTimer = NULL;
+	delete mHealthTimer;
+	mHealthTimer = NULL;
 
-    // LLView destructor cleans up children
+	// LLView destructor cleans up children
 }
 
 //-----------------------------------------------------------------------
@@ -145,465 +145,465 @@ LLStatusBar::~LLStatusBar()
 // virtual
 void LLStatusBar::draw()
 {
-    refresh();
-    LLPanel::draw();
+	refresh();
+	LLPanel::draw();
 }
 
 BOOL LLStatusBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
 {
-    show_navbar_context_menu(this,x,y);
-    return TRUE;
+	show_navbar_context_menu(this,x,y);
+	return TRUE;
 }
 
 BOOL LLStatusBar::postBuild()
 {
-    gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3));
+	gMenuBarView->setRightMouseDownCallback(boost::bind(&show_navbar_context_menu, _1, _2, _3));
 
-    mTextTime = getChild<LLTextBox>("TimeText" );
-    
-    getChild<LLUICtrl>("buyL")->setCommitCallback(
-        boost::bind(&LLStatusBar::onClickBuyCurrency, this));
+	mTextTime = getChild<LLTextBox>("TimeText" );
+	
+	getChild<LLUICtrl>("buyL")->setCommitCallback(
+		boost::bind(&LLStatusBar::onClickBuyCurrency, this));
 
     getChild<LLUICtrl>("goShop")->setCommitCallback(boost::bind(&LLWeb::loadURL, gSavedSettings.getString("MarketplaceURL"), LLStringUtil::null, LLStringUtil::null));
 
-    mBoxBalance = getChild<LLTextBox>("balance");
-    mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this );
-
-    mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" );
-    mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this));
-
-    mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" );
-    mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
-
-    mBtnVolume = getChild<LLButton>( "volume_btn" );
-    mBtnVolume->setClickedCallback( onClickVolume, this );
-    mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this));
-
-    mMediaToggle = getChild<LLButton>("media_toggle_btn");
-    mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this );
-    mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this));
-
-    LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle());
-
-    gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
-
-    // Adding Net Stat Graph
-    S32 x = getRect().getWidth() - 2;
-    S32 y = 0;
-    LLRect r;
-    r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
-    LLStatGraph::Params sgp;
-    sgp.name("BandwidthGraph");
-    sgp.rect(r);
-    sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
-    sgp.mouse_opaque(false);
-    sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED);
-    sgp.units("Kbps");
-    sgp.precision(0);
-    sgp.per_sec(true);
-    mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
-    addChild(mSGBandwidth);
-    x -= SIM_STAT_WIDTH + 2;
-
-    r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
-    //these don't seem to like being reused
-    LLStatGraph::Params pgp;
-    pgp.name("PacketLossPercent");
-    pgp.rect(r);
-    pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
-    pgp.mouse_opaque(false);
-    pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
-    pgp.units("%");
-    pgp.min(0.f);
-    pgp.max(5.f);
-    pgp.precision(1);
-    pgp.per_sec(false);
-    LLStatGraph::Thresholds thresholds;
-    thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green))
-                        .add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow))
-                        .add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red));
-
-    pgp.thresholds(thresholds);
-
-    mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
-    addChild(mSGPacketLoss);
-
-    mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown();
-    addChild(mPanelPresetsCameraPulldown);
-    mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-    mPanelPresetsCameraPulldown->setVisible(FALSE);
-
-    mPanelPresetsPulldown = new LLPanelPresetsPulldown();
-    addChild(mPanelPresetsPulldown);
-    mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-    mPanelPresetsPulldown->setVisible(FALSE);
-
-    mPanelVolumePulldown = new LLPanelVolumePulldown();
-    addChild(mPanelVolumePulldown);
-    mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-    mPanelVolumePulldown->setVisible(FALSE);
-
-    mPanelNearByMedia = new LLPanelNearByMedia();
-    addChild(mPanelNearByMedia);
-    mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
-    mPanelNearByMedia->setVisible(FALSE);
-
-    return TRUE;
+	mBoxBalance = getChild<LLTextBox>("balance");
+	mBoxBalance->setClickedCallback( &LLStatusBar::onClickBalance, this );
+
+	mIconPresetsCamera = getChild<LLIconCtrl>( "presets_icon_camera" );
+	mIconPresetsCamera->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresetsCamera, this));
+
+	mIconPresetsGraphic = getChild<LLIconCtrl>( "presets_icon_graphic" );
+	mIconPresetsGraphic->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterPresets, this));
+
+	mBtnVolume = getChild<LLButton>( "volume_btn" );
+	mBtnVolume->setClickedCallback( onClickVolume, this );
+	mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this));
+
+	mMediaToggle = getChild<LLButton>("media_toggle_btn");
+	mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this );
+	mMediaToggle->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterNearbyMedia, this));
+
+	LLHints::registerHintTarget("linden_balance", getChild<LLView>("balance_bg")->getHandle());
+
+	gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2));
+
+	// Adding Net Stat Graph
+	S32 x = getRect().getWidth() - 2;
+	S32 y = 0;
+	LLRect r;
+	r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
+	LLStatGraph::Params sgp;
+	sgp.name("BandwidthGraph");
+	sgp.rect(r);
+	sgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+	sgp.mouse_opaque(false);
+	sgp.stat.count_stat_float(&LLStatViewer::ACTIVE_MESSAGE_DATA_RECEIVED);
+	sgp.units("Kbps");
+	sgp.precision(0);
+	sgp.per_sec(true);
+	mSGBandwidth = LLUICtrlFactory::create<LLStatGraph>(sgp);
+	addChild(mSGBandwidth);
+	x -= SIM_STAT_WIDTH + 2;
+
+	r.set( x-SIM_STAT_WIDTH, y+MENU_BAR_HEIGHT-1, x, y+1);
+	//these don't seem to like being reused
+	LLStatGraph::Params pgp;
+	pgp.name("PacketLossPercent");
+	pgp.rect(r);
+	pgp.follows.flags(FOLLOWS_BOTTOM | FOLLOWS_RIGHT);
+	pgp.mouse_opaque(false);
+	pgp.stat.sample_stat_float(&LLStatViewer::PACKETS_LOST_PERCENT);
+	pgp.units("%");
+	pgp.min(0.f);
+	pgp.max(5.f);
+	pgp.precision(1);
+	pgp.per_sec(false);
+	LLStatGraph::Thresholds thresholds;
+	thresholds.threshold.add(LLStatGraph::ThresholdParams().value(0.1).color(LLColor4::green))
+						.add(LLStatGraph::ThresholdParams().value(0.25f).color(LLColor4::yellow))
+						.add(LLStatGraph::ThresholdParams().value(0.6f).color(LLColor4::red));
+
+	pgp.thresholds(thresholds);
+
+	mSGPacketLoss = LLUICtrlFactory::create<LLStatGraph>(pgp);
+	addChild(mSGPacketLoss);
+
+	mPanelPresetsCameraPulldown = new LLPanelPresetsCameraPulldown();
+	addChild(mPanelPresetsCameraPulldown);
+	mPanelPresetsCameraPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+	mPanelPresetsCameraPulldown->setVisible(FALSE);
+
+	mPanelPresetsPulldown = new LLPanelPresetsPulldown();
+	addChild(mPanelPresetsPulldown);
+	mPanelPresetsPulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+	mPanelPresetsPulldown->setVisible(FALSE);
+
+	mPanelVolumePulldown = new LLPanelVolumePulldown();
+	addChild(mPanelVolumePulldown);
+	mPanelVolumePulldown->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+	mPanelVolumePulldown->setVisible(FALSE);
+
+	mPanelNearByMedia = new LLPanelNearByMedia();
+	addChild(mPanelNearByMedia);
+	mPanelNearByMedia->setFollows(FOLLOWS_TOP|FOLLOWS_RIGHT);
+	mPanelNearByMedia->setVisible(FALSE);
+
+	return TRUE;
 }
 
 // Per-frame updates of visibility
 void LLStatusBar::refresh()
 {
-    static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false);
-    bool net_stats_visible = show_net_stats;
-
-    if (net_stats_visible)
-    {
-        // Adding Net Stat Meter back in
-        F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
-        mSGBandwidth->setMin(0.f);
-        mSGBandwidth->setMax(bwtotal*1.25f);
-        //mSGBandwidth->setThreshold(0, bwtotal*0.75f);
-        //mSGBandwidth->setThreshold(1, bwtotal);
-        //mSGBandwidth->setThreshold(2, bwtotal);
-    }
-    
-    // update clock every 10 seconds
-    if(mClockUpdateTimer.getElapsedTimeF32() > 10.f)
-    {
-        mClockUpdateTimer.reset();
-
-        // Get current UTC time, adjusted for the user's clock
-        // being off.
-        time_t utc_time;
-        utc_time = time_corrected();
-
-        std::string timeStr = getString("time");
-        LLSD substitution;
-        substitution["datetime"] = (S32) utc_time;
-        LLStringUtil::format (timeStr, substitution);
-        mTextTime->setText(timeStr);
-
-        // set the tooltip to have the date
-        std::string dtStr = getString("timeTooltip");
-        LLStringUtil::format (dtStr, substitution);
-        mTextTime->setToolTip (dtStr);
-    }
-
-    LLRect r;
-    const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
-
-    // reshape menu bar to its content's width
-    if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
-    {
-        gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
-    }
-
-    mSGBandwidth->setVisible(net_stats_visible);
-    mSGPacketLoss->setVisible(net_stats_visible);
-
-    // update the master volume button state
-    bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
-    mBtnVolume->setToggleState(mute_audio);
-    
-    // Disable media toggle if there's no media, parcel media, and no parcel audio
-    // (or if media is disabled)
-    bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && 
-                          (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
-    mMediaToggle->setEnabled(button_enabled);
-    // Note the "sense" of the toggle is opposite whether media is playing or not
-    bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || 
-                              LLViewerMedia::isParcelMediaPlaying() ||
-                              LLViewerMedia::isParcelAudioPlaying());
-    mMediaToggle->setValue(!any_media_playing);
+	static LLCachedControl<bool> show_net_stats(gSavedSettings, "ShowNetStats", false);
+	bool net_stats_visible = show_net_stats;
+
+	if (net_stats_visible)
+	{
+		// Adding Net Stat Meter back in
+		F32 bwtotal = gViewerThrottle.getMaxBandwidth() / 1000.f;
+		mSGBandwidth->setMin(0.f);
+		mSGBandwidth->setMax(bwtotal*1.25f);
+		//mSGBandwidth->setThreshold(0, bwtotal*0.75f);
+		//mSGBandwidth->setThreshold(1, bwtotal);
+		//mSGBandwidth->setThreshold(2, bwtotal);
+	}
+	
+	// update clock every 10 seconds
+	if(mClockUpdateTimer.getElapsedTimeF32() > 10.f)
+	{
+		mClockUpdateTimer.reset();
+
+		// Get current UTC time, adjusted for the user's clock
+		// being off.
+		time_t utc_time;
+		utc_time = time_corrected();
+
+		std::string timeStr = getString("time");
+		LLSD substitution;
+		substitution["datetime"] = (S32) utc_time;
+		LLStringUtil::format (timeStr, substitution);
+		mTextTime->setText(timeStr);
+
+		// set the tooltip to have the date
+		std::string dtStr = getString("timeTooltip");
+		LLStringUtil::format (dtStr, substitution);
+		mTextTime->setToolTip (dtStr);
+	}
+
+	LLRect r;
+	const S32 MENU_RIGHT = gMenuBarView->getRightmostMenuEdge();
+
+	// reshape menu bar to its content's width
+	if (MENU_RIGHT != gMenuBarView->getRect().getWidth())
+	{
+		gMenuBarView->reshape(MENU_RIGHT, gMenuBarView->getRect().getHeight());
+	}
+
+	mSGBandwidth->setVisible(net_stats_visible);
+	mSGPacketLoss->setVisible(net_stats_visible);
+
+	// update the master volume button state
+	bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
+	mBtnVolume->setToggleState(mute_audio);
+	
+	// Disable media toggle if there's no media, parcel media, and no parcel audio
+	// (or if media is disabled)
+	bool button_enabled = (gSavedSettings.getBOOL("AudioStreamingMusic")||gSavedSettings.getBOOL("AudioStreamingMedia")) && 
+						  (LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
+	mMediaToggle->setEnabled(button_enabled);
+	// Note the "sense" of the toggle is opposite whether media is playing or not
+	bool any_media_playing = (LLViewerMedia::isAnyMediaPlaying() || 
+							  LLViewerMedia::isParcelMediaPlaying() ||
+							  LLViewerMedia::isParcelAudioPlaying());
+	mMediaToggle->setValue(!any_media_playing);
 }
 
 void LLStatusBar::setVisibleForMouselook(bool visible)
 {
-    mTextTime->setVisible(visible);
-    getChild<LLUICtrl>("balance_bg")->setVisible(visible);
-    mBoxBalance->setVisible(visible);
-    mBtnVolume->setVisible(visible);
-    mMediaToggle->setVisible(visible);
-    mSGBandwidth->setVisible(visible);
-    mSGPacketLoss->setVisible(visible);
-    setBackgroundVisible(visible);
-    mIconPresetsCamera->setVisible(visible);
-    mIconPresetsGraphic->setVisible(visible);
+	mTextTime->setVisible(visible);
+	getChild<LLUICtrl>("balance_bg")->setVisible(visible);
+	mBoxBalance->setVisible(visible);
+	mBtnVolume->setVisible(visible);
+	mMediaToggle->setVisible(visible);
+	mSGBandwidth->setVisible(visible);
+	mSGPacketLoss->setVisible(visible);
+	setBackgroundVisible(visible);
+	mIconPresetsCamera->setVisible(visible);
+	mIconPresetsGraphic->setVisible(visible);
 }
 
 void LLStatusBar::debitBalance(S32 debit)
 {
-    setBalance(getBalance() - debit);
+	setBalance(getBalance() - debit);
 }
 
 void LLStatusBar::creditBalance(S32 credit)
 {
-    setBalance(getBalance() + credit);
+	setBalance(getBalance() + credit);
 }
 
 void LLStatusBar::setBalance(S32 balance)
 {
-    if (balance > getBalance() && getBalance() != 0)
-    {
-        LLFirstUse::receiveLindens();
-    }
-
-    std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance );
-
-    LLStringUtil::format_map_t string_args;
-    string_args["[AMT]"] = llformat("%s", money_str.c_str());
-    std::string label_str = getString("buycurrencylabel", string_args);
-    mBoxBalance->setValue(label_str);
-
-    // Resize the L$ balance background to be wide enough for your balance plus the buy button
-    {
-        const S32 HPAD = 24;
-        LLRect balance_rect = mBoxBalance->getTextBoundingRect();
-        LLRect buy_rect = getChildView("buyL")->getRect();
-        LLRect shop_rect = getChildView("goShop")->getRect();
-        LLView* balance_bg_view = getChildView("balance_bg");
-        LLRect balance_bg_rect = balance_bg_view->getRect();
-        balance_bg_rect.mLeft = balance_bg_rect.mRight - (buy_rect.getWidth() + shop_rect.getWidth() + balance_rect.getWidth() + HPAD);
-        balance_bg_view->setShape(balance_bg_rect);
-    }
-
-    if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
-    {
-        if (mBalance > balance)
-            make_ui_sound("UISndMoneyChangeDown");
-        else
-            make_ui_sound("UISndMoneyChangeUp");
-    }
-
-    if( balance != mBalance )
-    {
-        mBalanceTimer->reset();
-        mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
-        mBalance = balance;
-    }
+	if (balance > getBalance() && getBalance() != 0)
+	{
+		LLFirstUse::receiveLindens();
+	}
+
+	std::string money_str = LLResMgr::getInstance()->getMonetaryString( balance );
+
+	LLStringUtil::format_map_t string_args;
+	string_args["[AMT]"] = llformat("%s", money_str.c_str());
+	std::string label_str = getString("buycurrencylabel", string_args);
+	mBoxBalance->setValue(label_str);
+
+	// Resize the L$ balance background to be wide enough for your balance plus the buy button
+	{
+		const S32 HPAD = 24;
+		LLRect balance_rect = mBoxBalance->getTextBoundingRect();
+		LLRect buy_rect = getChildView("buyL")->getRect();
+		LLRect shop_rect = getChildView("goShop")->getRect();
+		LLView* balance_bg_view = getChildView("balance_bg");
+		LLRect balance_bg_rect = balance_bg_view->getRect();
+		balance_bg_rect.mLeft = balance_bg_rect.mRight - (buy_rect.getWidth() + shop_rect.getWidth() + balance_rect.getWidth() + HPAD);
+		balance_bg_view->setShape(balance_bg_rect);
+	}
+
+	if (mBalance && (fabs((F32)(mBalance - balance)) > gSavedSettings.getF32("UISndMoneyChangeThreshold")))
+	{
+		if (mBalance > balance)
+			make_ui_sound("UISndMoneyChangeDown");
+		else
+			make_ui_sound("UISndMoneyChangeUp");
+	}
+
+	if( balance != mBalance )
+	{
+		mBalanceTimer->reset();
+		mBalanceTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
+		mBalance = balance;
+	}
 }
 
 
 // static
 void LLStatusBar::sendMoneyBalanceRequest()
 {
-    LLMessageSystem* msg = gMessageSystem;
-    msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
-    msg->nextBlockFast(_PREHASH_AgentData);
-    msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
-    msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
-    msg->nextBlockFast(_PREHASH_MoneyData);
-    msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
-    gAgent.sendReliableMessage();
+	LLMessageSystem* msg = gMessageSystem;
+	msg->newMessageFast(_PREHASH_MoneyBalanceRequest);
+	msg->nextBlockFast(_PREHASH_AgentData);
+	msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID());
+	msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
+	msg->nextBlockFast(_PREHASH_MoneyData);
+	msg->addUUIDFast(_PREHASH_TransactionID, LLUUID::null );
+	gAgent.sendReliableMessage();
 }
 
 
 void LLStatusBar::setHealth(S32 health)
 {
-    //LL_INFOS() << "Setting health to: " << buffer << LL_ENDL;
-    if( mHealth > health )
-    {
-        if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
-        {
-            if (isAgentAvatarValid())
-            {
-                if (gAgentAvatarp->getSex() == SEX_FEMALE)
-                {
-                    make_ui_sound("UISndHealthReductionF");
-                }
-                else
-                {
-                    make_ui_sound("UISndHealthReductionM");
-                }
-            }
-        }
-
-        mHealthTimer->reset();
-        mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
-    }
-
-    mHealth = health;
+	//LL_INFOS() << "Setting health to: " << buffer << LL_ENDL;
+	if( mHealth > health )
+	{
+		if (mHealth > (health + gSavedSettings.getF32("UISndHealthReductionThreshold")))
+		{
+			if (isAgentAvatarValid())
+			{
+				if (gAgentAvatarp->getSex() == SEX_FEMALE)
+				{
+					make_ui_sound("UISndHealthReductionF");
+				}
+				else
+				{
+					make_ui_sound("UISndHealthReductionM");
+				}
+			}
+		}
+
+		mHealthTimer->reset();
+		mHealthTimer->setTimerExpirySec( ICON_TIMER_EXPIRY );
+	}
+
+	mHealth = health;
 }
 
 S32 LLStatusBar::getBalance() const
 {
-    return mBalance;
+	return mBalance;
 }
 
 
 S32 LLStatusBar::getHealth() const
 {
-    return mHealth;
+	return mHealth;
 }
 
 void LLStatusBar::setLandCredit(S32 credit)
 {
-    mSquareMetersCredit = credit;
+	mSquareMetersCredit = credit;
 }
 void LLStatusBar::setLandCommitted(S32 committed)
 {
-    mSquareMetersCommitted = committed;
+	mSquareMetersCommitted = committed;
 }
 
 BOOL LLStatusBar::isUserTiered() const
 {
-    return (mSquareMetersCredit > 0);
+	return (mSquareMetersCredit > 0);
 }
 
 S32 LLStatusBar::getSquareMetersCredit() const
 {
-    return mSquareMetersCredit;
+	return mSquareMetersCredit;
 }
 
 S32 LLStatusBar::getSquareMetersCommitted() const
 {
-    return mSquareMetersCommitted;
+	return mSquareMetersCommitted;
 }
 
 S32 LLStatusBar::getSquareMetersLeft() const
 {
-    return mSquareMetersCredit - mSquareMetersCommitted;
+	return mSquareMetersCredit - mSquareMetersCommitted;
 }
 
 void LLStatusBar::onClickBuyCurrency()
 {
-    // open a currency floater - actual one open depends on 
-    // value specified in settings.xml
-    LLBuyCurrencyHTML::openCurrencyFloater();
-    LLFirstUse::receiveLindens(false);
+	// open a currency floater - actual one open depends on 
+	// value specified in settings.xml
+	LLBuyCurrencyHTML::openCurrencyFloater();
+	LLFirstUse::receiveLindens(false);
 }
 
 void LLStatusBar::onMouseEnterPresetsCamera()
 {
-    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-    LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_camera" );
-    LLRect icon_rect = icon->getRect();
-    LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect();
-    pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
-         (pulldown_rect.getWidth() - icon_rect.getWidth()),
-                   icon_rect.mBottom,
-                   pulldown_rect.getWidth(),
-                   pulldown_rect.getHeight());
-
-    pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
-    mPanelPresetsCameraPulldown->setShape(pulldown_rect);
-
-    // show the master presets pull-down
-    LLUI::clearPopups();
-    LLUI::addPopup(mPanelPresetsCameraPulldown);
-    mPanelNearByMedia->setVisible(FALSE);
-    mPanelVolumePulldown->setVisible(FALSE);
-    mPanelPresetsPulldown->setVisible(FALSE);
-    mPanelPresetsCameraPulldown->setVisible(TRUE);
+	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_camera" );
+	LLRect icon_rect = icon->getRect();
+	LLRect pulldown_rect = mPanelPresetsCameraPulldown->getRect();
+	pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
+	     (pulldown_rect.getWidth() - icon_rect.getWidth()),
+			       icon_rect.mBottom,
+			       pulldown_rect.getWidth(),
+			       pulldown_rect.getHeight());
+
+	pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
+	mPanelPresetsCameraPulldown->setShape(pulldown_rect);
+
+	// show the master presets pull-down
+	LLUI::clearPopups();
+	LLUI::addPopup(mPanelPresetsCameraPulldown);
+	mPanelNearByMedia->setVisible(FALSE);
+	mPanelVolumePulldown->setVisible(FALSE);
+	mPanelPresetsPulldown->setVisible(FALSE);
+	mPanelPresetsCameraPulldown->setVisible(TRUE);
 }
 
 void LLStatusBar::onMouseEnterPresets()
 {
-    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-    LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_graphic" );
-    LLRect icon_rect = icon->getRect();
-    LLRect pulldown_rect = mPanelPresetsPulldown->getRect();
-    pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
-         (pulldown_rect.getWidth() - icon_rect.getWidth()),
-                   icon_rect.mBottom,
-                   pulldown_rect.getWidth(),
-                   pulldown_rect.getHeight());
-
-    pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
-    mPanelPresetsPulldown->setShape(pulldown_rect);
-
-    // show the master presets pull-down
-    LLUI::clearPopups();
-    LLUI::addPopup(mPanelPresetsPulldown);
-    mPanelNearByMedia->setVisible(FALSE);
-    mPanelVolumePulldown->setVisible(FALSE);
-    mPanelPresetsPulldown->setVisible(TRUE);
+	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+	LLIconCtrl* icon =  getChild<LLIconCtrl>( "presets_icon_graphic" );
+	LLRect icon_rect = icon->getRect();
+	LLRect pulldown_rect = mPanelPresetsPulldown->getRect();
+	pulldown_rect.setLeftTopAndSize(icon_rect.mLeft -
+	     (pulldown_rect.getWidth() - icon_rect.getWidth()),
+			       icon_rect.mBottom,
+			       pulldown_rect.getWidth(),
+			       pulldown_rect.getHeight());
+
+	pulldown_rect.translate(popup_holder->getRect().getWidth() - pulldown_rect.mRight, 0);
+	mPanelPresetsPulldown->setShape(pulldown_rect);
+
+	// show the master presets pull-down
+	LLUI::clearPopups();
+	LLUI::addPopup(mPanelPresetsPulldown);
+	mPanelNearByMedia->setVisible(FALSE);
+	mPanelVolumePulldown->setVisible(FALSE);
+	mPanelPresetsPulldown->setVisible(TRUE);
 }
 
 void LLStatusBar::onMouseEnterVolume()
 {
-    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-    LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
-    LLRect vol_btn_rect = volbtn->getRect();
-    LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
-    volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft -
-         (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth()),
-                   vol_btn_rect.mBottom,
-                   volume_pulldown_rect.getWidth(),
-                   volume_pulldown_rect.getHeight());
-
-    volume_pulldown_rect.translate(popup_holder->getRect().getWidth() - volume_pulldown_rect.mRight, 0);
-    mPanelVolumePulldown->setShape(volume_pulldown_rect);
-
-
-    // show the master volume pull-down
-    LLUI::clearPopups();
-    LLUI::addPopup(mPanelVolumePulldown);
-    mPanelPresetsCameraPulldown->setVisible(FALSE);
-    mPanelPresetsPulldown->setVisible(FALSE);
-    mPanelNearByMedia->setVisible(FALSE);
-    mPanelVolumePulldown->setVisible(TRUE);
+	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+	LLButton* volbtn =  getChild<LLButton>( "volume_btn" );
+	LLRect vol_btn_rect = volbtn->getRect();
+	LLRect volume_pulldown_rect = mPanelVolumePulldown->getRect();
+	volume_pulldown_rect.setLeftTopAndSize(vol_btn_rect.mLeft -
+	     (volume_pulldown_rect.getWidth() - vol_btn_rect.getWidth()),
+			       vol_btn_rect.mBottom,
+			       volume_pulldown_rect.getWidth(),
+			       volume_pulldown_rect.getHeight());
+
+	volume_pulldown_rect.translate(popup_holder->getRect().getWidth() - volume_pulldown_rect.mRight, 0);
+	mPanelVolumePulldown->setShape(volume_pulldown_rect);
+
+
+	// show the master volume pull-down
+	LLUI::clearPopups();
+	LLUI::addPopup(mPanelVolumePulldown);
+	mPanelPresetsCameraPulldown->setVisible(FALSE);
+	mPanelPresetsPulldown->setVisible(FALSE);
+	mPanelNearByMedia->setVisible(FALSE);
+	mPanelVolumePulldown->setVisible(TRUE);
 }
 
 void LLStatusBar::onMouseEnterNearbyMedia()
 {
-    LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
-    LLRect nearby_media_rect = mPanelNearByMedia->getRect();
-    LLButton* nearby_media_btn =  getChild<LLButton>( "media_toggle_btn" );
-    LLRect nearby_media_btn_rect = nearby_media_btn->getRect();
-    nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - 
-                                        (nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2,
-                                        nearby_media_btn_rect.mBottom,
-                                        nearby_media_rect.getWidth(),
-                                        nearby_media_rect.getHeight());
-    // force onscreen
-    nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0);
-    
-    // show the master volume pull-down
-    mPanelNearByMedia->setShape(nearby_media_rect);
-    LLUI::clearPopups();
-    LLUI::addPopup(mPanelNearByMedia);
-
-    mPanelPresetsCameraPulldown->setVisible(FALSE);
-    mPanelPresetsPulldown->setVisible(FALSE);
-    mPanelVolumePulldown->setVisible(FALSE);
-    mPanelNearByMedia->setVisible(TRUE);
+	LLView* popup_holder = gViewerWindow->getRootView()->getChildView("popup_holder");
+	LLRect nearby_media_rect = mPanelNearByMedia->getRect();
+	LLButton* nearby_media_btn =  getChild<LLButton>( "media_toggle_btn" );
+	LLRect nearby_media_btn_rect = nearby_media_btn->getRect();
+	nearby_media_rect.setLeftTopAndSize(nearby_media_btn_rect.mLeft - 
+										(nearby_media_rect.getWidth() - nearby_media_btn_rect.getWidth())/2,
+										nearby_media_btn_rect.mBottom,
+										nearby_media_rect.getWidth(),
+										nearby_media_rect.getHeight());
+	// force onscreen
+	nearby_media_rect.translate(popup_holder->getRect().getWidth() - nearby_media_rect.mRight, 0);
+	
+	// show the master volume pull-down
+	mPanelNearByMedia->setShape(nearby_media_rect);
+	LLUI::clearPopups();
+	LLUI::addPopup(mPanelNearByMedia);
+
+	mPanelPresetsCameraPulldown->setVisible(FALSE);
+	mPanelPresetsPulldown->setVisible(FALSE);
+	mPanelVolumePulldown->setVisible(FALSE);
+	mPanelNearByMedia->setVisible(TRUE);
 }
 
 
 static void onClickVolume(void* data)
 {
-    // toggle the master mute setting
-    bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
-    LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio); 
+	// toggle the master mute setting
+	bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
+	LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio);	
 }
 
 //static 
 void LLStatusBar::onClickBalance(void* )
 {
-    // Force a balance request message:
-    LLStatusBar::sendMoneyBalanceRequest();
-    // The refresh of the display (call to setBalance()) will be done by process_money_balance_reply()
+	// Force a balance request message:
+	LLStatusBar::sendMoneyBalanceRequest();
+	// The refresh of the display (call to setBalance()) will be done by process_money_balance_reply()
 }
 
 //static 
 void LLStatusBar::onClickMediaToggle(void* data)
 {
-    LLStatusBar *status_bar = (LLStatusBar*)data;
-    // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media
-    bool pause = status_bar->mMediaToggle->getValue();
-    LLViewerMedia::setAllMediaPaused(pause);
+	LLStatusBar *status_bar = (LLStatusBar*)data;
+	// "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media
+	bool pause = status_bar->mMediaToggle->getValue();
+	LLViewerMedia::setAllMediaPaused(pause);
 }
 
 BOOL can_afford_transaction(S32 cost)
 {
-    return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
+	return((cost <= 0)||((gStatusBar) && (gStatusBar->getBalance() >=cost)));
 }
 
 void LLStatusBar::onVolumeChanged(const LLSD& newvalue)
 {
-    refresh();
+	refresh();
 }
 
 // Implements secondlife:///app/balance/request to request a L$ balance
@@ -611,18 +611,18 @@ void LLStatusBar::onVolumeChanged(const LLSD& newvalue)
 class LLBalanceHandler : public LLCommandHandler
 {
 public:
-    // Requires "trusted" browser/URL source
-    LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { }
-    bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
-    {
-        if (tokens.size() == 1
-            && tokens[0].asString() == "request")
-        {
-            LLStatusBar::sendMoneyBalanceRequest();
-            return true;
-        }
-        return false;
-    }
+	// Requires "trusted" browser/URL source
+	LLBalanceHandler() : LLCommandHandler("balance", UNTRUSTED_BLOCK) { }
+	bool handle(const LLSD& tokens, const LLSD& query_map, LLMediaCtrl* web)
+	{
+		if (tokens.size() == 1
+			&& tokens[0].asString() == "request")
+		{
+			LLStatusBar::sendMoneyBalanceRequest();
+			return true;
+		}
+		return false;
+	}
 };
 // register with command dispatch system
 LLBalanceHandler gBalanceHandler;
diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h
index e9be398601..040b7bc949 100644
--- a/indra/newview/llstatusbar.h
+++ b/indra/newview/llstatusbar.h
@@ -48,82 +48,82 @@ class LLPanelNearByMedia;
 class LLIconCtrl;
 
 class LLStatusBar
-:   public LLPanel
+:	public LLPanel
 {
 public:
-    LLStatusBar(const LLRect& rect );
-    /*virtual*/ ~LLStatusBar();
-    
-    /*virtual*/ void draw();
+	LLStatusBar(const LLRect& rect );
+	/*virtual*/ ~LLStatusBar();
+	
+	/*virtual*/ void draw();
 
-    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL postBuild();
+	/*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+	/*virtual*/ BOOL postBuild();
 
-    // MANIPULATORS
-    void        setBalance(S32 balance);
-    void        debitBalance(S32 debit);
-    void        creditBalance(S32 credit);
+	// MANIPULATORS
+	void		setBalance(S32 balance);
+	void		debitBalance(S32 debit);
+	void		creditBalance(S32 credit);
 
-    // Request the latest currency balance from the server
-    static void sendMoneyBalanceRequest();
+	// Request the latest currency balance from the server
+	static void sendMoneyBalanceRequest();
 
-    void        setHealth(S32 percent);
+	void		setHealth(S32 percent);
 
-    void setLandCredit(S32 credit);
-    void setLandCommitted(S32 committed);
+	void setLandCredit(S32 credit);
+	void setLandCommitted(S32 committed);
 
-    void        refresh();
-    void setVisibleForMouselook(bool visible);
-        // some elements should hide in mouselook
+	void		refresh();
+	void setVisibleForMouselook(bool visible);
+		// some elements should hide in mouselook
 
-    // ACCESSORS
-    S32         getBalance() const;
-    S32         getHealth() const;
+	// ACCESSORS
+	S32			getBalance() const;
+	S32			getHealth() const;
 
-    BOOL isUserTiered() const;
-    S32 getSquareMetersCredit() const;
-    S32 getSquareMetersCommitted() const;
-    S32 getSquareMetersLeft() const;
+	BOOL isUserTiered() const;
+	S32 getSquareMetersCredit() const;
+	S32 getSquareMetersCommitted() const;
+	S32 getSquareMetersLeft() const;
 
-    LLPanelNearByMedia* getNearbyMediaPanel() { return mPanelNearByMedia; }
+	LLPanelNearByMedia* getNearbyMediaPanel() { return mPanelNearByMedia; }
 
 private:
-    
-    void onClickBuyCurrency();
-    void onVolumeChanged(const LLSD& newvalue);
+	
+	void onClickBuyCurrency();
+	void onVolumeChanged(const LLSD& newvalue);
 
-    void onMouseEnterPresetsCamera();
-    void onMouseEnterPresets();
-    void onMouseEnterVolume();
-    void onMouseEnterNearbyMedia();
-    void onClickScreen(S32 x, S32 y);
+	void onMouseEnterPresetsCamera();
+	void onMouseEnterPresets();
+	void onMouseEnterVolume();
+	void onMouseEnterNearbyMedia();
+	void onClickScreen(S32 x, S32 y);
 
-    static void onClickMediaToggle(void* data);
-    static void onClickBalance(void* data);
+	static void onClickMediaToggle(void* data);
+	static void onClickBalance(void* data);
 
 private:
-    LLTextBox   *mTextTime;
-
-    LLStatGraph *mSGBandwidth;
-    LLStatGraph *mSGPacketLoss;
-
-    LLIconCtrl  *mIconPresetsCamera;
-    LLIconCtrl  *mIconPresetsGraphic;
-    LLButton    *mBtnVolume;
-    LLTextBox   *mBoxBalance;
-    LLButton    *mMediaToggle;
-    LLFrameTimer    mClockUpdateTimer;
-
-    S32             mBalance;
-    S32             mHealth;
-    S32             mSquareMetersCredit;
-    S32             mSquareMetersCommitted;
-    LLFrameTimer*   mBalanceTimer;
-    LLFrameTimer*   mHealthTimer;
-    LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown;
-    LLPanelPresetsPulldown* mPanelPresetsPulldown;
-    LLPanelVolumePulldown* mPanelVolumePulldown;
-    LLPanelNearByMedia* mPanelNearByMedia;
+	LLTextBox	*mTextTime;
+
+	LLStatGraph *mSGBandwidth;
+	LLStatGraph *mSGPacketLoss;
+
+	LLIconCtrl	*mIconPresetsCamera;
+	LLIconCtrl	*mIconPresetsGraphic;
+	LLButton	*mBtnVolume;
+	LLTextBox	*mBoxBalance;
+	LLButton	*mMediaToggle;
+	LLFrameTimer	mClockUpdateTimer;
+
+	S32				mBalance;
+	S32				mHealth;
+	S32				mSquareMetersCredit;
+	S32				mSquareMetersCommitted;
+	LLFrameTimer*	mBalanceTimer;
+	LLFrameTimer*	mHealthTimer;
+	LLPanelPresetsCameraPulldown* mPanelPresetsCameraPulldown;
+	LLPanelPresetsPulldown* mPanelPresetsPulldown;
+	LLPanelVolumePulldown* mPanelVolumePulldown;
+	LLPanelNearByMedia*	mPanelNearByMedia;
 };
 
 // *HACK: Status bar owns your cached money balance. JC
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 968472fe4c..5237986cd6 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -166,216 +166,216 @@
 class LLFloaterOpenHandler : public LLCommandHandler
 {
 public:
-    // requires trusted browser to trigger
-    LLFloaterOpenHandler() : LLCommandHandler("openfloater", UNTRUSTED_THROTTLE) { }
+	// requires trusted browser to trigger
+	LLFloaterOpenHandler() : LLCommandHandler("openfloater", UNTRUSTED_THROTTLE) { }
 
-    bool handle(const LLSD& params, const LLSD& query_map,
-                LLMediaCtrl* web)
-    {
-        if (params.size() != 1)
-        {
-            return false;
-        }
+	bool handle(const LLSD& params, const LLSD& query_map,
+				LLMediaCtrl* web)
+	{
+		if (params.size() != 1)
+		{
+			return false;
+		}
 
-        const std::string floater_name = LLURI::unescape(params[0].asString());
-        LLFloaterReg::showInstance(floater_name);
+		const std::string floater_name = LLURI::unescape(params[0].asString());
+		LLFloaterReg::showInstance(floater_name);
 
-        return true;
-    }
+		return true;
+	}
 };
 
 LLFloaterOpenHandler gFloaterOpenHandler;
 
 void LLViewerFloaterReg::registerFloaters()
 {
-    // *NOTE: Please keep these alphabetized for easier merges
+	// *NOTE: Please keep these alphabetized for easier merges
 
-    LLFloaterAboutUtil::registerFloater();
-    LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
-    LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>);
-    LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-    LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>);
-    LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>);
-    LLFloaterReg::add("avatar", "floater_avatar.xml",  (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>);
-    LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>);
-    LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>);
-    LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>);
+	LLFloaterAboutUtil::registerFloater();
+	LLFloaterReg::add("block_timers", "floater_fast_timers.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFastTimerView>);
+	LLFloaterReg::add("about_land", "floater_about_land.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLand>);
+	LLFloaterReg::add("appearance", "floater_my_appearance.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+	LLFloaterReg::add("associate_listing", "floater_associate_listing.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAssociateListing>);
+	LLFloaterReg::add("auction", "floater_auction.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAuction>);
+	LLFloaterReg::add("avatar", "floater_avatar.xml",  (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatar>);
+	LLFloaterReg::add("avatar_picker", "floater_avatar_picker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarPicker>);
+	LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>);
+	LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>);
 
-    LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>);
-    LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>);
-    LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater);
-    LLFloaterReg::add("buy_currency_html", "floater_buy_currency_html.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyCurrencyHTML>);    
-    LLFloaterReg::add("buy_land", "floater_buy_land.xml", &LLFloaterBuyLand::buildFloater);
-    LLFloaterReg::add("buy_object", "floater_buy_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuy>);
-    LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>);
-    LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>);
-    LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>);
-    LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
+	LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>);
+	LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>);
+	LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater);
+	LLFloaterReg::add("buy_currency_html", "floater_buy_currency_html.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyCurrencyHTML>);	
+	LLFloaterReg::add("buy_land", "floater_buy_land.xml", &LLFloaterBuyLand::buildFloater);
+	LLFloaterReg::add("buy_object", "floater_buy_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuy>);
+	LLFloaterReg::add("buy_object_contents", "floater_buy_contents.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuyContents>);
+	LLFloaterReg::add("build", "floater_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTools>);
+	LLFloaterReg::add("build_options", "floater_build_options.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBuildOptions>);
+	LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
 
-    LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
-    LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>);
-    LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater);
-    LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);
-    LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>);
+	LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
+	LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>);
+	LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater);
+	LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);
+	LLFloaterReg::add("conversation", "floater_conversation_log.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationLog>);
 
-    LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>);
-    LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>);
+	LLFloaterReg::add("delete_pref_preset", "floater_delete_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeletePrefPreset>);
+	LLFloaterReg::add("destinations", "floater_destinations.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDestinations>);
 
-    LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>);
-    LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>);
-    LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>);
-    LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>);
-    LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>);
-    LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>);
+	LLFloaterReg::add("env_post_process", "floater_post_process.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPostProcess>);
+	LLFloaterReg::add("env_settings", "floater_environment_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEnvironmentSettings>);
+	LLFloaterReg::add("env_delete_preset", "floater_delete_env_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDeleteEnvPreset>);
+	LLFloaterReg::add("env_edit_sky", "floater_edit_sky_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditSky>);
+	LLFloaterReg::add("env_edit_water", "floater_edit_water_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditWater>);
+	LLFloaterReg::add("env_edit_day_cycle", "floater_edit_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEditDayCycle>);
 
     LLFloaterReg::add("event", "floater_event.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterEvent>);
     LLFloaterReg::add("experiences", "floater_experiences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiences>);
-    LLFloaterReg::add("experience_profile", "floater_experienceprofile.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperienceProfile>);
-    LLFloaterReg::add("experience_search", "floater_experience_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiencePicker>);
+	LLFloaterReg::add("experience_profile", "floater_experienceprofile.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperienceProfile>);
+	LLFloaterReg::add("experience_search", "floater_experience_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterExperiencePicker>);
 
-    LLFloaterReg::add("font_test", "floater_font_test.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFontTest>);
+	LLFloaterReg::add("font_test", "floater_font_test.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFontTest>);
 
-    LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>);
-    LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>);
-    LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>);
-    LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>);
+	LLFloaterReg::add("gestures", "floater_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGesture>);
+	LLFloaterReg::add("god_tools", "floater_god_tools.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGodTools>);
+	LLFloaterReg::add("grid_status", "floater_grid_status.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGridStatus>);
+	LLFloaterReg::add("group_picker", "floater_choose_group.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGroupPicker>);
 
-    LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>);
-    LLFloaterReg::add("edit_hover_height", "floater_edit_hover_height.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHoverHeight>);
-    LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>);
+	LLFloaterReg::add("help_browser", "floater_help_browser.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHelpBrowser>);
+	LLFloaterReg::add("edit_hover_height", "floater_edit_hover_height.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHoverHeight>);
+	LLFloaterReg::add("hud", "floater_hud.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterHUD>);
 
-    LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMSession>);
-    LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMContainer>);
-    LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>);
-    LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>);
-    LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-    LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>);
-    LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>);
-    LLInspectAvatarUtil::registerFloater();
-    LLInspectGroupUtil::registerFloater();
-    LLInspectObjectUtil::registerFloater();
-    LLInspectRemoteObjectUtil::registerFloater();
-    LLFloaterVoiceVolumeUtil::registerFloater();
-    LLNotificationsUI::registerFloater();
-    
-    LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
-    LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
-    LLFloaterReg::add("linkreplace", "floater_linkreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLinkReplace>);
-    LLFloaterReg::add("load_pref_preset", "floater_load_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLoadPrefPreset>);
-    
-    LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>);
+	LLFloaterReg::add("impanel", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMSession>);
+	LLFloaterReg::add("im_container", "floater_im_container.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterIMContainer>);
+	LLFloaterReg::add("im_well_window", "floater_sys_well.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIMWellWindow>);
+	LLFloaterReg::add("incoming_call", "floater_incoming_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLIncomingCallDialog>);
+	LLFloaterReg::add("inventory", "floater_my_inventory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+	LLFloaterReg::add("inspect", "floater_inspect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterInspect>);
+	LLFloaterReg::add("item_properties", "floater_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterItemProperties>);
+	LLInspectAvatarUtil::registerFloater();
+	LLInspectGroupUtil::registerFloater();
+	LLInspectObjectUtil::registerFloater();
+	LLInspectRemoteObjectUtil::registerFloater();
+	LLFloaterVoiceVolumeUtil::registerFloater();
+	LLNotificationsUI::registerFloater();
+	
+	LLFloaterReg::add("lagmeter", "floater_lagmeter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLagMeter>);
+	LLFloaterReg::add("land_holdings", "floater_land_holdings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLandHoldings>);
+	LLFloaterReg::add("linkreplace", "floater_linkreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLinkReplace>);
+	LLFloaterReg::add("load_pref_preset", "floater_load_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterLoadPrefPreset>);
+	
+	LLFloaterReg::add("mem_leaking", "floater_mem_leaking.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMemLeak>);
 
-    if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
-    {
-        LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>);
-    }
-    LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>);    
-    LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>);
-    LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>);
-    LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
-    LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
-    LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMove>);
-    LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGetBlockedObjectName>);
-    LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMap>);
+	if(gSavedSettings.getBOOL("TextureFetchDebuggerEnabled"))
+	{
+		LLFloaterReg::add("tex_fetch_debugger", "floater_texture_fetch_debugger.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTextureFetchDebugger>);
+	}
+	LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMediaSettings>);	
+	LLFloaterReg::add("marketplace_listings", "floater_marketplace_listings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceListings>);
+	LLFloaterReg::add("marketplace_validation", "floater_marketplace_validation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMarketplaceValidation>);
+	LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
+	LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTOS>);
+	LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMove>);
+	LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterGetBlockedObjectName>);
+	LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterMap>);
 
-    LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationConsole>);
-    
-    LLFloaterReg::add("notification_well_window", "floater_notifications_tabbed.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationsTabbed>);
+	LLFloaterReg::add("notifications_console", "floater_notifications_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationConsole>);
+	
+	LLFloaterReg::add("notification_well_window", "floater_notifications_tabbed.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotificationsTabbed>);
 
-    LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterObjectWeights>);
-    LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>);
-    LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>);
-    LLFloaterReg::add("outfit_photo_preview", "floater_outfit_photo_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitPhotoPreview>);
-    LLFloaterPayUtil::registerFloater();
+	LLFloaterReg::add("object_weights", "floater_object_weights.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterObjectWeights>);
+	LLFloaterReg::add("openobject", "floater_openobject.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOpenObject>);
+	LLFloaterReg::add("outgoing_call", "floater_outgoing_call.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLOutgoingCallDialog>);
+	LLFloaterReg::add("outfit_photo_preview", "floater_outfit_photo_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitPhotoPreview>);
+	LLFloaterPayUtil::registerFloater();
 
-    LLFloaterReg::add("pathfinding_characters", "floater_pathfinding_characters.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingCharacters>);
-    LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>);
-    LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>);
-    LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-    LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>);
-    LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-    LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
-    LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>);
-    LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>);
-    LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
-    LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>);
-    LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
-    LLFloaterReg::add("prefs_spellchecker", "floater_spellcheck.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerSettings>);
-    LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAutoReplaceSettings>);
-    LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
-    LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>);
-    LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview");
-    LLFloaterReg::add("preview_conversation", "floater_conversation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationPreview>);
-    LLFloaterReg::add("preview_gesture", "floater_preview_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewGesture>, "preview");
-    LLFloaterReg::add("preview_notecard", "floater_preview_notecard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewNotecard>, "preview");
-    LLFloaterReg::add("preview_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewLSL>, "preview");
-    LLFloaterReg::add("preview_scriptedit", "floater_live_lsleditor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLLiveLSLEditor>, "preview");
-    LLFloaterReg::add("preview_sound", "floater_preview_sound.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewSound>, "preview");
-    LLFloaterReg::add("preview_texture", "floater_preview_texture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewTexture>, "preview");
-    LLFloaterReg::add("preview_trash", "floater_preview_trash.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreviewTrash>);
-    LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>);
-    LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>);
-    LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>);
-    LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>);
+	LLFloaterReg::add("pathfinding_characters", "floater_pathfinding_characters.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingCharacters>);
+	LLFloaterReg::add("pathfinding_linksets", "floater_pathfinding_linksets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingLinksets>);
+	LLFloaterReg::add("pathfinding_console", "floater_pathfinding_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPathfindingConsole>);
+	LLFloaterReg::add("people", "floater_people.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+	LLFloaterReg::add("perms_default", "floater_perms_default.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPermsDefault>);
+	LLFloaterReg::add("places", "floater_places.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+	LLFloaterReg::add("preferences", "floater_preferences.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreference>);
+	LLFloaterReg::add("prefs_graphics_advanced", "floater_preferences_graphics_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceGraphicsAdvanced>);
+	LLFloaterReg::add("prefs_view_advanced", "floater_preferences_view_advanced.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceViewAdvanced>);
+	LLFloaterReg::add("prefs_proxy", "floater_preferences_proxy.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreferenceProxy>);
+	LLFloaterReg::add("prefs_spellchecker_import", "floater_spellcheck_import.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerImport>);
+	LLFloaterReg::add("prefs_translation", "floater_translation_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTranslationSettings>);
+	LLFloaterReg::add("prefs_spellchecker", "floater_spellcheck.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSpellCheckerSettings>);
+	LLFloaterReg::add("prefs_autoreplace", "floater_autoreplace.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAutoReplaceSettings>);
+	LLFloaterReg::add("picks", "floater_picks.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSidePanelContainer>);
+	LLFloaterReg::add("pref_joystick", "floater_joystick.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterJoystick>);
+	LLFloaterReg::add("preview_anim", "floater_preview_animation.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewAnim>, "preview");
+	LLFloaterReg::add("preview_conversation", "floater_conversation_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterConversationPreview>);
+	LLFloaterReg::add("preview_gesture", "floater_preview_gesture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewGesture>, "preview");
+	LLFloaterReg::add("preview_notecard", "floater_preview_notecard.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewNotecard>, "preview");
+	LLFloaterReg::add("preview_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewLSL>, "preview");
+	LLFloaterReg::add("preview_scriptedit", "floater_live_lsleditor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLLiveLSLEditor>, "preview");
+	LLFloaterReg::add("preview_sound", "floater_preview_sound.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewSound>, "preview");
+	LLFloaterReg::add("preview_texture", "floater_preview_texture.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPreviewTexture>, "preview");
+	LLFloaterReg::add("preview_trash", "floater_preview_trash.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterPreviewTrash>);
+	LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>);
+	LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>);
+	LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>);
+	LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>);
 
-    LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>);
-    LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build<LLFloaterTestInspectors>);
-    //LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build<LLFloaterTestListView>);
-    LLFloaterReg::add("test_textbox", "floater_test_textbox.xml", &LLFloaterReg::build<LLFloater>);
-    LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>);
-    LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>);
-    LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>);
-    LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>);
-    
-    LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>);
-    LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>);
-    LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>);
-    LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>);
-    LLFloaterReg::add("region_restarting", "floater_region_restarting.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionRestarting>);
-    
-    LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>);
-    LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>);
-    LLFloaterReg::add("script_floater", "floater_script.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLScriptFloater>);
-    LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptLimits>);
-    LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater);
-    LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>);
-    LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>);
-    LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
-    LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>);
-    LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>);
-    LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
-    LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
+	LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>);
+	LLFloaterReg::add("test_inspectors", "floater_test_inspectors.xml", &LLFloaterReg::build<LLFloaterTestInspectors>);
+	//LLFloaterReg::add("test_list_view", "floater_test_list_view.xml",&LLFloaterReg::build<LLFloaterTestListView>);
+	LLFloaterReg::add("test_textbox", "floater_test_textbox.xml", &LLFloaterReg::build<LLFloater>);
+	LLFloaterReg::add("test_text_editor", "floater_test_text_editor.xml", &LLFloaterReg::build<LLFloater>);
+	LLFloaterReg::add("test_widgets", "floater_test_widgets.xml", &LLFloaterReg::build<LLFloater>);
+	LLFloaterReg::add("top_objects", "floater_top_objects.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTopObjects>);
+	LLFloaterReg::add("toybox", "floater_toybox.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterToybox>);
+	
+	LLFloaterReg::add("reporter", "floater_report_abuse.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterReporter>);
+	LLFloaterReg::add("reset_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterResetQueue>);
+	LLFloaterReg::add("region_debug_console", "floater_region_debug_console.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionDebugConsole>);
+	LLFloaterReg::add("region_info", "floater_region_info.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionInfo>);
+	LLFloaterReg::add("region_restarting", "floater_region_restarting.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRegionRestarting>);
+	
+	LLFloaterReg::add("script_debug", "floater_script_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebug>);
+	LLFloaterReg::add("script_debug_output", "floater_script_debug_panel.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptDebugOutput>);
+	LLFloaterReg::add("script_floater", "floater_script.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLScriptFloater>);
+	LLFloaterReg::add("script_limits", "floater_script_limits.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptLimits>);
+	LLFloaterReg::add("sell_land", "floater_sell_land.xml", &LLFloaterSellLand::buildFloater);
+	LLFloaterReg::add("settings_debug", "floater_settings_debug.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSettingsDebug>);
+	LLFloaterReg::add("sound_devices", "floater_sound_devices.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundDevices>);
+	LLFloaterReg::add("stats", "floater_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>);
+	LLFloaterReg::add("start_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterRunQueue>);
+	LLFloaterReg::add("scene_load_stats", "floater_scene_load_stats.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSceneLoadStats>);
+	LLFloaterReg::add("stop_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterNotRunQueue>);
+	LLFloaterReg::add("snapshot", "floater_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSnapshot>);
     LLFloaterReg::add("outfit_snapshot", "floater_outfit_snapshot.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterOutfitSnapshot>);
     LLFloaterReg::add("search", "floater_search.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSearch>);
-    LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
-    LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
-    LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+	LLFloaterReg::add("my_profile", "floater_my_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
+	LLFloaterReg::add("profile", "floater_web_profile.xml", (LLFloaterBuildFunc)&LLFloaterWebProfile::create);
+	LLFloaterReg::add("how_to", "floater_how_to.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
 
-    LLFloaterReg::add("fbc_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-    LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-    LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
-    
-    LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>);
-    LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>);
-    LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>);
-    LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>);
-    
-    LLFloaterUIPreviewUtil::registerFloater();
-    LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload");
-    LLFloaterReg::add("upload_anim_anim", "floater_animation_anim_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
-    LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
-    LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
-    LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload");
-    LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
+	LLFloaterReg::add("fbc_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+	LLFloaterReg::add("flickr_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+	LLFloaterReg::add("twitter_web", "floater_fbc_web.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);
+	
+	LLFloaterReg::add("facebook", "floater_facebook.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFacebook>);
+	LLFloaterReg::add("flickr", "floater_flickr.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterFlickr>);
+	LLFloaterReg::add("twitter", "floater_twitter.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterTwitter>);
+	LLFloaterReg::add("big_preview", "floater_big_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBigPreview>);
+	
+	LLFloaterUIPreviewUtil::registerFloater();
+	LLFloaterReg::add("upload_anim_bvh", "floater_animation_bvh_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBvhPreview>, "upload");
+	LLFloaterReg::add("upload_anim_anim", "floater_animation_anim_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAnimPreview>, "upload");
+	LLFloaterReg::add("upload_image", "floater_image_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterImagePreview>, "upload");
+	LLFloaterReg::add("upload_model", "floater_model_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterModelPreview>, "upload");
+	LLFloaterReg::add("upload_script", "floater_script_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptPreview>, "upload");
+	LLFloaterReg::add("upload_sound", "floater_sound_preview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSoundPreview>, "upload");
 
-    LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>);
+	LLFloaterReg::add("voice_effect", "floater_voice_effect.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterVoiceEffect>);
 
-    LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);  
-    LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>); 
-    LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>);
-    LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>);   
+	LLFloaterReg::add("web_content", "floater_web_content.xml", (LLFloaterBuildFunc)&LLFloaterWebContent::create);	
+	LLFloaterReg::add("whitelist_entry", "floater_whitelist_entry.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWhiteListEntry>);	
+	LLFloaterReg::add("window_size", "floater_window_size.xml", &LLFloaterReg::build<LLFloaterWindowSize>);
+	LLFloaterReg::add("world_map", "floater_world_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterWorldMap>);	
 
-    // *NOTE: Please keep these alphabetized for easier merges
-    
-    LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving
+	// *NOTE: Please keep these alphabetized for easier merges
+	
+	LLFloaterReg::registerControlVariables(); // Make sure visibility and rect controls get preserved when saving
 }
-- 
cgit v1.2.3


From bb585d95b5955effb813621942e10429ea97df1f Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Wed, 8 May 2019 11:59:20 -0700
Subject: Fix merge by putting back loadFromFilename.

---
 indra/newview/llfloaterpreference.cpp | 46 +++++++++++++++++++++++++++++++++++
 indra/newview/llfloaterpreference.h   |  1 +
 2 files changed, 47 insertions(+)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 927124f333..28e77deec2 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -849,6 +849,13 @@ void LLFloaterPreference::onOpen(const LLSD& key)
 		save_camera_btn->setEnabled(started);
 		delete_camera_btn->setEnabled(started);
 	}
+
+    collectSearchableItems();
+	if (!mFilterEdit->getText().empty())
+	{
+		mFilterEdit->setText(LLStringExplicit(""));
+		onUpdateFilterTerm(true);
+	}
 }
 
 void LLFloaterPreference::onVertexShaderEnable()
@@ -2029,6 +2036,45 @@ void LLFloaterPreference::updateMaxComplexity()
         getChild<LLTextBox>("IndirectMaxComplexityText"));
 }
 
+bool LLFloaterPreference::loadFromFilename(const std::string& filename, std::map<std::string, std::string> &label_map)
+{
+    LLXMLNodePtr root;
+
+    if (!LLXMLNode::parseFile(filename, root, NULL))
+    {
+        LL_WARNS() << "Unable to parse file " << filename << LL_ENDL;
+        return false;
+    }
+
+    if (!root->hasName("labels"))
+    {
+        LL_WARNS() << filename << " is not a valid definition file" << LL_ENDL;
+        return false;
+    }
+
+    LabelTable params;
+    LLXUIParser parser;
+    parser.readXUI(root, params, filename);
+
+    if (params.validateBlock())
+    {
+        for (LLInitParam::ParamIterator<LabelDef>::const_iterator it = params.labels.begin();
+            it != params.labels.end();
+            ++it)
+        {
+            LabelDef label_entry = *it;
+            label_map[label_entry.name] = label_entry.value;
+        }
+    }
+    else
+    {
+        LL_WARNS() << filename << " failed to load" << LL_ENDL;
+        return false;
+    }
+
+    return true;
+}
+
 void LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity()
 {
 	// Called when the IndirectMaxComplexity control changes
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 54f985193a..fd6ce0239f 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -199,6 +199,7 @@ private:
 	void onDeleteTranscriptsResponse(const LLSD& notification, const LLSD& response);
 	void updateDeleteTranscriptsButton();
 	void updateMaxComplexity();
+	static bool loadFromFilename(const std::string& filename, std::map<std::string, std::string> &label_map);
 
 	static std::string sSkin;
 	notifications_map mNotificationOptions;
-- 
cgit v1.2.3


From 36cfb37ebeaa6fa6ac6ff8b706ffdabd933d56bd Mon Sep 17 00:00:00 2001
From: Graham Linden <graham@lindenlab.com>
Date: Wed, 8 May 2019 16:59:10 -0700
Subject: Put back new panel decl lost in merge.

---
 indra/newview/llfloaterpreference.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index fd6ce0239f..204916de86 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -272,6 +272,18 @@ private:
 	LOG_CLASS(LLPanelPreference);
 };
 
+class LLPanelPreferenceView : public LLPanelPreference
+{
+public:
+	BOOL postBuild();
+	void draw();
+	void setPresetText();
+
+private:
+	void onPresetsListChangeCamera();
+	LOG_CLASS(LLPanelPreferenceView);
+};
+
 class LLPanelPreferenceGraphics : public LLPanelPreference
 {
 public:
@@ -289,7 +301,6 @@ protected:
 	bool hasDirtyChilds();
 
 private:
-
 	void onPresetsListChange();
 	LOG_CLASS(LLPanelPreferenceGraphics);
 };
-- 
cgit v1.2.3


From 915587de4501a82487d3c355c247029f6a157341 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Tue, 29 Oct 2019 13:27:21 +0200
Subject: Fix crash on startup and restore missing settings

---
 indra/newview/app_settings/settings.xml | 22 ++++++++++++++++++++++
 indra/newview/llpresetsmanager.cpp      | 21 +++++++++++----------
 2 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 49601ae98f..a02cccb613 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -16299,6 +16299,28 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+  <key>CameraOpacity</key>
+  <map>
+    <key>Comment</key>
+    <string>Opacity of the Camera Controls floater</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>F32</string>
+    <key>Value</key>
+    <real>1.0</real>
+  </map>
+  <key>PresetCameraActive</key>
+  <map>
+    <key>Comment</key>
+    <string>Name of currently selected preference</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>String</string>
+    <key>Value</key>
+    <string />
+  </map>
     <key>CefVerboseLog</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index c1702b4132..17fefbe6b1 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -262,8 +262,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	}
 	else if(PRESETS_CAMERA == subdirectory)
 	{
-		gSavedSettings.setString("PresetGraphicActive", name);
-
 		name_list.clear();
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
@@ -292,14 +290,17 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		{
 			std::string ctrl_name = *it;
 			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
-			std::string comment = ctrl->getComment();
-			std::string type = LLControlGroup::typeEnumToString(ctrl->type());
-			LLSD value = ctrl->getValue();
-
-			paramsData[ctrl_name]["Comment"] = comment;
-			paramsData[ctrl_name]["Persist"] = 1;
-			paramsData[ctrl_name]["Type"] = type;
-			paramsData[ctrl_name]["Value"] = value;
+			if (ctrl)
+			{
+				std::string comment = ctrl->getComment();
+				std::string type = LLControlGroup::typeEnumToString(ctrl->type());
+				LLSD value = ctrl->getValue();
+
+				paramsData[ctrl_name]["Comment"] = comment;
+				paramsData[ctrl_name]["Persist"] = 1;
+				paramsData[ctrl_name]["Type"] = type;
+				paramsData[ctrl_name]["Value"] = value;
+			}
 		}
 	}
 
-- 
cgit v1.2.3


From c75d443c8359f0bceee2df2adc0a67b2890922ea Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Mon, 4 Nov 2019 20:35:34 +0200
Subject: SL-12186 WIP Updating UI for camera controls, including presets

---
 indra/newview/app_settings/camera/Front.xml        |   8 +-
 indra/newview/app_settings/camera/Pennys_Gamer.xml | 115 --------
 indra/newview/app_settings/camera/Side.xml         |   8 +-
 indra/newview/app_settings/settings.xml            |  30 +++
 indra/newview/llagentcamera.cpp                    |  17 ++
 indra/newview/llagentcamera.h                      |   9 +-
 indra/newview/llfloatercamera.cpp                  | 118 ++++-----
 indra/newview/llfloatercamera.h                    |  10 +-
 indra/newview/llfloaterpreferenceviewadvanced.cpp  |  40 +--
 indra/newview/llfloaterpreferenceviewadvanced.h    |   7 -
 indra/newview/llfloatersaveprefpreset.cpp          |  80 ++++--
 indra/newview/llfloatersaveprefpreset.h            |   9 +-
 indra/newview/llpresetsmanager.cpp                 |  96 ++++---
 indra/newview/llpresetsmanager.h                   |   4 +
 .../skins/default/xui/en/floater_camera.xml        | 292 +++++++++------------
 .../xui/en/floater_preferences_view_advanced.xml   |  28 +-
 .../default/xui/en/floater_save_pref_preset.xml    |  60 +++--
 .../newview/skins/default/xui/en/notifications.xml |  12 +
 .../default/xui/en/widgets/panel_camera_item.xml   |   4 +-
 19 files changed, 443 insertions(+), 504 deletions(-)
 delete mode 100644 indra/newview/app_settings/camera/Pennys_Gamer.xml

diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
index d5ead526b7..a4b5ace33c 100644
--- a/indra/newview/app_settings/camera/Front.xml
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -37,10 +37,10 @@
                 <real>6</real>
             </array>
         </map>
-    <key>CameraOffsetRearView</key>
+    <key>CameraOffsetFrontView</key>
         <map>
         <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
+            <string>Initial camera offset from avatar in Front View</string>
         <key>Persist</key>
             <integer>1</integer>
         <key>Type</key>
@@ -74,10 +74,10 @@
         <key>Value</key>
             <integer>0</integer>
         </map>
-    <key>FocusOffsetRearView</key>
+    <key>FocusOffsetFrontView</key>
         <map>
         <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+            <string>Initial focus point offset relative to avatar for the camera preset Front View (x-axis is forward)</string>
         <key>Persist</key>
             <integer>1</integer>
         <key>Type</key>
diff --git a/indra/newview/app_settings/camera/Pennys_Gamer.xml b/indra/newview/app_settings/camera/Pennys_Gamer.xml
deleted file mode 100644
index 5d249153a0..0000000000
--- a/indra/newview/app_settings/camera/Pennys_Gamer.xml
+++ /dev/null
@@ -1,115 +0,0 @@
-<llsd>
-    <map>
-    <key>AppearanceCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering appearance editing mode, camera zooms in on currently selected portion of avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    <key>CameraAngle</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera field of view angle (Radians)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1.047197551</real>
-        </map>
-    <key>CameraOffsetBuild</key>
-        <map>
-        <key>Comment</key>
-            <string>Default camera position relative to focus point when entering build mode</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-6</real>
-                <real>0</real>
-                <real>6</real>
-            </array>
-        </map>
-    <key>CameraOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3</string>
-        <key>Value</key>
-            <array>
-                <real>-3.0</real>
-                <real>0.0</real>
-                <real>-0.2</real>
-            </array>
-        </map>
-    <key>CameraOffsetScale</key>
-        <map>
-        <key>Comment</key>
-            <string>Scales the default offset</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>F32</string>
-        <key>Value</key>
-            <real>1</real>
-        </map>
-    <key>EditCameraMovement</key>
-        <map>
-        <key>Comment</key>
-            <string>When entering build mode, camera moves up above avatar</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>0</integer>
-        </map>
-    <key>FocusOffsetRearView</key>
-        <map>
-        <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Vector3D</string>
-        <key>Value</key>
-            <array>
-                <real>0.9</real>
-                <real>0.0</real>
-                <real>0.2</real>
-            </array>
-        </map>
-    <key>PresetCameraActive</key>
-        <map>
-        <key>Comment</key>
-            <string>Name of currently selected preference</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>String</string>
-        <key>Value</key>
-            <string>Default</string>
-        </map>
-    <key>TrackFocusObject</key>
-        <map>
-        <key>Comment</key>
-            <string>Camera tracks last object zoomed on</string>
-        <key>Persist</key>
-            <integer>1</integer>
-        <key>Type</key>
-            <string>Boolean</string>
-        <key>Value</key>
-            <integer>1</integer>
-        </map>
-    </map>
-</llsd>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
index 4cd5f2f5a4..677fd47e20 100644
--- a/indra/newview/app_settings/camera/Side.xml
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -37,10 +37,10 @@
                 <real>6</real>
             </array>
         </map>
-    <key>CameraOffsetRearView</key>
+    <key>CameraOffsetGroupView</key>
         <map>
         <key>Comment</key>
-            <string>Initial camera offset from avatar in Rear View</string>
+            <string>Initial camera offset from avatar in Side View</string>
         <key>Persist</key>
             <integer>1</integer>
         <key>Type</key>
@@ -74,10 +74,10 @@
         <key>Value</key>
             <integer>0</integer>
         </map>
-    <key>FocusOffsetRearView</key>
+    <key>FocusOffsetGroupView</key>
         <map>
         <key>Comment</key>
-            <string>Initial focus point offset relative to avatar for the camera preset Rear View (x-axis is forward)</string>
+            <string>Initial focus point offset relative to avatar for the camera preset Side View (x-axis is forward)</string>
         <key>Persist</key>
             <integer>1</integer>
         <key>Type</key>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a02cccb613..f44185340a 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1499,6 +1499,21 @@
         <real>0.5</real>
       </array>
     </map>
+    <key>CameraOffsetCustomPreset</key>
+    <map>
+      <key>Comment</key>
+      <string>Initial camera offset from avatar for the custom camera preset</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3</string>
+      <key>Value</key>
+      <array>
+        <real>-3.0</real>
+        <real>0.0</real>
+        <real>0.75</real>
+      </array>
+    </map>
     <key>CameraOffsetScale</key>
     <map>
       <key>Comment</key>
@@ -4356,6 +4371,21 @@
         <real>1.0</real>
       </array>
     </map>
+    <key>FocusOffsetCustomPreset</key>
+    <map>
+      <key>Comment</key>
+      <string>Initial focus point offset relative to avatar for the custom camera preset (x-axis is forward)</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Vector3D</string>
+      <key>Value</key>
+      <array>
+        <real>1.0</real>
+        <real>0.0</real>
+        <real>1.0</real>
+      </array>
+    </map>
     <key>FocusPosOnLogout</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index bbe1354fc3..3e56c1dd71 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -210,10 +210,12 @@ void LLAgentCamera::init()
 	mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
 	mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
 	mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
+	mCameraOffsetInitial[CAMERA_PRESET_CUSTOM] = gSavedSettings.getControl("CameraOffsetCustomPreset");
 
 	mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
 	mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
 	mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
+	mFocusOffsetInitial[CAMERA_PRESET_CUSTOM] = gSavedSettings.getControl("FocusOffsetCustomPreset");
 
 	mCameraCollidePlane.clearVec();
 	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
@@ -1936,6 +1938,21 @@ LLVector3 LLAgentCamera::getCameraOffsetInitial()
 	return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, "");
 }
 
+LLVector3d LLAgentCamera::getFocusOffsetInitial()
+{
+	return convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
+}
+
+std::string LLAgentCamera::getCameraOffsetCtrlName()
+{
+	return mCameraOffsetInitial[mCameraPreset]->getName();
+}
+
+std::string LLAgentCamera::getFocusOffsetCtrlName()
+{
+	return mFocusOffsetInitial[mCameraPreset]->getName();
+}
+
 F32 LLAgentCamera::getCameraMaxZoomDistance()
 {
     // Ignore "DisableCameraConstraints", we don't want to be out of draw range when we focus onto objects or avatars
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 4575c1501a..294e81c2e1 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -59,7 +59,7 @@ enum ECameraPreset
 	CAMERA_PRESET_GROUP_VIEW,
 
 	/** Current view when a preset is saved */
-	CAMERA_PRESET_CUSTOM0
+	CAMERA_PRESET_CUSTOM
 };
 
 //------------------------------------------------------------------------
@@ -112,9 +112,14 @@ private:
 	//--------------------------------------------------------------------
 public:
 	void switchCameraPreset(ECameraPreset preset);
-private:
 	/** Determines default camera offset depending on the current camera preset */
 	LLVector3 getCameraOffsetInitial();
+	/** Determines default focus offset depending on the current camera preset */
+	LLVector3d getFocusOffsetInitial();
+
+	std::string getCameraOffsetCtrlName();
+	std::string getFocusOffsetCtrlName();
+private:
 	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
 	F32 getCameraMaxZoomDistance();
 
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index c12ccb386e..933e758653 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -34,6 +34,7 @@
 // Viewer includes
 #include "llagent.h"
 #include "llagentcamera.h"
+#include "llpresetsmanager.h"
 #include "lljoystickbutton.h"
 #include "llviewercontrol.h"
 #include "llviewercamera.h"
@@ -53,7 +54,6 @@ const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed
 #define ORBIT "cam_rotate_stick"
 #define PAN "cam_track_stick"
 #define ZOOM "zoom"
-#define PRESETS "preset_views_list"
 #define CONTROLS "controls"
 
 bool LLFloaterCamera::sFreeCamera = false;
@@ -270,13 +270,7 @@ void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
 
 void LLFloaterCamera::handleAvatarEditingAppearance(bool editing)
 {
-	//camera presets (rear, front, etc.)
-	getChildView("preset_views_list")->setEnabled(!editing);
-	getChildView("presets_btn")->setEnabled(!editing);
 
-	//camera modes (object view, mouselook view)
-	getChildView("camera_modes_list")->setEnabled(!editing);
-	getChildView("avatarview_btn")->setEnabled(!editing);
 }
 
 void LLFloaterCamera::update()
@@ -323,6 +317,8 @@ void LLFloaterCamera::onOpen(const LLSD& key)
 	else
 		toPrevMode();
 	mClosed = FALSE;
+
+	populatePresetCombo();
 }
 
 void LLFloaterCamera::onClose(bool app_quitting)
@@ -354,7 +350,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val)
 {
 	LLHints::registerHintTarget("view_popup", getHandle());
 	mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
-	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLFloaterCamera::onViewButtonClick, this, _2));
+	mCommitCallbackRegistrar.add("CameraPresets.Save", boost::bind(&LLFloaterCamera::onSavePreset, this));
 }
 
 // virtual
@@ -366,9 +362,11 @@ BOOL LLFloaterCamera::postBuild()
 	mZoom = findChild<LLPanelCameraZoom>(ZOOM);
 	mTrack = getChild<LLJoystickCameraTrack>(PAN);
 
-	assignButton2Mode(CAMERA_CTRL_MODE_MODES,			"avatarview_btn");
-	assignButton2Mode(CAMERA_CTRL_MODE_PAN,				"pan_btn");
-	assignButton2Mode(CAMERA_CTRL_MODE_PRESETS,		"presets_btn");
+	getChild<LLTextBox>("precise_ctrs_label")->setShowCursorHand(false);
+	getChild<LLTextBox>("precise_ctrs_label")->setSoundFlags(LLView::MOUSE_UP);
+	getChild<LLTextBox>("precise_ctrs_label")->setClickedCallback(boost::bind(&LLFloaterReg::showInstance, "prefs_view_advanced", LLSD(), FALSE));
+	getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterCamera::onCustomPresetSelected, this));
+	LLPresetsManager::getInstance()->setPresetListChangeCameraCallback(boost::bind(&LLFloaterCamera::populatePresetCombo, this));
 
 	update();
 
@@ -387,24 +385,6 @@ F32	LLFloaterCamera::getCurrentTransparency()
 
 }
 
-void LLFloaterCamera::onViewButtonClick(const LLSD& user_data)
-{
-	// bring up the prefs floater
-	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
-	if (prefsfloater)
-	{
-		// grab the 'view' panel from the preferences floater and
-		// bring it the front!
-		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
-		if (tabcontainer && graphicspanel)
-		{
-			tabcontainer->selectTabPanel(graphicspanel);
-		}
-	}
-}
-
-
 void LLFloaterCamera::fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel)
 {
 	// copying child list and then iterating over a copy, because list itself
@@ -473,13 +453,6 @@ void LLFloaterCamera::switchMode(ECameraControlMode mode)
 
 	switch (mode)
 	{
-	case CAMERA_CTRL_MODE_MODES:
-		if(sFreeCamera)
-		{
-			switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
-		}
-		break;
-
 	case CAMERA_CTRL_MODE_PAN:
 		sFreeCamera = false;
 		clear_camera_tool();
@@ -503,36 +476,8 @@ void LLFloaterCamera::switchMode(ECameraControlMode mode)
 	}
 }
 
-
-void LLFloaterCamera::onClickBtn(ECameraControlMode mode)
-{
-	// check for a click on active button
-	if (mCurrMode == mode) mMode2Button[mode]->setToggleState(TRUE);
-	
-	switchMode(mode);
-
-}
-
-void LLFloaterCamera::assignButton2Mode(ECameraControlMode mode, const std::string& button_name)
-{
-	LLButton* button = getChild<LLButton>(button_name);
-	
-	button->setClickedCallback(boost::bind(&LLFloaterCamera::onClickBtn, this, mode));
-	mMode2Button[mode] = button;
-}
-
 void LLFloaterCamera::updateState()
 {
-	getChildView(ZOOM)->setVisible(CAMERA_CTRL_MODE_PAN == mCurrMode);
-	
-	bool show_presets = (CAMERA_CTRL_MODE_PRESETS == mCurrMode) || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
-																	&& CAMERA_CTRL_MODE_PRESETS == mPrevMode);
-	getChildView(PRESETS)->setVisible(show_presets);
-	
-	bool show_camera_modes = CAMERA_CTRL_MODE_MODES == mCurrMode || (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode
-																	&& CAMERA_CTRL_MODE_MODES == mPrevMode);
-	getChildView("camera_modes_list")->setVisible( show_camera_modes);
-
 	updateItemsSelection();
 
 	if (CAMERA_CTRL_MODE_FREE_CAMERA == mCurrMode)
@@ -552,11 +497,11 @@ void LLFloaterCamera::updateItemsSelection()
 {
 	ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
 	LLSD argument;
-	argument["selected"] = preset == CAMERA_PRESET_REAR_VIEW;
+	argument["selected"] = (preset == CAMERA_PRESET_REAR_VIEW) && !sFreeCamera;
 	getChild<LLPanelCameraItem>("rear_view")->setValue(argument);
-	argument["selected"] = preset == CAMERA_PRESET_GROUP_VIEW;
+	argument["selected"] = (preset == CAMERA_PRESET_GROUP_VIEW) && !sFreeCamera;
 	getChild<LLPanelCameraItem>("group_view")->setValue(argument);
-	argument["selected"] = preset == CAMERA_PRESET_FRONT_VIEW;
+	argument["selected"] = (preset == CAMERA_PRESET_FRONT_VIEW) && !sFreeCamera;
 	getChild<LLPanelCameraItem>("front_view")->setValue(argument);
 	argument["selected"] = gAgentCamera.getCameraMode() == CAMERA_MODE_MOUSELOOK;
 	getChild<LLPanelCameraItem>("mouselook_view")->setValue(argument);
@@ -580,6 +525,9 @@ void LLFloaterCamera::onClickCameraItem(const LLSD& param)
 	}
 	else
 	{
+		LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
+		if (camera_floater)
+			camera_floater->switchMode(CAMERA_CTRL_MODE_PAN);
 		switchToPreset(name);
 	}
 
@@ -599,14 +547,17 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 	if ("rear_view" == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_REAR);
 	}
 	else if ("group_view" == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_SIDE);
 	}
 	else if ("front_view" == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_FRONT);
 	}
 }
 
@@ -617,3 +568,36 @@ void LLFloaterCamera::fromFreeToPresets()
 		switchMode(CAMERA_CTRL_MODE_PRESETS);
 	}
 }
+
+void LLFloaterCamera::populatePresetCombo()
+{
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, getChild<LLComboBox>("preset_combo"), EDefaultOptions::DEFAULT_VIEWS_HIDE);
+	if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM)
+	{
+		getChild<LLComboBox>("preset_combo")->selectByValue(gSavedSettings.getString("PresetCameraActive"));
+	}
+	else
+	{
+		std::string inactive_text = getString("inactive_combo_text");
+		getChild<LLComboBox>("preset_combo")->setLabel(inactive_text);// add(inactive_text, inactive_text, ADD_TOP);
+	}
+}
+
+void LLFloaterCamera::onSavePreset()
+{
+	LLFloaterReg::hideInstance("delete_pref_preset", PRESETS_CAMERA);
+	LLFloaterReg::hideInstance("load_pref_preset", PRESETS_CAMERA);
+	LLFloaterReg::showInstance("save_pref_preset", PRESETS_CAMERA);
+}
+
+void LLFloaterCamera::onCustomPresetSelected()
+{
+	std::string selected_preset = getChild<LLComboBox>("preset_combo")->getSelectedItemLabel();
+	if (gSavedSettings.getString("PresetCameraActive") != selected_preset && getString("inactive_combo_text") != selected_preset)
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM);
+		updateItemsSelection();
+		fromFreeToPresets();
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, selected_preset);
+	}
+}
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index 481e9aec1b..b1e0c83ce0 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -39,7 +39,6 @@ class LLPanelCameraZoom;
 
 enum ECameraControlMode
 {
-	CAMERA_CTRL_MODE_MODES,
 	CAMERA_CTRL_MODE_PAN,
 	CAMERA_CTRL_MODE_FREE_CAMERA,
 	CAMERA_CTRL_MODE_PRESETS
@@ -50,7 +49,6 @@ class LLFloaterCamera : public LLFloater
 	friend class LLFloaterReg;
 	
 public:
-
 	/* whether in free camera mode */
 	static bool inFreeCameraMode();
 	/* callback for camera items selection changing */
@@ -77,6 +75,11 @@ public:
 	virtual void onOpen(const LLSD& key);
 	virtual void onClose(bool app_quitting);
 
+	void onSavePreset();
+	void onCustomPresetSelected();
+
+	void populatePresetCombo();
+
 	LLJoystickCameraRotate* mRotate;
 	LLPanelCameraZoom*	mZoom;
 	LLJoystickCameraTrack*	mTrack;
@@ -112,9 +115,6 @@ private:
 	/* update camera modes items selection and camera preset items selection according to the currently selected preset */
 	void updateItemsSelection();
 
-	void onClickBtn(ECameraControlMode mode);
-	void assignButton2Mode(ECameraControlMode mode, const std::string& button_name);
-	
 	// fills flatlist with items from given panel
 	void fillFlatlistFromPanel (LLFlatListView* list, LLPanel* panel);
 
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
index 791ff79d87..57484d0d0a 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -25,6 +25,7 @@
  */
 
 #include "llviewerprecompiledheaders.h"
+#include "llagentcamera.h"
 #include "llfloaterpreferenceviewadvanced.h"
 #include "llfloater.h"
 #include "llfloaterreg.h"
@@ -36,40 +37,12 @@
 LLFloaterPreferenceViewAdvanced::LLFloaterPreferenceViewAdvanced(const LLSD& key) 
 :	LLFloater(key)
 {
-	mCommitCallbackRegistrar.add("Cancel",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickCancel, this));
 	mCommitCallbackRegistrar.add("CommitSettings",	boost::bind(&LLFloaterPreferenceViewAdvanced::onCommitSettings, this));
-	mCommitCallbackRegistrar.add("Ok",	boost::bind(&LLFloaterPreferenceViewAdvanced::onClickOk, this));
-
 }
 
 LLFloaterPreferenceViewAdvanced::~LLFloaterPreferenceViewAdvanced()
 {}
 
-void LLFloaterPreferenceViewAdvanced::onClickOk()
-{
-	closeFloater();
-}
-
-void LLFloaterPreferenceViewAdvanced::onClickCancel()
-{
-	gSavedSettings.setVector3("CameraOffsetRearView", mCameraSaved);
-	gSavedSettings.setVector3d("FocusOffsetRearView", mFocusSaved);
-
-	updateCameraControl(mCameraSaved);
-	updateFocusControl(mFocusSaved);
-}
-
-BOOL LLFloaterPreferenceViewAdvanced::postBuild()
-{
-	mCameraSaved = gSavedSettings.getVector3("CameraOffsetRearView");
-	mFocusSaved = gSavedSettings.getVector3d("FocusOffsetRearView");
-
-	updateCameraControl(mCameraSaved);
-	updateFocusControl(mFocusSaved);
-
-	return TRUE;
-}
-
 void LLFloaterPreferenceViewAdvanced::updateCameraControl(const LLVector3& vector)
 {
 	getChild<LLSpinCtrl>("camera_x")->setValue(vector[VX]);
@@ -86,11 +59,8 @@ void LLFloaterPreferenceViewAdvanced::updateFocusControl(const LLVector3d& vecto
 
  void LLFloaterPreferenceViewAdvanced::draw()
 {
-	static LLCachedControl<LLVector3> camera(gSavedSettings, "CameraOffsetRearView");
-	static LLCachedControl<LLVector3d> focus(gSavedSettings, "FocusOffsetRearView");
-
-	updateCameraControl(camera);
-	updateFocusControl(focus);
+	updateCameraControl(gAgentCamera.getCameraOffsetInitial());
+	updateFocusControl(gAgentCamera.getFocusOffsetInitial());
 
 	LLFloater::draw();
 }
@@ -103,10 +73,10 @@ void LLFloaterPreferenceViewAdvanced::onCommitSettings()
 	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
 	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
 	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
-	gSavedSettings.setVector3("CameraOffsetRearView", vector);
+	gSavedSettings.setVector3(gAgentCamera.getCameraOffsetCtrlName(), vector);
 
 	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
 	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
 	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
-	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
+	gSavedSettings.setVector3d(gAgentCamera.getFocusOffsetCtrlName(), vector3d);
 }
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.h b/indra/newview/llfloaterpreferenceviewadvanced.h
index 8f4b594605..4619fdaab1 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.h
+++ b/indra/newview/llfloaterpreferenceviewadvanced.h
@@ -37,21 +37,14 @@ class LLFloaterPreferenceViewAdvanced
 
 public:
 	LLFloaterPreferenceViewAdvanced(const LLSD& key);
-	virtual BOOL postBuild();
 	virtual void draw();
 
 	void onCommitSettings();
-	void onClickCancel();
-	void onClickOk();
 	void updateCameraControl(const LLVector3& vector);
 	void updateFocusControl(const LLVector3d& vector3d);
 
 private:
 	virtual ~LLFloaterPreferenceViewAdvanced();
-
-	LLVector3	mCameraSaved;
-	LLVector3d	mFocusSaved;
-	
 };
 
 #endif //LLFLOATERPREFERENCEVIEWADVANCED_H
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index bae7602566..10fad347bf 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -32,12 +32,14 @@
 #include "llcombobox.h"
 #include "llfloaterpreference.h"
 #include "llfloaterreg.h"
+#include "lllineeditor.h"
 #include "llnotificationsutil.h"
 #include "llpresetsmanager.h"
+#include "llradiogroup.h"
 #include "lltrans.h"
 
 LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key)
-:	LLFloater(key)
+	: LLModalDialog(key)
 {
 }
 
@@ -49,29 +51,39 @@ BOOL LLFloaterSavePrefPreset::postBuild()
 	{
 		preferences->addDependentFloater(this);
 	}
-	getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
-	getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
-	getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
-	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
+	
+	mPresetCombo = getChild<LLComboBox>("preset_combo");
+	//mPresetCombo->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
 
-	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
+	mNameEditor = getChild<LLLineEditor>("preset_txt_editor");
+	mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL);
 
 	mSaveButton = getChild<LLButton>("save");
-	mPresetCombo = getChild<LLComboBox>("preset_combo");
+	mSaveButton->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
+	
+	mSaveRadioGroup = getChild<LLRadioGroup>("radio_save_preset");
+	mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onSwitchSaveReplace, this));
+	
+	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
+
+	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
 
 	return TRUE;
 }
 
 void LLFloaterSavePrefPreset::onPresetNameEdited()
 {
-	// Disable saving a preset having empty name.
-	std::string name = mPresetCombo->getSimple();
-
-	mSaveButton->setEnabled(!name.empty());
+	if (mSaveRadioGroup->getSelectedIndex() == 0)
+	{
+		// Disable saving a preset having empty name.
+		std::string name = mNameEditor->getValue();
+		mSaveButton->setEnabled(!name.empty());
+	}
 }
 
 void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 {
+	LLModalDialog::onOpen(key);
 	mSubdirectory = key.asString();
 
 	std::string floater_title = getString(std::string("title_") + mSubdirectory);
@@ -81,22 +93,41 @@ void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 	EDefaultOptions option = DEFAULT_HIDE;
 	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 
+	mSaveRadioGroup->setSelectedIndex(0);
 	onPresetNameEdited();
+	onSwitchSaveReplace();
 }
 
 void LLFloaterSavePrefPreset::onBtnSave()
 {
-	std::string name = mPresetCombo->getSimple();
+	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
+	std::string name = is_saving_new ? mNameEditor->getValue() : mPresetCombo->getSimple();
 
 	if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
 	{
 		LLNotificationsUtil::add("DefaultPresetNotSaved");
 	}
-	else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
+	else 
 	{
-		LLSD args;
-		args["NAME"] = name;
-		LLNotificationsUtil::add("PresetNotSaved", args);
+		if (is_saving_new)
+		{
+			std::list<std::string> preset_names;
+			std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(mSubdirectory);
+			LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE);
+			if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end())
+			{
+				LLSD args;
+				args["NAME"] = name;
+				LLNotificationsUtil::add("PresetAlreadyExists", args);
+				return;
+			}
+		}
+		if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
+		{
+			LLSD args;
+			args["NAME"] = name;
+			LLNotificationsUtil::add("PresetNotSaved", args);
+		}
 	}
 
 	closeFloater();
@@ -112,3 +143,20 @@ void LLFloaterSavePrefPreset::onBtnCancel()
 {
 	closeFloater();
 }
+
+void LLFloaterSavePrefPreset::onSwitchSaveReplace()
+{
+	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
+	std::string label = is_saving_new ? getString("btn_label_save") : getString("btn_label_replace");
+	mSaveButton->setLabel(label);
+	mNameEditor->setEnabled(is_saving_new);
+	mPresetCombo->setEnabled(!is_saving_new);
+	if (is_saving_new)
+	{
+		onPresetNameEdited();
+	}
+	else
+	{
+		mSaveButton->setEnabled(true);
+	}
+}
diff --git a/indra/newview/llfloatersaveprefpreset.h b/indra/newview/llfloatersaveprefpreset.h
index 09a87b8c62..c61379e5ad 100644
--- a/indra/newview/llfloatersaveprefpreset.h
+++ b/indra/newview/llfloatersaveprefpreset.h
@@ -28,11 +28,13 @@
 #ifndef LL_LLFLOATERSAVEPREFPRESET_H
 #define LL_LLFLOATERSAVEPREFPRESET_H
 
-#include "llfloater.h"
+#include "llmodaldialog.h"
 
 class LLComboBox;
+class LLRadioGroup;
+class LLLineEditor;
 
-class LLFloaterSavePrefPreset : public LLFloater
+class LLFloaterSavePrefPreset : public LLModalDialog
 {
 
 public:
@@ -43,8 +45,11 @@ public:
 
 	void onBtnSave();
 	void onBtnCancel();
+	void onSwitchSaveReplace();
 
 private:
+	LLRadioGroup*	mSaveRadioGroup;
+	LLLineEditor*	mNameEditor;
 	LLComboBox*		mPresetCombo;
 	LLButton*		mSaveButton;
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 17fefbe6b1..94e6e64754 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -65,22 +65,22 @@ void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 {
 	if(gDirUtilp->getLindenUserDir().empty())
 	{
-		return;
+return;
 	}
 
 	std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
-															  subdirectory, PRESETS_DEFAULT + ".xml");
+		subdirectory, PRESETS_DEFAULT + ".xml");
 	if (!gDirUtilp->fileExists(default_file))
 	{
 		LL_INFOS() << "No default preset found -- creating one at " << default_file << LL_ENDL;
 
 		// Write current settings as the default
-        savePreset(subdirectory, PRESETS_DEFAULT, true);
+		savePreset(subdirectory, PRESETS_DEFAULT, true);
+	}
+	else
+	{
+		LL_DEBUGS() << "default preset exists; no-op" << LL_ENDL;
 	}
-    else
-    {
-        LL_DEBUGS() << "default preset exists; no-op" << LL_ENDL;
-    }
 }
 
 void LLPresetsManager::startWatching(const std::string& subdirectory)
@@ -99,7 +99,7 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
 				if (cntrl_ptr.isNull())
 				{
 					LL_WARNS("Init") << "Unable to set signal on global setting '" << ctrl_name
-									<< "'" << LL_ENDL;
+						<< "'" << LL_ENDL;
 				}
 				else
 				{
@@ -120,25 +120,25 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 	if (!gDirUtilp->fileExists(dest_path))
 		LLFile::mkdir(dest_path);
 
-		if (PRESETS_CAMERA == subdirectory)
+	if (PRESETS_CAMERA == subdirectory)
+	{
+		std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
+		LLDirIterator dir_iter(source_dir, "*.xml");
+		bool found = true;
+		while (found)
 		{
-			std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
-			LLDirIterator dir_iter(source_dir, "*.xml");
-			bool found = true;
-			while (found)
-			{
-				std::string file;
-				found = dir_iter.next(file);
+			std::string file;
+			found = dir_iter.next(file);
 
-				if (found)
-				{
-					std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
-					file = LLURI::escape(file);
-					std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
-					LLFile::copy(source, dest);
-				}
+			if (found)
+			{
+				std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
+				file = LLURI::escape(file);
+				std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
+				LLFile::copy(source, dest);
 			}
 		}
+	}
 
 	return dest_path;
 }
@@ -160,8 +160,15 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 		{
 			std::string path = gDirUtilp->add(dir, file);
 			std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
-            LL_DEBUGS() << "  Found preset '" << name << "'" << LL_ENDL;
+			LL_DEBUGS() << "  Found preset '" << name << "'" << LL_ENDL;
 
+			if (default_option == DEFAULT_VIEWS_HIDE)
+			{
+				if (name == PRESETS_REAR || name == PRESETS_SIDE || name == PRESETS_FRONT)
+				{
+					continue;
+				}
+			}
 			if (PRESETS_DEFAULT != name)
 			{
 				mPresetNames.push_back(name);
@@ -205,11 +212,15 @@ void LLPresetsManager::settingChanged()
 {
 	setCameraDirty(true);
 
-	gSavedSettings.setString("PresetCameraActive", "");
-
-// Hack call because this is a static routine
-	LLPresetsManager::getInstance()->triggerChangeCameraSignal();
+	static LLCachedControl<std::string> preset_camera_active(gSavedSettings, "PresetCameraActive", "");
+	std::string preset_name = preset_camera_active;
+	if (!preset_name.empty())
+	{
+		gSavedSettings.setString("PresetCameraActive", "");
 
+		// Hack call because this is a static routine
+		LLPresetsManager::getInstance()->triggerChangeCameraSignal();
+	}
 }
 
 void LLPresetsManager::getControlNames(std::vector<std::string>& names)
@@ -222,8 +233,6 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 		("AppearanceCameraMovement")
 		// From llagentcamera.cpp
 		("CameraOffsetBuild")
-		("CameraOffsetRearView")
-		("FocusOffsetRearView")
 		("CameraOffsetScale")
 		("TrackFocusObject")
         ;
@@ -286,9 +295,25 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	}
 	else
 	{
+		bool custom_camera_offsets = false;
+		if (subdirectory == PRESETS_CAMERA)
+		{
+			name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
+			name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
+			custom_camera_offsets = (name != PRESETS_REAR && name != PRESETS_SIDE && name != PRESETS_FRONT);
+		}
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
 			std::string ctrl_name = *it;
+			std::string dest_ctrl_name = ctrl_name;
+			if (custom_camera_offsets && ctrl_name == gAgentCamera.getCameraOffsetCtrlName())
+			{
+				dest_ctrl_name = "CameraOffsetCustomPreset";
+			}
+			if (custom_camera_offsets && ctrl_name == gAgentCamera.getFocusOffsetCtrlName())
+			{
+				dest_ctrl_name = "FocusOffsetCustomPreset";
+			}
 			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
 			if (ctrl)
 			{
@@ -296,10 +321,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 				std::string type = LLControlGroup::typeEnumToString(ctrl->type());
 				LLSD value = ctrl->getValue();
 
-				paramsData[ctrl_name]["Comment"] = comment;
-				paramsData[ctrl_name]["Persist"] = 1;
-				paramsData[ctrl_name]["Type"] = type;
-				paramsData[ctrl_name]["Value"] = value;
+				paramsData[dest_ctrl_name]["Comment"] = comment;
+				paramsData[dest_ctrl_name]["Persist"] = 1;
+				paramsData[dest_ctrl_name]["Type"] = type;
+				paramsData[dest_ctrl_name]["Value"] = value;
 			}
 		}
 	}
@@ -354,6 +379,7 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 
 	combo->clearRows();
 
+
 	std::string presets_dir = getPresetsDir(subdirectory);
 
 	if (!presets_dir.empty())
@@ -368,7 +394,7 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 			for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
 			{
 				const std::string& name = *it;
-				combo->add(name, LLSD().with(0, name));
+				combo->add(name, name);
 			}
 		}
 		else
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 7370e0a3b1..cb32b58fc4 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -36,11 +36,15 @@ static const std::string PRESETS_DEFAULT = "Default";
 static const std::string PRESETS_DIR = "presets";
 static const std::string PRESETS_GRAPHIC = "graphic";
 static const std::string PRESETS_CAMERA = "camera";
+static const std::string PRESETS_REAR = "Rear";
+static const std::string PRESETS_FRONT = "Front";
+static const std::string PRESETS_SIDE = "Side";
 
 enum EDefaultOptions
 {
 	DEFAULT_SHOW,
 	DEFAULT_TOP,
+	DEFAULT_VIEWS_HIDE,
 	DEFAULT_HIDE				// Do not display "Default" in a list
 };
 
diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 25db24da2e..933d50acae 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -7,7 +7,7 @@
  legacy_header_height="18"
  can_minimize="true"
  can_close="true"
- height="164"
+ height="135"
  layout="topleft"
  name="camera_floater"
  help_topic="camera_floater"
@@ -16,7 +16,7 @@
  title="CAMERA CONTROLS"
  chrome="true"
  save_rect="true"
- width="228">
+ width="400">
     <floater.string
      name="rotate_tooltip">
         Rotate Camera Around Focus
@@ -33,6 +33,7 @@
      name="free_mode_title">
         View Object
     </floater.string>
+    <string name="inactive_combo_text">Use preset</string>
     <panel
      border="false"
      height="123"
@@ -41,130 +42,18 @@
      top="0"
      mouse_opaque="false"
      name="controls"
-     width="226">
-       <panel
-         follows="all"
-         height="102"
-         layout="topleft"
-         left="8"
-         name="preset_views_list"
-         top="24"
-         width="212"
-         visible="false">
-        <panel_camera_item
-          name="front_view">
-          <panel_camera_item.mousedown_callback
-            function="CameraPresets.ChangeView"
-            parameter="front_view" />
-          <panel_camera_item.picture
-            image_name="Cam_Preset_Front_Off" />
-          <panel_camera_item.selected_picture
-            image_name="Cam_Preset_Front_On" />
-          <panel_camera_item.text
-            name="front_view_text">
-            Front View
-          </panel_camera_item.text>
-        </panel_camera_item>
-        <panel_camera_item
-          name="group_view"
-          top_pad="4">
-          <panel_camera_item.mousedown_callback
-            function="CameraPresets.ChangeView"
-            parameter="group_view" />
-          <panel_camera_item.picture
-            image_name="Cam_Preset_Side_Off" />
-          <panel_camera_item.selected_picture
-            image_name="Cam_Preset_Side_On" />
-          <panel_camera_item.text
-            name="side_view_text">
-            Side View
-          </panel_camera_item.text>
-        </panel_camera_item>
-        <panel_camera_item
-          name="rear_view"
-          layout="topleft"
-          top_pad="4">
-          <panel_camera_item.mousedown_callback
-            function="CameraPresets.ChangeView"
-            parameter="rear_view" />
-          <panel_camera_item.picture
-            image_name="Cam_Preset_Back_Off" />
-          <panel_camera_item.selected_picture
-            image_name="Cam_Preset_Back_On" />
-          <panel_camera_item.text
-            name="rear_view_text">
-            Rear View
-          </panel_camera_item.text>
-        </panel_camera_item>
-      </panel>
-      <panel
-          follows="all"
-          height="68"
-          layout="topleft"
-          left="8"
-          name="camera_modes_list"
-          top="24"
-          width="212"
-          visible="false">
-        <panel_camera_item
-          name="object_view">
-          <panel_camera_item.mousedown_callback
-            function="CameraPresets.ChangeView"
-            parameter="object_view" />
-          <panel_camera_item.text
-            name="object_view_text">
-            Object View
-          </panel_camera_item.text>
-          <panel_camera_item.picture
-            image_name="Object_View_Off" />
-          <panel_camera_item.selected_picture
-            image_name="Object_View_On" />
-        </panel_camera_item>
-        <panel_camera_item
-          name="mouselook_view"
-          layout="topleft">
-          <panel_camera_item.mousedown_callback
-            function="CameraPresets.ChangeView"
-            parameter="mouselook_view" />
-          <panel_camera_item.text
-            name="mouselook_view_text">
-            Mouselook View
-          </panel_camera_item.text>
-          <panel_camera_item.picture
-            image_name="MouseLook_View_Off" />
-          <panel_camera_item.selected_picture
-            image_name="MouseLook_View_On" />
-        </panel_camera_item>
-      </panel>
+     width="220">
          <!--TODO: replace + - images -->
          <panel
             border="false"
             class="camera_zoom_panel"
-            height="114"
+            height="123"
             layout="topleft"
             left="0"
             mouse_opaque="false"
             name="zoom"
             top="0"
-            width="226">
-         <slider
-            can_edit_text="true"
-            control_name="CameraAngle"
-            decimal_digits="2"
-            follows="left|top"
-            height="16"
-            top="20"
-            increment="0.025"
-            initial_value="1.57"
-            layout="topleft"
-            label_width="112"
-            label="View angle"
-            left="10"
-            max_val="1.6"
-            min_val="0.17"
-            name="camera_fov"
-            show_text="false"
-            width="200" />
+            width="220">
            <joystick_rotate
               follows="top|left"
               height="78"
@@ -175,8 +64,8 @@
               sound_flags="3"
               visible="true"
               tool_tip="Orbit camera around focus"
-              top_delta="20"
-              width="78" />                      
+              top="25"
+              width="78" />
            <button
               follows="top|left"
               height="18"
@@ -187,7 +76,7 @@
               left_pad="14" 
               name="zoom_plus_btn"
               width="18"
-              top="38">
+              top="23">
              <commit_callback
                 function="Zoom.plus" />
              <mouse_held_callback
@@ -232,53 +121,128 @@
          scale_image="false"
          sound_flags="3"
          tool_tip="Move camera up and down, left and right"
-         top="40"
+         top="25"
          width="78"/>
+         <text
+          type="string"
+          length="1"
+          follows="left|top"
+          height="15"
+          layout="topleft"
+          left="41"
+          top_pad="9"
+          name="precise_ctrs_label"
+          width="200">
+            Use precise controls
+        </text>
         </panel>
     </panel>
     <panel
-     border="false"
-     height="42"
+     follows="all"
+     height="102"
      layout="topleft"
-     left="2"
-     top_pad="0"
-     name="buttons"
-     width="226">
-        <button
-         name="open_prefs_btn"
-         image_overlay="Icon_Gear_Foreground"
-         tool_tip = "Open view preferences"
-         layout="topleft"
-         left="70"
-         height="23"
-         width="28">
-           <button.commit_callback
-             function="Presets.GoViewPrefs" />
-        </button>
-        <button
-         height="23"
-         label=""
-         layout="topleft"
-         left_pad="1"
-         is_toggle="true"
-         image_overlay="PanOrbit_Off"
-         image_selected="PushButton_Selected_Press"
-         name="pan_btn"
-         tab_stop="false"
-         tool_tip="Orbit Zoom Pan"
-         width="25">
-        </button>
-        <button
-         height="23"
-         label=""
-         layout="topleft"
-         left_pad="1"
-         image_overlay="Cam_FreeCam_Off"
-         image_selected="PushButton_Selected_Press"
-         name="avatarview_btn"
-         tab_stop="false"
-         tool_tip="Camera modes"
-         width="25">
-        </button>
-    </panel>
+     left_pad="2"
+     name="buttons_panel"
+     top="22"
+     width="212">
+    <panel_camera_item
+      name="front_view"
+      tool_tip="Front View"
+      width="30">
+      <panel_camera_item.mousedown_callback
+        function="CameraPresets.ChangeView"
+        parameter="front_view" />
+      <panel_camera_item.picture
+        image_name="Cam_Preset_Front_Off" />
+      <panel_camera_item.selected_picture
+        image_name="Cam_Preset_Front_On" />
+    </panel_camera_item>
+    <panel_camera_item
+      name="group_view"
+      tool_tip="Side View"
+      width="30"
+      left_pad="4">
+      <panel_camera_item.mousedown_callback
+        function="CameraPresets.ChangeView"
+        parameter="group_view" />
+      <panel_camera_item.picture
+        image_name="Cam_Preset_Side_Off" />
+      <panel_camera_item.selected_picture
+        image_name="Cam_Preset_Side_On" />
+    </panel_camera_item>
+    <panel_camera_item
+      name="rear_view"
+      tool_tip="Rear View"
+      width="30"
+      left_pad="4">
+      <panel_camera_item.mousedown_callback
+        function="CameraPresets.ChangeView"
+        tool_tip="Rear View"
+        parameter="rear_view" />
+      <panel_camera_item.picture
+        image_name="Cam_Preset_Back_Off" />
+      <panel_camera_item.selected_picture
+        image_name="Cam_Preset_Back_On" />
+    </panel_camera_item>
+    <panel_camera_item
+        name="object_view"
+        tool_tip="Object View"
+        width="30"
+        left_pad="4">
+        <panel_camera_item.mousedown_callback
+          function="CameraPresets.ChangeView"
+          parameter="object_view" />
+        <panel_camera_item.picture
+          image_name="Object_View_Off" />
+        <panel_camera_item.selected_picture
+          image_name="Object_View_On" />
+      </panel_camera_item>
+      <panel_camera_item
+        name="mouselook_view"
+        tool_tip="Mouselook View"
+        width="30"
+        left_pad="4">
+        <panel_camera_item.mousedown_callback
+          function="CameraPresets.ChangeView"
+          parameter="mouselook_view" />
+        <panel_camera_item.picture
+          image_name="MouseLook_View_Off" />
+        <panel_camera_item.selected_picture
+          image_name="MouseLook_View_On" />
+      </panel_camera_item>
+      <combo_box
+        height="23"
+        left="0"
+        mouse_opaque="true"
+        name="preset_combo"
+        top_pad="10"
+        width="136">
+        <combo_box.item
+         label="Use preset"
+         name="Use preset"
+         value="default" />
+      </combo_box>
+      <icon
+        height="28"
+        width="28"
+        image_name="Command_Preferences_Icon"
+        layout="topleft"
+        mouse_opaque="true"
+        name="icon_gear"
+        tool_tip="My Camera Presets"
+        top_delta="0"
+        left_pad="5" />
+      <button
+        follows="top|left"
+        height="25"
+        label="Save as preset..."
+        layout="topleft"
+        left="0"
+        name="save_preset_btn"
+        top_pad="8"
+        width="150">
+        <button.commit_callback
+          function="CameraPresets.Save"/>
+      </button>
+  </panel>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
index 5b2cbee914..3826ead5c2 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater
- height="170"
+ height="128"
  layout="topleft"
  name="floaterpreferencesviewadvanced"
  help_topic="floaterviewadvanced"
- title="ADJUST CAMERA VIEW"
+ title="CAMERA POSITION"
  save_rect="true"
  width="280">
 
@@ -113,28 +113,4 @@
     <spinner.commit_callback
      function="CommitSettings" />
   </spinner>
-
-  <button
-   follows="left|top"
-   height="23"
-   label="OK"
-   layout="topleft"
-   left="90"
-   name="ok"
-   top_pad="30"
-   width="90">
-    <button.commit_callback
-     function="Ok"/>
-  </button>
-  <button
-   follows="left|top"
-   height="23"
-   label="Cancel"
-   layout="topleft"
-   left_pad="5"
-   name="cancel"
-   width="90">
-    <button.commit_callback
-     function="Cancel"/>
-  </button>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
index a9cda26f0b..178ecad0f3 100644
--- a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
@@ -1,51 +1,71 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <floater
  legacy_header_height="18"
- height="145"
+ height="185"
  help_topic="floater_save_preset"
  layout="topleft"
  name="save_pref_preset"
  save_rect="true"
  title="SAVE PREF PRESET"
- width="300">
+ width="280">
 
     <string name="title_graphic">Save Graphic Preset</string>
     <string name="title_camera">Save Camera Preset</string>
-
-    <text
-     follows="top|left|right"
-     height="32"
+    <string name="btn_label_save">Save</string>
+    <string name="btn_label_replace">Replace</string>
+    <radio_group
+     height="85"
      layout="topleft"
-     word_wrap="true"
      left="20"
-     name="Preset"
-     top="30"
-     width="200">
-     Type a name for the preset or choose an existing preset.
-    </text>
+     top="15"
+     width="150"
+     name="radio_save_preset">
+     <radio_item
+      label="Save as a new preset"
+      name="new_preset"
+      top="10" 
+      layout="topleft"
+      height="16" 
+      value="0"/>
+     <radio_item
+      label="Replace a preset"
+      name="replace_preset"
+      layout="topleft"
+      top="70" 
+      height="16" 
+      value="1"/>
+    </radio_group> 
+    <line_editor
+     commit_on_focus_lost = "true"
+     follows="top|left"
+     height="23"
+     layout="topleft"
+     left="41"
+     name="preset_txt_editor"
+     width="200"
+     top="45"/>
     <combo_box
      follows="top|left"
      layout="topleft"
-     left="20"
+     left="41"
      name="preset_combo"
-     top_delta="35"
-     allow_text_entry="true"
+     top_pad="35"
      width="200"/>
     <button
      follows="top|left"
-     height="23"
+     height="25"
      label="Save"
      layout="topleft"
      top_delta="40"
-     left="20"
+     left="25"
      name="save"
-     width="70"/>
+     width="110"/>
     <button
      follows="bottom|right"
-     height="23"
+     height="25"
      label="Cancel"
      layout="topleft"
      left_pad="20"
      name="cancel"
-     width="70"/>
+     width="110"/>
 </floater>
diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml
index f72767cceb..7e06389bfe 100644
--- a/indra/newview/skins/default/xui/en/notifications.xml
+++ b/indra/newview/skins/default/xui/en/notifications.xml
@@ -8355,6 +8355,18 @@ Error saving preset [NAME].
 Can not overwrite default preset.
   </notification>
 
+  <notification
+    icon="alertmodal.tga"
+    name="PresetAlreadyExists"
+    type="alertmodal">
+&apos;[NAME]&apos; is in use. You may replace
+this preset or choose another name.
+    <tag>fail</tag>
+    <usetemplate
+     name="okbutton"
+     yestext="OK"/>
+  </notification>
+
   <notification
     icon="notifytip.tga"
     name="PresetNotDeleted"
diff --git a/indra/newview/skins/default/xui/en/widgets/panel_camera_item.xml b/indra/newview/skins/default/xui/en/widgets/panel_camera_item.xml
index 98707b8495..564f695cd0 100644
--- a/indra/newview/skins/default/xui/en/widgets/panel_camera_item.xml
+++ b/indra/newview/skins/default/xui/en/widgets/panel_camera_item.xml
@@ -15,7 +15,7 @@
      top="30"
      scale_image="true"
      visible="false"
-     width="212" />
+     width="30" />
   <panel_camera_item.icon_selected
    follows="top|left"
      height="30"
@@ -27,7 +27,7 @@
      top="30"
      scale_image="true"
      visible="false"
-     width="212" />
+     width="30" />
   <panel_camera_item.picture
      follows="top|left"
      height="30"
-- 
cgit v1.2.3


From 1c2ab8938bd61097e85ea0ef90ef28c89edbee33 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 8 Nov 2019 16:38:13 +0200
Subject: SL-12186 WIP Revert Preferences changes

---
 indra/newview/llfloaterpreference.cpp              |  92 ----------
 indra/newview/llfloaterpreference.h                |  12 --
 .../skins/default/xui/en/floater_preferences.xml   |  11 +-
 .../default/xui/en/panel_preferences_move.xml      |  99 +++++++++--
 .../default/xui/en/panel_preferences_view.xml      | 185 ---------------------
 5 files changed, 89 insertions(+), 310 deletions(-)
 delete mode 100644 indra/newview/skins/default/xui/en/panel_preferences_view.xml

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 28e77deec2..63d3b75c00 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -839,17 +839,6 @@ void LLFloaterPreference::onOpen(const LLSD& key)
 		exceptions_btn->setEnabled(started);
 	}
 
-	LLButton* load_camera_btn = findChild<LLButton>("PrefCameraLoadButton");
-	LLButton* save_camera_btn = findChild<LLButton>("PrefCameraSaveButton");
-	LLButton* delete_camera_btn = findChild<LLButton>("PrefCameraDeleteButton");
-
-	if (load_camera_btn && save_camera_btn && delete_camera_btn)
-	{
-		load_camera_btn->setEnabled(started);
-		save_camera_btn->setEnabled(started);
-		delete_camera_btn->setEnabled(started);
-	}
-
     collectSearchableItems();
 	if (!mFilterEdit->getText().empty())
 	{
@@ -2308,11 +2297,6 @@ void LLFloaterPreference::changed()
 
 }
 
-void LLFloaterPreference::saveCameraPreset(std::string& preset)
-{
-	mSavedCameraPreset = preset;
-}
-
 void LLFloaterPreference::saveGraphicsPreset(std::string& preset)
 {
 	mSavedGraphicsPreset = preset;
@@ -2694,82 +2678,6 @@ private:
 
 static LLPanelInjector<LLPanelPreferenceGraphics> t_pref_graph("panel_preference_graphics");
 static LLPanelInjector<LLPanelPreferencePrivacy> t_pref_privacy("panel_preference_privacy");
-static LLPanelInjector<LLPanelPreferenceView> t_pref_view("panel_preference_view");
-
-BOOL LLPanelPreferenceView::postBuild()
-{
-	setPresetText();
-
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		presetsMgr->setPresetListChangeCameraCallback(boost::bind(&LLPanelPreferenceView::onPresetsListChangeCamera, this));
-		presetsMgr->createMissingDefault(PRESETS_CAMERA); // a no-op after the first time, but that's ok
-	}
-
-	return LLPanelPreference::postBuild();
-}
-
-void LLPanelPreferenceView::onPresetsListChangeCamera()
-{
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		presetsMgr->setCameraDirty(false);
-	}
-
-	setPresetText();
-
-	LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-	if (instance && !gSavedSettings.getString("PresetCameraActive").empty())
-	{
-		instance->saveSettings(); //make cancel work correctly after changing the preset
-	}
-}
-
-void LLPanelPreferenceView::draw()
-{
-	setPresetText();
-	LLPanelPreference::draw();
-}
-
-void LLPanelPreferenceView::setPresetText()
-{
-	LLTextBox* preset_text = getChild<LLTextBox>("preset_camera_text");
-
-	std::string preset_camera_active = gSavedSettings.getString("PresetCameraActive");
-
-	if (!preset_camera_active.empty() && preset_camera_active != preset_text->getText())
-	{
-		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
-		if (instance)
-		{
-			instance->saveCameraPreset(preset_camera_active);
-		}
-	}
-
-	LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-	if (presetsMgr)
-	{
-		if (presetsMgr->isCameraDirty() && !preset_camera_active.empty())
-		{
-			preset_camera_active.clear();
-		}
-	}
-
-	if (!preset_camera_active.empty())
-	{
-		if (preset_camera_active == PRESETS_DEFAULT)
-		{
-			preset_camera_active = LLTrans::getString(PRESETS_DEFAULT);
-		}
-		preset_text->setText(preset_camera_active);
-	}
-	else
-	{
-		preset_text->setText(LLTrans::getString("none_paren_cap"));
-	}
-}
 
 BOOL LLPanelPreferenceGraphics::postBuild()
 {
diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h
index 204916de86..4516c2635d 100644
--- a/indra/newview/llfloaterpreference.h
+++ b/indra/newview/llfloaterpreference.h
@@ -272,18 +272,6 @@ private:
 	LOG_CLASS(LLPanelPreference);
 };
 
-class LLPanelPreferenceView : public LLPanelPreference
-{
-public:
-	BOOL postBuild();
-	void draw();
-	void setPresetText();
-
-private:
-	void onPresetsListChangeCamera();
-	LOG_CLASS(LLPanelPreferenceView);
-};
-
 class LLPanelPreferenceGraphics : public LLPanelPreference
 {
 public:
diff --git a/indra/newview/skins/default/xui/en/floater_preferences.xml b/indra/newview/skins/default/xui/en/floater_preferences.xml
index d501fe9e36..0e62d50072 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences.xml
@@ -121,19 +121,12 @@ https://accounts.secondlife.com/change_email/
          help_topic="preferences_chat_tab"
          name="chat" />
         <panel
-		 class="panel_preference_view"
+		 class="panel_preference"
          filename="panel_preferences_move.xml"
-         label="Move"
+         label="Move &amp; View"
          layout="topleft"
          help_topic="preferences_move_tab"
          name="move" />
-        <panel
-		 class="panel_preference_view"
-         filename="panel_preferences_view.xml"
-         label="View"
-         layout="topleft"
-         help_topic="preferences_view_tab"
-         name="view" />
         <panel
 		 class="panel_preference"
          filename="panel_preferences_alerts.xml"
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_move.xml b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
index 79fbf66139..8794e3bf95 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_move.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_move.xml
@@ -2,24 +2,100 @@
 <panel
  border="true"
  follows="left|top|right|bottom"
- height="418"
+ height="408"
  label="Move"
  layout="topleft"
  left="102"
  name="move_panel"
  top="1"
  width="517">
-
   <icon
+     follows="left|top"
+     height="18"
+     image_name="Cam_FreeCam_Off"
+     layout="topleft"
+     name="camera_icon"
+     mouse_opaque="false"
+     visible="true"
+     width="18"
+     left="30"
+     top="10"/>
+  <slider
+   can_edit_text="true"
+   control_name="CameraAngle"
+   decimal_digits="2"
+   follows="left|top"
+   height="16"
+   increment="0.025"
+   initial_value="1.57"
+   layout="topleft"
+   label_width="100"
+   label="View angle"
+   left_pad="30"
+   max_val="2.97"
+   min_val="0.17"
+   name="camera_fov"
+   show_text="false"
+   width="240" />
+  <slider
+   can_edit_text="true"
+   control_name="CameraOffsetScale"
+   decimal_digits="2"
+   follows="left|top"
+   height="16"
+   increment="0.025"
+   initial_value="1"
+   layout="topleft"
+   label="Distance"
+   left_delta="0"
+   label_width="100"
+   max_val="3"
+   min_val="0.5"
+   name="camera_offset_scale"
+   show_text="false"
+   width="240"
+   top_pad="5"/>
+  <text
+  follows="left|top"
+  type="string"
+  length="1"
+  height="10"
+  left="80"
+  name="heading2"
+  width="270"
+  top_pad="5">
+    Automatic position for:
+  </text>
+  <check_box
+     control_name="EditCameraMovement"
+     height="20"
+     follows="left|top"
+     label="Build/Edit"
+     layout="topleft"
+     left_delta="30"
+     name="edit_camera_movement"
+     tool_tip="Use automatic camera positioning when entering and exiting edit mode"
+     width="280"
+     top_pad="5" />
+  <check_box
+   control_name="AppearanceCameraMovement"
    follows="left|top"
-   height="18"
-   image_name="Move_Walk_Off"
-   layout="topleft"
-   name="avatar_icon"
-   mouse_opaque="false"
-   visible="true"
-   width="18"
-   top_pad="4"
+   height="16"
+   label="Appearance"
+   layout="topleft"
+   name="appearance_camera_movement"
+   tool_tip="Use automatic camera positioning while in edit mode"
+   width="242" />
+  <icon
+	 follows="left|top"
+	 height="18"
+	 image_name="Move_Walk_Off"
+   layout="topleft"
+	 name="avatar_icon"
+	 mouse_opaque="false"
+	 visible="true"
+	 width="18"
+   top_pad="10"
    left="30" />
   <text
    follows="left|top"
@@ -188,11 +264,10 @@
    label="Other Devices"
    left="30"
    name="joystick_setup_button"
-   top_pad="5"
+   top="30"
    width="155">
     <button.commit_callback
      function="Floater.Show"
      parameter="pref_joystick" />
   </button>
-
 </panel>
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_view.xml b/indra/newview/skins/default/xui/en/panel_preferences_view.xml
deleted file mode 100644
index a7a69eb829..0000000000
--- a/indra/newview/skins/default/xui/en/panel_preferences_view.xml
+++ /dev/null
@@ -1,185 +0,0 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<panel
- border="true"
- follows="left|top|right|bottom"
- height="418"
- label="View"
- layout="topleft"
- left="102"
- name="view_panel"
- top="1"
- width="517">
-
-  <icon
-     follows="left|top"
-     height="18"
-     image_name="Cam_FreeCam_Off"
-     layout="topleft"
-     name="camera_icon"
-     mouse_opaque="false"
-     visible="true"
-     width="18"
-     left="30"
-     top="4"/>
-
-  <text
-    follows="top|left|right"
-    height="16"
-    layout="topleft"
-    left="80"
-    top_delta="0"
-    width="100">
-      Preset in use:
-  </text>
-
-  <text
-    follows="top|left|right"
-    height="16"
-    layout="topleft"
-    left_delta="100"
-    name="preset_camera_text"
-    width="120">
-      (None)
-  </text>
-
-  <slider
-   can_edit_text="true"
-   control_name="CameraAngle"
-   decimal_digits="2"
-   follows="left|top"
-   height="16"
-   top_pad="5"
-   increment="0.025"
-   initial_value="1.57"
-   layout="topleft"
-   label_width="100"
-   label="View angle"
-   left="80"
-   max_val="2.97"
-   min_val="0.17"
-   name="camera_fov"
-   show_text="false"
-   width="240" />
-  <slider
-   can_edit_text="true"
-   control_name="CameraOffsetScale"
-   decimal_digits="2"
-   follows="left|top"
-   height="16"
-   increment="0.025"
-   initial_value="1"
-   layout="topleft"
-   label="Distance"
-   left_delta="0"
-   label_width="100"
-   max_val="3"
-   min_val="0.5"
-   name="camera_offset_scale"
-   show_text="false"
-   width="240"
-   top_pad="5"/>
-  <text
-  follows="left|top"
-  type="string"
-  length="1"
-  height="10"
-  left="80"
-  name="heading2"
-  width="200"
-  top_pad="5">
-    Automatic position for:
-  </text>
-
-  <spinner
-   control_name="CameraOpacity"
-   decimal_digits="1"
-   follows="top|left|right"
-   height="24"
-   max_val="1.0"
-   min_val="0.0"
-   increment="0.1"
-   initial_value="1.0"
-   label="Camera controls opacity:"
-   label_width="180"
-   layout="topleft"
-   top_pad="-10"
-   left_pad="10"
-   width="220" />
-
-  <check_box
-     control_name="EditCameraMovement"
-     height="20"
-     follows="left|top"
-     label="Build/Edit"
-     layout="topleft"
-     left="100"
-     name="edit_camera_movement"
-     tool_tip="Use automatic camera positioning when entering and exiting edit mode"
-     width="280"
-     top_pad="-10" />
-  <check_box
-   control_name="AppearanceCameraMovement"
-   follows="left|top"
-   height="16"
-   label="Appearance"
-   layout="topleft"
-   name="appearance_camera_movement"
-   tool_tip="Use automatic camera positioning while in edit mode"
-   width="242" />
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Advanced..."
-    layout="topleft"
-    left_pad="-102"
-    name="PreferencesViewAdvanced"
-    tool_tip="Adjust camera positioning"
-    width="115">
-    <button.commit_callback
-     function="Floater.Show"
-     parameter="prefs_view_advanced" />
-  </button>  
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Save settings as a preset..."
-    layout="topleft"
-    left="30"
-    name="PrefCameraSaveButton"
-    top_pad="10"
-    width="200">
-    <button.commit_callback
-      function="Pref.PrefSave"
-      parameter="camera" />
-  </button>
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Load preset..."
-    layout="topleft"
-    left_pad="10"
-    name="PrefCameraLoadButton"
-    top_delta="0"
-    width="115">
-    <button.commit_callback
-      function="Pref.PrefLoad"
-	  parameter="camera"/>
-  </button>
-
-  <button
-    follows="top|left"
-    height="23"
-    label="Delete preset..."
-    layout="topleft"
-    left_pad="10"
-    name="PrefCameraDeleteButton"
-    top_delta="0"
-    width="115">
-    <button.commit_callback
-      function="Pref.PrefDelete"
-	  parameter="camera"/>
-  </button>
-</panel>
-- 
cgit v1.2.3


From bf5ee32838b9d4c53ff1ab709e2935d8d0b4ec0b Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 8 Nov 2019 16:47:11 +0200
Subject: SL-12186 WIP Add new icons

---
 .../skins/default/textures/icons/Presets_Icon.png        | Bin 0 -> 1293 bytes
 indra/newview/skins/default/textures/textures.xml        |   2 ++
 .../newview/skins/default/textures/windows/Icon_Gear.png | Bin 0 -> 6229 bytes
 indra/newview/skins/default/xui/en/panel_status_bar.xml  |  10 +++++-----
 4 files changed, 7 insertions(+), 5 deletions(-)
 create mode 100644 indra/newview/skins/default/textures/icons/Presets_Icon.png
 create mode 100644 indra/newview/skins/default/textures/windows/Icon_Gear.png

diff --git a/indra/newview/skins/default/textures/icons/Presets_Icon.png b/indra/newview/skins/default/textures/icons/Presets_Icon.png
new file mode 100644
index 0000000000..503ee892a5
Binary files /dev/null and b/indra/newview/skins/default/textures/icons/Presets_Icon.png differ
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index 40f1d8b88f..b086f7dfa8 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -206,6 +206,7 @@ with the same filename but different name
 
   <texture name="Presets_Icon" file_name="icons/Presets_Icon.png" preload="true" />
 
+  <texture name="Presets_Icon" file_name="icons/Presets_Icon.png" preload="true" />
   <texture name="Presets_Icon_Graphic" file_name="icons/Presets_Icon_Graphic.png" preload="true" />
  <texture name="Favorite_Star_Active" file_name="navbar/Favorite_Star_Active.png" preload="false" />
   <texture name="Favorite_Star_Off" file_name="navbar/Favorite_Star_Off.png" preload="false" />
@@ -256,6 +257,7 @@ with the same filename but different name
   <texture name="Icon_Gear_Background" file_name="windows/Icon_Gear_Background.png" preload="false" />
   <texture name="Icon_Gear_Foreground" file_name="windows/Icon_Gear_Foreground.png" preload="false" />
   <texture name="Icon_Gear_Press" file_name="windows/Icon_Gear_Press.png" preload="false" />
+  <texture name="Icon_Gear" file_name="windows/Icon_Gear.png" preload="false" />
 
   <texture name="Icon_Help_Foreground" file_name="windows/Icon_Help_Foreground.png" preload="true" />
   <texture name="Icon_Help_Press" file_name="windows/Icon_Help_Press.png" preload="true" />
diff --git a/indra/newview/skins/default/textures/windows/Icon_Gear.png b/indra/newview/skins/default/textures/windows/Icon_Gear.png
new file mode 100644
index 0000000000..e1e89b8f32
Binary files /dev/null and b/indra/newview/skins/default/textures/windows/Icon_Gear.png differ
diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml
index ffcfc3ae91..ada980cda1 100644
--- a/indra/newview/skins/default/xui/en/panel_status_bar.xml
+++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml
@@ -148,19 +148,19 @@
     <icon
      follows="right|top"
      height="16"
-     image_name="Cam_Avatar_Off"
+     image_name="Cam_FreeCam_Off"
      left_pad="8"
      top="2"
      name="presets_icon_camera"
      width="18" />
     <icon
      follows="right|top"
-     height="16"
-     image_name="Presets_Icon_Graphic"
+     height="13"
+     image_name="Presets_Icon"
      left_pad="8"
-     top="2"
+     top="4"
      name="presets_icon_graphic"
-     width="18" />
+     width="16" />
     <button
      follows="right|top"
      height="16"
-- 
cgit v1.2.3


From dd8128114c8cfe812e1dd8f2cfd449a4050d9aea Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 8 Nov 2019 17:31:59 +0200
Subject: SL-12186 WIP Minor updates for 'Camera controls' and 'Save preset'
 floaters

---
 indra/newview/llfloatercamera.cpp                  | 30 ++++++++++++++++------
 indra/newview/llfloatercamera.h                    |  3 +++
 indra/newview/llfloaterdeleteprefpreset.cpp        |  7 +++++
 indra/newview/llfloatersaveprefpreset.cpp          | 17 +++++++++---
 indra/newview/llpresetsmanager.cpp                 | 12 ++++++---
 indra/newview/llpresetsmanager.h                   |  2 ++
 indra/newview/llviewermenu.cpp                     | 11 ++++++--
 .../xui/en/floater_preferences_view_advanced.xml   | 12 ++++-----
 .../default/xui/en/floater_save_pref_preset.xml    | 17 ++++++------
 9 files changed, 81 insertions(+), 30 deletions(-)

diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 933e758653..8502b5685d 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -361,11 +361,13 @@ BOOL LLFloaterCamera::postBuild()
 	mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
 	mZoom = findChild<LLPanelCameraZoom>(ZOOM);
 	mTrack = getChild<LLJoystickCameraTrack>(PAN);
+	mPresetCombo = getChild<LLComboBox>("preset_combo");
 
 	getChild<LLTextBox>("precise_ctrs_label")->setShowCursorHand(false);
 	getChild<LLTextBox>("precise_ctrs_label")->setSoundFlags(LLView::MOUSE_UP);
 	getChild<LLTextBox>("precise_ctrs_label")->setClickedCallback(boost::bind(&LLFloaterReg::showInstance, "prefs_view_advanced", LLSD(), FALSE));
-	getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterCamera::onCustomPresetSelected, this));
+
+	mPresetCombo->setCommitCallback(boost::bind(&LLFloaterCamera::onCustomPresetSelected, this));
 	LLPresetsManager::getInstance()->setPresetListChangeCameraCallback(boost::bind(&LLFloaterCamera::populatePresetCombo, this));
 
 	update();
@@ -571,15 +573,21 @@ void LLFloaterCamera::fromFreeToPresets()
 
 void LLFloaterCamera::populatePresetCombo()
 {
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, getChild<LLComboBox>("preset_combo"), EDefaultOptions::DEFAULT_VIEWS_HIDE);
-	if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM)
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, EDefaultOptions::DEFAULT_VIEWS_HIDE);
+	std::string active_preset_name = gSavedSettings.getString("PresetCameraActive");
+	if (active_preset_name.empty())
 	{
-		getChild<LLComboBox>("preset_combo")->selectByValue(gSavedSettings.getString("PresetCameraActive"));
+		gSavedSettings.setU32("CameraPreset", CAMERA_PRESET_CUSTOM);
+		updateItemsSelection();
+		mPresetCombo->setLabel(getString("inactive_combo_text"));
+	}
+	else if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM)
+	{
+		mPresetCombo->selectByValue(active_preset_name);
 	}
 	else
 	{
-		std::string inactive_text = getString("inactive_combo_text");
-		getChild<LLComboBox>("preset_combo")->setLabel(inactive_text);// add(inactive_text, inactive_text, ADD_TOP);
+		mPresetCombo->setLabel(getString("inactive_combo_text"));
 	}
 }
 
@@ -587,12 +595,18 @@ void LLFloaterCamera::onSavePreset()
 {
 	LLFloaterReg::hideInstance("delete_pref_preset", PRESETS_CAMERA);
 	LLFloaterReg::hideInstance("load_pref_preset", PRESETS_CAMERA);
-	LLFloaterReg::showInstance("save_pref_preset", PRESETS_CAMERA);
+	
+	LLSD key;
+	key["subdirectory"] = PRESETS_CAMERA;
+	std::string current_preset = gSavedSettings.getString("PresetCameraActive");
+	bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultPreset(current_preset);
+	key["index"] = is_custom_preset ? 1 : 0;
+	LLFloaterReg::showInstance("save_pref_preset", key);
 }
 
 void LLFloaterCamera::onCustomPresetSelected()
 {
-	std::string selected_preset = getChild<LLComboBox>("preset_combo")->getSelectedItemLabel();
+	std::string selected_preset = mPresetCombo->getSelectedItemLabel();
 	if (gSavedSettings.getString("PresetCameraActive") != selected_preset && getString("inactive_combo_text") != selected_preset)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM);
diff --git a/indra/newview/llfloatercamera.h b/indra/newview/llfloatercamera.h
index b1e0c83ce0..9440f50c3f 100644
--- a/indra/newview/llfloatercamera.h
+++ b/indra/newview/llfloatercamera.h
@@ -36,6 +36,7 @@ class LLJoystickCameraRotate;
 class LLJoystickCameraTrack;
 class LLFloaterReg;
 class LLPanelCameraZoom;
+class LLComboBox;
 
 enum ECameraControlMode
 {
@@ -128,6 +129,8 @@ private:
 	ECameraControlMode mPrevMode;
 	ECameraControlMode mCurrMode;
 	std::map<ECameraControlMode, LLButton*> mMode2Button;
+
+	LLComboBox* mPresetCombo;
 };
 
 /**
diff --git a/indra/newview/llfloaterdeleteprefpreset.cpp b/indra/newview/llfloaterdeleteprefpreset.cpp
index bd62849b42..0765756b43 100644
--- a/indra/newview/llfloaterdeleteprefpreset.cpp
+++ b/indra/newview/llfloaterdeleteprefpreset.cpp
@@ -82,6 +82,13 @@ void LLFloaterDeletePrefPreset::onBtnDelete()
 		args["NAME"] = name;
 		LLNotificationsUtil::add("PresetNotDeleted", args);
 	}
+	else if (mSubdirectory == PRESETS_CAMERA)
+	{
+		if (gSavedSettings.getString("PresetCameraActive") == name)
+		{
+			gSavedSettings.setString("PresetCameraActive", "");
+		}
+	}
 
 	closeFloater();
 }
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index 10fad347bf..c8d6513f4d 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -53,7 +53,6 @@ BOOL LLFloaterSavePrefPreset::postBuild()
 	}
 	
 	mPresetCombo = getChild<LLComboBox>("preset_combo");
-	//mPresetCombo->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
 
 	mNameEditor = getChild<LLLineEditor>("preset_txt_editor");
 	mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL);
@@ -84,7 +83,19 @@ void LLFloaterSavePrefPreset::onPresetNameEdited()
 void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 {
 	LLModalDialog::onOpen(key);
-	mSubdirectory = key.asString();
+	S32 index = 0;
+	if (key.has("subdirectory"))
+	{
+		mSubdirectory = key["subdirectory"].asString();
+		if (key.has("index"))
+		{
+			index = key["index"].asInteger();
+		}
+	}
+	else
+	{
+		mSubdirectory = key.asString();
+	}
 
 	std::string floater_title = getString(std::string("title_") + mSubdirectory);
 
@@ -93,7 +104,7 @@ void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 	EDefaultOptions option = DEFAULT_HIDE;
 	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 
-	mSaveRadioGroup->setSelectedIndex(0);
+	mSaveRadioGroup->setSelectedIndex(index);
 	onPresetNameEdited();
 	onSwitchSaveReplace();
 }
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 94e6e64754..ea4850bdb0 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -164,7 +164,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 
 			if (default_option == DEFAULT_VIEWS_HIDE)
 			{
-				if (name == PRESETS_REAR || name == PRESETS_SIDE || name == PRESETS_FRONT)
+				if (isDefaultPreset(name))
 				{
 					continue;
 				}
@@ -300,7 +300,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		{
 			name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
 			name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
-			custom_camera_offsets = (name != PRESETS_REAR && name != PRESETS_SIDE && name != PRESETS_FRONT);
+			custom_camera_offsets = !isDefaultPreset(name);
 		}
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
@@ -378,7 +378,7 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 	bool sts = true;
 
 	combo->clearRows();
-
+	combo->setEnabled(TRUE);
 
 	std::string presets_dir = getPresetsDir(subdirectory);
 
@@ -400,6 +400,7 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 		else
 		{
 			combo->setLabel(LLTrans::getString("preset_combo_label"));
+			combo->setEnabled(FALSE);
 			sts = false;
 		}
 	}
@@ -488,6 +489,11 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string
 	return sts;
 }
 
+bool LLPresetsManager::isDefaultPreset(std::string preset_name)
+{
+	return (preset_name == PRESETS_REAR || preset_name == PRESETS_SIDE || preset_name == PRESETS_FRONT);
+}
+
 boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
 {
 	return mPresetListChangeCameraSignal.connect(cb);
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index cb32b58fc4..e865fe2512 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -71,6 +71,8 @@ public:
 	bool isCameraDirty();
 	static void setCameraDirty(bool dirty);
 
+	bool isDefaultPreset(std::string preset_name);
+
 	// Emitted when a preset gets loaded, deleted, or saved.
 	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
 	boost::signals2::connection setPresetListChangeCallback(const preset_list_signal_t::slot_type& cb);
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index 52b2c631fa..c18d63d72b 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -4109,8 +4109,15 @@ void handle_reset_view()
 		// switching to outfit selector should automagically save any currently edited wearable
 		LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "my_outfits"));
 	}
-
-	gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+	if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM)
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM);
+	}
+	else
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
+	}
+	
 	reset_view_final( TRUE );
 	LLFloaterCamera::resetCameraMode();
 }
diff --git a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
index 3826ead5c2..77e36f0b09 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
@@ -22,7 +22,7 @@
    height="20"
    label="X"
    label_width="12"
-   follows="topl|eft"
+   follows="top|left"
    left="10"
    name="camera_x"
    top_pad="5"
@@ -37,7 +37,7 @@
    height="20"
    label="Y"
    label_width="12"
-   follows="topl|eft"
+   follows="top|left"
    name="camera_y"
    left_pad="20"
    min_val="-1e+007"
@@ -51,7 +51,7 @@
    height="20"
    label="Z"
    label_width="12"
-   follows="topl|eft"
+   follows="top|left"
    name="camera_z"
    left_pad="20"
    min_val="-1e+007"
@@ -75,7 +75,7 @@
    height="20"
    label="X"
    label_width="12"
-   follows="topl|eft"
+   follows="top|left"
    left="10"
    name="focus_x"
    top_pad="5"
@@ -90,7 +90,7 @@
    height="20"
    label="Y"
    label_width="12"
-   follows="topl|eft"
+   follows="top|left"
    name="focus_y"
    left_pad="20"
    min_val="-1e+007"
@@ -104,7 +104,7 @@
    height="20"
    label="Z"
    label_width="12"
-   follows="topl|eft"
+   follows="top|left"
    name="focus_z"
    left_pad="20"
    min_val="-1e+007"
diff --git a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
index 178ecad0f3..3a5838e846 100644
--- a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
@@ -44,19 +44,12 @@
      name="preset_txt_editor"
      width="200"
      top="45"/>
-    <combo_box
-     follows="top|left"
-     layout="topleft"
-     left="41"
-     name="preset_combo"
-     top_pad="35"
-     width="200"/>
     <button
      follows="top|left"
      height="25"
      label="Save"
      layout="topleft"
-     top_delta="40"
+     top="145"
      left="25"
      name="save"
      width="110"/>
@@ -68,4 +61,12 @@
      left_pad="20"
      name="cancel"
      width="110"/>
+<!-- *HACK to correctly draw drop-down list over the buttons-->
+    <combo_box
+     follows="top|left"
+     layout="topleft"
+     left="41"
+     name="preset_combo"
+     top_delta="-40"
+     width="200"/>
 </floater>
-- 
cgit v1.2.3


From 1fa0b3fe954ead1a136d3c38b63db05b5f2f657e Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 8 Nov 2019 17:57:17 +0200
Subject: SL-12186 WIP Add new 'My camera presets' floater

---
 indra/newview/CMakeLists.txt                       |   2 +
 indra/newview/llfloatercamera.cpp                  |   3 +-
 indra/newview/llfloatercamerapresets.cpp           | 122 +++++++++++++++++++++
 indra/newview/llfloatercamerapresets.h             |  69 ++++++++++++
 indra/newview/llpresetsmanager.cpp                 |  27 ++++-
 indra/newview/llpresetsmanager.h                   |   4 +-
 indra/newview/llviewerfloaterreg.cpp               |   2 +
 .../skins/default/xui/en/floater_camera.xml        |  22 ++--
 .../default/xui/en/floater_camera_presets.xml      |  23 ++++
 .../default/xui/en/panel_camera_preset_item.xml    |  56 ++++++++++
 10 files changed, 317 insertions(+), 13 deletions(-)
 create mode 100644 indra/newview/llfloatercamerapresets.cpp
 create mode 100644 indra/newview/llfloatercamerapresets.h
 create mode 100644 indra/newview/skins/default/xui/en/floater_camera_presets.xml
 create mode 100644 indra/newview/skins/default/xui/en/panel_camera_preset_item.xml

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 17095d8fcd..534af4d8f6 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -229,6 +229,7 @@ set(viewer_SOURCE_FILES
     llfloaterbuycurrencyhtml.cpp
     llfloaterbuyland.cpp
     llfloatercamera.cpp
+    llfloatercamerapresets.cpp
     llfloaterchatvoicevolume.cpp
     llfloatercolorpicker.cpp
     llfloaterconversationlog.cpp
@@ -855,6 +856,7 @@ set(viewer_HEADER_FILES
     llfloaterbuycurrency.h
     llfloaterbuycurrencyhtml.h
     llfloaterbuyland.h
+    llfloatercamerapresets.h
     llfloatercamera.h
     llfloaterchatvoicevolume.h
     llfloatercolorpicker.h
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 8502b5685d..2f85e7db34 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -351,6 +351,7 @@ LLFloaterCamera::LLFloaterCamera(const LLSD& val)
 	LLHints::registerHintTarget("view_popup", getHandle());
 	mCommitCallbackRegistrar.add("CameraPresets.ChangeView", boost::bind(&LLFloaterCamera::onClickCameraItem, _2));
 	mCommitCallbackRegistrar.add("CameraPresets.Save", boost::bind(&LLFloaterCamera::onSavePreset, this));
+	mCommitCallbackRegistrar.add("CameraPresets.ShowPresetsList", boost::bind(&LLFloaterReg::showInstance, "camera_presets", LLSD(), FALSE));
 }
 
 // virtual
@@ -599,7 +600,7 @@ void LLFloaterCamera::onSavePreset()
 	LLSD key;
 	key["subdirectory"] = PRESETS_CAMERA;
 	std::string current_preset = gSavedSettings.getString("PresetCameraActive");
-	bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultPreset(current_preset);
+	bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultCameraPreset(current_preset);
 	key["index"] = is_custom_preset ? 1 : 0;
 	LLFloaterReg::showInstance("save_pref_preset", key);
 }
diff --git a/indra/newview/llfloatercamerapresets.cpp b/indra/newview/llfloatercamerapresets.cpp
new file mode 100644
index 0000000000..6a9df5d067
--- /dev/null
+++ b/indra/newview/llfloatercamerapresets.cpp
@@ -0,0 +1,122 @@
+/** 
+* @file llfloatercamerapresets.cpp
+*
+* $LicenseInfo:firstyear=2019&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2019, Linden Research, Inc.
+* 
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+* 
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+* 
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+* 
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+* $/LicenseInfo$
+*/
+#include "llviewerprecompiledheaders.h"
+
+#include "llfloatercamerapresets.h"
+#include "llfloaterreg.h"
+#include "llnotificationsutil.h"
+#include "llpresetsmanager.h"
+#include "llviewercontrol.h"
+
+LLFloaterCameraPresets::LLFloaterCameraPresets(const LLSD& key)
+:	LLFloater(key)
+{}
+
+LLFloaterCameraPresets::~LLFloaterCameraPresets()
+{}
+
+BOOL LLFloaterCameraPresets::postBuild()
+{
+    mPresetList = getChild<LLFlatListView>("preset_list");
+
+    LLPresetsManager::getInstance()->setPresetListChangeCameraCallback(boost::bind(&LLFloaterCameraPresets::populateList, this));
+
+    return TRUE;
+}
+void LLFloaterCameraPresets::onOpen(const LLSD& key)
+{
+    populateList();
+}
+
+void LLFloaterCameraPresets::populateList()
+{
+    mPresetList->clear();
+
+    LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
+    std::string presets_dir = presetsMgr->getPresetsDir(PRESETS_CAMERA);
+    std::list<std::string> preset_names;
+
+    presetsMgr->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_TOP);
+    for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
+    {
+        const std::string& name = *it;
+        bool is_default = presetsMgr->isDefaultCameraPreset(name);
+        LLCameraPresetFlatItem* item = new LLCameraPresetFlatItem(name, is_default);
+        item->postBuild();
+        mPresetList->addItem(item);
+    }
+}
+
+LLCameraPresetFlatItem::LLCameraPresetFlatItem(const std::string &preset_name, bool is_default)
+    : LLPanel(),
+    mPresetName(preset_name),
+    mIsDefaultPrest(is_default)
+{
+    mCommitCallbackRegistrar.add("CameraPresets.Delete", boost::bind(&LLCameraPresetFlatItem::onDeleteBtnClick, this));
+    mCommitCallbackRegistrar.add("CameraPresets.Reset", boost::bind(&LLCameraPresetFlatItem::onResetBtnClick, this));
+    buildFromFile("panel_camera_preset_item.xml");
+}
+
+LLCameraPresetFlatItem::~LLCameraPresetFlatItem()
+{
+}
+
+BOOL LLCameraPresetFlatItem::postBuild()
+{
+    mDeleteBtn = getChild<LLButton>("delete_btn");
+    mDeleteBtn->setVisible(!mIsDefaultPrest);
+
+    mResetBtn = getChild<LLButton>("reset_btn");
+    mResetBtn->setVisible(mIsDefaultPrest);
+
+    LLStyle::Params style;
+    LLTextBox* name_text = getChild<LLTextBox>("preset_name");
+    LLFontDescriptor new_desc(name_text->getFont()->getFontDesc());
+    new_desc.setStyle(mIsDefaultPrest ? LLFontGL::ITALIC : LLFontGL::NORMAL);
+    LLFontGL* new_font = LLFontGL::getFont(new_desc);
+    style.font = new_font;
+    name_text->setText(mPresetName, style);
+
+    return true;
+}
+
+void LLCameraPresetFlatItem::onDeleteBtnClick()
+{
+    if (!LLPresetsManager::getInstance()->deletePreset(PRESETS_CAMERA, mPresetName))
+    {
+        LLSD args;
+        args["NAME"] = mPresetName;
+        LLNotificationsUtil::add("PresetNotDeleted", args);
+    }
+	else if (gSavedSettings.getString("PresetCameraActive") == mPresetName)
+    {
+        gSavedSettings.setString("PresetCameraActive", "");
+    }
+}
+
+void LLCameraPresetFlatItem::onResetBtnClick()
+{
+    LLPresetsManager::getInstance()->resetCameraPreset(mPresetName);
+}
diff --git a/indra/newview/llfloatercamerapresets.h b/indra/newview/llfloatercamerapresets.h
new file mode 100644
index 0000000000..8c293c57de
--- /dev/null
+++ b/indra/newview/llfloatercamerapresets.h
@@ -0,0 +1,69 @@
+/** 
+* @file llfloatercamerapresets.h
+*
+* $LicenseInfo:firstyear=2019&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2019, Linden Research, Inc.
+* 
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+* 
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+* 
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+* 
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+* $/LicenseInfo$
+*/
+#ifndef LLFLOATERCAMERAPRESETS_H
+#define LLFLOATERCAMERAPRESETS_H
+
+#include "llfloater.h"
+#include "llflatlistview.h"
+
+class LLFloaterReg;
+
+class LLFloaterCameraPresets : public LLFloater
+{
+    friend class LLFloaterReg;
+
+    virtual BOOL postBuild();
+    virtual void onOpen(const LLSD& key);
+
+    void populateList();
+
+private:
+    LLFloaterCameraPresets(const LLSD& key);
+    ~LLFloaterCameraPresets();
+
+    LLFlatListView* mPresetList;
+};
+
+class LLCameraPresetFlatItem : public LLPanel
+{
+public:
+    LLCameraPresetFlatItem(const std::string &preset_name, bool is_default);
+    virtual ~LLCameraPresetFlatItem();
+
+    virtual BOOL postBuild();
+
+private:
+    void onDeleteBtnClick();
+    void onResetBtnClick();
+
+    LLButton* mDeleteBtn;
+    LLButton* mResetBtn;
+
+    std::string mPresetName;
+    bool mIsDefaultPrest;
+
+};
+
+#endif
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index ea4850bdb0..ab4f60d486 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -89,6 +89,7 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
 	{
 		std::vector<std::string> name_list;
 		getControlNames(name_list);
+		getOffsetControlNames(name_list);
 
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
@@ -164,7 +165,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 
 			if (default_option == DEFAULT_VIEWS_HIDE)
 			{
-				if (isDefaultPreset(name))
+				if (isDefaultCameraPreset(name))
 				{
 					continue;
 				}
@@ -239,6 +240,21 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
     names = camera_controls;
 }
 
+void LLPresetsManager::getOffsetControlNames(std::vector<std::string>& names)
+{
+	const std::vector<std::string> offset_controls = boost::assign::list_of
+		("CameraOffsetRearView")
+		("CameraOffsetFrontView")
+		("CameraOffsetGroupView")
+		("CameraOffsetCustomPreset")
+		("FocusOffsetRearView")
+		("FocusOffsetFrontView")
+		("FocusOffsetGroupView")
+		("FocusOffsetCustomPreset")
+		;
+	names.insert(std::end(names), std::begin(offset_controls), std::end(offset_controls));
+}
+
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
 {
 	if (LLTrans::getString(PRESETS_DEFAULT) == name)
@@ -300,7 +316,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		{
 			name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
 			name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
-			custom_camera_offsets = !isDefaultPreset(name);
+			custom_camera_offsets = !isDefaultCameraPreset(name);
 		}
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
@@ -489,11 +505,16 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string
 	return sts;
 }
 
-bool LLPresetsManager::isDefaultPreset(std::string preset_name)
+bool LLPresetsManager::isDefaultCameraPreset(std::string preset_name)
 {
 	return (preset_name == PRESETS_REAR || preset_name == PRESETS_SIDE || preset_name == PRESETS_FRONT);
 }
 
+void LLPresetsManager::resetCameraPreset(std::string preset_name)
+{
+
+}
+
 boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
 {
 	return mPresetListChangeCameraSignal.connect(cb);
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index e865fe2512..9964cc0fcf 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -71,7 +71,8 @@ public:
 	bool isCameraDirty();
 	static void setCameraDirty(bool dirty);
 
-	bool isDefaultPreset(std::string preset_name);
+	bool isDefaultCameraPreset(std::string preset_name);
+	void resetCameraPreset(std::string preset_name);
 
 	// Emitted when a preset gets loaded, deleted, or saved.
 	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
@@ -88,6 +89,7 @@ public:
 	LOG_CLASS(LLPresetsManager);
 
 	void getControlNames(std::vector<std::string>& names);
+	void getOffsetControlNames(std::vector<std::string>& names);
 	static void settingChanged();
 
 	boost::signals2::connection	mCameraChangedSignal;
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index 193ee17912..bc5e04a4c3 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -53,6 +53,7 @@
 #include "llfloaterbuyland.h"
 #include "llfloaterbvhpreview.h"
 #include "llfloatercamera.h"
+#include "llfloatercamerapresets.h"
 #include "llfloaterchatvoicevolume.h"
 #include "llfloaterconversationlog.h"
 #include "llfloaterconversationpreview.h"
@@ -215,6 +216,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("bumps", "floater_bumps.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBump>);
 
 	LLFloaterReg::add("camera", "floater_camera.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCamera>);
+	LLFloaterReg::add("camera_presets", "floater_camera_presets.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCameraPresets>);
 	LLFloaterReg::add("chat_voice", "floater_voice_chat_volume.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterChatVoiceVolume>);
 	LLFloaterReg::add("nearby_chat", "floater_im_session.xml", (LLFloaterBuildFunc)&LLFloaterIMNearbyChat::buildFloater);
 	LLFloaterReg::add("compile_queue", "floater_script_queue.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterCompileQueue>);
diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 933d50acae..9408e68c2d 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -222,16 +222,22 @@
          name="Use preset"
          value="default" />
       </combo_box>
-      <icon
-        height="28"
-        width="28"
-        image_name="Command_Preferences_Icon"
+      <button
+        height="16"
+        width="16"  
         layout="topleft"
         mouse_opaque="true"
-        name="icon_gear"
+        name="gear_btn"
         tool_tip="My Camera Presets"
-        top_delta="0"
-        left_pad="5" />
+        top_delta="3"
+        left_pad="10" 
+        image_selected="Icon_Gear"
+        image_pressed="Icon_Gear"
+        image_unselected="Icon_Gear"
+        is_toggle="true">
+        <button.commit_callback
+          function="CameraPresets.ShowPresetsList"/>
+      </button>
       <button
         follows="top|left"
         height="25"
@@ -239,7 +245,7 @@
         layout="topleft"
         left="0"
         name="save_preset_btn"
-        top_pad="8"
+        top_pad="18"
         width="150">
         <button.commit_callback
           function="CameraPresets.Save"/>
diff --git a/indra/newview/skins/default/xui/en/floater_camera_presets.xml b/indra/newview/skins/default/xui/en/floater_camera_presets.xml
new file mode 100644
index 0000000000..0d9a6bb16a
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_camera_presets.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ legacy_header_height="18"
+ can_resize="true"
+ height="200"
+ min_height="150"
+ title="MY CAMERA PRESETS"
+ layout="topleft"
+ name="floater_camera_presets"
+ single_instance="true"
+ min_width="185"
+ width="250">
+  <flat_list_view
+    allow_select="true"
+    follows="all"
+    height="165"
+    layout="topleft"
+    left="3"
+    multi_select="false"
+    name="preset_list"
+    top="20"
+    width="245" />
+  </floater>
diff --git a/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml b/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml
new file mode 100644
index 0000000000..187f5889eb
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel
+ follows="top|right|left"
+ height="20"
+ layout="topleft"
+ left="0"
+ name="camera_preset_item"
+ top="0"
+ width="280">
+    <text
+     follows="left"
+     height="20"
+     layout="topleft"
+     left="10"
+     parse_urls="false"
+     use_ellipses="true"
+     name="preset_name"
+     text_color="White"
+     top="2"
+     value="Default"
+     width="159" />
+    <button
+     follows="right"
+     image_selected="TrashItem_Off"
+     image_pressed="TrashItem_Off"
+     image_unselected="TrashItem_Off"
+     is_toggle="true"
+     layout="topleft"
+     left_pad="5"
+     right="-10"
+     name="delete_btn"
+     tool_tip="Delete preset"
+     top="3"
+     height="18"
+     width="18" >
+      <button.commit_callback
+        function="CameraPresets.Delete"/>
+    </button>
+  <button
+   follows="right"
+   image_selected="Refresh_Off"
+   image_pressed="Refresh_Off"
+   image_unselected="Refresh_Off"
+   is_toggle="true"
+   layout="topleft"
+   left_pad="5"
+   right="-10"
+   name="reset_btn"
+   tool_tip="Reset preset to default"
+   top="2"
+   height="20"
+   width="20" >
+    <button.commit_callback
+      function="CameraPresets.Reset"/>
+  </button>
+</panel>
-- 
cgit v1.2.3


From 382c1845012cc4e2be78a5a03334b4157a732349 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 12 Nov 2019 16:26:34 +0200
Subject: SL-12186 WIP Added ability to reset default presets and updated item
 list in 'My camera presets' floater

---
 indra/newview/app_settings/settings.xml            |  2 +-
 indra/newview/llfloatercamera.cpp                  |  7 ++-
 indra/newview/llfloatercamerapresets.cpp           | 32 ++++++++++-
 indra/newview/llfloatercamerapresets.h             |  4 ++
 indra/newview/llpresetsmanager.cpp                 | 65 ++++++++++++++++++++--
 indra/newview/llpresetsmanager.h                   |  9 +++
 .../default/xui/en/panel_camera_preset_item.xml    | 20 +++++++
 7 files changed, 126 insertions(+), 13 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index f44185340a..04ab620b3a 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1565,7 +1565,7 @@
     <key>CameraPreset</key>
     <map>
       <key>Comment</key>
-      <string>Preset camera position - view (0 - rear, 1 - front, 2 - group)</string>
+      <string>Preset camera position - view (0 - rear, 1 - front, 2 - group, 3 - custom)</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 2f85e7db34..47f05884b3 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -550,17 +550,17 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 	if ("rear_view" == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_REAR);
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_REAR_VIEW);
 	}
 	else if ("group_view" == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_SIDE);
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_SIDE_VIEW);
 	}
 	else if ("front_view" == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_FRONT);
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_FRONT_VIEW);
 	}
 }
 
@@ -590,6 +590,7 @@ void LLFloaterCamera::populatePresetCombo()
 	{
 		mPresetCombo->setLabel(getString("inactive_combo_text"));
 	}
+	updateItemsSelection();
 }
 
 void LLFloaterCamera::onSavePreset()
diff --git a/indra/newview/llfloatercamerapresets.cpp b/indra/newview/llfloatercamerapresets.cpp
index 6a9df5d067..75660e590a 100644
--- a/indra/newview/llfloatercamerapresets.cpp
+++ b/indra/newview/llfloatercamerapresets.cpp
@@ -58,7 +58,10 @@ void LLFloaterCameraPresets::populateList()
     std::string presets_dir = presetsMgr->getPresetsDir(PRESETS_CAMERA);
     std::list<std::string> preset_names;
 
-    presetsMgr->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_TOP);
+    presetsMgr->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_VIEWS_HIDE);
+    preset_names.push_back(PRESETS_FRONT_VIEW);
+    preset_names.push_back(PRESETS_REAR_VIEW);
+    preset_names.push_back(PRESETS_SIDE_VIEW);
     for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
     {
         const std::string& name = *it;
@@ -86,10 +89,10 @@ LLCameraPresetFlatItem::~LLCameraPresetFlatItem()
 BOOL LLCameraPresetFlatItem::postBuild()
 {
     mDeleteBtn = getChild<LLButton>("delete_btn");
-    mDeleteBtn->setVisible(!mIsDefaultPrest);
+    mDeleteBtn->setVisible(false);
 
     mResetBtn = getChild<LLButton>("reset_btn");
-    mResetBtn->setVisible(mIsDefaultPrest);
+    mResetBtn->setVisible(false);
 
     LLStyle::Params style;
     LLTextBox* name_text = getChild<LLTextBox>("preset_name");
@@ -102,6 +105,29 @@ BOOL LLCameraPresetFlatItem::postBuild()
     return true;
 }
 
+void LLCameraPresetFlatItem::onMouseEnter(S32 x, S32 y, MASK mask)
+{
+    mDeleteBtn->setVisible(!mIsDefaultPrest);
+    mResetBtn->setVisible(mIsDefaultPrest);
+    getChildView("hovered_icon")->setVisible(true);
+    LLPanel::onMouseEnter(x, y, mask);
+}
+
+void LLCameraPresetFlatItem::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+    mDeleteBtn->setVisible(false);
+    mResetBtn->setVisible(false);
+    getChildView("hovered_icon")->setVisible(false);
+    LLPanel::onMouseLeave(x, y, mask);
+}
+
+void LLCameraPresetFlatItem::setValue(const LLSD& value)
+{
+    if (!value.isMap()) return;;
+    if (!value.has("selected")) return;
+    getChildView("selected_icon")->setVisible(value["selected"]);
+}
+
 void LLCameraPresetFlatItem::onDeleteBtnClick()
 {
     if (!LLPresetsManager::getInstance()->deletePreset(PRESETS_CAMERA, mPresetName))
diff --git a/indra/newview/llfloatercamerapresets.h b/indra/newview/llfloatercamerapresets.h
index 8c293c57de..66430fa399 100644
--- a/indra/newview/llfloatercamerapresets.h
+++ b/indra/newview/llfloatercamerapresets.h
@@ -52,7 +52,11 @@ public:
     LLCameraPresetFlatItem(const std::string &preset_name, bool is_default);
     virtual ~LLCameraPresetFlatItem();
 
+    void setValue(const LLSD& value);
+
     virtual BOOL postBuild();
+    virtual void onMouseEnter(S32 x, S32 y, MASK mask);
+    virtual void onMouseLeave(S32 x, S32 y, MASK mask);
 
 private:
     void onDeleteBtnClick();
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index ab4f60d486..057f60a015 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -65,7 +65,13 @@ void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 {
 	if(gDirUtilp->getLindenUserDir().empty())
 	{
-return;
+		return;
+	}
+
+	if (PRESETS_CAMERA == subdirectory)
+	{
+		createCameraDefaultPresets();
+		return;
 	}
 
 	std::string default_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
@@ -83,6 +89,13 @@ return;
 	}
 }
 
+void LLPresetsManager::createCameraDefaultPresets()
+{
+	createDefaultCameraPreset(PRESETS_REAR_VIEW);
+	createDefaultCameraPreset(PRESETS_FRONT_VIEW);
+	createDefaultCameraPreset(PRESETS_SIDE_VIEW);
+}
+
 void LLPresetsManager::startWatching(const std::string& subdirectory)
 {
 	if (PRESETS_CAMERA == subdirectory)
@@ -163,6 +176,10 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 			std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
 			LL_DEBUGS() << "  Found preset '" << name << "'" << LL_ENDL;
 
+			if (isTemplateCameraPreset(name))
+			{
+				continue;
+			}
 			if (default_option == DEFAULT_VIEWS_HIDE)
 			{
 				if (isDefaultCameraPreset(name))
@@ -198,6 +215,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 }
 
 bool LLPresetsManager::mCameraDirty = false;
+bool LLPresetsManager::mIgnoreChangedSignal = false;
 
 void LLPresetsManager::setCameraDirty(bool dirty)
 {
@@ -215,7 +233,7 @@ void LLPresetsManager::settingChanged()
 
 	static LLCachedControl<std::string> preset_camera_active(gSavedSettings, "PresetCameraActive", "");
 	std::string preset_name = preset_camera_active;
-	if (!preset_name.empty())
+	if (!preset_name.empty() && !mIgnoreChangedSignal)
 	{
 		gSavedSettings.setString("PresetCameraActive", "");
 
@@ -267,6 +285,12 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		return false;
 	}
 
+	if (isTemplateCameraPreset(name))
+	{
+		LL_WARNS() << "Should not overwrite template presets" << LL_ENDL;
+		return false;
+	}
+
 	bool saved = false;
 	std::vector<std::string> name_list;
 
@@ -434,8 +458,10 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n
 
     LL_DEBUGS() << "attempting to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
 
+	mIgnoreChangedSignal = true;
 	if(gSavedSettings.loadFromFile(full_path, false, true) > 0)
 	{
+		mIgnoreChangedSignal = false;
 		if(PRESETS_GRAPHIC == subdirectory)
 		{
 			gSavedSettings.setString("PresetGraphicActive", name);
@@ -453,10 +479,11 @@ void LLPresetsManager::loadPreset(const std::string& subdirectory, std::string n
 			triggerChangeCameraSignal();
 		}
 	}
-    else
-    {
-        LL_WARNS("Presets") << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
-    }
+	else
+	{
+		mIgnoreChangedSignal = false;
+		LL_WARNS("Presets") << "failed to load preset '"<<name<<"' from '"<<full_path<<"'" << LL_ENDL;
+	}
 }
 
 bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string name)
@@ -506,13 +533,39 @@ bool LLPresetsManager::deletePreset(const std::string& subdirectory, std::string
 }
 
 bool LLPresetsManager::isDefaultCameraPreset(std::string preset_name)
+{
+	return (preset_name == PRESETS_REAR_VIEW || preset_name == PRESETS_SIDE_VIEW || preset_name == PRESETS_FRONT_VIEW);
+}
+
+bool LLPresetsManager::isTemplateCameraPreset(std::string preset_name)
 {
 	return (preset_name == PRESETS_REAR || preset_name == PRESETS_SIDE || preset_name == PRESETS_FRONT);
 }
 
 void LLPresetsManager::resetCameraPreset(std::string preset_name)
 {
+	if (isDefaultCameraPreset(preset_name))
+	{
+		createDefaultCameraPreset(preset_name, true);
+
+		if (gSavedSettings.getString("PresetCameraActive") == preset_name)
+		{
+			loadPreset(PRESETS_CAMERA, preset_name);
+		}
+	}
+}
 
+void LLPresetsManager::createDefaultCameraPreset(std::string preset_name, bool force_reset)
+{
+	std::string preset_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
+		PRESETS_CAMERA, LLURI::escape(preset_name) + ".xml");
+	if (!gDirUtilp->fileExists(preset_file) || force_reset)
+	{
+		std::string template_name = preset_name.substr(0, preset_name.size() - PRESETS_VIEW_SUFFIX.size());
+		std::string default_template_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
+			PRESETS_CAMERA, template_name + ".xml");
+		LLFile::copy(default_template_file, preset_file);
+	}
 }
 
 boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 9964cc0fcf..d489a0ad5a 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -39,6 +39,10 @@ static const std::string PRESETS_CAMERA = "camera";
 static const std::string PRESETS_REAR = "Rear";
 static const std::string PRESETS_FRONT = "Front";
 static const std::string PRESETS_SIDE = "Side";
+static const std::string PRESETS_VIEW_SUFFIX = " View";
+static const std::string PRESETS_REAR_VIEW = PRESETS_REAR + PRESETS_VIEW_SUFFIX;
+static const std::string PRESETS_FRONT_VIEW = PRESETS_FRONT + PRESETS_VIEW_SUFFIX;
+static const std::string PRESETS_SIDE_VIEW = PRESETS_SIDE + PRESETS_VIEW_SUFFIX;
 
 enum EDefaultOptions
 {
@@ -71,8 +75,12 @@ public:
 	bool isCameraDirty();
 	static void setCameraDirty(bool dirty);
 
+	void createCameraDefaultPresets();
+
+	bool isTemplateCameraPreset(std::string preset_name);
 	bool isDefaultCameraPreset(std::string preset_name);
 	void resetCameraPreset(std::string preset_name);
+	void createDefaultCameraPreset(std::string preset_name, bool force_reset = false);
 
 	// Emitted when a preset gets loaded, deleted, or saved.
 	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
@@ -95,6 +103,7 @@ public:
 	boost::signals2::connection	mCameraChangedSignal;
 
 	static bool	mCameraDirty;
+	static bool mIgnoreChangedSignal;
 };
 
 #endif // LL_PRESETSMANAGER_H
diff --git a/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml b/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml
index 187f5889eb..9417ab4ac2 100644
--- a/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml
+++ b/indra/newview/skins/default/xui/en/panel_camera_preset_item.xml
@@ -7,6 +7,26 @@
  name="camera_preset_item"
  top="0"
  width="280">
+    <icon
+     follows="top|right|left"
+     height="20"
+     image_name="ListItem_Over"
+     layout="topleft"
+     left="0"
+     name="hovered_icon"
+     top="0"
+     visible="false"
+     width="380" />
+    <icon
+     height="20"
+     follows="top|right|left"
+     image_name="ListItem_Select"
+     layout="topleft"
+     left="0"
+     name="selected_icon"
+     top="0"
+     visible="false"
+     width="380" />
     <text
      follows="left"
      height="20"
-- 
cgit v1.2.3


From 4778417f25f070e9019e975c979d93fb8881b5ac Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Wed, 13 Nov 2019 15:55:02 +0200
Subject: SL-12186 WIP Use appropriate offset names when saving presets

---
 indra/newview/llagentcamera.cpp                    | 10 ++++
 indra/newview/llagentcamera.h                      |  2 +
 indra/newview/llpanelpresetscamerapulldown.cpp     | 16 +-----
 indra/newview/llpresetsmanager.cpp                 | 63 ++++++++++++++++------
 .../xui/en/panel_presets_camera_pulldown.xml       |  6 +--
 5 files changed, 64 insertions(+), 33 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 3e56c1dd71..882e3cee55 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1948,11 +1948,21 @@ std::string LLAgentCamera::getCameraOffsetCtrlName()
 	return mCameraOffsetInitial[mCameraPreset]->getName();
 }
 
+std::string LLAgentCamera::getCameraOffsetCtrlName(ECameraPreset preset)
+{
+	return mCameraOffsetInitial[preset]->getName();
+}
+
 std::string LLAgentCamera::getFocusOffsetCtrlName()
 {
 	return mFocusOffsetInitial[mCameraPreset]->getName();
 }
 
+std::string LLAgentCamera::getFocusOffsetCtrlName(ECameraPreset preset)
+{
+	return mFocusOffsetInitial[preset]->getName();
+}
+
 F32 LLAgentCamera::getCameraMaxZoomDistance()
 {
     // Ignore "DisableCameraConstraints", we don't want to be out of draw range when we focus onto objects or avatars
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 294e81c2e1..5c8172bbfc 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -118,7 +118,9 @@ public:
 	LLVector3d getFocusOffsetInitial();
 
 	std::string getCameraOffsetCtrlName();
+	std::string getCameraOffsetCtrlName(ECameraPreset preset);
 	std::string getFocusOffsetCtrlName();
+	std::string getFocusOffsetCtrlName(ECameraPreset preset);
 private:
 	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
 	F32 getCameraMaxZoomDistance();
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index 7612c428d9..1ac105e1c8 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -52,7 +52,7 @@ LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown()
 {
 	mHoverTimer.stop();
 
-	mCommitCallbackRegistrar.add("Presets.GoViewPrefs", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
+	mCommitCallbackRegistrar.add("Presets.toggleCameraFloater", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
 	mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
 
 	buildFromFile( "panel_presets_camera_pulldown.xml");
@@ -205,19 +205,7 @@ void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data)
 	// close the minicontrol, we're bringing up the big one
 	setVisible(FALSE);
 
-	// bring up the prefs floater
-	LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
-	if (prefsfloater)
-	{
-		// grab the 'view' panel from the preferences floater and
-		// bring it the front!
-		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
-		LLPanel* graphicspanel = prefsfloater->getChild<LLPanel>("view");
-		if (tabcontainer && graphicspanel)
-		{
-			tabcontainer->selectTabPanel(graphicspanel);
-		}
-	}
+	LLFloaterReg::toggleInstanceOrBringToFront("camera");
 }
 
 //virtual
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 057f60a015..71f0cd72d4 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -275,6 +275,9 @@ void LLPresetsManager::getOffsetControlNames(std::vector<std::string>& names)
 
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
 {
+	bool IS_CAMERA = (PRESETS_CAMERA == subdirectory);
+	bool IS_GRAPHIC = (PRESETS_GRAPHIC == subdirectory);
+
 	if (LLTrans::getString(PRESETS_DEFAULT) == name)
 	{
 		name = PRESETS_DEFAULT;
@@ -294,7 +297,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	bool saved = false;
 	std::vector<std::string> name_list;
 
-	if(PRESETS_GRAPHIC == subdirectory)
+	if (IS_GRAPHIC)
 	{
 		LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
 		if (instance && !createDefault)
@@ -309,11 +312,13 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 			LL_WARNS("Presets") << "preferences floater instance not found" << LL_ENDL;
 		}
 	}
-	else if(PRESETS_CAMERA == subdirectory)
+	else if (IS_CAMERA)
 	{
 		name_list.clear();
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
+		name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
+		name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
 	}
 	else
 	{
@@ -324,7 +329,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	LLSD paramsData(LLSD::emptyMap());
 
 	// Create a default graphics preset from hw recommended settings 
-	if (createDefault && name == PRESETS_DEFAULT && subdirectory == PRESETS_GRAPHIC)
+	if (IS_GRAPHIC && createDefault && name == PRESETS_DEFAULT)
 	{
 		paramsData = LLFeatureManager::getInstance()->getRecommendedSettingsMap();
 		if (gSavedSettings.getU32("RenderAvatarMaxComplexity") == 0)
@@ -335,25 +340,47 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	}
 	else
 	{
-		bool custom_camera_offsets = false;
-		if (subdirectory == PRESETS_CAMERA)
+		ECameraPreset new_camera_preset = (ECameraPreset)gSavedSettings.getU32("CameraPreset");
+		bool new_camera_offsets = false;
+		if (IS_CAMERA)
 		{
-			name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
-			name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
-			custom_camera_offsets = !isDefaultCameraPreset(name);
+			if (isDefaultCameraPreset(name))
+			{
+				if (PRESETS_REAR_VIEW == name)
+				{
+					new_camera_preset = CAMERA_PRESET_REAR_VIEW;
+				}
+				else if (PRESETS_SIDE_VIEW == name)
+				{
+					new_camera_preset = CAMERA_PRESET_GROUP_VIEW;
+				}
+				else if (PRESETS_FRONT_VIEW == name)
+				{
+					new_camera_preset = CAMERA_PRESET_FRONT_VIEW;
+				}
+			}
+			else 
+			{
+				new_camera_preset = CAMERA_PRESET_CUSTOM;
+			}
+			new_camera_offsets = (!isDefaultCameraPreset(name) || (ECameraPreset)gSavedSettings.getU32("CameraPreset") != new_camera_preset);
 		}
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
 			std::string ctrl_name = *it;
 			std::string dest_ctrl_name = ctrl_name;
-			if (custom_camera_offsets && ctrl_name == gAgentCamera.getCameraOffsetCtrlName())
-			{
-				dest_ctrl_name = "CameraOffsetCustomPreset";
-			}
-			if (custom_camera_offsets && ctrl_name == gAgentCamera.getFocusOffsetCtrlName())
+			if (IS_CAMERA && new_camera_offsets)
 			{
-				dest_ctrl_name = "FocusOffsetCustomPreset";
+				if (ctrl_name == gAgentCamera.getCameraOffsetCtrlName())
+				{
+					dest_ctrl_name = gAgentCamera.getCameraOffsetCtrlName(new_camera_preset);
+				}
+				if (ctrl_name == gAgentCamera.getFocusOffsetCtrlName())
+				{
+					dest_ctrl_name = gAgentCamera.getFocusOffsetCtrlName(new_camera_preset);
+				}
 			}
+
 			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
 			if (ctrl)
 			{
@@ -367,6 +394,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 				paramsData[dest_ctrl_name]["Value"] = value;
 			}
 		}
+		if (IS_CAMERA)
+		{
+			gSavedSettings.setU32("CameraPreset", new_camera_preset);
+		}
 	}
 
 	std::string pathName(getPresetsDir(subdirectory) + gDirUtilp->getDirDelimiter() + LLURI::escape(name) + ".xml");
@@ -385,14 +416,14 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
             
 			LL_DEBUGS() << "saved preset '" << name << "'; " << paramsData.size() << " parameters" << LL_ENDL;
 
-			if (subdirectory == PRESETS_GRAPHIC)
+			if (IS_GRAPHIC)
 			{
 				gSavedSettings.setString("PresetGraphicActive", name);
 				// signal interested parties
 				triggerChangeSignal();
 			}
 
-			if (subdirectory == PRESETS_CAMERA)
+			if (IS_CAMERA)
 			{
 				gSavedSettings.setString("PresetCameraActive", name);
 				setCameraDirty(false);
diff --git a/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml b/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml
index dc37270751..25d9c47449 100644
--- a/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml
+++ b/indra/newview/skins/default/xui/en/panel_presets_camera_pulldown.xml
@@ -57,13 +57,13 @@
     width="215" />
   <button
     name="open_prefs_btn"
-    label="Open View Preferences"
-    tool_tip = "Bring up view preferences"
+    label="Open Camera floater"
+    tool_tip = "Bring up Camera floater"
     top_delta="5"
     left="15"
     height="20"
     width="200">
     <button.commit_callback
-      function="Presets.GoViewPrefs" />
+      function="Presets.toggleCameraFloater" />
   </button>
 </panel>
-- 
cgit v1.2.3


From 7637f343865960ee509ae31205c097f0bb04aac1 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Wed, 13 Nov 2019 17:39:40 +0200
Subject: SL-12186 WIP Get rid of excessive offset settings as we moved to
 store data in xml

---
 indra/newview/app_settings/camera/Front.xml       |  4 +--
 indra/newview/app_settings/camera/Side.xml        |  4 +--
 indra/newview/llagentcamera.cpp                   | 37 +++------------------
 indra/newview/llagentcamera.h                     | 12 +++----
 indra/newview/llfloaterpreferenceviewadvanced.cpp |  4 +--
 indra/newview/llpresetsmanager.cpp                | 40 ++++-------------------
 indra/newview/llpresetsmanager.h                  |  1 -
 indra/newview/llviewermenu.cpp                    |  8 -----
 8 files changed, 21 insertions(+), 89 deletions(-)

diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
index a4b5ace33c..cb3380589e 100644
--- a/indra/newview/app_settings/camera/Front.xml
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -37,7 +37,7 @@
                 <real>6</real>
             </array>
         </map>
-    <key>CameraOffsetFrontView</key>
+    <key>CameraOffsetRearView</key>
         <map>
         <key>Comment</key>
             <string>Initial camera offset from avatar in Front View</string>
@@ -74,7 +74,7 @@
         <key>Value</key>
             <integer>0</integer>
         </map>
-    <key>FocusOffsetFrontView</key>
+    <key>FocusOffsetRearView</key>
         <map>
         <key>Comment</key>
             <string>Initial focus point offset relative to avatar for the camera preset Front View (x-axis is forward)</string>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
index 677fd47e20..49582a8a3c 100644
--- a/indra/newview/app_settings/camera/Side.xml
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -37,7 +37,7 @@
                 <real>6</real>
             </array>
         </map>
-    <key>CameraOffsetGroupView</key>
+    <key>CameraOffsetRearView</key>
         <map>
         <key>Comment</key>
             <string>Initial camera offset from avatar in Side View</string>
@@ -74,7 +74,7 @@
         <key>Value</key>
             <integer>0</integer>
         </map>
-    <key>FocusOffsetGroupView</key>
+    <key>FocusOffsetRearView</key>
         <map>
         <key>Comment</key>
             <string>Initial focus point offset relative to avatar for the camera preset Side View (x-axis is forward)</string>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 882e3cee55..285a1509cd 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -207,15 +207,8 @@ void LLAgentCamera::init()
 	
 	mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
 
-	mCameraOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("CameraOffsetRearView");
-	mCameraOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("CameraOffsetFrontView");
-	mCameraOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("CameraOffsetGroupView");
-	mCameraOffsetInitial[CAMERA_PRESET_CUSTOM] = gSavedSettings.getControl("CameraOffsetCustomPreset");
-
-	mFocusOffsetInitial[CAMERA_PRESET_REAR_VIEW] = gSavedSettings.getControl("FocusOffsetRearView");
-	mFocusOffsetInitial[CAMERA_PRESET_FRONT_VIEW] = gSavedSettings.getControl("FocusOffsetFrontView");
-	mFocusOffsetInitial[CAMERA_PRESET_GROUP_VIEW] = gSavedSettings.getControl("FocusOffsetGroupView");
-	mFocusOffsetInitial[CAMERA_PRESET_CUSTOM] = gSavedSettings.getControl("FocusOffsetCustomPreset");
+	mCameraOffsetInitial = gSavedSettings.getControl("CameraOffsetRearView");
+	mFocusOffsetInitial = gSavedSettings.getControl("FocusOffsetRearView");
 
 	mCameraCollidePlane.clearVec();
 	mCurrentCameraDistance = getCameraOffsetInitial().magVec() * gSavedSettings.getF32("CameraOffsetScale");
@@ -1603,7 +1596,7 @@ LLVector3d LLAgentCamera::calcThirdPersonFocusOffset()
 		agent_rot *= ((LLViewerObject*)(gAgentAvatarp->getParent()))->getRenderRotation();
 	}
 
-	focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
+	focus_offset = convert_from_llsd<LLVector3d>(mFocusOffsetInitial->get(), TYPE_VEC3D, "");
 	return focus_offset * agent_rot;
 }
 
@@ -1935,32 +1928,12 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 LLVector3 LLAgentCamera::getCameraOffsetInitial()
 {
-	return convert_from_llsd<LLVector3>(mCameraOffsetInitial[mCameraPreset]->get(), TYPE_VEC3, "");
+	return convert_from_llsd<LLVector3>(mCameraOffsetInitial->get(), TYPE_VEC3, "");
 }
 
 LLVector3d LLAgentCamera::getFocusOffsetInitial()
 {
-	return convert_from_llsd<LLVector3d>(mFocusOffsetInitial[mCameraPreset]->get(), TYPE_VEC3D, "");
-}
-
-std::string LLAgentCamera::getCameraOffsetCtrlName()
-{
-	return mCameraOffsetInitial[mCameraPreset]->getName();
-}
-
-std::string LLAgentCamera::getCameraOffsetCtrlName(ECameraPreset preset)
-{
-	return mCameraOffsetInitial[preset]->getName();
-}
-
-std::string LLAgentCamera::getFocusOffsetCtrlName()
-{
-	return mFocusOffsetInitial[mCameraPreset]->getName();
-}
-
-std::string LLAgentCamera::getFocusOffsetCtrlName(ECameraPreset preset)
-{
-	return mFocusOffsetInitial[preset]->getName();
+	return convert_from_llsd<LLVector3d>(mFocusOffsetInitial->get(), TYPE_VEC3D, "");
 }
 
 F32 LLAgentCamera::getCameraMaxZoomDistance()
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 5c8172bbfc..8a922bf678 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -117,10 +117,6 @@ public:
 	/** Determines default focus offset depending on the current camera preset */
 	LLVector3d getFocusOffsetInitial();
 
-	std::string getCameraOffsetCtrlName();
-	std::string getCameraOffsetCtrlName(ECameraPreset preset);
-	std::string getFocusOffsetCtrlName();
-	std::string getFocusOffsetCtrlName(ECameraPreset preset);
 private:
 	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
 	F32 getCameraMaxZoomDistance();
@@ -128,11 +124,11 @@ private:
 	/** Camera preset in Third Person Mode */
 	ECameraPreset mCameraPreset; 
 
-	/** Initial camera offsets */
-	std::map<ECameraPreset, LLPointer<LLControlVariable> > mCameraOffsetInitial;
+	/** Initial camera offset */
+	LLPointer<LLControlVariable> mCameraOffsetInitial;
 
-	/** Initial focus offsets */
-	std::map<ECameraPreset, LLPointer<LLControlVariable> > mFocusOffsetInitial;
+	/** Initial focus offset */
+	LLPointer<LLControlVariable> mFocusOffsetInitial;
 
 	//--------------------------------------------------------------------
 	// Position
diff --git a/indra/newview/llfloaterpreferenceviewadvanced.cpp b/indra/newview/llfloaterpreferenceviewadvanced.cpp
index 57484d0d0a..f8db738923 100644
--- a/indra/newview/llfloaterpreferenceviewadvanced.cpp
+++ b/indra/newview/llfloaterpreferenceviewadvanced.cpp
@@ -73,10 +73,10 @@ void LLFloaterPreferenceViewAdvanced::onCommitSettings()
 	vector.mV[VX] = (F32)getChild<LLUICtrl>("camera_x")->getValue().asReal();
 	vector.mV[VY] = (F32)getChild<LLUICtrl>("camera_y")->getValue().asReal();
 	vector.mV[VZ] = (F32)getChild<LLUICtrl>("camera_z")->getValue().asReal();
-	gSavedSettings.setVector3(gAgentCamera.getCameraOffsetCtrlName(), vector);
+	gSavedSettings.setVector3("CameraOffsetRearView", vector);
 
 	vector3d.mdV[VX] = (F32)getChild<LLUICtrl>("focus_x")->getValue().asReal();
 	vector3d.mdV[VY] = (F32)getChild<LLUICtrl>("focus_y")->getValue().asReal();
 	vector3d.mdV[VZ] = (F32)getChild<LLUICtrl>("focus_z")->getValue().asReal();
-	gSavedSettings.setVector3d(gAgentCamera.getFocusOffsetCtrlName(), vector3d);
+	gSavedSettings.setVector3d("FocusOffsetRearView", vector3d);
 }
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 71f0cd72d4..4f25e93ebd 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -102,7 +102,6 @@ void LLPresetsManager::startWatching(const std::string& subdirectory)
 	{
 		std::vector<std::string> name_list;
 		getControlNames(name_list);
-		getOffsetControlNames(name_list);
 
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
@@ -254,23 +253,10 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 		("CameraOffsetBuild")
 		("CameraOffsetScale")
 		("TrackFocusObject")
-        ;
-    names = camera_controls;
-}
-
-void LLPresetsManager::getOffsetControlNames(std::vector<std::string>& names)
-{
-	const std::vector<std::string> offset_controls = boost::assign::list_of
 		("CameraOffsetRearView")
-		("CameraOffsetFrontView")
-		("CameraOffsetGroupView")
-		("CameraOffsetCustomPreset")
 		("FocusOffsetRearView")
-		("FocusOffsetFrontView")
-		("FocusOffsetGroupView")
-		("FocusOffsetCustomPreset")
-		;
-	names.insert(std::end(names), std::begin(offset_controls), std::end(offset_controls));
+        ;
+    names = camera_controls;
 }
 
 bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string name, bool createDefault)
@@ -317,8 +303,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		name_list.clear();
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
-		name_list.push_back(gAgentCamera.getCameraOffsetCtrlName());
-		name_list.push_back(gAgentCamera.getFocusOffsetCtrlName());
 	}
 	else
 	{
@@ -368,18 +352,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
 			std::string ctrl_name = *it;
-			std::string dest_ctrl_name = ctrl_name;
-			if (IS_CAMERA && new_camera_offsets)
-			{
-				if (ctrl_name == gAgentCamera.getCameraOffsetCtrlName())
-				{
-					dest_ctrl_name = gAgentCamera.getCameraOffsetCtrlName(new_camera_preset);
-				}
-				if (ctrl_name == gAgentCamera.getFocusOffsetCtrlName())
-				{
-					dest_ctrl_name = gAgentCamera.getFocusOffsetCtrlName(new_camera_preset);
-				}
-			}
 
 			LLControlVariable* ctrl = gSavedSettings.getControl(ctrl_name).get();
 			if (ctrl)
@@ -388,10 +360,10 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 				std::string type = LLControlGroup::typeEnumToString(ctrl->type());
 				LLSD value = ctrl->getValue();
 
-				paramsData[dest_ctrl_name]["Comment"] = comment;
-				paramsData[dest_ctrl_name]["Persist"] = 1;
-				paramsData[dest_ctrl_name]["Type"] = type;
-				paramsData[dest_ctrl_name]["Value"] = value;
+				paramsData[ctrl_name]["Comment"] = comment;
+				paramsData[ctrl_name]["Persist"] = 1;
+				paramsData[ctrl_name]["Type"] = type;
+				paramsData[ctrl_name]["Value"] = value;
 			}
 		}
 		if (IS_CAMERA)
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index d489a0ad5a..09010413a9 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -97,7 +97,6 @@ public:
 	LOG_CLASS(LLPresetsManager);
 
 	void getControlNames(std::vector<std::string>& names);
-	void getOffsetControlNames(std::vector<std::string>& names);
 	static void settingChanged();
 
 	boost::signals2::connection	mCameraChangedSignal;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index c18d63d72b..7dfb6a6ac2 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -4109,14 +4109,6 @@ void handle_reset_view()
 		// switching to outfit selector should automagically save any currently edited wearable
 		LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "my_outfits"));
 	}
-	if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM)
-	{
-		gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM);
-	}
-	else
-	{
-		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
-	}
 	
 	reset_view_final( TRUE );
 	LLFloaterCamera::resetCameraMode();
-- 
cgit v1.2.3


From 16015cfb9f1e7d9983057e35c5ab41c92271b9a5 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Thu, 14 Nov 2019 17:51:58 +0200
Subject: SL-12186 Buildfix and update for creation of default presets

---
 indra/newview/app_settings/settings.xml   | 2 +-
 indra/newview/llfloatersaveprefpreset.cpp | 2 +-
 indra/newview/llstartup.cpp               | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 04ab620b3a..2fe5817772 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -16349,7 +16349,7 @@
     <key>Type</key>
     <string>String</string>
     <key>Value</key>
-    <string />
+    <string>Rear View</string>
   </map>
     <key>CefVerboseLog</key>
     <map>
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index c8d6513f4d..3142991704 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -112,7 +112,7 @@ void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 void LLFloaterSavePrefPreset::onBtnSave()
 {
 	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
-	std::string name = is_saving_new ? mNameEditor->getValue() : mPresetCombo->getSimple();
+	std::string name = is_saving_new ? mNameEditor->getText() : mPresetCombo->getSimple();
 
 	if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
 	{
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 6e0a36be49..8a5dbf317a 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -71,6 +71,7 @@
 #include "llnotifications.h"
 #include "llnotificationsutil.h"
 #include "llpersistentnotificationstorage.h"
+#include "llpresetsmanager.h"
 #include "llteleporthistory.h"
 #include "llregionhandle.h"
 #include "llsd.h"
@@ -1960,6 +1961,8 @@ bool idle_startup()
 		// JC - 7/20/2002
 		gViewerWindow->sendShapeToSim();
 
+		LLPresetsManager::getInstance()->createMissingDefault(PRESETS_CAMERA);
+
 		// The reason we show the alert is because we want to
 		// reduce confusion for when you log in and your provided
 		// location is not your expected location. So, if this is
-- 
cgit v1.2.3


From 26732bc576f86fde532e1f9448bd127515f70612 Mon Sep 17 00:00:00 2001
From: AndreyL ProductEngine <alihatskiy@productengine.com>
Date: Thu, 14 Nov 2019 23:43:52 +0200
Subject: Line endings fix

---
 .../default/xui/en/floater_camera_presets.xml      | 46 +++++++++++-----------
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/indra/newview/skins/default/xui/en/floater_camera_presets.xml b/indra/newview/skins/default/xui/en/floater_camera_presets.xml
index 0d9a6bb16a..930357f568 100644
--- a/indra/newview/skins/default/xui/en/floater_camera_presets.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera_presets.xml
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
-<floater
- legacy_header_height="18"
- can_resize="true"
- height="200"
- min_height="150"
- title="MY CAMERA PRESETS"
- layout="topleft"
- name="floater_camera_presets"
- single_instance="true"
- min_width="185"
- width="250">
-  <flat_list_view
-    allow_select="true"
-    follows="all"
-    height="165"
-    layout="topleft"
-    left="3"
-    multi_select="false"
-    name="preset_list"
-    top="20"
-    width="245" />
-  </floater>
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<floater
+ legacy_header_height="18"
+ can_resize="true"
+ height="200"
+ min_height="150"
+ title="MY CAMERA PRESETS"
+ layout="topleft"
+ name="floater_camera_presets"
+ single_instance="true"
+ min_width="185"
+ width="250">
+  <flat_list_view
+    allow_select="true"
+    follows="all"
+    height="165"
+    layout="topleft"
+    left="3"
+    multi_select="false"
+    name="preset_list"
+    top="20"
+    width="245" />
+  </floater>
-- 
cgit v1.2.3


From f21da58f05d70c44d810323a533f8b11c8fafb5e Mon Sep 17 00:00:00 2001
From: AndreyL ProductEngine <alihatskiy@productengine.com>
Date: Fri, 15 Nov 2019 01:47:20 +0200
Subject: Post-merge build fix

---
 indra/newview/llstatusbar.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp
index 359615d46a..3d31aa7003 100644
--- a/indra/newview/llstatusbar.cpp
+++ b/indra/newview/llstatusbar.cpp
@@ -513,8 +513,8 @@ void LLStatusBar::onMouseEnterPresetsCamera()
 	mPanelPresetsCameraPulldown->setShape(pulldown_rect);
 
 	// show the master presets pull-down
-	LLUI::clearPopups();
-	LLUI::addPopup(mPanelPresetsCameraPulldown);
+	LLUI::getInstance()->clearPopups();
+	LLUI::getInstance()->addPopup(mPanelPresetsCameraPulldown);
 	mPanelNearByMedia->setVisible(FALSE);
 	mPanelVolumePulldown->setVisible(FALSE);
 	mPanelPresetsPulldown->setVisible(FALSE);
-- 
cgit v1.2.3


From 3824624ab1df4eb8809ec31965f251cda74c8d23 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 15 Nov 2019 14:16:12 +0200
Subject: SL-12186 Correctly populate list after creating default presets

---
 indra/newview/llpresetsmanager.cpp | 16 +++++++++++-----
 indra/newview/llpresetsmanager.h   |  2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 4f25e93ebd..88b24265e3 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -91,9 +91,14 @@ void LLPresetsManager::createMissingDefault(const std::string& subdirectory)
 
 void LLPresetsManager::createCameraDefaultPresets()
 {
-	createDefaultCameraPreset(PRESETS_REAR_VIEW);
-	createDefaultCameraPreset(PRESETS_FRONT_VIEW);
-	createDefaultCameraPreset(PRESETS_SIDE_VIEW);
+	bool is_default_created = createDefaultCameraPreset(PRESETS_REAR_VIEW);
+	is_default_created |= createDefaultCameraPreset(PRESETS_FRONT_VIEW);
+	is_default_created |= createDefaultCameraPreset(PRESETS_SIDE_VIEW);
+
+	if (is_default_created)
+	{
+		triggerChangeCameraSignal();
+	}
 }
 
 void LLPresetsManager::startWatching(const std::string& subdirectory)
@@ -558,7 +563,7 @@ void LLPresetsManager::resetCameraPreset(std::string preset_name)
 	}
 }
 
-void LLPresetsManager::createDefaultCameraPreset(std::string preset_name, bool force_reset)
+bool LLPresetsManager::createDefaultCameraPreset(std::string preset_name, bool force_reset)
 {
 	std::string preset_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
 		PRESETS_CAMERA, LLURI::escape(preset_name) + ".xml");
@@ -567,8 +572,9 @@ void LLPresetsManager::createDefaultCameraPreset(std::string preset_name, bool f
 		std::string template_name = preset_name.substr(0, preset_name.size() - PRESETS_VIEW_SUFFIX.size());
 		std::string default_template_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
 			PRESETS_CAMERA, template_name + ".xml");
-		LLFile::copy(default_template_file, preset_file);
+		return LLFile::copy(default_template_file, preset_file);
 	}
+	return false;
 }
 
 boost::signals2::connection LLPresetsManager::setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb)
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index 09010413a9..d9ca178dd7 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -80,7 +80,7 @@ public:
 	bool isTemplateCameraPreset(std::string preset_name);
 	bool isDefaultCameraPreset(std::string preset_name);
 	void resetCameraPreset(std::string preset_name);
-	void createDefaultCameraPreset(std::string preset_name, bool force_reset = false);
+	bool createDefaultCameraPreset(std::string preset_name, bool force_reset = false);
 
 	// Emitted when a preset gets loaded, deleted, or saved.
 	boost::signals2::connection setPresetListChangeCameraCallback(const preset_list_signal_t::slot_type& cb);
-- 
cgit v1.2.3


From 716552a0c014455def500a669b916a68293187de Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 19 Nov 2019 11:55:02 +0200
Subject: SL-12186 Don't copy templates from app_settings directory, because
 it's excessive

---
 indra/newview/llpresetsmanager.cpp | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 88b24265e3..dda705eeca 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -138,26 +138,6 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 	if (!gDirUtilp->fileExists(dest_path))
 		LLFile::mkdir(dest_path);
 
-	if (PRESETS_CAMERA == subdirectory)
-	{
-		std::string source_dir = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA);
-		LLDirIterator dir_iter(source_dir, "*.xml");
-		bool found = true;
-		while (found)
-		{
-			std::string file;
-			found = dir_iter.next(file);
-
-			if (found)
-			{
-				std::string source = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, file);
-				file = LLURI::escape(file);
-				std::string dest = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR, PRESETS_CAMERA, file);
-				LLFile::copy(source, dest);
-			}
-		}
-	}
-
 	return dest_path;
 }
 
@@ -570,8 +550,7 @@ bool LLPresetsManager::createDefaultCameraPreset(std::string preset_name, bool f
 	if (!gDirUtilp->fileExists(preset_file) || force_reset)
 	{
 		std::string template_name = preset_name.substr(0, preset_name.size() - PRESETS_VIEW_SUFFIX.size());
-		std::string default_template_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PRESETS_DIR,
-			PRESETS_CAMERA, template_name + ".xml");
+		std::string default_template_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, PRESETS_CAMERA, template_name + ".xml");
 		return LLFile::copy(default_template_file, preset_file);
 	}
 	return false;
-- 
cgit v1.2.3


From f4d4fb2ad0927ebb8545bac1abd1b74918a006f5 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 22 Nov 2019 14:34:20 +0200
Subject: SL-12288 Enhancement for Rotate and Track camera controls

---
 indra/newview/llagentcamera.cpp                    |  58 ++++++++++++-
 indra/newview/llagentcamera.h                      |  13 ++-
 indra/newview/lljoystickbutton.cpp                 |  95 +++++++++++++++++----
 indra/newview/lljoystickbutton.h                   |   9 +-
 .../textures/bottomtray/Cam_Rotate_Center.png      | Bin 0 -> 10689 bytes
 .../textures/bottomtray/Cam_Tracking_Center.png    | Bin 0 -> 1714 bytes
 indra/newview/skins/default/textures/textures.xml  |   2 +
 7 files changed, 155 insertions(+), 22 deletions(-)
 create mode 100644 indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png
 create mode 100644 indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index e5fba7f28f..67b117657f 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -184,6 +184,9 @@ LLAgentCamera::LLAgentCamera() :
 	clearGeneralKeys();
 	clearOrbitKeys();
 	clearPanKeys();
+
+	resetPanDiff();
+	resetOrbitDiff();
 }
 
 // Requires gSavedSettings to be initialized.
@@ -343,7 +346,8 @@ void LLAgentCamera::resetView(BOOL reset_camera, BOOL change_camera)
 
 		mCameraFOVZoomFactor = 0.f;
 	}
-
+	resetPanDiff();
+	resetOrbitDiff();
 	mHUDTargetZoom = 1.f;
 }
 
@@ -822,6 +826,7 @@ void LLAgentCamera::cameraOrbitAround(const F32 radians)
 	}
 	else
 	{
+		mOrbitAroundRadians += radians;
 		mCameraFocusOffsetTarget.rotVec(radians, 0.f, 0.f, 1.f);
 		
 		cameraZoomIn(1.f);
@@ -853,12 +858,34 @@ void LLAgentCamera::cameraOrbitOver(const F32 angle)
 		LLVector3d left_axis;
 		left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
 		F32 new_angle = llclamp(angle_from_up - angle, 1.f * DEG_TO_RAD, 179.f * DEG_TO_RAD);
+		mOrbitOverAngle += angle_from_up - new_angle;
 		mCameraFocusOffsetTarget.rotVec(angle_from_up - new_angle, left_axis);
 
 		cameraZoomIn(1.f);
 	}
 }
 
+void LLAgentCamera::resetCameraOrbit()
+{
+	LLVector3 camera_offset_unit(mCameraFocusOffsetTarget);
+	camera_offset_unit.normalize();
+
+	LLVector3d left_axis;
+	left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
+	mCameraFocusOffsetTarget.rotVec(-mOrbitOverAngle, left_axis);
+	
+	mCameraFocusOffsetTarget.rotVec(-mOrbitAroundRadians, 0.f, 0.f, 1.f);
+
+	cameraZoomIn(1.f);
+	resetOrbitDiff();
+}
+
+void LLAgentCamera::resetOrbitDiff()
+{
+	mOrbitAroundRadians = 0;
+	mOrbitOverAngle = 0;
+}
+
 //-----------------------------------------------------------------------------
 // cameraZoomIn()
 //-----------------------------------------------------------------------------
@@ -997,6 +1024,8 @@ void LLAgentCamera::cameraPanIn(F32 meters)
 	LLVector3d at_axis;
 	at_axis.setVec(LLViewerCamera::getInstance()->getAtAxis());
 
+	mPanFocusDiff += meters * at_axis;
+
 	mFocusTargetGlobal += meters * at_axis;
 	mFocusGlobal = mFocusTargetGlobal;
 	// don't enforce zoom constraints as this is the only way for users to get past them easily
@@ -1013,6 +1042,8 @@ void LLAgentCamera::cameraPanLeft(F32 meters)
 	LLVector3d left_axis;
 	left_axis.setVec(LLViewerCamera::getInstance()->getLeftAxis());
 
+	mPanFocusDiff += meters * left_axis;
+
 	mFocusTargetGlobal += meters * left_axis;
 	mFocusGlobal = mFocusTargetGlobal;
 
@@ -1033,6 +1064,8 @@ void LLAgentCamera::cameraPanUp(F32 meters)
 	LLVector3d up_axis;
 	up_axis.setVec(LLViewerCamera::getInstance()->getUpAxis());
 
+	mPanFocusDiff += meters * up_axis;
+
 	mFocusTargetGlobal += meters * up_axis;
 	mFocusGlobal = mFocusTargetGlobal;
 
@@ -1045,6 +1078,26 @@ void LLAgentCamera::cameraPanUp(F32 meters)
 	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
 }
 
+void LLAgentCamera::resetCameraPan()
+{
+	mFocusTargetGlobal -= mPanFocusDiff;
+
+	mFocusGlobal = mFocusTargetGlobal;
+	mCameraSmoothingStop = true;
+
+	cameraZoomIn(1.f);
+	updateFocusOffset();
+
+	mCameraSmoothingLastPositionGlobal = calcCameraPositionTargetGlobal();
+
+	resetPanDiff();
+}
+
+void LLAgentCamera::resetPanDiff()
+{
+	mPanFocusDiff.clear();
+}
+
 //-----------------------------------------------------------------------------
 // updateLookAt()
 //-----------------------------------------------------------------------------
@@ -2330,6 +2383,9 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset)
 
 	mCameraPreset = preset;
 
+	resetPanDiff();
+	resetOrbitDiff();
+
 	gSavedSettings.setU32("CameraPreset", mCameraPreset);
 }
 
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 8a922bf678..0608507d1a 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -262,7 +262,8 @@ public:
 	void			cameraOrbitAround(const F32 radians);	// Rotate camera CCW radians about build focus point
 	void			cameraOrbitOver(const F32 radians);		// Rotate camera forward radians over build focus point
 	void			cameraOrbitIn(const F32 meters);		// Move camera in toward build focus point
-
+	void			resetCameraOrbit();
+	void			resetOrbitDiff();
 	//--------------------------------------------------------------------
 	// Zoom
 	//--------------------------------------------------------------------
@@ -279,8 +280,9 @@ public:
 public:
 	void			cameraPanIn(const F32 meters);
 	void			cameraPanLeft(const F32 meters);
-	void			cameraPanUp(const F32 meters);
-	
+	void			cameraPanUp(const F32 meters);	
+	void			resetCameraPan();
+	void			resetPanDiff();
 	//--------------------------------------------------------------------
 	// View
 	//--------------------------------------------------------------------
@@ -367,6 +369,9 @@ private:
 	F32				mOrbitInKey;
 	F32				mOrbitOutKey;
 
+	F32				mOrbitAroundRadians;
+	F32				mOrbitOverAngle;
+
 	//--------------------------------------------------------------------
 	// Pan
 	//--------------------------------------------------------------------
@@ -394,6 +399,8 @@ private:
 	F32				mPanInKey;
 	F32				mPanOutKey;
 
+	LLVector3d		mPanFocusDiff;
+
 /**                    Keys
  **                                                                            **
  *******************************************************************************/
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp
index 59e14e6cc0..eb4e4f4100 100644
--- a/indra/newview/lljoystickbutton.cpp
+++ b/indra/newview/lljoystickbutton.cpp
@@ -37,6 +37,7 @@
 #include "llui.h"
 #include "llagent.h"
 #include "llagentcamera.h"
+#include "llviewercamera.h"
 #include "llviewertexture.h"
 #include "llviewertexturelist.h"
 #include "llviewerwindow.h"
@@ -54,6 +55,8 @@ static LLDefaultChildRegistry::Register<LLJoystickCameraTrack> r5("joystick_trac
 const F32 NUDGE_TIME = 0.25f;		// in seconds
 const F32 ORBIT_NUDGE_RATE = 0.05f; // fraction of normal speed
 
+const S32 CENTER_DOT_RADIUS = 7;
+
 //
 // Public Methods
 //
@@ -138,9 +141,25 @@ bool LLJoystick::pointInCircle(S32 x, S32 y) const
 	//center is x and y coordinates of center of joystick circle, and also its radius
 	int center = this->getLocalRect().getHeight()/2;
 	bool in_circle = (x - center) * (x - center) + (y - center) * (y - center) <= center * center;
+	
 	return in_circle;
 }
 
+bool LLJoystick::pointInCenterDot(S32 x, S32 y, S32 radius) const
+{
+	if (this->getLocalRect().getHeight() != this->getLocalRect().getWidth())
+	{
+		LL_WARNS() << "Joystick shape is not square" << LL_ENDL;
+		return true;
+	}
+
+	S32 center = this->getLocalRect().getHeight() / 2;
+
+	bool in_center_circle = (x - center) * (x - center) + (y - center) * (y - center) <= radius * radius;
+
+	return in_center_circle;
+}
+
 BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask)
 {
 	//LL_INFOS() << "joystick mouse down " << x << ", " << y << LL_ENDL;
@@ -403,8 +422,11 @@ LLJoystickCameraRotate::LLJoystickCameraRotate(const LLJoystickCameraRotate::Par
 	mInLeft( FALSE ),
 	mInTop( FALSE ),
 	mInRight( FALSE ),
-	mInBottom( FALSE )
-{ }
+	mInBottom( FALSE ),
+	mInCenter( FALSE )
+{ 
+	mCenterImageName = "Cam_Rotate_Center";
+}
 
 
 void LLJoystickCameraRotate::updateSlop()
@@ -434,7 +456,16 @@ BOOL LLJoystickCameraRotate::handleMouseDown(S32 x, S32 y, MASK mask)
 	S32 dx = x - horiz_center;
 	S32 dy = y - vert_center;
 
-	if (dy > dx && dy > -dx)
+	if (pointInCenterDot(x, y, CENTER_DOT_RADIUS))
+	{
+		mInitialOffset.mX = 0;
+		mInitialOffset.mY = 0;
+		mInitialQuadrant = JQ_ORIGIN;
+		mInCenter = TRUE;
+
+		resetJoystickCamera();
+	}
+	else if (dy > dx && dy > -dx)
 	{
 		// top
 		mInitialOffset.mX = 0;
@@ -469,9 +500,20 @@ BOOL LLJoystickCameraRotate::handleMouseDown(S32 x, S32 y, MASK mask)
 BOOL LLJoystickCameraRotate::handleMouseUp(S32 x, S32 y, MASK mask)
 {
 	gAgent.setMovementLocked(FALSE);
+	mInCenter = FALSE;
 	return LLJoystick::handleMouseUp(x, y, mask);
 }
 
+BOOL LLJoystickCameraRotate::handleHover(S32 x, S32 y, MASK mask)
+{
+	if (!pointInCenterDot(x, y, CENTER_DOT_RADIUS))
+	{
+		mInCenter = FALSE;
+	}
+
+	return LLJoystick::handleHover(x, y, mask);
+}
+
 void LLJoystickCameraRotate::onHeldDown()
 {
 	updateSlop();
@@ -504,6 +546,11 @@ void LLJoystickCameraRotate::onHeldDown()
 	}
 }
 
+void LLJoystickCameraRotate::resetJoystickCamera()
+{
+	gAgentCamera.resetCameraOrbit();
+}
+
 F32 LLJoystickCameraRotate::getOrbitRate()
 {
 	F32 time = getElapsedHeldDownTime();
@@ -536,24 +583,31 @@ void LLJoystickCameraRotate::draw()
 	getImageUnselected()->draw( 0, 0 );
 	LLPointer<LLUIImage> image = getImageSelected();
 
-	if( mInTop )
+	if (mInCenter)
 	{
-		drawRotatedImage( getImageSelected(), 0 );
+		drawRotatedImage(LLUI::getUIImage(mCenterImageName), 0);
 	}
-
-	if( mInRight )
+	else
 	{
-		drawRotatedImage( getImageSelected(), 1 );
-	}
+		if (mInTop)
+		{
+			drawRotatedImage(getImageSelected(), 0);
+		}
 
-	if( mInBottom )
-	{
-		drawRotatedImage( getImageSelected(), 2 );
-	}
+		if (mInRight)
+		{
+			drawRotatedImage(getImageSelected(), 1);
+		}
 
-	if( mInLeft )
-	{
-		drawRotatedImage( getImageSelected(), 3 );
+		if (mInBottom)
+		{
+			drawRotatedImage(getImageSelected(), 2);
+		}
+
+		if (mInLeft)
+		{
+			drawRotatedImage(getImageSelected(), 3);
+		}
 	}
 }
 
@@ -613,7 +667,9 @@ LLJoystickCameraTrack::Params::Params()
 
 LLJoystickCameraTrack::LLJoystickCameraTrack(const LLJoystickCameraTrack::Params& p)
 :	LLJoystickCameraRotate(p)
-{}
+{
+	mCenterImageName = "Cam_Tracking_Center";
+}
 
 
 void LLJoystickCameraTrack::onHeldDown()
@@ -646,3 +702,8 @@ void LLJoystickCameraTrack::onHeldDown()
 		gAgentCamera.setPanDownKey(getOrbitRate());
 	}
 }
+
+void LLJoystickCameraTrack::resetJoystickCamera()
+{
+	gAgentCamera.resetCameraPan();
+}
diff --git a/indra/newview/lljoystickbutton.h b/indra/newview/lljoystickbutton.h
index 4e6c774cad..3e29215f61 100644
--- a/indra/newview/lljoystickbutton.h
+++ b/indra/newview/lljoystickbutton.h
@@ -79,7 +79,8 @@ public:
 	 * Image containing circle is square and this square has adherent points with joystick
 	 * circle. Make sure to change method according to shape other than square. 
 	 */
-	bool			pointInCircle(S32 x, S32 y) const;
+	bool	pointInCircle(S32 x, S32 y) const;
+	bool	pointInCenterDot(S32 x, S32 y, S32 radius) const;
 	
 	static std::string nameFromQuadrant(const EJoystickQuadrant quadrant);
 	static EJoystickQuadrant quadrantFromName(const std::string& name);
@@ -147,7 +148,9 @@ public:
 
 	virtual BOOL	handleMouseDown(S32 x, S32 y, MASK mask);
 	virtual BOOL	handleMouseUp(S32 x, S32 y, MASK mask);
+	virtual BOOL	handleHover(S32 x, S32 y, MASK mask);
 	virtual void	onHeldDown();
+	virtual void	resetJoystickCamera();
 	virtual void	draw();
 
 protected:
@@ -160,6 +163,9 @@ protected:
 	BOOL			mInTop;
 	BOOL			mInRight;
 	BOOL			mInBottom;
+	BOOL			mInCenter;
+
+	std::string		mCenterImageName;
 };
 
 
@@ -176,6 +182,7 @@ public:
 
 	LLJoystickCameraTrack(const LLJoystickCameraTrack::Params&);
 	virtual void	onHeldDown();
+	virtual void	resetJoystickCamera();
 };
 
 #endif  // LL_LLJOYSTICKBUTTON_H
diff --git a/indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png b/indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png
new file mode 100644
index 0000000000..ffc3c85ea2
Binary files /dev/null and b/indra/newview/skins/default/textures/bottomtray/Cam_Rotate_Center.png differ
diff --git a/indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png b/indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png
new file mode 100644
index 0000000000..2812d614e6
Binary files /dev/null and b/indra/newview/skins/default/textures/bottomtray/Cam_Tracking_Center.png differ
diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml
index b086f7dfa8..2a4171f11b 100644
--- a/indra/newview/skins/default/textures/textures.xml
+++ b/indra/newview/skins/default/textures/textures.xml
@@ -113,8 +113,10 @@ with the same filename but different name
 
   <texture name="Cam_Rotate_In" file_name="bottomtray/Cam_Rotate_In.png" preload="false" />
   <texture name="Cam_Rotate_Out" file_name="bottomtray/Cam_Rotate_Out.png" preload="false" />
+  <texture name="Cam_Rotate_Center" file_name="bottomtray/Cam_Rotate_Center.png" preload="false" />
   <texture name="Cam_Tracking_In" file_name="bottomtray/Cam_Tracking_In.png" preload="false" />
   <texture name="Cam_Tracking_Out" file_name="bottomtray/Cam_Tracking_Out.png" preload="false" />
+  <texture name="Cam_Tracking_Center" file_name="bottomtray/Cam_Tracking_Center.png" preload="false" />
 
   <texture name="Checkbox_Off_Disabled" file_name="widgets/Checkbox_Disabled.png" preload="true" />
   <texture name="Checkbox_On_Disabled" file_name="widgets/Checkbox_On_Disabled.png" preload="true" />
-- 
cgit v1.2.3


From 8d94e2af12aaf3cdb170a0b36e9ae36e91a2365d Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 26 Nov 2019 17:36:14 +0200
Subject: SL-12186 Update camera controls if preset was selected from the
 pulldown menu

---
 indra/newview/llfloatercamera.cpp                  | 45 +++++++++++++---------
 indra/newview/llpanelpresetscamerapulldown.cpp     |  3 +-
 .../skins/default/xui/en/floater_camera.xml        |  6 +--
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index c7eb60e186..d3c1ba764b 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -524,7 +524,11 @@ void LLFloaterCamera::onClickCameraItem(const LLSD& param)
 	{
 		LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
 		if (camera_floater)
-		camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+		{
+			camera_floater->switchMode(CAMERA_CTRL_MODE_FREE_CAMERA);
+			camera_floater->updateItemsSelection();
+			camera_floater->fromFreeToPresets();
+		}
 	}
 	else
 	{
@@ -533,13 +537,6 @@ void LLFloaterCamera::onClickCameraItem(const LLSD& param)
 			camera_floater->switchMode(CAMERA_CTRL_MODE_PAN);
 		switchToPreset(name);
 	}
-
-	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
-	if (camera_floater)
-	{
-		camera_floater->updateItemsSelection();
-		camera_floater->fromFreeToPresets();
-	}
 }
 
 /*static*/
@@ -547,20 +544,33 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 {
 	sFreeCamera = false;
 	clear_camera_tool();
-	if ("rear_view" == name)
+	if (PRESETS_REAR_VIEW == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_REAR_VIEW);
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_REAR_VIEW);
 	}
-	else if ("group_view" == name)
+	else if (PRESETS_SIDE_VIEW == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_GROUP_VIEW);
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_SIDE_VIEW);
 	}
-	else if ("front_view" == name)
+	else if (PRESETS_FRONT_VIEW == name)
 	{
 		gAgentCamera.switchCameraPreset(CAMERA_PRESET_FRONT_VIEW);
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, PRESETS_FRONT_VIEW);
+	}
+	else
+	{
+		gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM);
+	}
+	
+	if (gSavedSettings.getString("PresetCameraActive") != name)
+	{
+		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
+	}
+
+	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
+	if (camera_floater)
+	{
+		camera_floater->updateItemsSelection();
+		camera_floater->fromFreeToPresets();
 	}
 }
 
@@ -609,11 +619,8 @@ void LLFloaterCamera::onSavePreset()
 void LLFloaterCamera::onCustomPresetSelected()
 {
 	std::string selected_preset = mPresetCombo->getSelectedItemLabel();
-	if (gSavedSettings.getString("PresetCameraActive") != selected_preset && getString("inactive_combo_text") != selected_preset)
+	if (getString("inactive_combo_text") != selected_preset)
 	{
-		gAgentCamera.switchCameraPreset(CAMERA_PRESET_CUSTOM);
-		updateItemsSelection();
-		fromFreeToPresets();
-		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, selected_preset);
+		switchToPreset(selected_preset);
 	}
 }
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index 1ac105e1c8..ae3d182f09 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -33,6 +33,7 @@
 
 #include "llbutton.h"
 #include "lltabcontainer.h"
+#include "llfloatercamera.h"
 #include "llfloaterreg.h"
 #include "llfloaterpreference.h"
 #include "llpresetsmanager.h"
@@ -185,7 +186,7 @@ void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
 			std::string name = item->getColumn(1)->getValue().asString();
 
             LL_DEBUGS() << "selected '" << name << "'" << LL_ENDL;
-			LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
+			LLFloaterCamera::switchToPreset(name);
 
 			setVisible(FALSE);
 		}
diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 9408e68c2d..60461c5743 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -151,7 +151,7 @@
       width="30">
       <panel_camera_item.mousedown_callback
         function="CameraPresets.ChangeView"
-        parameter="front_view" />
+        parameter="Front View" />
       <panel_camera_item.picture
         image_name="Cam_Preset_Front_Off" />
       <panel_camera_item.selected_picture
@@ -164,7 +164,7 @@
       left_pad="4">
       <panel_camera_item.mousedown_callback
         function="CameraPresets.ChangeView"
-        parameter="group_view" />
+        parameter="Side View" />
       <panel_camera_item.picture
         image_name="Cam_Preset_Side_Off" />
       <panel_camera_item.selected_picture
@@ -178,7 +178,7 @@
       <panel_camera_item.mousedown_callback
         function="CameraPresets.ChangeView"
         tool_tip="Rear View"
-        parameter="rear_view" />
+        parameter="Rear View" />
       <panel_camera_item.picture
         image_name="Cam_Preset_Back_Off" />
       <panel_camera_item.selected_picture
-- 
cgit v1.2.3


From 5f86203f261b376ad74814e1e635dba077c7718b Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 10 Dec 2019 15:44:01 +0200
Subject: SL-12429 Use different setting name to prevent crash on old viewer

---
 indra/newview/app_settings/settings.xml | 15 +++++++++++++--
 indra/newview/llagentcamera.cpp         |  4 ++--
 indra/newview/llfloatercamera.cpp       |  6 +++---
 indra/newview/llpresetsmanager.cpp      |  6 +++---
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 2fe5817772..86c3e6cf3f 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1562,10 +1562,10 @@
       <key>Value</key>
       <real>1.0</real>
     </map>
-    <key>CameraPreset</key>
+    <key>CameraPreset</key>  <!-- deprecated (see SL-12429) -->
     <map>
       <key>Comment</key>
-      <string>Preset camera position - view (0 - rear, 1 - front, 2 - group, 3 - custom)</string>
+      <string>Preset camera position - view (0 - rear, 1 - front, 2 - group)</string>
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
@@ -16351,6 +16351,17 @@
     <key>Value</key>
     <string>Rear View</string>
   </map>
+  <key>CameraPresetType</key>
+  <map>
+    <key>Comment</key>
+    <string>Preset camera position - view (0 - rear, 1 - front, 2 - group, 3 - custom)</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>U32</string>
+    <key>Value</key>
+    <integer>0</integer>
+   </map>
     <key>CefVerboseLog</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 67b117657f..eb730d105d 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -208,7 +208,7 @@ void LLAgentCamera::init()
 
 	mCameraFocusOffsetTarget = LLVector4(gSavedSettings.getVector3("CameraOffsetBuild"));
 	
-	mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
+	mCameraPreset = (ECameraPreset) gSavedSettings.getU32("CameraPresetType");
 
 	mCameraOffsetInitial = gSavedSettings.getControl("CameraOffsetRearView");
 	mFocusOffsetInitial = gSavedSettings.getControl("FocusOffsetRearView");
@@ -2386,7 +2386,7 @@ void LLAgentCamera::switchCameraPreset(ECameraPreset preset)
 	resetPanDiff();
 	resetOrbitDiff();
 
-	gSavedSettings.setU32("CameraPreset", mCameraPreset);
+	gSavedSettings.setU32("CameraPresetType", mCameraPreset);
 }
 
 
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index d3c1ba764b..7e538d1bfc 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -498,7 +498,7 @@ void LLFloaterCamera::updateState()
 
 void LLFloaterCamera::updateItemsSelection()
 {
-	ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPreset");
+	ECameraPreset preset = (ECameraPreset) gSavedSettings.getU32("CameraPresetType");
 	LLSD argument;
 	argument["selected"] = (preset == CAMERA_PRESET_REAR_VIEW) && !sFreeCamera;
 	getChild<LLPanelCameraItem>("rear_view")->setValue(argument);
@@ -588,11 +588,11 @@ void LLFloaterCamera::populatePresetCombo()
 	std::string active_preset_name = gSavedSettings.getString("PresetCameraActive");
 	if (active_preset_name.empty())
 	{
-		gSavedSettings.setU32("CameraPreset", CAMERA_PRESET_CUSTOM);
+		gSavedSettings.setU32("CameraPresetType", CAMERA_PRESET_CUSTOM);
 		updateItemsSelection();
 		mPresetCombo->setLabel(getString("inactive_combo_text"));
 	}
-	else if ((ECameraPreset)gSavedSettings.getU32("CameraPreset") == CAMERA_PRESET_CUSTOM)
+	else if ((ECameraPreset)gSavedSettings.getU32("CameraPresetType") == CAMERA_PRESET_CUSTOM)
 	{
 		mPresetCombo->selectByValue(active_preset_name);
 	}
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index dda705eeca..c4161ed1bc 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -309,7 +309,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 	}
 	else
 	{
-		ECameraPreset new_camera_preset = (ECameraPreset)gSavedSettings.getU32("CameraPreset");
+		ECameraPreset new_camera_preset = (ECameraPreset)gSavedSettings.getU32("CameraPresetType");
 		bool new_camera_offsets = false;
 		if (IS_CAMERA)
 		{
@@ -332,7 +332,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 			{
 				new_camera_preset = CAMERA_PRESET_CUSTOM;
 			}
-			new_camera_offsets = (!isDefaultCameraPreset(name) || (ECameraPreset)gSavedSettings.getU32("CameraPreset") != new_camera_preset);
+			new_camera_offsets = (!isDefaultCameraPreset(name) || (ECameraPreset)gSavedSettings.getU32("CameraPresetType") != new_camera_preset);
 		}
 		for (std::vector<std::string>::iterator it = name_list.begin(); it != name_list.end(); ++it)
 		{
@@ -353,7 +353,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		}
 		if (IS_CAMERA)
 		{
-			gSavedSettings.setU32("CameraPreset", new_camera_preset);
+			gSavedSettings.setU32("CameraPresetType", new_camera_preset);
 		}
 	}
 
-- 
cgit v1.2.3


From abd5277a7b3dac90e8a555eefe855cfcca1536dc Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Wed, 18 Dec 2019 11:26:22 +0200
Subject: SL-12424 WIP Save mousewheel zoom fraction in preset

---
 indra/newview/app_settings/camera/Front.xml | 11 +++++++++++
 indra/newview/app_settings/camera/Rear.xml  | 11 +++++++++++
 indra/newview/app_settings/camera/Side.xml  | 11 +++++++++++
 indra/newview/app_settings/settings.xml     | 11 +++++++++++
 indra/newview/llfloatercamera.cpp           |  1 +
 indra/newview/llpresetsmanager.cpp          |  4 +++-
 6 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
index cb3380589e..e4839d48ec 100644
--- a/indra/newview/app_settings/camera/Front.xml
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -63,6 +63,17 @@
         <key>Value</key>
             <real>1</real>
         </map>
+    <key>CameraZoomFraction</key>
+        <map>
+        <key>Comment</key>
+            <string>Mousewheel driven fraction of zoom</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>0.9</real>
+        </map>
     <key>EditCameraMovement</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml
index 0bfe5a9ed8..72e6c5d93a 100644
--- a/indra/newview/app_settings/camera/Rear.xml
+++ b/indra/newview/app_settings/camera/Rear.xml
@@ -63,6 +63,17 @@
         <key>Value</key>
             <real>1</real>
         </map>
+    <key>CameraZoomFraction</key>
+        <map>
+        <key>Comment</key>
+            <string>Mousewheel driven fraction of zoom</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>0.9</real>
+        </map>
     <key>EditCameraMovement</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
index 49582a8a3c..eb3b3253c1 100644
--- a/indra/newview/app_settings/camera/Side.xml
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -63,6 +63,17 @@
         <key>Value</key>
             <real>1</real>
         </map>
+    <key>CameraZoomFraction</key>
+        <map>
+        <key>Comment</key>
+            <string>Mousewheel driven fraction of zoom</string>
+        <key>Persist</key>
+            <integer>1</integer>
+        <key>Type</key>
+            <string>F32</string>
+        <key>Value</key>
+            <real>0.9</real>
+        </map>
     <key>EditCameraMovement</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5be89c92a8..93a3c29530 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1525,6 +1525,17 @@
       <key>Value</key>
       <real>1.0</real>
     </map>
+    <key>CameraZoomFraction</key>
+    <map>
+      <key>Comment</key>
+      <string>Mousewheel driven fraction of zoom</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>F32</string>
+      <key>Value</key>
+      <real>0.9</real>
+    </map>
     <key>CameraPosOnLogout</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 7e538d1bfc..f45033aa20 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -565,6 +565,7 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 	{
 		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
 	}
+	gAgentCamera.setCameraZoomFraction(gSavedSettings.getF32("CameraZoomFraction"));
 
 	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
 	if (camera_floater)
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index c4161ed1bc..73978e9dfb 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -236,7 +236,6 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 		("AppearanceCameraMovement")
 		// From llagentcamera.cpp
 		("CameraOffsetBuild")
-		("CameraOffsetScale")
 		("TrackFocusObject")
 		("CameraOffsetRearView")
 		("FocusOffsetRearView")
@@ -288,6 +287,9 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		name_list.clear();
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
+
+		gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction());
+		name_list.push_back("CameraZoomFraction");
 	}
 	else
 	{
-- 
cgit v1.2.3


From a2f0fd64e947f96305200edbdfd496529cadb90e Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Wed, 8 Jan 2020 18:14:21 +0200
Subject: SL-12510 Revert changes and separate 'Save Graphic Preset' floater

---
 indra/newview/CMakeLists.txt                       |   2 +
 indra/newview/llfloatercamera.cpp                  |   3 +-
 indra/newview/llfloatersavecamerapreset.cpp        | 153 +++++++++++++++++++++
 indra/newview/llfloatersavecamerapreset.h          |  60 ++++++++
 indra/newview/llfloatersaveprefpreset.cpp          |  97 +++----------
 indra/newview/llfloatersaveprefpreset.h            |  12 +-
 indra/newview/llpresetsmanager.cpp                 |   2 +-
 indra/newview/llviewerfloaterreg.cpp               |   2 +
 .../default/xui/en/floater_save_camera_preset.xml  |  70 ++++++++++
 .../default/xui/en/floater_save_pref_preset.xml    |  72 ++++------
 10 files changed, 335 insertions(+), 138 deletions(-)
 create mode 100644 indra/newview/llfloatersavecamerapreset.cpp
 create mode 100644 indra/newview/llfloatersavecamerapreset.h
 create mode 100644 indra/newview/skins/default/xui/en/floater_save_camera_preset.xml

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 6472b464d8..8016ce496a 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -296,6 +296,7 @@ set(viewer_SOURCE_FILES
     llfloaterregioninfo.cpp
     llfloaterreporter.cpp
     llfloaterregionrestarting.cpp
+    llfloatersavecamerapreset.cpp
     llfloatersaveprefpreset.cpp
     llfloatersceneloadstats.cpp
     llfloaterscriptdebug.cpp
@@ -923,6 +924,7 @@ set(viewer_HEADER_FILES
     llfloaterregioninfo.h
     llfloaterreporter.h
     llfloaterregionrestarting.h
+    llfloatersavecamerapreset.h
     llfloatersaveprefpreset.h
     llfloatersceneloadstats.h
     llfloaterscriptdebug.h
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index f45033aa20..860005bfbe 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -610,11 +610,10 @@ void LLFloaterCamera::onSavePreset()
 	LLFloaterReg::hideInstance("load_pref_preset", PRESETS_CAMERA);
 	
 	LLSD key;
-	key["subdirectory"] = PRESETS_CAMERA;
 	std::string current_preset = gSavedSettings.getString("PresetCameraActive");
 	bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultCameraPreset(current_preset);
 	key["index"] = is_custom_preset ? 1 : 0;
-	LLFloaterReg::showInstance("save_pref_preset", key);
+	LLFloaterReg::showInstance("save_camera_preset", key);
 }
 
 void LLFloaterCamera::onCustomPresetSelected()
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
new file mode 100644
index 0000000000..b1c9e561f7
--- /dev/null
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -0,0 +1,153 @@
+/** 
+ * @file llfloatersavecamerapreset.cpp
+ * @brief Floater to save a camera preset
+ *
+ * $LicenseInfo:firstyear=2020&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2020, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "LLFloaterSaveCameraPreset.h"
+
+#include "llbutton.h"
+#include "llcombobox.h"
+#include "llfloaterpreference.h"
+#include "llfloaterreg.h"
+#include "lllineeditor.h"
+#include "llnotificationsutil.h"
+#include "llpresetsmanager.h"
+#include "llradiogroup.h"
+#include "lltrans.h"
+
+LLFloaterSaveCameraPreset::LLFloaterSaveCameraPreset(const LLSD &key)
+	: LLModalDialog(key)
+{
+}
+
+// virtual
+BOOL LLFloaterSaveCameraPreset::postBuild()
+{
+	mPresetCombo = getChild<LLComboBox>("preset_combo");
+
+	mNameEditor = getChild<LLLineEditor>("preset_txt_editor");
+	mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSaveCameraPreset::onPresetNameEdited, this), NULL);
+
+	mSaveButton = getChild<LLButton>("save");
+	mSaveButton->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onBtnSave, this));
+	
+	mSaveRadioGroup = getChild<LLRadioGroup>("radio_save_preset");
+	mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onSwitchSaveReplace, this));
+	
+	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSaveCameraPreset::onBtnCancel, this));
+
+	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSaveCameraPreset::onPresetsListChange, this));
+
+	return TRUE;
+}
+
+void LLFloaterSaveCameraPreset::onPresetNameEdited()
+{
+	if (mSaveRadioGroup->getSelectedIndex() == 0)
+	{
+		// Disable saving a preset having empty name.
+		std::string name = mNameEditor->getValue();
+		mSaveButton->setEnabled(!name.empty());
+	}
+}
+
+void LLFloaterSaveCameraPreset::onOpen(const LLSD& key)
+{
+	LLModalDialog::onOpen(key);
+	S32 index = 0;
+	if (key.has("index"))
+	{
+		index = key["index"].asInteger();
+	}
+
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_HIDE);
+
+	mSaveRadioGroup->setSelectedIndex(index);
+	onPresetNameEdited();
+	onSwitchSaveReplace();
+}
+
+void LLFloaterSaveCameraPreset::onBtnSave()
+{
+	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
+	std::string name = is_saving_new ? mNameEditor->getText() : mPresetCombo->getSimple();
+
+	if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
+	{
+		LLNotificationsUtil::add("DefaultPresetNotSaved");
+	}
+	else 
+	{
+		if (is_saving_new)
+		{
+			std::list<std::string> preset_names;
+			std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
+			LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE);
+			if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end())
+			{
+				LLSD args;
+				args["NAME"] = name;
+				LLNotificationsUtil::add("PresetAlreadyExists", args);
+				return;
+			}
+		}
+		if (!LLPresetsManager::getInstance()->savePreset(PRESETS_CAMERA, name))
+		{
+			LLSD args;
+			args["NAME"] = name;
+			LLNotificationsUtil::add("PresetNotSaved", args);
+		}
+	}
+
+	closeFloater();
+}
+
+void LLFloaterSaveCameraPreset::onPresetsListChange()
+{
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_HIDE);
+}
+
+void LLFloaterSaveCameraPreset::onBtnCancel()
+{
+	closeFloater();
+}
+
+void LLFloaterSaveCameraPreset::onSwitchSaveReplace()
+{
+	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
+	std::string label = is_saving_new ? getString("btn_label_save") : getString("btn_label_replace");
+	mSaveButton->setLabel(label);
+	mNameEditor->setEnabled(is_saving_new);
+	mPresetCombo->setEnabled(!is_saving_new);
+	if (is_saving_new)
+	{
+		onPresetNameEdited();
+	}
+	else
+	{
+		mSaveButton->setEnabled(true);
+	}
+}
diff --git a/indra/newview/llfloatersavecamerapreset.h b/indra/newview/llfloatersavecamerapreset.h
new file mode 100644
index 0000000000..282f213438
--- /dev/null
+++ b/indra/newview/llfloatersavecamerapreset.h
@@ -0,0 +1,60 @@
+/** 
+ * @file llfloatersavecamerapreset.h
+ * @brief Floater to save a camera preset
+
+ *
+ * $LicenseInfo:firstyear=2020&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2020, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLFLOATERSAVECAMERAPRESET_H
+#define LL_LLFLOATERSAVECAMERAPRESET_H
+
+#include "llmodaldialog.h"
+
+class LLComboBox;
+class LLRadioGroup;
+class LLLineEditor;
+
+class LLFloaterSaveCameraPreset : public LLModalDialog
+{
+
+public:
+	LLFloaterSaveCameraPreset(const LLSD &key);
+
+	/*virtual*/	BOOL	postBuild();
+	/*virtual*/ void	onOpen(const LLSD& key);
+
+	void onBtnSave();
+	void onBtnCancel();
+	void onSwitchSaveReplace();
+
+private:
+	LLRadioGroup*	mSaveRadioGroup;
+	LLLineEditor*	mNameEditor;
+	LLComboBox*		mPresetCombo;
+	LLButton*		mSaveButton;
+
+	void onPresetsListChange();
+	void onPresetNameEdited();
+};
+
+#endif // LL_LLFLOATERSAVECAMERAPRESET_H
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp
index 3142991704..5f3cf9d95b 100644
--- a/indra/newview/llfloatersaveprefpreset.cpp
+++ b/indra/newview/llfloatersaveprefpreset.cpp
@@ -1,6 +1,6 @@
 /** 
  * @file llfloatersaveprefpreset.cpp
- * @brief Floater to save a graphics / camera preset
+ * @brief Floater to save a graphics preset
  *
  * $LicenseInfo:firstyear=2014&license=viewerlgpl$
  * Second Life Viewer Source Code
@@ -32,14 +32,12 @@
 #include "llcombobox.h"
 #include "llfloaterpreference.h"
 #include "llfloaterreg.h"
-#include "lllineeditor.h"
 #include "llnotificationsutil.h"
 #include "llpresetsmanager.h"
-#include "llradiogroup.h"
 #include "lltrans.h"
 
 LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key)
-	: LLModalDialog(key)
+	: LLFloater(key)
 {
 }
 
@@ -52,93 +50,51 @@ BOOL LLFloaterSavePrefPreset::postBuild()
 		preferences->addDependentFloater(this);
 	}
 	
-	mPresetCombo = getChild<LLComboBox>("preset_combo");
-
-	mNameEditor = getChild<LLLineEditor>("preset_txt_editor");
-	mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL);
+	getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
+	getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this));
+	getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
 
-	mSaveButton = getChild<LLButton>("save");
-	mSaveButton->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this));
-	
-	mSaveRadioGroup = getChild<LLRadioGroup>("radio_save_preset");
-	mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onSwitchSaveReplace, this));
-	
 	getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this));
 
 	LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this));
+	
+	mSaveButton = getChild<LLButton>("save");
+	mPresetCombo = getChild<LLComboBox>("preset_combo");
 
 	return TRUE;
 }
 
 void LLFloaterSavePrefPreset::onPresetNameEdited()
 {
-	if (mSaveRadioGroup->getSelectedIndex() == 0)
-	{
-		// Disable saving a preset having empty name.
-		std::string name = mNameEditor->getValue();
-		mSaveButton->setEnabled(!name.empty());
-	}
+	// Disable saving a preset having empty name.
+	std::string name = mPresetCombo->getSimple();
+
+	mSaveButton->setEnabled(!name.empty());
 }
 
 void LLFloaterSavePrefPreset::onOpen(const LLSD& key)
 {
-	LLModalDialog::onOpen(key);
-	S32 index = 0;
-	if (key.has("subdirectory"))
-	{
-		mSubdirectory = key["subdirectory"].asString();
-		if (key.has("index"))
-		{
-			index = key["index"].asInteger();
-		}
-	}
-	else
-	{
-		mSubdirectory = key.asString();
-	}
-
-	std::string floater_title = getString(std::string("title_") + mSubdirectory);
-
-	setTitle(floater_title);
+	mSubdirectory = key.asString();
 
 	EDefaultOptions option = DEFAULT_HIDE;
 	LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option);
 
-	mSaveRadioGroup->setSelectedIndex(index);
 	onPresetNameEdited();
-	onSwitchSaveReplace();
 }
 
 void LLFloaterSavePrefPreset::onBtnSave()
 {
-	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
-	std::string name = is_saving_new ? mNameEditor->getText() : mPresetCombo->getSimple();
+	std::string name = mPresetCombo->getSimple();
 
 	if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT))
 	{
 		LLNotificationsUtil::add("DefaultPresetNotSaved");
 	}
-	else 
+	else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
 	{
-		if (is_saving_new)
-		{
-			std::list<std::string> preset_names;
-			std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(mSubdirectory);
-			LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE);
-			if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end())
-			{
-				LLSD args;
-				args["NAME"] = name;
-				LLNotificationsUtil::add("PresetAlreadyExists", args);
-				return;
-			}
-		}
-		if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name))
-		{
-			LLSD args;
-			args["NAME"] = name;
-			LLNotificationsUtil::add("PresetNotSaved", args);
-		}
+		LLSD args;
+		args["NAME"] = name;
+		LLNotificationsUtil::add("PresetNotSaved", args);
 	}
 
 	closeFloater();
@@ -154,20 +110,3 @@ void LLFloaterSavePrefPreset::onBtnCancel()
 {
 	closeFloater();
 }
-
-void LLFloaterSavePrefPreset::onSwitchSaveReplace()
-{
-	bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0;
-	std::string label = is_saving_new ? getString("btn_label_save") : getString("btn_label_replace");
-	mSaveButton->setLabel(label);
-	mNameEditor->setEnabled(is_saving_new);
-	mPresetCombo->setEnabled(!is_saving_new);
-	if (is_saving_new)
-	{
-		onPresetNameEdited();
-	}
-	else
-	{
-		mSaveButton->setEnabled(true);
-	}
-}
diff --git a/indra/newview/llfloatersaveprefpreset.h b/indra/newview/llfloatersaveprefpreset.h
index c61379e5ad..ae58180e7f 100644
--- a/indra/newview/llfloatersaveprefpreset.h
+++ b/indra/newview/llfloatersaveprefpreset.h
@@ -1,6 +1,6 @@
 /** 
  * @file llfloatersaveprefpreset.h
- * @brief Floater to save a graphics / camera preset
+ * @brief Floater to save a graphics preset
 
  *
  * $LicenseInfo:firstyear=2014&license=viewerlgpl$
@@ -28,13 +28,11 @@
 #ifndef LL_LLFLOATERSAVEPREFPRESET_H
 #define LL_LLFLOATERSAVEPREFPRESET_H
 
-#include "llmodaldialog.h"
+#include "llfloater.h"
 
 class LLComboBox;
-class LLRadioGroup;
-class LLLineEditor;
 
-class LLFloaterSavePrefPreset : public LLModalDialog
+class LLFloaterSavePrefPreset : public LLFloater
 {
 
 public:
@@ -45,11 +43,9 @@ public:
 
 	void onBtnSave();
 	void onBtnCancel();
-	void onSwitchSaveReplace();
 
 private:
-	LLRadioGroup*	mSaveRadioGroup;
-	LLLineEditor*	mNameEditor;
+
 	LLComboBox*		mPresetCombo;
 	LLButton*		mSaveButton;
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 73978e9dfb..6b83be2b70 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -430,7 +430,7 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 		else
 		{
 			combo->setLabel(LLTrans::getString("preset_combo_label"));
-			combo->setEnabled(FALSE);
+			combo->setEnabled(PRESETS_CAMERA != subdirectory);
 			sts = false;
 		}
 	}
diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp
index d897d59217..90682f8f43 100644
--- a/indra/newview/llviewerfloaterreg.cpp
+++ b/indra/newview/llviewerfloaterreg.cpp
@@ -112,6 +112,7 @@
 #include "llfloaterregioninfo.h"
 #include "llfloaterregionrestarting.h"
 #include "llfloaterreporter.h"
+#include "llfloatersavecamerapreset.h"
 #include "llfloatersaveprefpreset.h"
 #include "llfloatersceneloadstats.h"
 #include "llfloaterscriptdebug.h"
@@ -318,6 +319,7 @@ void LLViewerFloaterReg::registerFloaters()
 	LLFloaterReg::add("properties", "floater_inventory_item_properties.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProperties>);
 	LLFloaterReg::add("publish_classified", "floater_publish_classified.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLPublishClassifiedFloater>);
 	LLFloaterReg::add("save_pref_preset", "floater_save_pref_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSavePrefPreset>);
+	LLFloaterReg::add("save_camera_preset", "floater_save_camera_preset.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterSaveCameraPreset>);
 	LLFloaterReg::add("script_colors", "floater_script_ed_prefs.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterScriptEdPrefs>);
 
 	LLFloaterReg::add("telehubs", "floater_telehub.xml",&LLFloaterReg::build<LLFloaterTelehub>);
diff --git a/indra/newview/skins/default/xui/en/floater_save_camera_preset.xml b/indra/newview/skins/default/xui/en/floater_save_camera_preset.xml
new file mode 100644
index 0000000000..54fdb6d167
--- /dev/null
+++ b/indra/newview/skins/default/xui/en/floater_save_camera_preset.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<floater
+ legacy_header_height="18"
+ height="185"
+ help_topic="floater_save_preset"
+ layout="topleft"
+ name="save_camera_preset"
+ save_rect="true"
+ title="Save Camera Preset"
+ width="280">
+
+    <string name="btn_label_save">Save</string>
+    <string name="btn_label_replace">Replace</string>
+    <radio_group
+     height="85"
+     layout="topleft"
+     left="20"
+     top="15"
+     width="150"
+     name="radio_save_preset">
+     <radio_item
+      label="Save as a new preset"
+      name="new_preset"
+      top="10" 
+      layout="topleft"
+      height="16" 
+      value="0"/>
+     <radio_item
+      label="Replace a preset"
+      name="replace_preset"
+      layout="topleft"
+      top="70" 
+      height="16" 
+      value="1"/>
+    </radio_group> 
+    <line_editor
+     commit_on_focus_lost = "true"
+     follows="top|left"
+     height="23"
+     layout="topleft"
+     left="41"
+     name="preset_txt_editor"
+     width="200"
+     top="45"/>
+    <button
+     follows="top|left"
+     height="25"
+     label="Save"
+     layout="topleft"
+     top="145"
+     left="25"
+     name="save"
+     width="110"/>
+    <button
+     follows="bottom|right"
+     height="25"
+     label="Cancel"
+     layout="topleft"
+     left_pad="20"
+     name="cancel"
+     width="110"/>
+<!-- *HACK to correctly draw drop-down list over the buttons-->
+    <combo_box
+     follows="top|left"
+     layout="topleft"
+     left="41"
+     name="preset_combo"
+     top_delta="-40"
+     width="200"/>
+</floater>
diff --git a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
index 3a5838e846..62260274f5 100644
--- a/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
+++ b/indra/newview/skins/default/xui/en/floater_save_pref_preset.xml
@@ -1,72 +1,48 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <floater
  legacy_header_height="18"
- height="185"
+ height="145"
  help_topic="floater_save_preset"
  layout="topleft"
  name="save_pref_preset"
  save_rect="true"
- title="SAVE PREF PRESET"
- width="280">
+ title="Save Graphic Preset"
+ width="300">
 
-    <string name="title_graphic">Save Graphic Preset</string>
-    <string name="title_camera">Save Camera Preset</string>
-    <string name="btn_label_save">Save</string>
-    <string name="btn_label_replace">Replace</string>
-    <radio_group
-     height="85"
+    <text
+     follows="top|left|right"
+     height="32"
      layout="topleft"
+     word_wrap="true"
      left="20"
-     top="15"
-     width="150"
-     name="radio_save_preset">
-     <radio_item
-      label="Save as a new preset"
-      name="new_preset"
-      top="10" 
-      layout="topleft"
-      height="16" 
-      value="0"/>
-     <radio_item
-      label="Replace a preset"
-      name="replace_preset"
-      layout="topleft"
-      top="70" 
-      height="16" 
-      value="1"/>
-    </radio_group> 
-    <line_editor
-     commit_on_focus_lost = "true"
+     name="Preset"
+     top="30"
+     width="200">
+     Type a name for the preset or choose an existing preset.
+    </text>
+    <combo_box
      follows="top|left"
-     height="23"
      layout="topleft"
-     left="41"
-     name="preset_txt_editor"
-     width="200"
-     top="45"/>
+     left="20"
+     name="preset_combo"
+     top_delta="35"
+     allow_text_entry="true"
+     width="200"/>
     <button
      follows="top|left"
-     height="25"
+     height="23"
      label="Save"
      layout="topleft"
-     top="145"
-     left="25"
+     top_delta="40"
+     left="20"
      name="save"
-     width="110"/>
+     width="70"/>
     <button
      follows="bottom|right"
-     height="25"
+     height="23"
      label="Cancel"
      layout="topleft"
      left_pad="20"
      name="cancel"
-     width="110"/>
-<!-- *HACK to correctly draw drop-down list over the buttons-->
-    <combo_box
-     follows="top|left"
-     layout="topleft"
-     left="41"
-     name="preset_combo"
-     top_delta="-40"
-     width="200"/>
+     width="70"/>
 </floater>
-- 
cgit v1.2.3


From 6d4bf056192dfed3acd6f6ab2894fab0072909a1 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Wed, 8 Jan 2020 18:18:16 +0200
Subject: SL-12509 FIXED The Load, Save, and Delete preset floaters aren't
 opened together in the graphics preferences

---
 indra/newview/llfloaterpreference.cpp | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 2324c08855..da6f332cab 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -2678,26 +2678,17 @@ void LLPanelPreference::updateMediaAutoPlayCheckbox(LLUICtrl* ctrl)
 
 void LLPanelPreference::deletePreset(const LLSD& user_data)
 {
-	std::string subdirectory = user_data.asString();
-	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
-	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
-	LLFloaterReg::showInstance("delete_pref_preset", subdirectory);
+	LLFloaterReg::showInstance("delete_pref_preset", user_data.asString());
 }
 
 void LLPanelPreference::savePreset(const LLSD& user_data)
 {
-	std::string subdirectory = user_data.asString();
-	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
-	LLFloaterReg::hideInstance("load_pref_preset", subdirectory);
-	LLFloaterReg::showInstance("save_pref_preset", subdirectory);
+	LLFloaterReg::showInstance("save_pref_preset", user_data.asString());
 }
 
 void LLPanelPreference::loadPreset(const LLSD& user_data)
 {
-	std::string subdirectory = user_data.asString();
-	LLFloaterReg::hideInstance("delete_pref_preset", subdirectory);
-	LLFloaterReg::hideInstance("save_pref_preset", subdirectory);
-	LLFloaterReg::showInstance("load_pref_preset", subdirectory);
+	LLFloaterReg::showInstance("load_pref_preset", user_data.asString());
 }
 
 void LLPanelPreference::setHardwareDefaults()
-- 
cgit v1.2.3


From 65ea59904c3372102f8c31d3876a231607d7525a Mon Sep 17 00:00:00 2001
From: AndreyL ProductEngine <alihatskiy@productengine.com>
Date: Wed, 8 Jan 2020 20:22:51 +0200
Subject: Mac buildfix

---
 indra/newview/llfloatersavecamerapreset.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index b1c9e561f7..5d62aff0e2 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -26,7 +26,7 @@
 
 #include "llviewerprecompiledheaders.h"
 
-#include "LLFloaterSaveCameraPreset.h"
+#include "llfloatersavecamerapreset.h"
 
 #include "llbutton.h"
 #include "llcombobox.h"
-- 
cgit v1.2.3


From fcbccd59d98ea0a4a11b26da6b19a9f90f65dae5 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 17 Jan 2020 17:54:40 +0200
Subject: SL-12424 Allow saving offsets based on current camera position

---
 indra/newview/llagentcamera.cpp             | 16 ++++++++++++++++
 indra/newview/llagentcamera.h               |  4 ++++
 indra/newview/llfloatersavecamerapreset.cpp |  6 ++++++
 3 files changed, 26 insertions(+)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 04d726a131..18825d5b27 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1985,6 +1985,22 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 }
 
 
+LLVector3 LLAgentCamera::getCurrentCameraOffset()
+{
+	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->getRenderPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion();
+	return  camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale");
+}
+
+LLVector3d LLAgentCamera::getCurrentFocusOffset()
+{
+	return (mFocusTargetGlobal - gAgent.getPositionGlobal()) * ~gAgent.getFrameAgent().getQuaternion();
+}
+
+bool LLAgentCamera::isJoystickCameraUsed()
+{
+	return ((mOrbitAroundRadians != 0) || (mOrbitOverAngle != 0) || !mPanFocusDiff.isNull());
+}
+
 LLVector3 LLAgentCamera::getCameraOffsetInitial()
 {
 	return convert_from_llsd<LLVector3>(mCameraOffsetInitial->get(), TYPE_VEC3, "");
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 6e73b7b0f0..af65ab431a 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -117,6 +117,10 @@ public:
 	/** Determines default focus offset depending on the current camera preset */
 	LLVector3d getFocusOffsetInitial();
 
+	LLVector3 getCurrentCameraOffset();
+	LLVector3d getCurrentFocusOffset();
+	bool isJoystickCameraUsed();
+
 private:
 	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
 	F32 getCameraMaxZoomDistance();
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index 5d62aff0e2..bbc4b5e354 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -28,6 +28,7 @@
 
 #include "llfloatersavecamerapreset.h"
 
+#include "llagentcamera.h"
 #include "llbutton.h"
 #include "llcombobox.h"
 #include "llfloaterpreference.h"
@@ -101,6 +102,11 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 	}
 	else 
 	{
+		if (gAgentCamera.isJoystickCameraUsed())
+		{
+			gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset());
+			gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset());
+		}
 		if (is_saving_new)
 		{
 			std::list<std::string> preset_names;
-- 
cgit v1.2.3


From e865c94513ea22f06ceab4c3698cb180fb30707a Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Fri, 17 Jan 2020 18:58:07 +0200
Subject: SL-12424 Use correct avatar position

---
 indra/newview/llagentcamera.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 18825d5b27..d4d4f8e124 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1987,7 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 LLVector3 LLAgentCamera::getCurrentCameraOffset()
 {
-	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->getRenderPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion();
+	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->mRoot->getWorldPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion();
 	return  camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale");
 }
 
-- 
cgit v1.2.3


From 2c7a8a2485b98ff56e6fdc431bba5ccd226ae740 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Thu, 30 Jan 2020 17:51:41 +0200
Subject: SL-12618 FIXED The camera zoom position is incorrect after selecting
 the preset in some cases

---
 indra/newview/app_settings/camera/Front.xml | 2 +-
 indra/newview/app_settings/camera/Rear.xml  | 2 +-
 indra/newview/app_settings/camera/Side.xml  | 2 +-
 indra/newview/llagentcamera.cpp             | 4 ++--
 indra/newview/llagentcamera.h               | 8 ++++----
 indra/newview/llpresetsmanager.cpp          | 2 +-
 6 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
index e4839d48ec..7b5d597fdf 100644
--- a/indra/newview/app_settings/camera/Front.xml
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -72,7 +72,7 @@
         <key>Type</key>
             <string>F32</string>
         <key>Value</key>
-            <real>0.9</real>
+            <real>0.90322577953338623</real>
         </map>
     <key>EditCameraMovement</key>
         <map>
diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml
index 72e6c5d93a..7aa36c3e59 100644
--- a/indra/newview/app_settings/camera/Rear.xml
+++ b/indra/newview/app_settings/camera/Rear.xml
@@ -72,7 +72,7 @@
         <key>Type</key>
             <string>F32</string>
         <key>Value</key>
-            <real>0.9</real>
+            <real>0.90322577953338623</real>
         </map>
     <key>EditCameraMovement</key>
         <map>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
index eb3b3253c1..8890d9cbce 100644
--- a/indra/newview/app_settings/camera/Side.xml
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -72,7 +72,7 @@
         <key>Type</key>
             <string>F32</string>
         <key>Value</key>
-            <real>0.9</real>
+            <real>0.90322577953338623</real>
         </map>
     <key>EditCameraMovement</key>
         <map>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index d4d4f8e124..6b1dd4c3c3 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -717,7 +717,7 @@ BOOL LLAgentCamera::calcCameraMinDistance(F32 &obj_min_distance)
 	return TRUE;
 }
 
-F32 LLAgentCamera::getCameraZoomFraction()
+F32 LLAgentCamera::getCameraZoomFraction(bool get_third_person)
 {
 	// 0.f -> camera zoomed all the way out
 	// 1.f -> camera zoomed all the way in
@@ -727,7 +727,7 @@ F32 LLAgentCamera::getCameraZoomFraction()
 		// already [0,1]
 		return mHUDTargetZoom;
 	}
-	else if (mFocusOnAvatar && cameraThirdPerson())
+	else if (get_third_person || (mFocusOnAvatar && cameraThirdPerson()))
 	{
 		return clamp_rescale(mCameraZoomFraction, MIN_ZOOM_FRACTION, MAX_ZOOM_FRACTION, 1.f, 0.f);
 	}
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index af65ab431a..128974666e 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -272,10 +272,10 @@ public:
 	// Zoom
 	//--------------------------------------------------------------------
 public:
-	void			handleScrollWheel(S32 clicks); 			// Mousewheel driven zoom
-	void			cameraZoomIn(const F32 factor);			// Zoom in by fraction of current distance
-	F32				getCameraZoomFraction();				// Get camera zoom as fraction of minimum and maximum zoom
-	void			setCameraZoomFraction(F32 fraction);	// Set camera zoom as fraction of minimum and maximum zoom
+	void			handleScrollWheel(S32 clicks); 							// Mousewheel driven zoom
+	void			cameraZoomIn(const F32 factor);							// Zoom in by fraction of current distance
+	F32				getCameraZoomFraction(bool get_third_person = false);	// Get camera zoom as fraction of minimum and maximum zoom
+	void			setCameraZoomFraction(F32 fraction);					// Set camera zoom as fraction of minimum and maximum zoom
 	F32				calcCameraFOVZoomFactor();
 	F32				getAgentHUDTargetZoom();
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 6b83be2b70..eaf139b106 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -288,7 +288,7 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
 
-		gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction());
+		gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction(true));
 		name_list.push_back("CameraZoomFraction");
 	}
 	else
-- 
cgit v1.2.3


From a5c1ae9fafa3b1415eb75aefc9c8ace19e8940d5 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Mon, 10 Feb 2020 16:43:21 +0200
Subject: SL-12621 Add CameraOffsetScale option to "Precise Controls" floater

---
 .../xui/en/floater_preferences_view_advanced.xml   | 43 +++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
index 77e36f0b09..6aedde84a0 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8" standalone="yes" ?>
 <floater
- height="128"
+ height="190"
  layout="topleft"
  name="floaterpreferencesviewadvanced"
  help_topic="floaterviewadvanced"
@@ -10,6 +10,7 @@
 
   <text
     follows="top|left|right"
+    name="camera_offset_lbl"
     height="16"
     layout="topleft"
     left="10"
@@ -63,6 +64,7 @@
 
   <text
     follows="top|left|right"
+    name="focus_offset_lbl"
     height="16"
     layout="topleft"
     left="10"
@@ -113,4 +115,43 @@
     <spinner.commit_callback
      function="CommitSettings" />
   </spinner>
+
+   <text
+    follows="top|left|right"
+    name="offset_scale_lbl"
+    height="16"
+    layout="topleft"
+    left="10"
+    top_pad="20"
+    width="140">
+      Camera offset scale:
+  </text>
+
+  <slider
+   control_name="CameraOffsetScale"
+   follows="top|left|right"
+   height="16"
+   top_pad="5"
+   increment="0.1"
+   min_val="-3"
+   max_val="5"
+   show_text="false"
+   layout="topleft"
+   left="3"
+   name="offset_scale_sld"
+   tool_tip="Choose name tag opacity"
+   width="196" />
+  <spinner
+   control_name="CameraOffsetScale"
+   height="20"
+   follows="top|left|right"
+   left_pad="5"
+   name="offset_scale_ctrl"
+   min_val="-3"
+   max_val="5"
+   width="58">
+    <spinner.commit_callback
+     function="CommitSettings" />
+  </spinner>
+
 </floater>
-- 
cgit v1.2.3


From 95992bd1a2c14fd88b18c73a068989bd4235bd55 Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Tue, 11 Feb 2020 14:25:53 +0200
Subject: SL-12621 Remove inappropriate tooltip

---
 indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
index 6aedde84a0..4c3c7e4930 100644
--- a/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
+++ b/indra/newview/skins/default/xui/en/floater_preferences_view_advanced.xml
@@ -139,7 +139,6 @@
    layout="topleft"
    left="3"
    name="offset_scale_sld"
-   tool_tip="Choose name tag opacity"
    width="196" />
   <spinner
    control_name="CameraOffsetScale"
-- 
cgit v1.2.3


From afd45506c12c93ff4b705d72de249005b9c27944 Mon Sep 17 00:00:00 2001
From: Andrey Lihatskiy <alihatskiy@productengine.com>
Date: Wed, 4 Mar 2020 05:31:22 +0200
Subject: SL-12792 Made "save as a new preset" a default option

---
 indra/newview/llfloatercamera.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 860005bfbe..cf25e35f63 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -609,11 +609,7 @@ void LLFloaterCamera::onSavePreset()
 	LLFloaterReg::hideInstance("delete_pref_preset", PRESETS_CAMERA);
 	LLFloaterReg::hideInstance("load_pref_preset", PRESETS_CAMERA);
 	
-	LLSD key;
-	std::string current_preset = gSavedSettings.getString("PresetCameraActive");
-	bool is_custom_preset = current_preset != "" && !LLPresetsManager::getInstance()->isDefaultCameraPreset(current_preset);
-	key["index"] = is_custom_preset ? 1 : 0;
-	LLFloaterReg::showInstance("save_camera_preset", key);
+	LLFloaterReg::showInstance("save_camera_preset");
 }
 
 void LLFloaterCamera::onCustomPresetSelected()
-- 
cgit v1.2.3


From 3e403ffb4f6d295b11c9842bed53df5d15848f0b Mon Sep 17 00:00:00 2001
From: maxim_productengine <mnikolenko@productengine.com>
Date: Mon, 16 Mar 2020 17:48:23 +0200
Subject: SL-4495 Add setting to ignore Hover height when setting Camera
 position

---
 indra/newview/app_settings/settings.xml               | 11 +++++++++++
 indra/newview/llagentcamera.cpp                       | 10 ++++++++--
 indra/newview/llagentcamera.h                         |  2 ++
 .../default/xui/en/floater_edit_hover_height.xml      | 19 +++++++++++++------
 4 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index f35408f48e..cc86ba85c1 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -16406,6 +16406,17 @@
     <key>Value</key>
     <integer>0</integer>
    </map>
+  <key>HoverHeightAffectsCamera</key>
+  <map>
+    <key>Comment</key>
+    <string>Camera view is affected by Hover Height setting</string>
+    <key>Persist</key>
+    <integer>1</integer>
+    <key>Type</key>
+    <string>Boolean</string>
+    <key>Value</key>
+    <integer>1</integer>
+   </map>
     <key>CefVerboseLog</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 6b1dd4c3c3..a1920f0332 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1730,7 +1730,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 	F32			camera_land_height;
 	LLVector3d	frame_center_global = !isAgentAvatarValid() ? 
 		gAgent.getPositionGlobal() :
-		gAgent.getPosGlobalFromAgent(gAgentAvatarp->mRoot->getWorldPosition());
+		gAgent.getPosGlobalFromAgent(getAvatarRootPosition());
 	
 	BOOL		isConstrained = FALSE;
 	LLVector3d	head_offset;
@@ -1987,7 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 LLVector3 LLAgentCamera::getCurrentCameraOffset()
 {
-	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - gAgentAvatarp->mRoot->getWorldPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion();
+	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion();
 	return  camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale");
 }
 
@@ -2019,6 +2019,12 @@ F32 LLAgentCamera::getCameraMaxZoomDistance()
                  LLWorld::getInstance()->getRegionWidthInMeters() - CAMERA_FUDGE_FROM_OBJECT);
 }
 
+LLVector3 LLAgentCamera::getAvatarRootPosition()
+{
+    static LLCachedControl<bool> use_hover_height(gSavedSettings, "HoverHeightAffectsCamera");
+    return use_hover_height ? gAgentAvatarp->mRoot->getWorldPosition() : gAgentAvatarp->mRoot->getWorldPosition() - gAgentAvatarp->getHoverOffset();
+
+}
 //-----------------------------------------------------------------------------
 // handleScrollWheel()
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 128974666e..a9f57cf956 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -147,6 +147,8 @@ public:
 	F32				getCurrentCameraBuildOffset() 	{ return (F32)mCameraFocusOffset.length(); }
 	void			clearCameraLag() { mCameraLag.clearVec(); }
 private:
+	LLVector3		getAvatarRootPosition();
+
 	F32				mCurrentCameraDistance;	 		// Current camera offset from avatar
 	F32				mTargetCameraDistance;			// Target camera offset from avatar
 	F32				mCameraFOVZoomFactor;			// Amount of fov zoom applied to camera when zeroing in on an object
diff --git a/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml b/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml
index 52084e5f8e..3570456b44 100644
--- a/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml
+++ b/indra/newview/skins/default/xui/en/floater_edit_hover_height.xml
@@ -4,18 +4,16 @@
  legacy_header_height="225"
  can_minimize="true"
  can_close="true"
- can_resize="true"
- min_height="65"
- min_width="515"
- height="65"
+ can_resize="false"
+ height="80"
+ width="515"
  layout="topleft"
  name="HoverHeight"
  single_instance="true"
  help_topic="hover_height"
  save_rect="true"
  save_visibility="true"
- title="SET HOVER HEIGHT"
- width="515">
+ title="SET HOVER HEIGHT">
       <slider
      enabled="false"
      control_name="HoverHeightSlider"
@@ -34,4 +32,13 @@
      can_edit_text="true"
      >
     </slider>
+  <check_box
+     control_name="HoverHeightAffectsCamera"
+     follows="all"
+     height="15"
+     label="Bind Camera view"
+     layout="topleft"
+     name="BindCameraCheck"
+     top_pad="7"
+     width="237"/>
 </floater>
-- 
cgit v1.2.3


From aefd01bd9cd3f8bf88231b15462abc1ccd79a7b9 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Fri, 27 Mar 2020 20:00:27 +0200
Subject: SL-12904 FIXED Camera Preset does not restore correctly when sitting

---
 indra/newview/llagentcamera.cpp | 12 ++++++++++--
 indra/newview/llagentcamera.h   |  1 +
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index a1920f0332..bac31d48a1 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1987,13 +1987,21 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 LLVector3 LLAgentCamera::getCurrentCameraOffset()
 {
-	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~gAgent.getFrameAgent().getQuaternion();
+	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation();
 	return  camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale");
 }
 
 LLVector3d LLAgentCamera::getCurrentFocusOffset()
 {
-	return (mFocusTargetGlobal - gAgent.getPositionGlobal()) * ~gAgent.getFrameAgent().getQuaternion();
+	return (mFocusTargetGlobal - gAgent.getPositionGlobal()) * ~getCurrentAvatarRotation();
+}
+
+LLQuaternion LLAgentCamera::getCurrentAvatarRotation()
+{
+	LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent();
+	LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion();
+	LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT;
+	return av_rot * obj_rot;
 }
 
 bool LLAgentCamera::isJoystickCameraUsed()
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index a9f57cf956..357dd5e12a 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -119,6 +119,7 @@ public:
 
 	LLVector3 getCurrentCameraOffset();
 	LLVector3d getCurrentFocusOffset();
+	LLQuaternion getCurrentAvatarRotation();
 	bool isJoystickCameraUsed();
 
 private:
-- 
cgit v1.2.3


From 2dde3869171105748c1005502481c51eeff59511 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Thu, 2 Apr 2020 15:32:04 +0300
Subject: SL-12927 FIXED [Camera Presets] when sitting pressing ESC key causes
 rotation

---
 indra/newview/llagentcamera.cpp | 20 ++------------------
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index bac31d48a1..5a5a3efc0f 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -2312,15 +2312,7 @@ void LLAgentCamera::changeCameraToThirdPerson(BOOL animate)
 	}
 
 	// Remove any pitch from the avatar
-	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-	{
-		LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-		at_axis = LLViewerCamera::getInstance()->getAtAxis();
-		at_axis.mV[VZ] = 0.f;
-		at_axis.normalize();
-		gAgent.resetAxes(at_axis * ~obj_rot);
-	}
-	else
+	if (!isAgentAvatarValid() || !gAgentAvatarp->getParent())
 	{
 		at_axis = gAgent.getFrameAgent().getAtAxis();
 		at_axis.mV[VZ] = 0.f;
@@ -2691,15 +2683,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
 		if (mCameraMode == CAMERA_MODE_THIRD_PERSON)
 		{
 			LLVector3 at_axis;
-			if (isAgentAvatarValid() && gAgentAvatarp->getParent())
-			{
-				LLQuaternion obj_rot = ((LLViewerObject*)gAgentAvatarp->getParent())->getRenderRotation();
-				at_axis = LLViewerCamera::getInstance()->getAtAxis();
-				at_axis.mV[VZ] = 0.f;
-				at_axis.normalize();
-				gAgent.resetAxes(at_axis * ~obj_rot);
-			}
-			else
+			if (!isAgentAvatarValid() || !gAgentAvatarp->getParent())
 			{
 				at_axis = LLViewerCamera::getInstance()->getAtAxis();
 				at_axis.mV[VZ] = 0.f;
-- 
cgit v1.2.3


From 1f5bb7be28768fe5341b1ca4b5a5d366f176045e Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Mon, 6 Apr 2020 16:03:19 +0300
Subject: SL-12904 FIXED Camera Preset does not restore correctly when sitting

---
 indra/newview/llagentcamera.cpp    | 6 ++----
 indra/newview/llviewerkeyboard.cpp | 2 ++
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 5a5a3efc0f..d1da132587 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1805,7 +1805,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 				at_axis.normalize();
 				gAgent.resetAxes(at_axis * ~parent_rot);
 
-				local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
+				local_camera_offset = local_camera_offset * parent_rot;
 			}
 			else
 			{
@@ -1999,9 +1999,7 @@ LLVector3d LLAgentCamera::getCurrentFocusOffset()
 LLQuaternion LLAgentCamera::getCurrentAvatarRotation()
 {
 	LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent();
-	LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion();
-	LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT;
-	return av_rot * obj_rot;
+	return sit_object ? sit_object->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
 }
 
 bool LLAgentCamera::isJoystickCameraUsed()
diff --git a/indra/newview/llviewerkeyboard.cpp b/indra/newview/llviewerkeyboard.cpp
index e930eb20d3..bccbe61f44 100644
--- a/indra/newview/llviewerkeyboard.cpp
+++ b/indra/newview/llviewerkeyboard.cpp
@@ -345,6 +345,7 @@ void camera_spin_around_ccw_sitting( EKeystate s )
 	else
 	{
 		//change camera but do not send keystrokes
+		gAgentCamera.unlockView();
 		gAgentCamera.setOrbitLeftKey( get_orbit_rate() );
 	}
 }
@@ -361,6 +362,7 @@ void camera_spin_around_cw_sitting( EKeystate s )
 	else
 	{
 		//change camera but do not send keystrokes
+		gAgentCamera.unlockView();
 		gAgentCamera.setOrbitRightKey( get_orbit_rate() );
 	}
 }
-- 
cgit v1.2.3


From 3bac0d4283c8d8a7f067a302c4ec0e533457c899 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Tue, 7 Apr 2020 19:15:40 +0300
Subject: SL-12991 [Camera Presets] Sort all Camera preset lists in the same
 way

---
 indra/newview/llfloatercamera.cpp              |  2 +-
 indra/newview/llfloatercamerapresets.cpp       |  7 +--
 indra/newview/llfloatersavecamerapreset.cpp    |  7 ++-
 indra/newview/llpanelpresetscamerapulldown.cpp |  3 +-
 indra/newview/llpanelpresetspulldown.cpp       |  3 +-
 indra/newview/llpresetsmanager.cpp             | 75 +++++++++++++++-----------
 indra/newview/llpresetsmanager.h               |  4 +-
 7 files changed, 54 insertions(+), 47 deletions(-)

diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index cf25e35f63..cc02862868 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -585,7 +585,7 @@ void LLFloaterCamera::fromFreeToPresets()
 
 void LLFloaterCamera::populatePresetCombo()
 {
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, EDefaultOptions::DEFAULT_VIEWS_HIDE);
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, EDefaultOptions::DEFAULT_HIDE);
 	std::string active_preset_name = gSavedSettings.getString("PresetCameraActive");
 	if (active_preset_name.empty())
 	{
diff --git a/indra/newview/llfloatercamerapresets.cpp b/indra/newview/llfloatercamerapresets.cpp
index 75660e590a..300c945a85 100644
--- a/indra/newview/llfloatercamerapresets.cpp
+++ b/indra/newview/llfloatercamerapresets.cpp
@@ -55,13 +55,10 @@ void LLFloaterCameraPresets::populateList()
     mPresetList->clear();
 
     LLPresetsManager* presetsMgr = LLPresetsManager::getInstance();
-    std::string presets_dir = presetsMgr->getPresetsDir(PRESETS_CAMERA);
     std::list<std::string> preset_names;
 
-    presetsMgr->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_VIEWS_HIDE);
-    preset_names.push_back(PRESETS_FRONT_VIEW);
-    preset_names.push_back(PRESETS_REAR_VIEW);
-    preset_names.push_back(PRESETS_SIDE_VIEW);
+	presetsMgr->loadPresetNamesFromDir(PRESETS_CAMERA, preset_names, DEFAULT_BOTTOM);
+
     for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
     {
         const std::string& name = *it;
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index bbc4b5e354..34aefdf1c1 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -84,7 +84,7 @@ void LLFloaterSaveCameraPreset::onOpen(const LLSD& key)
 		index = key["index"].asInteger();
 	}
 
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_HIDE);
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_BOTTOM);
 
 	mSaveRadioGroup->setSelectedIndex(index);
 	onPresetNameEdited();
@@ -110,8 +110,7 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 		if (is_saving_new)
 		{
 			std::list<std::string> preset_names;
-			std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
-			LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE);
+			LLPresetsManager::getInstance()->loadPresetNamesFromDir(PRESETS_CAMERA, preset_names, DEFAULT_HIDE);
 			if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end())
 			{
 				LLSD args;
@@ -133,7 +132,7 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 
 void LLFloaterSaveCameraPreset::onPresetsListChange()
 {
-	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_HIDE);
+	LLPresetsManager::getInstance()->setPresetNamesInComboBox(PRESETS_CAMERA, mPresetCombo, DEFAULT_BOTTOM);
 }
 
 void LLFloaterSaveCameraPreset::onBtnCancel()
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index ae3d182f09..fdf73e069e 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -79,8 +79,7 @@ BOOL LLPanelPresetsCameraPulldown::postBuild()
 
 void LLPanelPresetsCameraPulldown::populatePanel()
 {
-	std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_CAMERA);
-	LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
+	LLPresetsManager::getInstance()->loadPresetNamesFromDir(PRESETS_CAMERA, mPresetNames, DEFAULT_BOTTOM);
 
 	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
 
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index 0bbf1781a5..332fd9969d 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -72,8 +72,7 @@ BOOL LLPanelPresetsPulldown::postBuild()
 
 void LLPanelPresetsPulldown::populatePanel()
 {
-	std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_GRAPHIC);
-	LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_TOP);
+	LLPresetsManager::getInstance()->loadPresetNamesFromDir(PRESETS_GRAPHIC, mPresetNames, DEFAULT_TOP);
 
 	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_list");
 
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index eaf139b106..b1a94be68c 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -141,8 +141,12 @@ std::string LLPresetsManager::getPresetsDir(const std::string& subdirectory)
 	return dest_path;
 }
 
-void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option)
+void LLPresetsManager::loadPresetNamesFromDir(const std::string& subdirectory, preset_name_list_t& presets, EDefaultOptions default_option)
 {
+	bool IS_CAMERA = (PRESETS_CAMERA == subdirectory);
+	bool IS_GRAPHIC = (PRESETS_GRAPHIC == subdirectory);
+
+	std::string dir = LLPresetsManager::getInstance()->getPresetsDir(subdirectory);
 	LL_INFOS("AppInit") << "Loading list of preset names from " << dir << LL_ENDL;
 
 	mPresetNames.clear();
@@ -160,25 +164,31 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 			std::string name = LLURI::unescape(gDirUtilp->getBaseFileName(path, /*strip_exten = */ true));
 			LL_DEBUGS() << "  Found preset '" << name << "'" << LL_ENDL;
 
-			if (isTemplateCameraPreset(name))
-			{
-				continue;
-			}
-			if (default_option == DEFAULT_VIEWS_HIDE)
+			if (IS_CAMERA)
 			{
-				if (isDefaultCameraPreset(name))
+				if (isTemplateCameraPreset(name))
 				{
 					continue;
 				}
-			}
-			if (PRESETS_DEFAULT != name)
-			{
+				if ((default_option == DEFAULT_HIDE) || (default_option == DEFAULT_BOTTOM))
+				{
+					if (isDefaultCameraPreset(name))
+					{
+						continue;
+					}
+				}
 				mPresetNames.push_back(name);
 			}
-			else
+			if (IS_GRAPHIC)
 			{
-				switch (default_option)
+				if (PRESETS_DEFAULT != name)
 				{
+					mPresetNames.push_back(name);
+				}
+				else
+				{
+					switch (default_option)
+					{
 					case DEFAULT_SHOW:
 						mPresetNames.push_back(LLTrans::getString(PRESETS_DEFAULT));
 						break;
@@ -190,11 +200,20 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& dir, preset_nam
 					case DEFAULT_HIDE:
 					default:
 						break;
+					}
 				}
 			}
 		}
 	}
 
+	if (IS_CAMERA && (default_option == DEFAULT_BOTTOM))
+	{
+		mPresetNames.sort();
+		mPresetNames.push_back(PRESETS_FRONT_VIEW);
+		mPresetNames.push_back(PRESETS_REAR_VIEW);
+		mPresetNames.push_back(PRESETS_SIDE_VIEW);
+	}
+
 	presets = mPresetNames;
 }
 
@@ -410,30 +429,24 @@ bool LLPresetsManager::setPresetNamesInComboBox(const std::string& subdirectory,
 	combo->clearRows();
 	combo->setEnabled(TRUE);
 
-	std::string presets_dir = getPresetsDir(subdirectory);
+	std::list<std::string> preset_names;
+	loadPresetNamesFromDir(subdirectory, preset_names, default_option);
 
-	if (!presets_dir.empty())
+	if (preset_names.begin() != preset_names.end())
 	{
-		std::list<std::string> preset_names;
-		loadPresetNamesFromDir(presets_dir, preset_names, default_option);
-
-		std::string preset_graphic_active = gSavedSettings.getString("PresetGraphicActive");
-
-		if (preset_names.begin() != preset_names.end())
-		{
-			for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
-			{
-				const std::string& name = *it;
-				combo->add(name, name);
-			}
-		}
-		else
+		for (std::list<std::string>::const_iterator it = preset_names.begin(); it != preset_names.end(); ++it)
 		{
-			combo->setLabel(LLTrans::getString("preset_combo_label"));
-			combo->setEnabled(PRESETS_CAMERA != subdirectory);
-			sts = false;
+			const std::string& name = *it;
+			combo->add(name, name);
 		}
 	}
+	else
+	{
+		combo->setLabel(LLTrans::getString("preset_combo_label"));
+		combo->setEnabled(PRESETS_CAMERA != subdirectory);
+		sts = false;
+	}
+
 	return sts;
 }
 
diff --git a/indra/newview/llpresetsmanager.h b/indra/newview/llpresetsmanager.h
index d9ca178dd7..d5b384ceb9 100644
--- a/indra/newview/llpresetsmanager.h
+++ b/indra/newview/llpresetsmanager.h
@@ -48,7 +48,7 @@ enum EDefaultOptions
 {
 	DEFAULT_SHOW,
 	DEFAULT_TOP,
-	DEFAULT_VIEWS_HIDE,
+	DEFAULT_BOTTOM,
 	DEFAULT_HIDE				// Do not display "Default" in a list
 };
 
@@ -68,7 +68,7 @@ public:
 	void triggerChangeSignal();
 	static std::string getPresetsDir(const std::string& subdirectory);
 	bool setPresetNamesInComboBox(const std::string& subdirectory, LLComboBox* combo, EDefaultOptions default_option);
-	void loadPresetNamesFromDir(const std::string& dir, preset_name_list_t& presets, EDefaultOptions default_option);
+	void loadPresetNamesFromDir(const std::string& subdirectory, preset_name_list_t& presets, EDefaultOptions default_option);
 	bool savePreset(const std::string& subdirectory, std::string name, bool createDefault = false);
 	void loadPreset(const std::string& subdirectory, std::string name);
 	bool deletePreset(const std::string& subdirectory, std::string name);
-- 
cgit v1.2.3


From 40394752f7f757012c032746ea0de48aa3c0323c Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Tue, 7 Apr 2020 21:26:13 +0300
Subject: SL-12991 [Camera Presets] Sort all Camera preset lists in the same
 way

---
 indra/newview/llpresetsmanager.cpp | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index b1a94be68c..fd89a1fcb6 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -206,12 +206,15 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& subdirectory, p
 		}
 	}
 
-	if (IS_CAMERA && (default_option == DEFAULT_BOTTOM))
+	if (IS_CAMERA)
 	{
-		mPresetNames.sort();
-		mPresetNames.push_back(PRESETS_FRONT_VIEW);
-		mPresetNames.push_back(PRESETS_REAR_VIEW);
-		mPresetNames.push_back(PRESETS_SIDE_VIEW);
+		mPresetNames.sort(); 
+		if (default_option == DEFAULT_BOTTOM)
+		{
+			mPresetNames.push_back(PRESETS_FRONT_VIEW);
+			mPresetNames.push_back(PRESETS_REAR_VIEW);
+			mPresetNames.push_back(PRESETS_SIDE_VIEW);
+		}
 	}
 
 	presets = mPresetNames;
-- 
cgit v1.2.3


From b1bf8443b2a8340d0d873e8b6b82ba22a8019a36 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Thu, 9 Apr 2020 21:39:15 +0300
Subject: SL-12999 Some menus allow mouse scroll to zoom camera

---
 indra/newview/CMakeLists.txt                   |   2 +
 indra/newview/llpanelnearbymedia.cpp           |  55 +-----------
 indra/newview/llpanelnearbymedia.h             |   9 +-
 indra/newview/llpanelpresetscamerapulldown.cpp |  78 +---------------
 indra/newview/llpanelpresetscamerapulldown.h   |  17 +---
 indra/newview/llpanelpresetspulldown.cpp       |  76 +---------------
 indra/newview/llpanelpresetspulldown.h         |  16 +---
 indra/newview/llpanelpulldown.cpp              | 118 +++++++++++++++++++++++++
 indra/newview/llpanelpulldown.h                |  55 ++++++++++++
 indra/newview/llpanelvolumepulldown.cpp        |  58 +-----------
 indra/newview/llpanelvolumepulldown.h          |  15 +---
 11 files changed, 190 insertions(+), 309 deletions(-)
 create mode 100644 indra/newview/llpanelpulldown.cpp
 create mode 100644 indra/newview/llpanelpulldown.h

diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index e5748ce4a5..c62fe1a82d 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -495,6 +495,7 @@ set(viewer_SOURCE_FILES
     llpaneltiptoast.cpp
     llpanelvoiceeffect.cpp
     llpaneltopinfobar.cpp
+    llpanelpulldown.cpp
     llpanelvoicedevicesettings.cpp
     llpanelvolume.cpp
     llpanelvolumepulldown.cpp
@@ -1111,6 +1112,7 @@ set(viewer_HEADER_FILES
     llpanelsnapshot.h
     llpanelteleporthistory.h
     llpaneltiptoast.h
+    llpanelpulldown.h
     llpanelvoicedevicesettings.h
     llpanelvoiceeffect.h
     llpaneltopinfobar.h
diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index b654e928e2..a8887eb936 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -82,8 +82,6 @@ LLPanelNearByMedia::LLPanelNearByMedia()
 	  mParcelMediaItem(NULL),
 	  mParcelAudioItem(NULL)
 {
-	mHoverTimer.stop();
-
     // This is just an initial value, mParcelAudioAutoStart does not affect ParcelMediaAutoPlayEnable
     mParcelAudioAutoStart = gSavedSettings.getS32("ParcelMediaAutoPlayEnable") != 0
                             && gSavedSettings.getBOOL("MediaTentativeAutoPlay");
@@ -111,7 +109,7 @@ LLPanelNearByMedia::~LLPanelNearByMedia()
 
 BOOL LLPanelNearByMedia::postBuild()
 {
-	LLPanel::postBuild();
+	LLPanelPulldown::postBuild();
 
 	const S32 RESIZE_BAR_THICKNESS = 6;
 	LLResizeBar::Params p;
@@ -193,45 +191,10 @@ void LLPanelNearByMedia::handleMediaAutoPlayChanged(const LLSD& newvalue)
     inst->cancelNotification();
 }
 
-/*virtual*/
-void LLPanelNearByMedia::onMouseEnter(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.stop();
-	LLPanel::onMouseEnter(x,y,mask);
-}
-
-
-/*virtual*/
-void LLPanelNearByMedia::onMouseLeave(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.start();
-	LLPanel::onMouseLeave(x,y,mask);
-}
-
-/*virtual*/ 
-void LLPanelNearByMedia::onTopLost()
-{
-	setVisible(FALSE);
-}
-
-
-/*virtual*/ 
-void LLPanelNearByMedia::onVisibilityChange ( BOOL new_visibility )
-{
-	if (new_visibility)	
-	{
-		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-	}
-	else
-	{
-		mHoverTimer.stop();
-	}
-}
-
 /*virtual*/
 void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent)
 {
-	LLPanel::reshape(width, height, called_from_parent);
+	LLPanelPulldown::reshape(width, height, called_from_parent);
 
 	LLButton* more_btn = findChild<LLButton>("more_btn");
 	if (more_btn && more_btn->getValue().asBoolean())
@@ -255,24 +218,14 @@ void LLPanelNearByMedia::draw()
 
 	refreshList();
 	updateControls();
-	
-	F32 alpha = mHoverTimer.getStarted() 
-		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START, AUTO_CLOSE_FADE_TIME_END, 1.f, 0.f)
-		: 1.0f;
-	LLViewDrawContext context(alpha);
 
-	LLPanel::draw();
-
-	if (alpha == 0.f)
-	{
-		setVisible(false);
-	}
+	LLPanelPulldown::draw();
 }
 
 /*virtual*/
 BOOL LLPanelNearByMedia::handleHover(S32 x, S32 y, MASK mask)
 {
-	LLPanel::handleHover(x, y, mask);
+	LLPanelPulldown::handleHover(x, y, mask);
 	
 	// If we are hovering over this panel, make sure to clear any hovered media
 	// ID.  Note that the more general solution would be to clear this ID when
diff --git a/indra/newview/llpanelnearbymedia.h b/indra/newview/llpanelnearbymedia.h
index a9c1b190cf..2d898d0aa1 100644
--- a/indra/newview/llpanelnearbymedia.h
+++ b/indra/newview/llpanelnearbymedia.h
@@ -27,7 +27,7 @@
 #ifndef LL_LLPANELNEARBYMEDIA_H
 #define LL_LLPANELNEARBYMEDIA_H
 
-#include "llpanel.h"
+#include "llpanelpulldown.h"
 
 class LLPanelNearbyMedia;
 class LLButton;
@@ -39,16 +39,12 @@ class LLTextBox;
 class LLComboBox;
 class LLViewerMediaImpl;
 
-class LLPanelNearByMedia : public LLPanel
+class LLPanelNearByMedia : public LLPanelPulldown
 {
 public:
 	
 	/*virtual*/ BOOL postBuild();
 	/*virtual*/ void draw();
-	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onTopLost();
-	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 	/*virtual*/ void reshape(S32 width, S32 height, BOOL called_from_parent);
 	/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
 
@@ -173,7 +169,6 @@ private:
 	
 	LLRect				mMoreRect;
 	LLRect				mLessRect;
-	LLFrameTimer		mHoverTimer;
 	LLScrollListItem*	mParcelMediaItem;
 	LLScrollListItem*	mParcelAudioItem;
 };
diff --git a/indra/newview/llpanelpresetscamerapulldown.cpp b/indra/newview/llpanelpresetscamerapulldown.cpp
index fdf73e069e..183123e534 100644
--- a/indra/newview/llpanelpresetscamerapulldown.cpp
+++ b/indra/newview/llpanelpresetscamerapulldown.cpp
@@ -41,9 +41,6 @@
 #include "llscrolllistctrl.h"
 #include "lltrans.h"
 
-/* static */ const F32 LLPanelPresetsCameraPulldown::sAutoCloseFadeStartTimeSec = 2.0f;
-/* static */ const F32 LLPanelPresetsCameraPulldown::sAutoCloseTotalTimeSec = 3.0f;
-
 ///----------------------------------------------------------------------------
 /// Class LLPanelPresetsCameraPulldown
 ///----------------------------------------------------------------------------
@@ -51,8 +48,6 @@
 // Default constructor
 LLPanelPresetsCameraPulldown::LLPanelPresetsCameraPulldown()
 {
-	mHoverTimer.stop();
-
 	mCommitCallbackRegistrar.add("Presets.toggleCameraFloater", boost::bind(&LLPanelPresetsCameraPulldown::onViewButtonClick, this, _2));
 	mCommitCallbackRegistrar.add("PresetsCamera.RowClick", boost::bind(&LLPanelPresetsCameraPulldown::onRowClick, this, _2));
 
@@ -74,7 +69,7 @@ BOOL LLPanelPresetsCameraPulldown::postBuild()
 
 	populatePanel();
 
-	return LLPanel::postBuild();
+	return LLPanelPulldown::postBuild();
 }
 
 void LLPanelPresetsCameraPulldown::populatePanel()
@@ -118,61 +113,6 @@ void LLPanelPresetsCameraPulldown::populatePanel()
 	}
 }
 
-/*virtual*/
-void LLPanelPresetsCameraPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.stop();
-	LLPanel::onMouseEnter(x,y,mask);
-}
-
-/*virtual*/
-void LLPanelPresetsCameraPulldown::onTopLost()
-{
-	setVisible(FALSE);
-}
-
-/*virtual*/
-BOOL LLPanelPresetsCameraPulldown::handleMouseDown(S32 x, S32 y, MASK mask)
-{
-    LLPanel::handleMouseDown(x,y,mask);
-    return TRUE;
-}
-
-/*virtual*/
-BOOL LLPanelPresetsCameraPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask)
-{
-    LLPanel::handleRightMouseDown(x, y, mask);
-    return TRUE;
-}
-
-/*virtual*/
-BOOL LLPanelPresetsCameraPulldown::handleDoubleClick(S32 x, S32 y, MASK mask)
-{
-    LLPanel::handleDoubleClick(x, y, mask);
-    return TRUE;
-}
-
-/*virtual*/
-void LLPanelPresetsCameraPulldown::onMouseLeave(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.start();
-	LLPanel::onMouseLeave(x,y,mask);
-}
-
-/*virtual*/ 
-void LLPanelPresetsCameraPulldown::onVisibilityChange ( BOOL new_visibility )
-{
-	if (new_visibility)	
-	{
-		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-	}
-	else
-	{
-		mHoverTimer.stop();
-
-	}
-}
-
 void LLPanelPresetsCameraPulldown::onRowClick(const LLSD& user_data)
 {
 	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_camera_list");
@@ -207,19 +147,3 @@ void LLPanelPresetsCameraPulldown::onViewButtonClick(const LLSD& user_data)
 
 	LLFloaterReg::toggleInstanceOrBringToFront("camera");
 }
-
-//virtual
-void LLPanelPresetsCameraPulldown::draw()
-{
-	F32 alpha = mHoverTimer.getStarted() 
-		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
-		: 1.0f;
-	LLViewDrawContext context(alpha);
-
-	LLPanel::draw();
-
-	if (alpha == 0.f)
-	{
-		setVisible(FALSE);
-	}
-}
diff --git a/indra/newview/llpanelpresetscamerapulldown.h b/indra/newview/llpanelpresetscamerapulldown.h
index 12d9bc26ec..c49bab042e 100644
--- a/indra/newview/llpanelpresetscamerapulldown.h
+++ b/indra/newview/llpanelpresetscamerapulldown.h
@@ -29,22 +29,12 @@
 
 #include "linden_common.h"
 
-#include "llpanel.h"
+#include "llpanelpulldown.h"
 
-class LLFrameTimer;
-
-class LLPanelPresetsCameraPulldown : public LLPanel
+class LLPanelPresetsCameraPulldown : public LLPanelPulldown
 {
  public:
 	LLPanelPresetsCameraPulldown();
-	/*virtual*/ void draw();
-	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onTopLost();
-	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 	/*virtual*/ BOOL postBuild();
 	void populatePanel();
 	
@@ -53,9 +43,6 @@ class LLPanelPresetsCameraPulldown : public LLPanel
 	void onRowClick(const LLSD& user_data);
 
 	std::list<std::string> mPresetNames;
-	LLFrameTimer mHoverTimer;
-	static const F32 sAutoCloseFadeStartTimeSec;
-	static const F32 sAutoCloseTotalTimeSec;
     LOG_CLASS(LLPanelPresetsCameraPulldown);
 };
 
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index 332fd9969d..aa5ba3f210 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -40,9 +40,6 @@
 #include "llscrolllistctrl.h"
 #include "lltrans.h"
 
-/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseFadeStartTimeSec = 2.0f;
-/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseTotalTimeSec = 3.0f;
-
 ///----------------------------------------------------------------------------
 /// Class LLPanelPresetsPulldown
 ///----------------------------------------------------------------------------
@@ -67,7 +64,7 @@ BOOL LLPanelPresetsPulldown::postBuild()
 
 	populatePanel();
 
-	return LLPanel::postBuild();
+	return LLPanelPulldown::postBuild();
 }
 
 void LLPanelPresetsPulldown::populatePanel()
@@ -111,61 +108,6 @@ void LLPanelPresetsPulldown::populatePanel()
 	}
 }
 
-/*virtual*/
-void LLPanelPresetsPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.stop();
-	LLPanel::onMouseEnter(x,y,mask);
-}
-
-/*virtual*/
-void LLPanelPresetsPulldown::onTopLost()
-{
-	setVisible(FALSE);
-}
-
-/*virtual*/
-BOOL LLPanelPresetsPulldown::handleMouseDown(S32 x, S32 y, MASK mask)
-{
-    LLPanel::handleMouseDown(x,y,mask);
-    return TRUE;
-}
-
-/*virtual*/
-BOOL LLPanelPresetsPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask)
-{
-    LLPanel::handleRightMouseDown(x, y, mask);
-    return TRUE;
-}
-
-/*virtual*/
-BOOL LLPanelPresetsPulldown::handleDoubleClick(S32 x, S32 y, MASK mask)
-{
-    LLPanel::handleDoubleClick(x, y, mask);
-    return TRUE;
-}
-
-/*virtual*/
-void LLPanelPresetsPulldown::onMouseLeave(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.start();
-	LLPanel::onMouseLeave(x,y,mask);
-}
-
-/*virtual*/ 
-void LLPanelPresetsPulldown::onVisibilityChange ( BOOL new_visibility )
-{
-	if (new_visibility)	
-	{
-		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-	}
-	else
-	{
-		mHoverTimer.stop();
-
-	}
-}
-
 void LLPanelPresetsPulldown::onRowClick(const LLSD& user_data)
 {
 	LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_list");
@@ -212,19 +154,3 @@ void LLPanelPresetsPulldown::onGraphicsButtonClick(const LLSD& user_data)
 		}
 	}
 }
-
-//virtual
-void LLPanelPresetsPulldown::draw()
-{
-	F32 alpha = mHoverTimer.getStarted() 
-		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
-		: 1.0f;
-	LLViewDrawContext context(alpha);
-
-	LLPanel::draw();
-
-	if (alpha == 0.f)
-	{
-		setVisible(FALSE);
-	}
-}
diff --git a/indra/newview/llpanelpresetspulldown.h b/indra/newview/llpanelpresetspulldown.h
index 322bf5a58f..c0d32b9b21 100644
--- a/indra/newview/llpanelpresetspulldown.h
+++ b/indra/newview/llpanelpresetspulldown.h
@@ -29,22 +29,13 @@
 
 #include "linden_common.h"
 
-#include "llpanel.h"
+#include "llpanelpulldown.h"
 
-class LLFrameTimer;
 
-class LLPanelPresetsPulldown : public LLPanel
+class LLPanelPresetsPulldown : public LLPanelPulldown
 {
  public:
 	LLPanelPresetsPulldown();
-	/*virtual*/ void draw();
-	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
-    /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onTopLost();
-	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 	/*virtual*/ BOOL postBuild();
 	void populatePanel();
 	
@@ -53,9 +44,6 @@ class LLPanelPresetsPulldown : public LLPanel
 	void onRowClick(const LLSD& user_data);
 
 	std::list<std::string> mPresetNames;
-	LLFrameTimer mHoverTimer;
-	static const F32 sAutoCloseFadeStartTimeSec;
-	static const F32 sAutoCloseTotalTimeSec;
     LOG_CLASS(LLPanelPresetsPulldown);
 };
 
diff --git a/indra/newview/llpanelpulldown.cpp b/indra/newview/llpanelpulldown.cpp
new file mode 100644
index 0000000000..4de6ee8182
--- /dev/null
+++ b/indra/newview/llpanelpulldown.cpp
@@ -0,0 +1,118 @@
+/**
+* @file llpanelpulldown.cpp
+* @brief A panel that serves as a basis for multiple toolbar pulldown panels
+*
+* $LicenseInfo:firstyear=2020&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2020, Linden Research, Inc.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation;
+* version 2.1 of the License only.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+*
+* Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+* $/LicenseInfo$
+*/
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llpanelpulldown.h"
+
+const F32 AUTO_CLOSE_FADE_TIME_START_SEC = 2.0f;
+const F32 AUTO_CLOSE_FADE_TIME_END_SEC = 3.0f;
+
+///----------------------------------------------------------------------------
+/// Class LLPanelPresetsCameraPulldown
+///----------------------------------------------------------------------------
+
+// Default constructor
+LLPanelPulldown::LLPanelPulldown()
+{
+    mHoverTimer.stop();
+}
+
+/*virtual*/
+void LLPanelPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
+{
+    mHoverTimer.stop();
+    LLPanel::onMouseEnter(x, y, mask);
+}
+
+/*virtual*/
+void LLPanelPulldown::onTopLost()
+{
+    setVisible(FALSE);
+}
+
+/*virtual*/
+BOOL LLPanelPulldown::handleMouseDown(S32 x, S32 y, MASK mask)
+{
+    LLPanel::handleMouseDown(x, y, mask);
+    return TRUE;
+}
+
+/*virtual*/
+BOOL LLPanelPulldown::handleRightMouseDown(S32 x, S32 y, MASK mask)
+{
+    LLPanel::handleRightMouseDown(x, y, mask);
+    return TRUE;
+}
+
+/*virtual*/
+BOOL LLPanelPulldown::handleDoubleClick(S32 x, S32 y, MASK mask)
+{
+    LLPanel::handleDoubleClick(x, y, mask);
+    return TRUE;
+}
+
+BOOL LLPanelPulldown::handleScrollWheel(S32 x, S32 y, S32 clicks)
+{
+    LLPanel::handleScrollWheel(x, y, clicks);
+    return TRUE; //If we got here, then we are in Pulldown's rect, consume the event.
+}
+
+/*virtual*/
+void LLPanelPulldown::onMouseLeave(S32 x, S32 y, MASK mask)
+{
+    mHoverTimer.start();
+    LLPanel::onMouseLeave(x, y, mask);
+}
+
+/*virtual*/
+void LLPanelPulldown::onVisibilityChange(BOOL new_visibility)
+{
+    if (new_visibility)
+    {
+        mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
+    }
+    else
+    {
+        mHoverTimer.stop();
+    }
+}
+
+//virtual
+void LLPanelPulldown::draw()
+{
+    F32 alpha = mHoverTimer.getStarted()
+        ? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START_SEC, AUTO_CLOSE_FADE_TIME_END_SEC, 1.f, 0.f)
+        : 1.0f;
+    LLViewDrawContext context(alpha);
+
+    LLPanel::draw();
+
+    if (alpha == 0.f)
+    {
+        setVisible(FALSE);
+    }
+}
diff --git a/indra/newview/llpanelpulldown.h b/indra/newview/llpanelpulldown.h
new file mode 100644
index 0000000000..705e76d0ab
--- /dev/null
+++ b/indra/newview/llpanelpulldown.h
@@ -0,0 +1,55 @@
+/** 
+ * @file llpanelpulldown.h
+ * @brief A panel that serves as a basis for multiple toolbar pulldown panels
+ *
+ * $LicenseInfo:firstyear=2020&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2020, Linden Research, Inc.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ * 
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLPANELPULLDOWN_H
+#define LL_LLPANELPULLDOWN_H
+
+#include "linden_common.h"
+
+#include "llpanel.h"
+
+class LLFrameTimer;
+
+class LLPanelPulldown : public LLPanel
+{
+public:
+    LLPanelPulldown();
+    /*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
+    /*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleDoubleClick(S32 x, S32 y, MASK mask);
+    /*virtual*/ BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
+    /*virtual*/ void onTopLost();
+    /*virtual*/ void onVisibilityChange(BOOL new_visibility);
+
+    /*virtual*/ void draw();
+
+protected:
+    LLFrameTimer mHoverTimer;
+};
+
+#endif // LL_LLPANELPULLDOWN_H
diff --git a/indra/newview/llpanelvolumepulldown.cpp b/indra/newview/llpanelvolumepulldown.cpp
index f063d84272..6f11e76a72 100644
--- a/indra/newview/llpanelvolumepulldown.cpp
+++ b/indra/newview/llpanelvolumepulldown.cpp
@@ -41,9 +41,6 @@
 #include "llfloaterpreference.h"
 #include "llsliderctrl.h"
 
-/* static */ const F32 LLPanelVolumePulldown::sAutoCloseFadeStartTimeSec = 2.0f;
-/* static */ const F32 LLPanelVolumePulldown::sAutoCloseTotalTimeSec = 3.0f;
-
 ///----------------------------------------------------------------------------
 /// Class LLPanelVolumePulldown
 ///----------------------------------------------------------------------------
@@ -51,8 +48,6 @@
 // Default constructor
 LLPanelVolumePulldown::LLPanelVolumePulldown()
 {
-	mHoverTimer.stop();
-
 	mCommitCallbackRegistrar.add("Vol.setControlFalse", boost::bind(&LLPanelVolumePulldown::setControlFalse, this, _2));
 	mCommitCallbackRegistrar.add("Vol.SetSounds", boost::bind(&LLPanelVolumePulldown::onClickSetSounds, this));
 	mCommitCallbackRegistrar.add("Vol.updateMediaAutoPlayCheckbox",	boost::bind(&LLPanelVolumePulldown::updateMediaAutoPlayCheckbox, this, _1));
@@ -62,41 +57,7 @@ LLPanelVolumePulldown::LLPanelVolumePulldown()
 
 BOOL LLPanelVolumePulldown::postBuild()
 {
-	return LLPanel::postBuild();
-}
-
-/*virtual*/
-void LLPanelVolumePulldown::onMouseEnter(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.stop();
-	LLPanel::onMouseEnter(x,y,mask);
-}
-
-/*virtual*/
-void LLPanelVolumePulldown::onTopLost()
-{
-	setVisible(FALSE);
-}
-
-/*virtual*/
-void LLPanelVolumePulldown::onMouseLeave(S32 x, S32 y, MASK mask)
-{
-	mHoverTimer.start();
-	LLPanel::onMouseLeave(x,y,mask);
-}
-
-/*virtual*/ 
-void LLPanelVolumePulldown::onVisibilityChange ( BOOL new_visibility )
-{
-	if (new_visibility)	
-	{
-		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
-	}
-	else
-	{
-		mHoverTimer.stop();
-
-	}
+	return LLPanelPulldown::postBuild();
 }
 
 void LLPanelVolumePulldown::onAdvancedButtonClick(const LLSD& user_data)
@@ -150,20 +111,3 @@ void LLPanelVolumePulldown::onClickSetSounds()
 	// or if sound effects are disabled.
 	getChild<LLCheckBoxCtrl>("gesture_audio_play_btn")->setEnabled(!gSavedSettings.getBOOL("MuteSounds"));
 }
-
-//virtual
-void LLPanelVolumePulldown::draw()
-{
-	F32 alpha = mHoverTimer.getStarted() 
-		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), sAutoCloseFadeStartTimeSec, sAutoCloseTotalTimeSec, 1.f, 0.f)
-		: 1.0f;
-	LLViewDrawContext context(alpha);
-
-	LLPanel::draw();
-
-	if (alpha == 0.f)
-	{
-		setVisible(FALSE);
-	}
-}
-
diff --git a/indra/newview/llpanelvolumepulldown.h b/indra/newview/llpanelvolumepulldown.h
index 4f23112f50..e907bb0c78 100644
--- a/indra/newview/llpanelvolumepulldown.h
+++ b/indra/newview/llpanelvolumepulldown.h
@@ -30,19 +30,12 @@
 
 #include "linden_common.h"
 
-#include "llpanel.h"
+#include "llpanelpulldown.h"
 
-class LLFrameTimer;
-
-class LLPanelVolumePulldown : public LLPanel
+class LLPanelVolumePulldown : public LLPanelPulldown
 {
  public:
 	LLPanelVolumePulldown();
-	/*virtual*/ void draw();
-	/*virtual*/ void onMouseEnter(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onMouseLeave(S32 x, S32 y, MASK mask);
-	/*virtual*/ void onTopLost();
-	/*virtual*/ void onVisibilityChange ( BOOL new_visibility );
 	/*virtual*/ BOOL postBuild();
 	
  private:
@@ -52,10 +45,6 @@ class LLPanelVolumePulldown : public LLPanel
 	// "Streaming Music" and "Media" are unchecked. Otherwise enables it.
 	void updateMediaAutoPlayCheckbox(LLUICtrl* ctrl);
 	void onAdvancedButtonClick(const LLSD& user_data);
-
-	LLFrameTimer mHoverTimer;
-	static const F32 sAutoCloseFadeStartTimeSec;
-	static const F32 sAutoCloseTotalTimeSec;
 };
 
 
-- 
cgit v1.2.3


From f96fb4fe4e8f7e72607862d10c5212f2108bec88 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 10 Apr 2020 15:34:23 +0300
Subject: SL-12999 Removed unused variables

---
 indra/newview/llpanelnearbymedia.cpp | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/indra/newview/llpanelnearbymedia.cpp b/indra/newview/llpanelnearbymedia.cpp
index a8887eb936..02911313ed 100644
--- a/indra/newview/llpanelnearbymedia.cpp
+++ b/indra/newview/llpanelnearbymedia.cpp
@@ -66,9 +66,6 @@ extern LLControlGroup gSavedSettings;
 static const LLUUID PARCEL_MEDIA_LIST_ITEM_UUID = LLUUID("CAB5920F-E484-4233-8621-384CF373A321");
 static const LLUUID PARCEL_AUDIO_LIST_ITEM_UUID = LLUUID("DF4B020D-8A24-4B95-AB5D-CA970D694822");
 
-const F32 AUTO_CLOSE_FADE_TIME_START= 2.0f;
-const F32 AUTO_CLOSE_FADE_TIME_END = 3.0f;
-
 //
 // LLPanelNearByMedia
 //
-- 
cgit v1.2.3


From 1ec8c7a68adb10c78e1cc31182b797d6a2ae386f Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 10 Apr 2020 17:06:14 +0300
Subject: SL-12999 List can go out of floater's rect, so it should consume
 scroll events

---
 indra/newview/skins/default/xui/en/floater_camera.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/newview/skins/default/xui/en/floater_camera.xml b/indra/newview/skins/default/xui/en/floater_camera.xml
index 60461c5743..9deb38e3af 100644
--- a/indra/newview/skins/default/xui/en/floater_camera.xml
+++ b/indra/newview/skins/default/xui/en/floater_camera.xml
@@ -217,6 +217,8 @@
         name="preset_combo"
         top_pad="10"
         width="136">
+        <combo_list
+        mouse_wheel_opaque="true"/>
         <combo_box.item
          label="Use preset"
          name="Use preset"
-- 
cgit v1.2.3


From 944b908be10367ae5770db03bddddd40cd4d18d8 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Fri, 10 Apr 2020 18:38:56 +0300
Subject: SL-12994 FIXED [Camera Presets] Zoom fraction should be saved as a
 part of Camera preset, not as separate setting

---
 indra/newview/llagentcamera.cpp             | 8 ++++++--
 indra/newview/llagentcamera.h               | 3 +++
 indra/newview/llfloatercamera.cpp           | 3 ++-
 indra/newview/llfloatersavecamerapreset.cpp | 6 ++++++
 indra/newview/llpresetsmanager.cpp          | 3 ---
 5 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index d1da132587..f1d8bf3cf1 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1987,8 +1987,7 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 
 LLVector3 LLAgentCamera::getCurrentCameraOffset()
 {
-	LLVector3 camera_offset = (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation();
-	return  camera_offset / mCameraZoomFraction / gSavedSettings.getF32("CameraOffsetScale");
+	return (LLViewerCamera::getInstance()->getOrigin() - getAvatarRootPosition() - mThirdPersonHeadOffset) * ~getCurrentAvatarRotation();
 }
 
 LLVector3d LLAgentCamera::getCurrentFocusOffset()
@@ -2829,6 +2828,11 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object,
 	return mPointAt->setPointAt(target_type, object, position);
 }
 
+void LLAgentCamera::resetCameraZoomFraction()
+{ 
+	mCameraZoomFraction = INITIAL_ZOOM_FRACTION; 
+}
+
 ELookAtType LLAgentCamera::getLookAtType()
 {
 	if (mLookAt) 
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 357dd5e12a..420cc0b601 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -282,6 +282,9 @@ public:
 	F32				calcCameraFOVZoomFactor();
 	F32				getAgentHUDTargetZoom();
 
+	void			resetCameraZoomFraction();
+	F32				getCurrentCameraZoomFraction() { return mCameraZoomFraction; }
+
 	//--------------------------------------------------------------------
 	// Pan
 	//--------------------------------------------------------------------
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index cc02862868..e1e7ee8445 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -565,7 +565,8 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 	{
 		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
 	}
-	gAgentCamera.setCameraZoomFraction(gSavedSettings.getF32("CameraZoomFraction"));
+
+	gAgentCamera.resetCameraZoomFraction();
 
 	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
 	if (camera_floater)
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index 34aefdf1c1..e2bd2e6d6a 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -107,6 +107,12 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 			gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset());
 			gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset());
 		}
+		else
+		{
+			LLVector3 camera_offset = gSavedSettings.getVector3("CameraOffsetRearView") * gAgentCamera.getCurrentCameraZoomFraction();
+			gSavedSettings.setVector3("CameraOffsetRearView", camera_offset);
+			gAgentCamera.resetCameraZoomFraction();
+		}
 		if (is_saving_new)
 		{
 			std::list<std::string> preset_names;
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index fd89a1fcb6..129187ccbd 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -309,9 +309,6 @@ bool LLPresetsManager::savePreset(const std::string& subdirectory, std::string n
 		name_list.clear();
 		getControlNames(name_list);
 		name_list.push_back("PresetCameraActive");
-
-		gSavedSettings.setF32("CameraZoomFraction", gAgentCamera.getCameraZoomFraction(true));
-		name_list.push_back("CameraZoomFraction");
 	}
 	else
 	{
-- 
cgit v1.2.3


From 70d340a1bff2707138ac41fdd1408a5b2e46fc71 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Mon, 13 Apr 2020 20:02:58 +0300
Subject: SL-12993 Focus on avatar after saving new preset

---
 indra/newview/llagentcamera.cpp             | 4 ++--
 indra/newview/llagentcamera.h               | 2 +-
 indra/newview/llfloatersavecamerapreset.cpp | 2 ++
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index f1d8bf3cf1..5efd614b22 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -2656,7 +2656,7 @@ void LLAgentCamera::setSitCamera(const LLUUID &object_id, const LLVector3 &camer
 //-----------------------------------------------------------------------------
 // setFocusOnAvatar()
 //-----------------------------------------------------------------------------
-void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
+void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate, BOOL reset_axes)
 {
 	if (focus_on_avatar != mFocusOnAvatar)
 	{
@@ -2673,7 +2673,7 @@ void LLAgentCamera::setFocusOnAvatar(BOOL focus_on_avatar, BOOL animate)
 	//RN: when focused on the avatar, we're not "looking" at it
 	// looking implies intent while focusing on avatar means
 	// you're just walking around with a camera on you...eesh.
-	if (!mFocusOnAvatar && focus_on_avatar)
+	if (!mFocusOnAvatar && focus_on_avatar && reset_axes)
 	{
 		setFocusGlobal(LLVector3d::zero);
 		mCameraFOVZoomFactor = 0.f;
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 420cc0b601..841b0e353d 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -217,7 +217,7 @@ public:
 	void			validateFocusObject();
 	void			setFocusGlobal(const LLPickInfo& pick);
 	void			setFocusGlobal(const LLVector3d &focus, const LLUUID &object_id = LLUUID::null);
-	void			setFocusOnAvatar(BOOL focus, BOOL animate);
+	void			setFocusOnAvatar(BOOL focus, BOOL animate, BOOL reset_axes = TRUE);
 	void			setCameraPosAndFocusGlobal(const LLVector3d& pos, const LLVector3d& focus, const LLUUID &object_id);
 	void			clearFocusObject();
 	void			setFocusObject(LLViewerObject* object);
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index e2bd2e6d6a..c02f8f0ea1 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -106,6 +106,8 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 		{
 			gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset());
 			gSavedSettings.setVector3d("FocusOffsetRearView", gAgentCamera.getCurrentFocusOffset());
+			gAgentCamera.resetCameraZoomFraction();
+			gAgentCamera.setFocusOnAvatar(TRUE, TRUE, FALSE);
 		}
 		else
 		{
-- 
cgit v1.2.3


From 74d6e6b65c9c3e85e8ec84939b35a1e584379e1f Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Mon, 20 Apr 2020 14:27:22 +0300
Subject: SL-12904 FIXED Camera Preset does not restore correctly when sitting

---
 indra/llmath/llquaternion.h                 | 24 ++++++++++++++
 indra/llxml/llcontrol.cpp                   | 51 +++++++++++++++++++++++++++++
 indra/llxml/llcontrol.h                     | 15 ++++++---
 indra/llxml/llcontrolgroupreader.h          |  1 +
 indra/newview/app_settings/camera/Front.xml | 16 +++++++++
 indra/newview/app_settings/camera/Rear.xml  | 16 +++++++++
 indra/newview/app_settings/camera/Side.xml  | 16 +++++++++
 indra/newview/app_settings/settings.xml     | 16 +++++++++
 indra/newview/llagentcamera.cpp             | 15 +++++++--
 indra/newview/llagentcamera.h               |  4 +++
 indra/newview/llfloatercamera.cpp           | 14 ++++++++
 indra/newview/llfloatersavecamerapreset.cpp |  6 ++++
 indra/newview/llfloatersettingsdebug.cpp    | 42 ++++++++++++++++++++++++
 indra/newview/llpresetsmanager.cpp          |  1 +
 indra/newview/llvoavatar.cpp                |  3 +-
 15 files changed, 232 insertions(+), 8 deletions(-)

diff --git a/indra/llmath/llquaternion.h b/indra/llmath/llquaternion.h
index aa0b1752f4..95e4c09695 100644
--- a/indra/llmath/llquaternion.h
+++ b/indra/llmath/llquaternion.h
@@ -28,6 +28,7 @@
 #define LLQUATERNION_H
 
 #include <iostream>
+#include <llsd.h>
 
 #ifndef LLMATH_H //enforce specific include order to avoid tangling inline dependencies
 #error "Please include llmath.h first."
@@ -64,6 +65,29 @@ public:
 				 const LLVector3 &y_axis,
 				 const LLVector3 &z_axis);			// Initializes Quaternion from Matrix3 = [x_axis ; y_axis ; z_axis]
 
+	explicit LLQuaternion(const LLSD& sd)
+	{
+		setValue(sd);
+	}
+
+	void setValue(const LLSD& sd)
+	{
+		mQ[VX] = (F32) sd[0].asReal();
+		mQ[VY] = (F32) sd[1].asReal();
+		mQ[VZ] = (F32) sd[2].asReal();
+		mQ[VS] = (F32) sd[3].asReal();
+	}
+
+	LLSD getValue() const
+	{
+		LLSD ret;
+		ret[0] = mQ[VX];
+		ret[1] = mQ[VY];
+		ret[2] = mQ[VZ];
+		ret[3] = mQ[VS];
+		return ret;
+	}
+
 	BOOL isIdentity() const;
 	BOOL isNotIdentity() const;
 	BOOL isFinite() const;									// checks to see if all values of LLQuaternion are finite
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index ccf4f3ddf5..80a414d00f 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -40,6 +40,7 @@
 #include "v4coloru.h"
 #include "v4color.h"
 #include "v3color.h"
+#include "llquaternion.h"
 #include "llrect.h"
 #include "llxmltree.h"
 #include "llsdserialize.h"
@@ -125,6 +126,9 @@ bool LLControlVariable::llsd_compare(const LLSD& a, const LLSD & b)
 	case TYPE_VEC3D:
 		result = LLVector3d(a) == LLVector3d(b);
 		break;
+	case TYPE_QUAT:
+		result = LLQuaternion(a) == LLQuaternion(b);
+		break;
 	case TYPE_RECT:
 		result = LLRect(a) == LLRect(b);
 		break;
@@ -361,6 +365,7 @@ const std::string LLControlGroup::mTypeString[TYPE_COUNT] = { "U32"
                                                              ,"String"
                                                              ,"Vector3"
                                                              ,"Vector3D"
+                                                             ,"Quaternion"
                                                              ,"Rect"
                                                              ,"Color4"
                                                              ,"Color3"
@@ -523,6 +528,11 @@ LLControlVariable* LLControlGroup::declareVec3d(const std::string& name, const L
 	return declareControl(name, TYPE_VEC3D, initial_val.getValue(), comment, persist);
 }
 
+LLControlVariable* LLControlGroup::declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
+{
+	return declareControl(name, TYPE_QUAT, initial_val.getValue(), comment, persist);
+}
+
 LLControlVariable* LLControlGroup::declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist)
 {
 	return declareControl(name, TYPE_RECT, initial_val.getValue(), comment, persist);
@@ -600,6 +610,11 @@ LLVector3d LLControlGroup::getVector3d(const std::string& name)
 	return get<LLVector3d>(name);
 }
 
+LLQuaternion LLControlGroup::getQuaternion(const std::string& name)
+{
+	return get<LLQuaternion>(name);
+}
+
 LLRect LLControlGroup::getRect(const std::string& name)
 {
 	return get<LLRect>(name);
@@ -677,6 +692,11 @@ void LLControlGroup::setVector3d(const std::string& name, const LLVector3d &val)
 	set(name, val);
 }
 
+void LLControlGroup::setQuaternion(const std::string& name, const LLQuaternion &val)
+{
+	set(name, val);
+}
+
 void LLControlGroup::setRect(const std::string& name, const LLRect &val)
 {
 	set(name, val);
@@ -859,6 +879,16 @@ U32 LLControlGroup::loadFromFileLegacy(const std::string& filename, BOOL require
 				validitems++;
 			}
 			break;
+		case TYPE_QUAT:
+			{
+				LLQuaternion quat;
+
+				child_nodep->getAttributeQuat("value", quat);
+
+				control->set(quat.getValue());
+				validitems++;
+			}
+			break;
 		case TYPE_RECT:
 			{
 				//RN: hack to support reading rectangles from a string
@@ -1201,6 +1231,11 @@ template <> eControlType get_control_type<LLVector3d>()
 	return TYPE_VEC3D; 
 }
 
+template <> eControlType get_control_type<LLQuaternion>()
+{
+	return TYPE_QUAT;
+}
+
 template <> eControlType get_control_type<LLRect>() 
 { 
 	return TYPE_RECT; 
@@ -1236,6 +1271,10 @@ template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in)
 { 
 	return in.getValue(); 
 }
+template <> LLSD convert_to_llsd<LLQuaternion>(const LLQuaternion& in)
+{
+	return in.getValue();
+}
 
 template <> LLSD convert_to_llsd<LLRect>(const LLRect& in) 
 { 
@@ -1348,6 +1387,18 @@ LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, cons
 	}
 }
 
+template<>
+LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name)
+{
+	if (type == TYPE_QUAT)
+		return (LLQuaternion)sd;
+	else
+	{
+		CONTROL_ERRS << "Invalid LLQuaternion value for " << control_name << ": " << LLControlGroup::typeEnumToString(type) << " " << sd << LL_ENDL;
+		return LLQuaternion();
+	}
+}
+
 template<>
 LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name)
 {
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index de0d366492..f136918896 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -67,6 +67,7 @@
 
 class LLVector3;
 class LLVector3d;
+class LLQuaternion;
 class LLColor4;
 class LLColor3;
 
@@ -80,6 +81,7 @@ typedef enum e_control_type
 	TYPE_STRING,
 	TYPE_VEC3,
 	TYPE_VEC3D,
+	TYPE_QUAT,
 	TYPE_RECT,
 	TYPE_COL4,
 	TYPE_COL3,
@@ -220,6 +222,7 @@ public:
 	LLControlVariable* declareString(const std::string& name, const std::string &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
 	LLControlVariable* declareVec3(const std::string& name, const LLVector3 &initial_val,const std::string& comment,  LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
 	LLControlVariable* declareVec3d(const std::string& name, const LLVector3d &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
+	LLControlVariable* declareQuat(const std::string& name, const LLQuaternion &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
 	LLControlVariable* declareRect(const std::string& name, const LLRect &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
 	LLControlVariable* declareColor4(const std::string& name, const LLColor4 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
 	LLControlVariable* declareColor3(const std::string& name, const LLColor3 &initial_val, const std::string& comment, LLControlVariable::ePersist persist = LLControlVariable::PERSIST_NONDFT);
@@ -234,10 +237,10 @@ public:
 	
 	LLWString	getWString(const std::string& name);
 	LLVector3	getVector3(const std::string& name);
-	LLVector3d	getVector3d(const std::string& name);
+	LLVector3d	getVector3d(const std::string& name);	
 	LLRect		getRect(const std::string& name);
 	LLSD        getLLSD(const std::string& name);
-
+	LLQuaternion	getQuaternion(const std::string& name);
 
 	LLColor4	getColor(const std::string& name);
 	LLColor4	getColor4(const std::string& name);
@@ -270,6 +273,7 @@ public:
 	void	setString(const std::string&  name, const std::string& val);
 	void	setVector3(const std::string& name, const LLVector3 &val);
 	void	setVector3d(const std::string& name, const LLVector3d &val);
+	void	setQuaternion(const std::string& name, const LLQuaternion &val);
 	void	setRect(const std::string& name, const LLRect &val);
 	void	setColor4(const std::string& name, const LLColor4 &val);
 	void    setLLSD(const std::string& name, const LLSD& val);
@@ -436,7 +440,8 @@ template <> eControlType get_control_type<bool>();
 //template <> eControlType get_control_type<BOOL> () 
 template <> eControlType get_control_type<std::string>();
 template <> eControlType get_control_type<LLVector3>();
-template <> eControlType get_control_type<LLVector3d>(); 
+template <> eControlType get_control_type<LLVector3d>();
+template <> eControlType get_control_type<LLQuaternion>();
 template <> eControlType get_control_type<LLRect>();
 template <> eControlType get_control_type<LLColor4>();
 template <> eControlType get_control_type<LLColor3>();
@@ -444,7 +449,8 @@ template <> eControlType get_control_type<LLSD>();
 
 template <> LLSD convert_to_llsd<U32>(const U32& in);
 template <> LLSD convert_to_llsd<LLVector3>(const LLVector3& in);
-template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in); 
+template <> LLSD convert_to_llsd<LLVector3d>(const LLVector3d& in);
+template <> LLSD convert_to_llsd<LLQuaternion>(const LLQuaternion& in);
 template <> LLSD convert_to_llsd<LLRect>(const LLRect& in);
 template <> LLSD convert_to_llsd<LLColor4>(const LLColor4& in);
 template <> LLSD convert_to_llsd<LLColor3>(const LLColor3& in);
@@ -453,6 +459,7 @@ template<> std::string convert_from_llsd<std::string>(const LLSD& sd, eControlTy
 template<> LLWString convert_from_llsd<LLWString>(const LLSD& sd, eControlType type, const std::string& control_name);
 template<> LLVector3 convert_from_llsd<LLVector3>(const LLSD& sd, eControlType type, const std::string& control_name);
 template<> LLVector3d convert_from_llsd<LLVector3d>(const LLSD& sd, eControlType type, const std::string& control_name);
+template<> LLQuaternion convert_from_llsd<LLQuaternion>(const LLSD& sd, eControlType type, const std::string& control_name);
 template<> LLRect convert_from_llsd<LLRect>(const LLSD& sd, eControlType type, const std::string& control_name);
 template<> bool convert_from_llsd<bool>(const LLSD& sd, eControlType type, const std::string& control_name);
 template<> S32 convert_from_llsd<S32>(const LLSD& sd, eControlType type, const std::string& control_name);
diff --git a/indra/llxml/llcontrolgroupreader.h b/indra/llxml/llcontrolgroupreader.h
index 6a27a65499..fe77d33fc4 100644
--- a/indra/llxml/llcontrolgroupreader.h
+++ b/indra/llxml/llcontrolgroupreader.h
@@ -65,6 +65,7 @@ public:
 	virtual void		setString(const std::string&  name, const std::string& val) {}
 	virtual void		setVector3(const std::string& name, const LLVector3 &val) {}
 	virtual void		setVector3d(const std::string& name, const LLVector3d &val) {}
+	virtual void		setQuaternion(const std::string& name, const LLQuaternion &val) {}
 	virtual void		setRect(const std::string& name, const LLRect &val) {}
 	virtual void		setColor4(const std::string& name, const LLColor4 &val) {}
 	virtual void    	setLLSD(const std::string& name, const LLSD& val) {}
diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
index 7b5d597fdf..f9f615c4a7 100644
--- a/indra/newview/app_settings/camera/Front.xml
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -11,6 +11,22 @@
         <key>Value</key>
             <integer>1</integer>
         </map>
+    <key>AvatarSitRotation</key>
+    <map>
+        <key>Comment</key>
+        <string>Avatar real sitting rotation used in preset</string>
+        <key>Persist</key>
+        <integer>1</integer>
+        <key>Type</key>
+        <string>Quaternion</string>
+        <key>Value</key>
+        <array>
+          <real>0</real>
+          <real>0</real>
+          <real>0</real>
+          <real>1</real>
+        </array>
+    </map>
     <key>CameraAngle</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml
index 7aa36c3e59..a084f83bfe 100644
--- a/indra/newview/app_settings/camera/Rear.xml
+++ b/indra/newview/app_settings/camera/Rear.xml
@@ -11,6 +11,22 @@
         <key>Value</key>
             <integer>1</integer>
         </map>
+    <key>AvatarSitRotation</key>
+    <map>
+        <key>Comment</key>
+        <string>Avatar real sitting rotation used in preset</string>
+        <key>Persist</key>
+        <integer>1</integer>
+        <key>Type</key>
+        <string>Quaternion</string>
+        <key>Value</key>
+        <array>
+          <real>0</real>
+          <real>0</real>
+          <real>0</real>
+          <real>1</real>
+        </array>
+    </map>
     <key>CameraAngle</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
index 8890d9cbce..5db5b164bd 100644
--- a/indra/newview/app_settings/camera/Side.xml
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -11,6 +11,22 @@
         <key>Value</key>
             <integer>1</integer>
         </map>
+    <key>AvatarSitRotation</key>
+    <map>
+        <key>Comment</key>
+        <string>Avatar real sitting rotation used in preset</string>
+        <key>Persist</key>
+        <integer>1</integer>
+        <key>Type</key>
+        <string>Quaternion</string>
+        <key>Value</key>
+        <array>
+          <real>0</real>
+          <real>0</real>
+          <real>0</real>
+          <real>1</real>
+        </array>
+    </map>
     <key>CameraAngle</key>
         <map>
         <key>Comment</key>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index cc86ba85c1..84448919e1 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4397,6 +4397,22 @@
         <real>1.0</real>
       </array>
     </map>
+    <key>AvatarSitRotation</key>
+    <map>
+      <key>Comment</key>
+      <string>Avatar real sitting rotation used in preset</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Quaternion</string>
+      <key>Value</key>
+      <array>
+        <real>0</real>
+        <real>0</real>
+        <real>0</real>
+        <real>1</real>
+      </array>
+    </map>
     <key>FocusPosOnLogout</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp
index 5efd614b22..7a82cf2f66 100644
--- a/indra/newview/llagentcamera.cpp
+++ b/indra/newview/llagentcamera.cpp
@@ -1804,8 +1804,8 @@ LLVector3d LLAgentCamera::calcCameraPositionTargetGlobal(BOOL *hit_limit)
 				at_axis.mV[VZ] = 0.f;
 				at_axis.normalize();
 				gAgent.resetAxes(at_axis * ~parent_rot);
-
-				local_camera_offset = local_camera_offset * parent_rot;
+				
+				local_camera_offset = local_camera_offset * gAgent.getFrameAgent().getQuaternion() * parent_rot;
 			}
 			else
 			{
@@ -1998,7 +1998,10 @@ LLVector3d LLAgentCamera::getCurrentFocusOffset()
 LLQuaternion LLAgentCamera::getCurrentAvatarRotation()
 {
 	LLViewerObject* sit_object = (LLViewerObject*)gAgentAvatarp->getParent();
-	return sit_object ? sit_object->getRenderRotation() : gAgent.getFrameAgent().getQuaternion();
+	
+	LLQuaternion av_rot = gAgent.getFrameAgent().getQuaternion();
+	LLQuaternion obj_rot = sit_object ? sit_object->getRenderRotation() : LLQuaternion::DEFAULT;
+	return av_rot * obj_rot;
 }
 
 bool LLAgentCamera::isJoystickCameraUsed()
@@ -2828,6 +2831,12 @@ BOOL LLAgentCamera::setPointAt(EPointAtType target_type, LLViewerObject *object,
 	return mPointAt->setPointAt(target_type, object, position);
 }
 
+void LLAgentCamera::rotateToInitSitRot()
+{
+	gAgent.rotate(~gAgent.getFrameAgent().getQuaternion());
+	gAgent.rotate(mInitSitRot);
+}
+
 void LLAgentCamera::resetCameraZoomFraction()
 { 
 	mCameraZoomFraction = INITIAL_ZOOM_FRACTION; 
diff --git a/indra/newview/llagentcamera.h b/indra/newview/llagentcamera.h
index 841b0e353d..ec1ed433d7 100644
--- a/indra/newview/llagentcamera.h
+++ b/indra/newview/llagentcamera.h
@@ -121,6 +121,8 @@ public:
 	LLVector3d getCurrentFocusOffset();
 	LLQuaternion getCurrentAvatarRotation();
 	bool isJoystickCameraUsed();
+	void setInitSitRot(LLQuaternion sit_rot) { mInitSitRot = sit_rot; };
+	void rotateToInitSitRot();
 
 private:
 	/** Determines maximum camera distance from target for mouselook, opposite to LAND_MIN_ZOOM */
@@ -135,6 +137,8 @@ private:
 	/** Initial focus offset */
 	LLPointer<LLControlVariable> mFocusOffsetInitial;
 
+	LLQuaternion mInitSitRot;
+
 	//--------------------------------------------------------------------
 	// Position
 	//--------------------------------------------------------------------
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index e1e7ee8445..2399e4f495 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -44,6 +44,7 @@
 #include "llfirstuse.h"
 #include "llhints.h"
 #include "lltabcontainer.h"
+#include "llvoavatarself.h"
 
 static LLDefaultChildRegistry::Register<LLPanelCameraItem> r("panel_camera_item");
 
@@ -566,6 +567,19 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 		LLPresetsManager::getInstance()->loadPreset(PRESETS_CAMERA, name);
 	}
 
+	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+	{
+		LLQuaternion sit_rot = gSavedSettings.getQuaternion("AvatarSitRotation");
+		if (sit_rot != LLQuaternion())
+		{
+			gAgent.rotate(~gAgent.getFrameAgent().getQuaternion());
+			gAgent.rotate(sit_rot);
+		}
+		else
+		{
+			gAgentCamera.rotateToInitSitRot();
+		}
+	}
 	gAgentCamera.resetCameraZoomFraction();
 
 	LLFloaterCamera* camera_floater = LLFloaterCamera::findInstance();
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index c02f8f0ea1..5704a7a525 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -28,6 +28,7 @@
 
 #include "llfloatersavecamerapreset.h"
 
+#include "llagent.h"
 #include "llagentcamera.h"
 #include "llbutton.h"
 #include "llcombobox.h"
@@ -38,6 +39,7 @@
 #include "llpresetsmanager.h"
 #include "llradiogroup.h"
 #include "lltrans.h"
+#include "llvoavatarself.h"
 
 LLFloaterSaveCameraPreset::LLFloaterSaveCameraPreset(const LLSD &key)
 	: LLModalDialog(key)
@@ -102,6 +104,10 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 	}
 	else 
 	{
+		if (isAgentAvatarValid() && gAgentAvatarp->getParent())
+		{
+			gSavedSettings.setQuaternion("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion());
+		}
 		if (gAgentCamera.isJoystickCameraUsed())
 		{
 			gSavedSettings.setVector3("CameraOffsetRearView", gAgentCamera.getCurrentCameraOffset());
diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp
index fb202b4c40..186994c857 100644
--- a/indra/newview/llfloatersettingsdebug.cpp
+++ b/indra/newview/llfloatersettingsdebug.cpp
@@ -111,6 +111,7 @@ void LLFloaterSettingsDebug::onCommitSettings()
 
 	LLVector3 vector;
 	LLVector3d vectord;
+	LLQuaternion quat;
 	LLRect rect;
 	LLColor4 col4;
 	LLColor3 col3;
@@ -146,6 +147,13 @@ void LLFloaterSettingsDebug::onCommitSettings()
 		vectord.mdV[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
 		controlp->set(vectord.getValue());
 		break;
+	  case TYPE_QUAT:
+		quat.mQ[VX] = getChild<LLUICtrl>("val_spinner_1")->getValue().asReal();
+		quat.mQ[VY] = getChild<LLUICtrl>("val_spinner_2")->getValue().asReal();
+		quat.mQ[VZ] = getChild<LLUICtrl>("val_spinner_3")->getValue().asReal();
+		quat.mQ[VS] = getChild<LLUICtrl>("val_spinner_4")->getValue().asReal();;
+		controlp->set(quat.getValue());
+		break;
 	  case TYPE_RECT:
 		rect.mLeft = getChild<LLUICtrl>("val_spinner_1")->getValue().asInteger();
 		rect.mRight = getChild<LLUICtrl>("val_spinner_2")->getValue().asInteger();
@@ -351,6 +359,40 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
 			}
 			break;
 		  }
+		  case TYPE_QUAT:
+		  {
+			  LLQuaternion q;
+			  q.setValue(sd);
+			  spinner1->setVisible(TRUE);
+			  spinner1->setLabel(std::string("X"));
+			  spinner2->setVisible(TRUE);
+			  spinner2->setLabel(std::string("Y"));
+			  spinner3->setVisible(TRUE);
+			  spinner3->setLabel(std::string("Z"));
+			  spinner4->setVisible(TRUE);
+			  spinner4->setLabel(std::string("S"));
+			  if (!spinner1->hasFocus())
+			  {
+				  spinner1->setPrecision(4);
+				  spinner1->setValue(q.mQ[VX]);
+			  }
+			  if (!spinner2->hasFocus())
+			  {
+				  spinner2->setPrecision(4);
+				  spinner2->setValue(q.mQ[VY]);
+			  }
+			  if (!spinner3->hasFocus())
+			  {
+				  spinner3->setPrecision(4);
+				  spinner3->setValue(q.mQ[VZ]);
+			  }
+			  if (!spinner4->hasFocus())
+			  {
+				  spinner4->setPrecision(4);
+				  spinner4->setValue(q.mQ[VS]);
+			  }
+			  break;
+		  }
 		  case TYPE_RECT:
 		  {
 			LLRect r;
diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 129187ccbd..4dbd6a523d 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -261,6 +261,7 @@ void LLPresetsManager::getControlNames(std::vector<std::string>& names)
 		("TrackFocusObject")
 		("CameraOffsetRearView")
 		("FocusOffsetRearView")
+		("AvatarSitRotation")
         ;
     names = camera_controls;
 }
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index b524db478e..7fb4cc6822 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -7336,7 +7336,8 @@ void LLVOAvatar::sitOnObject(LLViewerObject *sit_object)
 	mRoot->updateWorldMatrixChildren();
 
 	stopMotion(ANIM_AGENT_BODY_NOISE);
-
+	
+	gAgentCamera.setInitSitRot(gAgent.getFrameAgent().getQuaternion());
 }
 
 //-----------------------------------------------------------------------------
-- 
cgit v1.2.3


From 2ea5c5986a467e253ad0131b4af0faee23b263a4 Mon Sep 17 00:00:00 2001
From: Mnikolenko Productengine <mnikolenko@productengine.com>
Date: Thu, 23 Apr 2020 13:22:27 +0300
Subject: SL-12904 Temporarily use LLSD to avoid crashes on older viewers

---
 indra/newview/app_settings/camera/Front.xml | 2 +-
 indra/newview/app_settings/camera/Rear.xml  | 2 +-
 indra/newview/app_settings/camera/Side.xml  | 2 +-
 indra/newview/app_settings/settings.xml     | 2 +-
 indra/newview/llfloatercamera.cpp           | 2 +-
 indra/newview/llfloatersavecamerapreset.cpp | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/indra/newview/app_settings/camera/Front.xml b/indra/newview/app_settings/camera/Front.xml
index f9f615c4a7..39f44e11a8 100644
--- a/indra/newview/app_settings/camera/Front.xml
+++ b/indra/newview/app_settings/camera/Front.xml
@@ -18,7 +18,7 @@
         <key>Persist</key>
         <integer>1</integer>
         <key>Type</key>
-        <string>Quaternion</string>
+        <string>LLSD</string>
         <key>Value</key>
         <array>
           <real>0</real>
diff --git a/indra/newview/app_settings/camera/Rear.xml b/indra/newview/app_settings/camera/Rear.xml
index a084f83bfe..8dc36353ce 100644
--- a/indra/newview/app_settings/camera/Rear.xml
+++ b/indra/newview/app_settings/camera/Rear.xml
@@ -18,7 +18,7 @@
         <key>Persist</key>
         <integer>1</integer>
         <key>Type</key>
-        <string>Quaternion</string>
+        <string>LLSD</string>
         <key>Value</key>
         <array>
           <real>0</real>
diff --git a/indra/newview/app_settings/camera/Side.xml b/indra/newview/app_settings/camera/Side.xml
index 5db5b164bd..089ab93a8f 100644
--- a/indra/newview/app_settings/camera/Side.xml
+++ b/indra/newview/app_settings/camera/Side.xml
@@ -18,7 +18,7 @@
         <key>Persist</key>
         <integer>1</integer>
         <key>Type</key>
-        <string>Quaternion</string>
+        <string>LLSD</string>
         <key>Value</key>
         <array>
           <real>0</real>
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 84448919e1..3e3d6a7237 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -4404,7 +4404,7 @@
       <key>Persist</key>
       <integer>1</integer>
       <key>Type</key>
-      <string>Quaternion</string>
+      <string>LLSD</string>
       <key>Value</key>
       <array>
         <real>0</real>
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 2399e4f495..d574f1433f 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -569,7 +569,7 @@ void LLFloaterCamera::switchToPreset(const std::string& name)
 
 	if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 	{
-		LLQuaternion sit_rot = gSavedSettings.getQuaternion("AvatarSitRotation");
+		LLQuaternion sit_rot(gSavedSettings.getLLSD("AvatarSitRotation"));
 		if (sit_rot != LLQuaternion())
 		{
 			gAgent.rotate(~gAgent.getFrameAgent().getQuaternion());
diff --git a/indra/newview/llfloatersavecamerapreset.cpp b/indra/newview/llfloatersavecamerapreset.cpp
index 5704a7a525..11809f9c82 100644
--- a/indra/newview/llfloatersavecamerapreset.cpp
+++ b/indra/newview/llfloatersavecamerapreset.cpp
@@ -106,7 +106,7 @@ void LLFloaterSaveCameraPreset::onBtnSave()
 	{
 		if (isAgentAvatarValid() && gAgentAvatarp->getParent())
 		{
-			gSavedSettings.setQuaternion("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion());
+			gSavedSettings.setLLSD("AvatarSitRotation", gAgent.getFrameAgent().getQuaternion().getValue());
 		}
 		if (gAgentCamera.isJoystickCameraUsed())
 		{
-- 
cgit v1.2.3


From 49db074be4a778153bf88d7a3846068b43912a7d Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 21 Feb 2020 23:38:39 +0200
Subject: SL-12678 Removed auto login retry

---
 indra/newview/lllogininstance.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp
index 8a69acb8dc..873531ef22 100644
--- a/indra/newview/lllogininstance.cpp
+++ b/indra/newview/lllogininstance.cpp
@@ -62,7 +62,7 @@
 #include <boost/scoped_ptr.hpp>
 #include <sstream>
 
-const S32 LOGIN_MAX_RETRIES = 3;
+const S32 LOGIN_MAX_RETRIES = 0; // Viewer should not autmatically retry login
 const F32 LOGIN_SRV_TIMEOUT_MIN = 10;
 const F32 LOGIN_SRV_TIMEOUT_MAX = 120;
 const F32 LOGIN_DNS_TIMEOUT_FACTOR = 0.9; // make DNS wait shorter then retry time
-- 
cgit v1.2.3


From ec77b2e0ea1504f767f93868d7c4580bae078cc0 Mon Sep 17 00:00:00 2001
From: Andrey Lihatskiy <alihatskiy@productengine.com>
Date: Tue, 28 Apr 2020 19:07:55 +0300
Subject: SL-13133 Numerical camera preset names sorting order fix

---
 indra/newview/llpresetsmanager.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llpresetsmanager.cpp b/indra/newview/llpresetsmanager.cpp
index 4dbd6a523d..c267c3c699 100644
--- a/indra/newview/llpresetsmanager.cpp
+++ b/indra/newview/llpresetsmanager.cpp
@@ -208,7 +208,7 @@ void LLPresetsManager::loadPresetNamesFromDir(const std::string& subdirectory, p
 
 	if (IS_CAMERA)
 	{
-		mPresetNames.sort(); 
+		mPresetNames.sort(LLStringUtil::precedesDict);
 		if (default_option == DEFAULT_BOTTOM)
 		{
 			mPresetNames.push_back(PRESETS_FRONT_VIEW);
-- 
cgit v1.2.3


From ed3d9abdd01304b5a9708880d9b150fb6568256b Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Mon, 18 May 2020 16:26:52 -0400
Subject: Increment viewer version to 6.4.3 following promotion of DRTVWR-460

---
 indra/newview/VIEWER_VERSION.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt
index a4c853ea2e..133cad286f 100644
--- a/indra/newview/VIEWER_VERSION.txt
+++ b/indra/newview/VIEWER_VERSION.txt
@@ -1 +1 @@
-6.4.2
+6.4.3
-- 
cgit v1.2.3