From f332eaa4a69a4546e0b9b2ba3719e3c038731fd3 Mon Sep 17 00:00:00 2001
From: McCabe Maxsted
Date: Thu, 10 Sep 2009 21:43:11 -0700
Subject: Created new toolbar control for windlight presets and options

---
 linden/indra/newview/CMakeLists.txt                |   5 +
 linden/indra/newview/app_settings/settings.xml     |  22 ++
 linden/indra/newview/llfloaterwindlight.cpp        |   1 +
 linden/indra/newview/lloverlaybar.cpp              |  13 +
 linden/indra/newview/lloverlaybar.h                |   8 +-
 linden/indra/newview/llpaneldisplay.cpp            |   7 +
 linden/indra/newview/llpaneldisplay.h              |   2 +
 linden/indra/newview/llwindlightremotectrl.cpp     | 262 +++++++++++++++++++++
 linden/indra/newview/llwindlightremotectrl.h       |  60 +++++
 linden/indra/newview/llwlparammanager.cpp          |  40 ++++
 linden/indra/newview/llwlparammanager.h            |  14 ++
 .../skins/default/xui/en-us/panel_overlaybar.xml   |  17 +-
 .../xui/en-us/panel_preferences_graphics1.xml      |   4 +
 .../default/xui/en-us/panel_windlight_controls.xml |  14 ++
 .../default/xui/en-us/panel_windlight_remote.xml   |  22 ++
 .../xui/en-us/panel_windlight_remote_expanded.xml  |  12 +
 16 files changed, 495 insertions(+), 8 deletions(-)
 create mode 100644 linden/indra/newview/llwindlightremotectrl.cpp
 create mode 100644 linden/indra/newview/llwindlightremotectrl.h
 create mode 100644 linden/indra/newview/skins/default/xui/en-us/panel_windlight_controls.xml
 create mode 100644 linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote.xml
 create mode 100644 linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote_expanded.xml

(limited to 'linden')

diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt
index ad044a9..2f2bdd1 100644
--- a/linden/indra/newview/CMakeLists.txt
+++ b/linden/indra/newview/CMakeLists.txt
@@ -422,6 +422,7 @@ set(viewer_SOURCE_FILES
     llwearablelist.cpp
     llweb.cpp
     llwebbrowserctrl.cpp
+    llwindlightremotectrl.cpp
     llwind.cpp
     llwlanimator.cpp
     llwldaycycle.cpp
@@ -824,6 +825,7 @@ set(viewer_HEADER_FILES
     llwebbrowserctrl.h
     llwind.h
     llwindebug.h
+    llwindlightremotectrl.h
     llwlanimator.h
     llwldaycycle.h
     llwlparammanager.h
@@ -1200,6 +1202,9 @@ set(viewer_XUI_FILES
     skins/default/xui/en-us/panel_voice_options.xml
     skins/default/xui/en-us/panel_voice_remote_expanded.xml
     skins/default/xui/en-us/panel_voice_remote.xml
+    skins/default/xui/en-us/panel_windlight_controls.xml
+    skins/default/xui/en-us/panel_windlight_remote.xml
+    skins/default/xui/en-us/panel_windlight_remote_expanded.xml
     skins/default/xui/en-us/role_actions.xml
     skins/default/xui/en-us/strings.xml
     skins/default/xui/en-us/teleport_strings.xml
diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml
index 56d65f4..39b482b 100644
--- a/linden/indra/newview/app_settings/settings.xml
+++ b/linden/indra/newview/app_settings/settings.xml
@@ -2393,6 +2393,17 @@
       <key>Value</key>
       <integer>1</integer>
     </map>
+    <key>EnableWindlightRemote</key>
+    <map>
+      <key>Comment</key>
+      <string>Enable windlight quick access remote in toolbar</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>1</integer>
+    </map>
     <key>EnergyFromTop</key>
     <map>
       <key>Comment</key>
@@ -7425,6 +7436,17 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>ShowWindlightSettingsPopup</key>
+    <map>
+      <key>Comment</key>
+      <string>Show environment settings popup</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>0</integer>
+    </map>
     <key>ShowWorldMap</key>
     <map>
       <key>Comment</key>
diff --git a/linden/indra/newview/llfloaterwindlight.cpp b/linden/indra/newview/llfloaterwindlight.cpp
index 37cd4ef..43e8e1e 100644
--- a/linden/indra/newview/llfloaterwindlight.cpp
+++ b/linden/indra/newview/llfloaterwindlight.cpp
@@ -60,6 +60,7 @@
 
 #undef max
 
+
 LLFloaterWindLight* LLFloaterWindLight::sWindLight = NULL;
 
 std::set<std::string> LLFloaterWindLight::sDefaultPresets;
diff --git a/linden/indra/newview/lloverlaybar.cpp b/linden/indra/newview/lloverlaybar.cpp
index 91a7375..6b51b3a 100644
--- a/linden/indra/newview/lloverlaybar.cpp
+++ b/linden/indra/newview/lloverlaybar.cpp
@@ -62,6 +62,7 @@
 #include "llvoavatar.h"
 #include "llvoiceremotectrl.h"
 #include "llwebbrowserctrl.h"
+#include "llwindlightremotectrl.h"
 #include "llselectmgr.h"
 
 //
@@ -92,6 +93,13 @@ void* LLOverlayBar::createVoiceRemote(void* userdata)
 	return self->mVoiceRemote;
 }
 
+void* LLOverlayBar::createWindlightRemote(void* userdata)
+{
+	LLOverlayBar *self = (LLOverlayBar*)userdata;	
+	self->mWindlightRemote = new LLWindlightRemoteCtrl();
+	return self->mWindlightRemote;
+}
+
 void* LLOverlayBar::createChatBar(void* userdata)
 {
 	gChatBar = new LLChatBar();
@@ -102,6 +110,7 @@ LLOverlayBar::LLOverlayBar()
 	:	LLPanel(),
 		mMediaRemote(NULL),
 		mVoiceRemote(NULL),
+		mWindlightRemote(NULL),
 		mMusicState(STOPPED),
 		mOriginalIMLabel("")
 {
@@ -113,6 +122,7 @@ LLOverlayBar::LLOverlayBar()
 	LLCallbackMap::map_t factory_map;
 	factory_map["media_remote"] = LLCallbackMap(LLOverlayBar::createMediaRemote, this);
 	factory_map["voice_remote"] = LLCallbackMap(LLOverlayBar::createVoiceRemote, this);
+	factory_map["windlight_remote"] = LLCallbackMap(LLOverlayBar::createWindlightRemote, this);
 	factory_map["chat_bar"] = LLCallbackMap(LLOverlayBar::createChatBar, this);
 	
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_overlaybar.xml", &factory_map);
@@ -269,6 +279,7 @@ void LLOverlayBar::refresh()
 	}
 
 
+	moveChildToBackOfTabGroup(mWindlightRemote);
 	moveChildToBackOfTabGroup(mMediaRemote);
 	moveChildToBackOfTabGroup(mVoiceRemote);
 
@@ -277,6 +288,7 @@ void LLOverlayBar::refresh()
 	{
 		childSetVisible("media_remote_container", FALSE);
 		childSetVisible("voice_remote_container", FALSE);
+		childSetVisible("windlight_remote_container", FALSE);
 		childSetVisible("state_buttons", FALSE);
 	}
 	else
@@ -284,6 +296,7 @@ void LLOverlayBar::refresh()
 		// update "remotes"
 		childSetVisible("media_remote_container", TRUE);
 		childSetVisible("voice_remote_container", LLVoiceClient::voiceEnabled());
+		childSetVisible("windlight_remote_container", gSavedSettings.getBOOL("EnableWindlightRemote"));
 		childSetVisible("state_buttons", TRUE);
 	}
 
diff --git a/linden/indra/newview/lloverlaybar.h b/linden/indra/newview/lloverlaybar.h
index 52a469a..140fabf 100644
--- a/linden/indra/newview/lloverlaybar.h
+++ b/linden/indra/newview/lloverlaybar.h
@@ -40,6 +40,7 @@ extern S32 STATUS_BAR_HEIGHT;
 class LLButton;
 class LLLineEditor;
 class LLMediaRemoteCtrl;
+
 class LLMessageSystem;
 class LLTextBox;
 class LLTextEditor;
@@ -49,6 +50,7 @@ class LLFrameTimer;
 class LLStatGraph;
 class LLSlider;
 class LLVoiceRemoteCtrl;
+class LLWindlightRemoteCtrl;
 
 class LLOverlayBar
 :	public LLPanel
@@ -88,13 +90,15 @@ public:
 protected:	
 	static void* createMediaRemote(void* userdata);
 	static void* createVoiceRemote(void* userdata);
+	static void* createWindlightRemote(void* userdata);
 	static void* createChatBar(void* userdata);
 
 	void enableMediaButtons();
 
 protected:
-	LLMediaRemoteCtrl*	mMediaRemote;
-	LLVoiceRemoteCtrl*	mVoiceRemote;
+	LLMediaRemoteCtrl*		mMediaRemote;
+	LLVoiceRemoteCtrl*		mVoiceRemote;
+	LLWindlightRemoteCtrl*	mWindlightRemote;
 	bool				mBuilt;	// dialog constructed yet?
 	S32					mMusicState;
 	std::string			mOriginalIMLabel;
diff --git a/linden/indra/newview/llpaneldisplay.cpp b/linden/indra/newview/llpaneldisplay.cpp
index d510775..308f3df 100644
--- a/linden/indra/newview/llpaneldisplay.cpp
+++ b/linden/indra/newview/llpaneldisplay.cpp
@@ -318,6 +318,9 @@ BOOL LLPanelDisplay::postBuild()
 	mLightingText = getChild<LLTextBox>("LightingDetailText");
 	mMeshDetailText = getChild<LLTextBox>("MeshDetailText");
 
+	childSetValue("toggle_windlight_control", gSavedSettings.getBOOL("EnableWindlightRemote"));
+	mWLControl = gSavedSettings.getBOOL("EnableWindlightRemote");
+
 	refresh();
 
 	return TRUE;
@@ -690,6 +693,8 @@ void LLPanelDisplay::cancel()
 	gSavedSettings.setU32("WLSkyDetail", mSkyLOD);
 	gSavedSettings.setS32("RenderMaxPartCount", mParticleCount);
 	gSavedSettings.setS32("RenderGlowResolutionPow", mPostProcess);
+
+	gSavedSettings.setBOOL("EnableWindlightRemote", mWLControl);
 }
 
 void LLPanelDisplay::apply()
@@ -701,6 +706,8 @@ void LLPanelDisplay::apply()
 	{
 		applyWindowSize();
 	}
+
+	gSavedSettings.setBOOL("EnableWindlightRemote", childGetValue("toggle_windlight_control").asBoolean());
 }
 
 void LLPanelDisplay::onChangeQuality(LLUICtrl *ctrl, void *data)
diff --git a/linden/indra/newview/llpaneldisplay.h b/linden/indra/newview/llpaneldisplay.h
index f98e94e..80ef5cb 100644
--- a/linden/indra/newview/llpaneldisplay.h
+++ b/linden/indra/newview/llpaneldisplay.h
@@ -170,6 +170,8 @@ protected:
 	S32 mParticleCount;
 	S32 mPostProcess;
 
+	BOOL mWLControl;
+
 	static void setGraphicsSettings(LLControlGroup& group);
 	static void createGroup();
 
diff --git a/linden/indra/newview/llwindlightremotectrl.cpp b/linden/indra/newview/llwindlightremotectrl.cpp
new file mode 100644
index 0000000..e47eef7
--- /dev/null
+++ b/linden/indra/newview/llwindlightremotectrl.cpp
@@ -0,0 +1,262 @@
+/**
+* @file llwindlightremotectrl.cpp
+* @brief toolbar remote for windlight options and presets
+*
+* $LicenseInfo:firstyear=2009&license=viewergpl$
+*
+* Copyright (c) 2009, McCabe Maxsted
+*
+* Imprudence Viewer Source Code
+* The source code in this file ("Source Code") is provided to you
+* under the terms of the GNU General Public License, version 2.0
+* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
+* this distribution, or online at
+* http://secondlifegrid.net/programs/open_source/licensing/gplv2
+*
+* There are special exceptions to the terms and conditions of the GPL as
+* it is applied to this Source Code. View the full text of the exception
+* in the file doc/FLOSS-exception.txt in this software distribution, or
+* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
+*
+* By copying, modifying or distributing this software, you acknowledge
+* that you have read and understood your obligations described above,
+* and agree to abide by those obligations.
+*
+* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
+* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+* COMPLETENESS OR PERFORMANCE.
+* $/LicenseInfo$
+*/
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llwindlightremotectrl.h"
+
+#include "llbutton.h"
+#include "llcombobox.h"
+#include "llfloaterenvsettings.h"
+#include "llfloaterwindlight.h"
+#include "lloverlaybar.h"
+#include "lluictrlfactory.h"
+#include "llwlparammanager.h"
+#include "llviewercontrol.h"
+
+
+class LLWindlightRemoteObserver : public LLWLPresetsObserver
+{
+public:
+	LLWindlightRemoteObserver(LLWindlightRemoteCtrl* wind_rem) : mWindlightRemote(wind_rem){}
+	virtual ~LLWindlightRemoteObserver() {}
+	virtual void changed() { mWindlightRemote->refreshPresets(); }
+private:
+	LLWindlightRemoteCtrl* mWindlightRemote;
+};
+
+
+LLWindlightRemoteCtrl::LLWindlightRemoteCtrl() 	
+{
+	mPresetsCombo = NULL;
+	mObserver = NULL;
+	setIsChrome(TRUE);
+
+	build();
+
+	setFocusRoot(TRUE);
+}
+
+LLWindlightRemoteCtrl::~LLWindlightRemoteCtrl()
+{
+	delete mObserver;
+	mObserver = NULL;
+}
+
+void LLWindlightRemoteCtrl::draw()
+{
+	LLButton* expand_button = getChild<LLButton>("Popup");
+	if (expand_button)
+	{
+		if (expand_button->getToggleState())
+		{
+			expand_button->setImageOverlay("arrow_down.tga");
+		}
+		else
+		{
+			expand_button->setImageOverlay("arrow_up.tga");
+		}
+	}
+
+	LLPanel::draw();
+}
+
+void LLWindlightRemoteCtrl::build()
+{
+	if (gSavedSettings.getBOOL("ShowWindlightSettingsPopup"))
+	{
+		LLUICtrlFactory::getInstance()->buildPanel(this, "panel_windlight_remote_expanded.xml"/*, &getFactoryMap()*/);
+	}
+	else
+	{
+		LLUICtrlFactory::getInstance()->buildPanel(this, "panel_windlight_remote.xml"/*, &getFactoryMap()*/);
+	}
+}
+
+BOOL LLWindlightRemoteCtrl::postBuild()
+{
+	
+	childSetAction("Environment", onClickToggleEnvironment, this);
+	childSetAction("Popup", onClickPopupBtn, this);
+
+	mPresetsCombo = getChild<LLComboBox>("Presets");
+	if (mPresetsCombo)
+	{
+		mPresetsCombo->setCommitCallback(onCommitPreset);
+		mPresetsCombo->setCallbackUserData(this);
+
+		// set up observer to follow changes
+		mObserver = new LLWindlightRemoteObserver(this);
+		LLWLParamManager::addObserver(mObserver);
+
+		// refresh list from current presets
+		refreshPresets();
+	}
+
+	return TRUE;
+}
+
+void LLWindlightRemoteCtrl::refreshPresets()
+{
+	if (mPresetsCombo)
+	{
+		//store current preset
+		std::string cur_preset = mPresetsCombo->getValue().asString();
+		
+		mPresetsCombo->clearRows();
+
+		std::map<std::string, LLWLParamSet>::iterator mIt = 
+			LLWLParamManager::instance()->mParamList.begin();
+		for(; mIt != LLWLParamManager::instance()->mParamList.end(); mIt++) 
+		{
+			mPresetsCombo->add(mIt->first);
+		}
+		
+		// Insert label after sorting, at top, with separator below it
+		mPresetsCombo->addSeparator(ADD_BOTTOM);
+		mPresetsCombo->addSimpleElement(getString("sunrise"), ADD_BOTTOM);
+		mPresetsCombo->addSimpleElement(getString("noon"), ADD_BOTTOM);
+		mPresetsCombo->addSimpleElement(getString("sunset"), ADD_BOTTOM);
+		mPresetsCombo->addSimpleElement(getString("midnight"), ADD_BOTTOM);
+		mPresetsCombo->addSimpleElement(getString("revert_region"), ADD_BOTTOM);
+
+		if (!cur_preset.empty())
+		{ 
+			mPresetsCombo->selectByValue(LLSD(cur_preset));
+		}
+		else
+		{
+			mPresetsCombo->selectByValue(LLSD("Default"));
+		}
+	}
+}
+
+// static
+void LLWindlightRemoteCtrl::onCommitPreset(LLUICtrl* ctrl, void* data)
+{
+	LLWindlightRemoteCtrl* self = (LLWindlightRemoteCtrl*)data;
+
+	LLCtrlListInterface* presets = self->mPresetsCombo ? self->mPresetsCombo->getListInterface() : NULL;
+	if (presets)
+	{
+		S32 index = presets->getFirstSelectedIndex();
+		if (index <= 0)
+		{
+			// Open Advanced Sky
+			LLFloaterWindLight::show();
+			return;
+		}
+
+		// check for World menu options; if none, apply preset
+		std::string selected = self->mPresetsCombo->getSelectedValue().asString();
+
+		if (selected == self->getString("sunrise"))
+		{
+			// set the value, turn off animation
+			LLWLParamManager::instance()->mAnimator.setDayTime(0.25);
+			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
+			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
+
+			// then call update once
+			LLWLParamManager::instance()->mAnimator.update(
+				LLWLParamManager::instance()->mCurParams);
+		}
+		else if (selected == self->getString("noon"))
+		{
+			// set the value, turn off animation
+			LLWLParamManager::instance()->mAnimator.setDayTime(0.567);
+			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
+			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
+
+			// then call update once
+			LLWLParamManager::instance()->mAnimator.update(
+				LLWLParamManager::instance()->mCurParams);
+		}
+		else if (selected == self->getString("sunset"))
+		{
+			// set the value, turn off animation
+			LLWLParamManager::instance()->mAnimator.setDayTime(0.75);
+			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
+			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
+
+			// then call update once
+			LLWLParamManager::instance()->mAnimator.update(
+				LLWLParamManager::instance()->mCurParams);
+		}
+		else if (selected == self->getString("midnight"))
+		{
+			// set the value, turn off animation
+			LLWLParamManager::instance()->mAnimator.setDayTime(0.0);
+			LLWLParamManager::instance()->mAnimator.mIsRunning = false;
+			LLWLParamManager::instance()->mAnimator.mUseLindenTime = false;
+
+			// then call update once
+			LLWLParamManager::instance()->mAnimator.update(
+				LLWLParamManager::instance()->mCurParams);
+		}
+		else if (selected == self->getString("revert_region"))
+		{
+			LLWLParamManager::instance()->mAnimator.mIsRunning = true;
+			LLWLParamManager::instance()->mAnimator.mUseLindenTime = true;	
+		}
+		else
+		{
+			// Apply preset
+			LLWLParamManager::instance()->loadPreset(selected);
+		}
+	}
+}
+
+// static
+void LLWindlightRemoteCtrl::onClickToggleEnvironment(void* data)
+{
+	// if evn settings not there or is hidden, show it
+	if(	!LLFloaterEnvSettings::isOpen() || 
+		!LLFloaterEnvSettings::instance()->getVisible()) 
+	{
+		LLFloaterEnvSettings::show();
+	
+	// otherwise, close it button acts like a toggle
+	} 
+	else 
+	{
+		LLFloaterEnvSettings::instance()->close();
+	}
+}
+
+//static
+void LLWindlightRemoteCtrl::onClickPopupBtn(void* data)
+{
+	LLWindlightRemoteCtrl* remotep = (LLWindlightRemoteCtrl*)data;
+
+	remotep->deleteAllChildren();
+	remotep->build();
+	gOverlayBar->layoutButtons();
+}
diff --git a/linden/indra/newview/llwindlightremotectrl.h b/linden/indra/newview/llwindlightremotectrl.h
new file mode 100644
index 0000000..e4ad2d5
--- /dev/null
+++ b/linden/indra/newview/llwindlightremotectrl.h
@@ -0,0 +1,60 @@
+/**
+* @file llwindlightremotectrl.h
+* @brief toolbar remote for windlight options and presets
+*
+* $LicenseInfo:firstyear=2009&license=viewergpl$
+*
+* Copyright (c) 2009, McCabe Maxsted
+*
+* Imprudence Viewer Source Code
+* The source code in this file ("Source Code") is provided to you
+* under the terms of the GNU General Public License, version 2.0
+* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in
+* this distribution, or online at
+* http://secondlifegrid.net/programs/open_source/licensing/gplv2
+*
+* There are special exceptions to the terms and conditions of the GPL as
+* it is applied to this Source Code. View the full text of the exception
+* in the file doc/FLOSS-exception.txt in this software distribution, or
+* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
+*
+* By copying, modifying or distributing this software, you acknowledge
+* that you have read and understood your obligations described above,
+* and agree to abide by those obligations.
+*
+* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO
+* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+* COMPLETENESS OR PERFORMANCE.
+* $/LicenseInfo$
+*/
+
+#ifndef LL_LLWINDLIGHTREMOTECTRL_H
+#define LL_LLWINDLIGHTREMOTECTRL_H
+
+#include "llpanel.h"
+
+class LLComboBox;
+class LLWLPresetsObserver;
+
+class LLWindlightRemoteCtrl : public LLPanel
+{
+public:
+	LLWindlightRemoteCtrl();
+	virtual ~LLWindlightRemoteCtrl();
+	/*virtual*/ BOOL postBuild();
+	/*virtual*/ void draw();
+
+	void refreshPresets();
+
+private:
+	LLComboBox*						mPresetsCombo;
+	LLWLPresetsObserver*		mObserver;
+
+	void build();
+
+	static void onCommitPreset(LLUICtrl* ctrl, void* data);
+	static void onClickToggleEnvironment(void* data);
+	static void onClickPopupBtn(void* data);
+};
+
+#endif
diff --git a/linden/indra/newview/llwlparammanager.cpp b/linden/indra/newview/llwlparammanager.cpp
index c1723f7..ba3d070 100644
--- a/linden/indra/newview/llwlparammanager.cpp
+++ b/linden/indra/newview/llwlparammanager.cpp
@@ -62,6 +62,7 @@
 #include "curl/curl.h"
 
 LLWLParamManager * LLWLParamManager::sInstance = NULL;
+std::vector<LLWLPresetsObserver*> LLWLParamManager::sObservers;
 
 LLWLParamManager::LLWLParamManager() :
 
@@ -238,6 +239,8 @@ void LLWLParamManager::loadPreset(const std::string & name,bool propagate)
 		getParamSet(name, mCurParams);
 		propagateParameters();
 	}
+
+	notifyObservers();
 }	
 
 void LLWLParamManager::savePreset(const std::string & name)
@@ -264,6 +267,7 @@ void LLWLParamManager::savePreset(const std::string & name)
 	presetsXML.close();
 
 	propagateParameters();
+	notifyObservers();
 }
 
 void LLWLParamManager::updateShaderUniforms(LLGLSLShader * shader)
@@ -538,6 +542,8 @@ bool LLWLParamManager::removeParamSet(const std::string& name, bool delete_from_
 		gDirUtilp->deleteFilesInDir(path_name, escaped_name + ".xml");
 	}
 
+	notifyObservers();
+
 	return true;
 }
 
@@ -566,3 +572,37 @@ LLWLParamManager * LLWLParamManager::instance()
 
 	return sInstance;
 }
+
+// static
+void LLWLParamManager::addObserver(LLWLPresetsObserver* observer)
+{
+	sObservers.push_back(observer);
+}
+
+// static
+void LLWLParamManager::removeObserver(LLWLPresetsObserver* observer)
+{
+	std::vector<LLWLPresetsObserver*>::iterator it;
+	it = std::find(sObservers.begin(), sObservers.end(), observer);
+	if (it != sObservers.end())
+	{
+		sObservers.erase(it);
+	}
+}
+
+// Call this method when it's time to update everyone on a new state.
+// Copy the list because an observer could respond by removing itself
+// from the list. Static
+void LLWLParamManager::notifyObservers()
+{
+	lldebugs << "LLWLPresetsObserver::notifyObservers" << llendl;
+
+	std::vector<LLWLPresetsObserver*> observers = sObservers;
+
+	std::vector<LLWLPresetsObserver*>::iterator it;
+	for (it = observers.begin(); it != observers.end(); ++it)
+	{
+		LLWLPresetsObserver* observer = *it;
+		observer->changed();
+	}
+}
diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h
index 1d9291c..9895e91 100644
--- a/linden/indra/newview/llwlparammanager.h
+++ b/linden/indra/newview/llwlparammanager.h
@@ -40,6 +40,13 @@
 #include "llviewercamera.h"
 
 class LLGLSLShader;
+
+class LLWLPresetsObserver
+{
+public:
+	virtual ~LLWLPresetsObserver() { };
+	virtual void changed() = 0;
+};
  
 // color control
 struct WLColorControl {
@@ -195,6 +202,11 @@ public:
 	// singleton pattern implementation
 	static LLWLParamManager * instance();
 
+	// manage observers
+	static void addObserver(LLWLPresetsObserver* observer);
+	static void removeObserver(LLWLPresetsObserver* observer);
+	static void notifyObservers();
+
 public:
 
 	// helper variables
@@ -255,6 +267,8 @@ public:
 private:
 	// our parameter manager singleton instance
 	static LLWLParamManager * sInstance;
+	
+	static std::vector<LLWLPresetsObserver*> sObservers;
 
 };
 
diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_overlaybar.xml b/linden/indra/newview/skins/default/xui/en-us/panel_overlaybar.xml
index e785909..21a7664 100644
--- a/linden/indra/newview/skins/default/xui/en-us/panel_overlaybar.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/panel_overlaybar.xml
@@ -45,16 +45,21 @@
 				     use_bounding_rect="true" width="395" />
 			</layout_stack>
 		</layout_panel>
-		<layout_panel auto_resize="false" bottom="0" left="0" min_width="220" mouse_opaque="false"
+    <layout_panel auto_resize="false" bottom="0" left="0" min_width="202" mouse_opaque="false"
+     			name="windlight_remote_container" use_bounding_rect="true" user_resize="false"
+     			width="200">
+      <panel background_visible="false" border="false" bottom="0" name="windlight_remote" />
+    </layout_panel>
+    <layout_panel auto_resize="false" bottom="0" left="0" min_width="220" mouse_opaque="false"
 		     name="media_remote_container" use_bounding_rect="true" user_resize="false"
 		     width="220">
-			<panel background_visible="false" border="false" bottom="0" name="media_remote" />
-		</layout_panel>
-		<layout_panel auto_resize="false" bottom="0" left="0" min_width="130" mouse_opaque="false"
+      <panel background_visible="false" border="false" bottom="0" name="media_remote" />
+    </layout_panel>
+    <layout_panel auto_resize="false" bottom="0" left="0" min_width="130" mouse_opaque="false"
 		     name="voice_remote_container" use_bounding_rect="true" user_resize="false"
 		     width="128">
-			<panel background_visible="false" border="false" bottom="0" name="voice_remote" />
-		</layout_panel>
+      <panel background_visible="false" border="false" bottom="0" name="voice_remote" />
+    </layout_panel>
 	</layout_stack>
   <string name="unread_count_string_plural">
     New IMs
diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml
index 527309e..d5d43b1 100644
--- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml
@@ -8,6 +8,10 @@
 	     height="16" initial_value="false"
 	     label="Run Second Life in a window" left="10" mouse_opaque="true"
 	     name="windowed mode" radio_style="false" width="100" />
+  <check_box bottom_delta="0" enabled="true" follows="left|top"
+	     font="SansSerifSmall" height="16" initial_value="false"
+       label="Show environment control in toolbar" left="248" mouse_opaque="true"
+	     name="toggle_windlight_control" radio_style="false" width="237" />
 	<text_editor type="string" length="1" allow_html="false" bg_readonly_color="0 0 0 0" bottom="-43"
 	     embedded_items="false" enabled="false" follows="left|top"
 	     font="SansSerifSmall" height="20" hide_border="true"
diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_windlight_controls.xml b/linden/indra/newview/skins/default/xui/en-us/panel_windlight_controls.xml
new file mode 100644
index 0000000..e282c3c
--- /dev/null
+++ b/linden/indra/newview/skins/default/xui/en-us/panel_windlight_controls.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel bg_visible="false" border="false" border_visible="false" bottom="1"
+     enabled="true" follows="right|bottom" height="20" left="0"
+     name="windlight_controls" width="200">
+  <button bottom="-21" follows="left|bottom" font="SansSerif" halign="center" height="20"
+	     label="Editor" left="4" name="Environment"
+	     tool_tip="Click here to adjust world environment" width="80" />
+  <flyout_button bottom="-21" follows="left|bottom" height="20" label="Presets" left_delta="82" width="86"
+       list_position="above" mouse_opaque="true" name="Presets" tool_tip="Windlight presets">
+  </flyout_button>
+  <button bottom="-22" follows="left|bottom" font="SansSerif" halign="center" height="22" toggle="true" 
+	     label="" left_delta="88" name="Popup" scale_image="true" control_name="ShowWindlightSettingsPopup" 
+       tool_tip="Click here to adjust world environment" width="22" />
+</panel>
diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote.xml b/linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote.xml
new file mode 100644
index 0000000..89ae7ce
--- /dev/null
+++ b/linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel bg_visible="false" border="false" border_visible="false" bottom="0"
+     enabled="true" follows="right|bottom" height="20" left="0" mouse_opaque="true"
+     name="windlight_remote" use_bounding_rect="true" width="200">
+	<panel bottom="1" filename="panel_bg_tab.xml" name="panel_bg_tab" height="22" left="0" width="200" />
+	<panel bottom="3" filename="panel_windlight_controls.xml" name="panel_windlight_controls" height="20" left="0" width="200" />
+  <string name="sunrise">
+    Sunrise
+  </string>
+  <string name="sunset">
+    Midday
+  </string>
+  <string name="noon">
+    Noon
+  </string>
+  <string name="midnight">
+    Midnight
+  </string>
+  <string name="revert_region">
+    Revert to Region Default
+  </string>
+</panel>
diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote_expanded.xml b/linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote_expanded.xml
new file mode 100644
index 0000000..31a3dc2
--- /dev/null
+++ b/linden/indra/newview/skins/default/xui/en-us/panel_windlight_remote_expanded.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<panel bg_visible="false" border="false" border_visible="false" bottom="0"
+     follows="right|bottom" height="47" left="0" mouse_opaque="true"
+     name="windlight_remote" use_bounding_rect="true" width="200">
+	<panel bottom="1" filename="panel_bg_tab.xml" name="panel_bg_tab" height="47" left="0" width="200" />
+	<slider bottom="-20" can_edit_text="false" control_name="RenderFarClip"
+	     decimal_digits="0" enabled="true" height="18"
+	     increment="8" initial_val="160" label="Draw Distance:"
+	     label_width="80" left="6" max_val="512" min_val="64" mouse_opaque="true"
+	     name="DrawDistance" show_text="true" width="195" />
+	<panel bottom="13" filename="panel_windlight_controls.xml" left="0" width="200" />
+</panel>
-- 
cgit v1.1