summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelpresetspulldown.cpp
diff options
context:
space:
mode:
authorJonathan Yap <jhwelch@gmail.com>2014-12-03 06:35:46 -0500
committerJonathan Yap <jhwelch@gmail.com>2014-12-03 06:35:46 -0500
commitcc22efa4c0d6b06bac6f49b6243df7726f89c7c4 (patch)
tree4ab1120c671cfb5953ee7e4f362df2da0ea319d9 /indra/newview/llpanelpresetspulldown.cpp
parentade3953e380d9211ad6d332b9b27fa23e57a7d81 (diff)
STORM-2082 Remove Apply button.
Add new control variable to track which preset is active. Save settings to active preset when clicking on Ok button. Initial work to make pulldown operational. Still to do: add pretty icon for current preset. Notifications do not appear when called from this panel.
Diffstat (limited to 'indra/newview/llpanelpresetspulldown.cpp')
-rw-r--r--indra/newview/llpanelpresetspulldown.cpp65
1 files changed, 52 insertions, 13 deletions
diff --git a/indra/newview/llpanelpresetspulldown.cpp b/indra/newview/llpanelpresetspulldown.cpp
index 977e9ff5e2..cd049712e1 100644
--- a/indra/newview/llpanelpresetspulldown.cpp
+++ b/indra/newview/llpanelpresetspulldown.cpp
@@ -37,6 +37,7 @@
#include "llfloaterpreference.h"
#include "llpresetsmanager.h"
#include "llsliderctrl.h"
+#include "llscrolllistctrl.h"
/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseFadeStartTimeSec = 4.0f;
/* static */ const F32 LLPanelPresetsPulldown::sAutoCloseTotalTimeSec = 5.0f;
@@ -50,19 +51,53 @@ LLPanelPresetsPulldown::LLPanelPresetsPulldown()
{
mHoverTimer.stop();
- mCommitCallbackRegistrar.add("Presets.GoMoveViewPrefs", boost::bind(&LLPanelPresetsPulldown::onMoveViewButtonClick, this, _2));
mCommitCallbackRegistrar.add("Presets.GoGraphicsPrefs", boost::bind(&LLPanelPresetsPulldown::onGraphicsButtonClick, this, _2));
+ mCommitCallbackRegistrar.add("Presets.RowClick", boost::bind(&LLPanelPresetsPulldown::onRowClick, this, _2));
+
buildFromFile( "panel_presets_pulldown.xml");
}
BOOL LLPanelPresetsPulldown::postBuild()
{
+ LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLPanelPresetsPulldown::populatePanel, this));
// Make sure there is a default preference file
LLPresetsManager::getInstance()->createMissingDefault();
+ populatePanel();
+
return LLPanel::postBuild();
}
+void LLPanelPresetsPulldown::populatePanel()
+{
+ std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(PRESETS_GRAPHIC);
+ LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, mPresetNames, DEFAULT_POSITION_NORMAL);
+
+ LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_list");
+
+ if (scroll && mPresetNames.begin() != mPresetNames.end())
+ {
+ scroll->clearRows();
+
+ for (std::list<std::string>::const_iterator it = mPresetNames.begin(); it != mPresetNames.end(); ++it)
+ {
+ const std::string& name = *it;
+
+ LLSD row;
+ row["columns"][0]["column"] = "preset_name";
+ row["columns"][0]["value"] = name;
+
+ if (name == gSavedSettings.getString("PresetGraphicActive"))
+ {
+ row["columns"][1]["column"] = "active_name";
+ row["columns"][1]["value"] = "X";
+ }
+
+ scroll->addElement(row);
+ }
+ }
+}
+
/*virtual*/
void LLPanelPresetsPulldown::onMouseEnter(S32 x, S32 y, MASK mask)
{
@@ -97,22 +132,26 @@ void LLPanelPresetsPulldown::onVisibilityChange ( BOOL new_visibility )
}
}
-void LLPanelPresetsPulldown::onMoveViewButtonClick(const LLSD& user_data)
+void LLPanelPresetsPulldown::onRowClick(const LLSD& user_data)
{
- // close the minicontrol, we're bringing up the big one
- setVisible(FALSE);
+ LLScrollListCtrl* scroll = getChild<LLScrollListCtrl>("preset_list");
- // bring up the prefs floater
- LLFloater* prefsfloater = LLFloaterReg::showInstance("preferences");
- if (prefsfloater)
+ if (scroll)
{
- // grab the 'move' panel from the preferences floater and
- // bring it the front!
- LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
- LLPanel* movepanel = prefsfloater->getChild<LLPanel>("move");
- if (tabcontainer && movepanel)
+ LLScrollListItem* item = scroll->getFirstSelected();
+ if (item)
{
- tabcontainer->selectTabPanel(movepanel);
+ std::string name = item->getColumn(1)->getValue().asString();
+
+ LLPresetsManager::getInstance()->loadPreset(PRESETS_GRAPHIC, name);
+ LLFloaterPreference* instance = LLFloaterReg::findTypedInstance<LLFloaterPreference>("preferences");
+ if (instance)
+ {
+ instance->refreshEnabledGraphics();
+ }
+ setVisible(FALSE);
+ // This line shouldn't be necessary but it is.
+ populatePanel();
}
}
}