And finally, update the callbacks on the last few panels to use boost

Cleans up LLPanelSkins enough to remove sInstance hack.
Modernizes some callbacks on wlfPanel
This commit is contained in:
Lirusaito
2013-06-26 11:14:32 -04:00
parent 14736d24a5
commit d7d5925fd1
7 changed files with 84 additions and 132 deletions

View File

@@ -45,10 +45,9 @@ LLPanelInput::LLPanelInput()
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_input.xml"); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_input.xml");
} }
static void onFOVAdjust(LLUICtrl* source, void* data) static void onFOVAdjust(const LLSD& value)
{ {
LLSliderCtrl* slider = dynamic_cast<LLSliderCtrl*>(source); LLViewerCamera::getInstance()->setDefaultFOV(value.asFloat());
LLViewerCamera::getInstance()->setDefaultFOV(slider->getValueF32());
} }
BOOL LLPanelInput::postBuild() BOOL LLPanelInput::postBuild()
@@ -68,7 +67,7 @@ BOOL LLPanelInput::postBuild()
childSetValue("first_person_avatar_visible", gSavedSettings.getBOOL("FirstPersonAvatarVisible")); childSetValue("first_person_avatar_visible", gSavedSettings.getBOOL("FirstPersonAvatarVisible"));
LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov"); LLSliderCtrl* fov_slider = getChild<LLSliderCtrl>("camera_fov");
fov_slider->setCommitCallback(&onFOVAdjust); fov_slider->setCommitCallback(boost::bind(onFOVAdjust, _2));
fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView()); fov_slider->setMinValue(LLViewerCamera::getInstance()->getMinView());
fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView()); fov_slider->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
fov_slider->setValue(LLViewerCamera::getInstance()->getView()); fov_slider->setValue(LLViewerCamera::getInstance()->getView());

View File

@@ -202,9 +202,9 @@ namespace {
boost::intrusive_ptr< LLIamHereLogin > gResponsePtr = 0; boost::intrusive_ptr< LLIamHereLogin > gResponsePtr = 0;
}; };
void set_start_location(LLUICtrl* ctrl, void* data) void set_start_location(const LLSD& value)
{ {
LLURLSimString::setString(ctrl->getValue().asString()); LLURLSimString::setString(value.asString());
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@@ -252,7 +252,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
#if !USE_VIEWER_AUTH #if !USE_VIEWER_AUTH
LLComboBox* name_combo = sInstance->getChild<LLComboBox>("name_combo"); LLComboBox* name_combo = sInstance->getChild<LLComboBox>("name_combo");
name_combo->setCommitCallback(onSelectLoginEntry); name_combo->setCommitCallback(boost::bind(LLPanelLogin::onSelectLoginEntry, _1, this));
name_combo->setFocusLostCallback(boost::bind(&LLPanelLogin::onLoginComboLostFocus, this, name_combo)); name_combo->setFocusLostCallback(boost::bind(&LLPanelLogin::onLoginComboLostFocus, this, name_combo));
name_combo->setPrevalidate(LLLineEditor::prevalidatePrintableNotPipe); name_combo->setPrevalidate(LLLineEditor::prevalidatePrintableNotPipe);
name_combo->setSuppressTentative(true); name_combo->setSuppressTentative(true);
@@ -327,7 +327,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
combo->setCurrentByIndex( 0 ); combo->setCurrentByIndex( 0 );
} }
combo->setCommitCallback( &set_start_location ); combo->setCommitCallback(boost::bind(set_start_location, _2));
childSetAction("connect_btn", onClickConnect, this); childSetAction("connect_btn", onClickConnect, this);

View File

@@ -209,7 +209,7 @@ BOOL LLInventoryView::postBuild()
if (mQuickFilterCombo) if (mQuickFilterCombo)
{ {
mQuickFilterCombo->setCommitCallback(onQuickFilterCommit); mQuickFilterCombo->setCommitCallback(boost::bind(LLInventoryView::onQuickFilterCommit, _1, this));
} }

View File

@@ -48,24 +48,20 @@
#include "llsdserialize.h" #include "llsdserialize.h"
LLPanelSkins* LLPanelSkins::sInstance;
LLPanelSkins::LLPanelSkins() LLPanelSkins::LLPanelSkins()
{ {
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_skins.xml"); LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_skins.xml");
if(sInstance)delete sInstance;
sInstance = this;
} }
LLPanelSkins::~LLPanelSkins() LLPanelSkins::~LLPanelSkins()
{ {
sInstance = NULL;
} }
BOOL LLPanelSkins::postBuild() BOOL LLPanelSkins::postBuild()
{ {
mSkin = gSavedSettings.getString("SkinCurrent"); mSkin = gSavedSettings.getString("SkinCurrent");
oldSkin=mSkin; oldSkin=mSkin;
getChild<LLComboBox>("custom_skin_combo")->setCommitCallback(onComboBoxCommit); getChild<LLComboBox>("custom_skin_combo")->setCommitCallback(boost::bind(&LLPanelSkins::onComboBoxCommit, this, _2));
refresh(); refresh();
return TRUE; return TRUE;
} }
@@ -159,26 +155,20 @@ void LLPanelSkins::cancel()
gSavedSettings.setString("SkinCurrent", oldSkin); gSavedSettings.setString("SkinCurrent", oldSkin);
} }
//static void LLPanelSkins::onComboBoxCommit(const LLSD& value)
void LLPanelSkins::onComboBoxCommit(LLUICtrl* ctrl, void* userdata)
{ {
LLComboBox* box = (LLComboBox*)ctrl; const std::string skinName = value.asString();
if(box) for(int i = 0; i < (int)datas.size(); ++i)
{ {
std::string skinName = box->getValue().asString(); const LLSD tdata = datas[i];
for(int i =0;i<(int)sInstance->datas.size();i++) if (tdata["skin_name"].asString() == skinName)
{ {
LLSD tdata=sInstance->datas[i]; std::string newFolder(tdata["folder_name"].asString());
std::string tempName = tdata["skin_name"].asString(); gSavedSettings.setString("SkinCurrent", newFolder);
if(tempName==skinName) mSkin = newFolder;
{
std::string newFolder(tdata["folder_name"].asString());
gSavedSettings.setString("SkinCurrent",newFolder);
sInstance->mSkin=newFolder;
if(sInstance)sInstance->refresh(); refresh();
return; return;
}
} }
} }
} }

View File

@@ -48,11 +48,10 @@ public:
void refresh(); void refresh();
void apply(); void apply();
void cancel(); void cancel();
static void onComboBoxCommit(LLUICtrl* ctrl, void* userdata); void onComboBoxCommit(const LLSD& value);
std::string mSkin; std::string mSkin;
private: private:
static LLPanelSkins* sInstance;
std::string oldSkin; std::string oldSkin;
}; };

View File

@@ -147,16 +147,16 @@ BOOL wlfPanel_AdvSettings::postBuild()
if (!gSavedSettings.getBOOL("wlfAdvSettingsPopup")) if (!gSavedSettings.getBOOL("wlfAdvSettingsPopup"))
{ {
getChild<LLCheckBoxCtrl>("use_estate_wl")->setCommitCallback(onUseRegionSettings); getChild<LLCheckBoxCtrl>("use_estate_wl")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onUseRegionSettings, this, _2));
mWaterPresetCombo = getChild<LLComboBox>("WLWaterPresetsCombo"); mWaterPresetCombo = getChild<LLComboBox>("WLWaterPresetsCombo");
mWaterPresetCombo->setCommitCallback(onChangeWWPresetName); mWaterPresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeWWPresetName, this, _2));
mSkyPresetCombo = getChild<LLComboBox>("WLSkyPresetsCombo"); mSkyPresetCombo = getChild<LLComboBox>("WLSkyPresetsCombo");
mSkyPresetCombo->setCommitCallback(onChangeWLPresetName); mSkyPresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeWLPresetName, this, _2));
// mDayCyclePresetCombo = getChild<LLComboBox>("DCPresetsCombo"); // mDayCyclePresetCombo = getChild<LLComboBox>("DCPresetsCombo");
// mDayCyclePresetCombo->setCommitCallback(onChangeDCPresetName); // mDayCyclePresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeDCPresetName, this, _2));
LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&wlfPanel_AdvSettings::refreshLists, this)); LLEnvManagerNew::instance().setPreferencesChangeCallback(boost::bind(&wlfPanel_AdvSettings::refreshLists, this));
LLWaterParamManager::getInstance()->setPresetListChangeCallback(boost::bind(&wlfPanel_AdvSettings::populateWaterPresetsList, this)); LLWaterParamManager::getInstance()->setPresetListChangeCallback(boost::bind(&wlfPanel_AdvSettings::populateWaterPresetsList, this));
@@ -168,16 +168,16 @@ BOOL wlfPanel_AdvSettings::postBuild()
//populateDayCyclePresetsList(); //populateDayCyclePresetsList();
// next/prev buttons // next/prev buttons
childSetAction("WWnext", onClickWWNext, this); getChild<LLUICtrl>("WWnext")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWWNext, this));
childSetAction("WWprev", onClickWWPrev, this); getChild<LLUICtrl>("WWprev")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWWPrev, this));
childSetAction("WLnext", onClickWLNext, this); getChild<LLUICtrl>("WLnext")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWLNext, this));
childSetAction("WLprev", onClickWLPrev, this); getChild<LLUICtrl>("WLprev")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWLPrev, this));
childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL); getChild<LLUICtrl>("EnvAdvancedSkyButton")->setCommitCallback(boost::bind(LLFloaterWindLight::show));
childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, NULL); getChild<LLUICtrl>("EnvAdvancedWaterButton")->setCommitCallback(boost::bind(LLFloaterWater::show));
mTimeSlider = getChild<LLSliderCtrl>("EnvTimeSlider"); mTimeSlider = getChild<LLSliderCtrl>("EnvTimeSlider");
mTimeSlider->setCommitCallback(onChangeDayTime); mTimeSlider->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeDayTime, this, _2));
updateTimeSlider(); updateTimeSlider();
} }
@@ -203,21 +203,15 @@ void wlfPanel_AdvSettings::onClickExpandBtn(void* user_data)
gOverlayBar->layoutButtons(); gOverlayBar->layoutButtons();
} }
void wlfPanel_AdvSettings::onUseRegionSettings(LLUICtrl* ctrl, void* userdata) void wlfPanel_AdvSettings::onUseRegionSettings(const LLSD& value)
{ {
LLEnvManagerNew::instance().setUseRegionSettings(gSavedSettings.getBOOL("UseEnvironmentFromRegion"), gSavedSettings.getBOOL("PhoenixInterpolateSky")); LLEnvManagerNew::instance().setUseRegionSettings(value.asBoolean(), gSavedSettings.getBOOL("PhoenixInterpolateSky"));
} }
void wlfPanel_AdvSettings::onChangeWWPresetName(LLUICtrl* ctrl, void * userData) void wlfPanel_AdvSettings::onChangeWWPresetName(const LLSD& value)
{ {
LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl); const std::string& wwset = value.asString();
if (wwset.empty()) return;
if(combo_box->getSimple() == "")
{
return;
}
const std::string& wwset = combo_box->getSelectedValue().asString();
if (LLWaterParamManager::getInstance()->hasParamSet(wwset)) if (LLWaterParamManager::getInstance()->hasParamSet(wwset))
{ {
LLEnvManagerNew::instance().setUseWaterPreset(wwset, gSavedSettings.getBOOL("PhoenixInterpolateWater")); LLEnvManagerNew::instance().setUseWaterPreset(wwset, gSavedSettings.getBOOL("PhoenixInterpolateWater"));
@@ -230,19 +224,14 @@ void wlfPanel_AdvSettings::onChangeWWPresetName(LLUICtrl* ctrl, void * userData)
} }
} }
void wlfPanel_AdvSettings::onChangeWLPresetName(LLUICtrl* ctrl, void * userData) void wlfPanel_AdvSettings::onChangeWLPresetName(const LLSD& value)
{ {
LLComboBox * combo_box = static_cast<LLComboBox*>(ctrl); const std::string& wlset = value.asString();
if (wlset.empty()) return;
if(combo_box->getSimple() == "") const LLWLParamKey key(wlset, LLEnvKey::SCOPE_LOCAL);
{
return;
}
const LLWLParamKey key(combo_box->getSelectedValue().asString(), LLEnvKey::SCOPE_LOCAL);
if (LLWLParamManager::getInstance()->hasParamSet(key)) if (LLWLParamManager::getInstance()->hasParamSet(key))
{ {
LLEnvManagerNew::instance().setUseSkyPreset(key.name, gSavedSettings.getBOOL("PhoenixInterpolateSky")); LLEnvManagerNew::instance().setUseSkyPreset(wlset, gSavedSettings.getBOOL("PhoenixInterpolateSky"));
} }
else else
{ {
@@ -252,86 +241,63 @@ void wlfPanel_AdvSettings::onChangeWLPresetName(LLUICtrl* ctrl, void * userData)
} }
} }
void wlfPanel_AdvSettings::onClickWWNext(void* user_data) void wlfPanel_AdvSettings::onClickWWNext()
{ {
wlfPanel_AdvSettings* self = (wlfPanel_AdvSettings*) user_data; S32 index = mWaterPresetCombo->getCurrentIndex();
++index;
S32 index = self->mWaterPresetCombo->getCurrentIndex(); if (index == mWaterPresetCombo->getItemCount())
index++;
if (index == self->mWaterPresetCombo->getItemCount())
index = 0; index = 0;
self->mWaterPresetCombo->setCurrentByIndex(index); mWaterPresetCombo->setCurrentByIndex(index);
wlfPanel_AdvSettings::onChangeWWPresetName(self->mWaterPresetCombo, self); wlfPanel_AdvSettings::onChangeWWPresetName(mWaterPresetCombo->getSelectedValue());
} }
void wlfPanel_AdvSettings::onClickWWPrev(void* user_data) void wlfPanel_AdvSettings::onClickWWPrev()
{ {
wlfPanel_AdvSettings* self = (wlfPanel_AdvSettings*) user_data; S32 index = mWaterPresetCombo->getCurrentIndex();
S32 index = self->mWaterPresetCombo->getCurrentIndex();
if (index == 0) if (index == 0)
index = self->mWaterPresetCombo->getItemCount(); index = mWaterPresetCombo->getItemCount();
index--; --index;
self->mWaterPresetCombo->setCurrentByIndex(index); mWaterPresetCombo->setCurrentByIndex(index);
wlfPanel_AdvSettings::onChangeWWPresetName(self->mWaterPresetCombo, self); wlfPanel_AdvSettings::onChangeWWPresetName(mWaterPresetCombo->getSelectedValue());
} }
void wlfPanel_AdvSettings::onClickWLNext(void* user_data) void wlfPanel_AdvSettings::onClickWLNext()
{ {
wlfPanel_AdvSettings* self = (wlfPanel_AdvSettings*) user_data; S32 index = mSkyPresetCombo->getCurrentIndex();
++index;
S32 index = self->mSkyPresetCombo->getCurrentIndex(); if (index == mSkyPresetCombo->getItemCount())
index++;
if (index == self->mSkyPresetCombo->getItemCount())
index = 0; index = 0;
self->mSkyPresetCombo->setCurrentByIndex(index); mSkyPresetCombo->setCurrentByIndex(index);
wlfPanel_AdvSettings::onChangeWLPresetName(self->mSkyPresetCombo, self); wlfPanel_AdvSettings::onChangeWLPresetName(mSkyPresetCombo->getSelectedValue());
} }
void wlfPanel_AdvSettings::onClickWLPrev(void* user_data) void wlfPanel_AdvSettings::onClickWLPrev()
{ {
wlfPanel_AdvSettings* self = (wlfPanel_AdvSettings*) user_data; S32 index = mSkyPresetCombo->getCurrentIndex();
S32 index = self->mSkyPresetCombo->getCurrentIndex();
if (index == 0) if (index == 0)
index = self->mSkyPresetCombo->getItemCount(); index = mSkyPresetCombo->getItemCount();
index--; --index;
self->mSkyPresetCombo->setCurrentByIndex(index); mSkyPresetCombo->setCurrentByIndex(index);
wlfPanel_AdvSettings::onChangeWLPresetName(self->mSkyPresetCombo, self); wlfPanel_AdvSettings::onChangeWLPresetName(mSkyPresetCombo->getSelectedValue());
} }
void wlfPanel_AdvSettings::onOpenAdvancedSky(void* userData) void wlfPanel_AdvSettings::onChangeDayTime(const LLSD& value)
{ {
LLFloaterWindLight::show(); // deactivate animator
} LLWLParamManager::getInstance()->mAnimator.deactivate();
void wlfPanel_AdvSettings::onOpenAdvancedWater(void* userData) F32 val = value.asFloat() + 0.25f;
{ if(val > 1.0)
LLFloaterWater::show(); {
} val--;
void wlfPanel_AdvSettings::onChangeDayTime(LLUICtrl* ctrl, void* userData)
{
LLSliderCtrl* sldr = static_cast<LLSliderCtrl*>(ctrl);
if (sldr) {
// deactivate animator
LLWLParamManager::getInstance()->mAnimator.deactivate();
F32 val = sldr->getValueF32() + 0.25f;
if(val > 1.0)
{
val--;
}
LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val);
LLWLParamManager::getInstance()->mAnimator.update(
LLWLParamManager::getInstance()->mCurParams);
} }
LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val);
LLWLParamManager::getInstance()->mAnimator.update(LLWLParamManager::getInstance()->mCurParams);
} }
void wlfPanel_AdvSettings::populateWaterPresetsList() void wlfPanel_AdvSettings::populateWaterPresetsList()

View File

@@ -49,20 +49,18 @@ public:
static void fixPanel(); static void fixPanel();
static void onClickExpandBtn(void* user_data); static void onClickExpandBtn(void* user_data);
static void onChangeWWPresetName(LLUICtrl* ctrl, void* userData); void onChangeWWPresetName(const LLSD& value);
static void onChangeWLPresetName(LLUICtrl* ctrl, void* userData); void onChangeWLPresetName(const LLSD& value);
protected: protected:
void build(); void build();
static void onUseRegionSettings(LLUICtrl* ctrl, void* userdata); void onUseRegionSettings(const LLSD& value);
static void onClickWWNext(void* user_data); void onClickWWNext();
static void onClickWWPrev(void* user_data); void onClickWWPrev();
static void onClickWLNext(void* user_data); void onClickWLNext();
static void onClickWLPrev(void* user_data); void onClickWLPrev();
static void onOpenAdvancedSky(void* userData); void onChangeDayTime(const LLSD& value);
static void onOpenAdvancedWater(void* userData);
static void onChangeDayTime(LLUICtrl* ctrl, void* userData);
void refreshLists(); /// update controls with user prefs void refreshLists(); /// update controls with user prefs