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");
}
static void onFOVAdjust(LLUICtrl* source, void* data)
static void onFOVAdjust(const LLSD& value)
{
LLSliderCtrl* slider = dynamic_cast<LLSliderCtrl*>(source);
LLViewerCamera::getInstance()->setDefaultFOV(slider->getValueF32());
LLViewerCamera::getInstance()->setDefaultFOV(value.asFloat());
}
BOOL LLPanelInput::postBuild()
@@ -68,7 +67,7 @@ BOOL LLPanelInput::postBuild()
childSetValue("first_person_avatar_visible", gSavedSettings.getBOOL("FirstPersonAvatarVisible"));
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->setMaxValue(LLViewerCamera::getInstance()->getMaxView());
fov_slider->setValue(LLViewerCamera::getInstance()->getView());

View File

@@ -202,9 +202,9 @@ namespace {
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
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->setPrevalidate(LLLineEditor::prevalidatePrintableNotPipe);
name_combo->setSuppressTentative(true);
@@ -327,7 +327,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
combo->setCurrentByIndex( 0 );
}
combo->setCommitCallback( &set_start_location );
combo->setCommitCallback(boost::bind(set_start_location, _2));
childSetAction("connect_btn", onClickConnect, this);

View File

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

View File

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

View File

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

View File

@@ -147,16 +147,16 @@ BOOL wlfPanel_AdvSettings::postBuild()
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->setCommitCallback(onChangeWWPresetName);
mWaterPresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeWWPresetName, this, _2));
mSkyPresetCombo = getChild<LLComboBox>("WLSkyPresetsCombo");
mSkyPresetCombo->setCommitCallback(onChangeWLPresetName);
mSkyPresetCombo->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeWLPresetName, this, _2));
// 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));
LLWaterParamManager::getInstance()->setPresetListChangeCallback(boost::bind(&wlfPanel_AdvSettings::populateWaterPresetsList, this));
@@ -168,16 +168,16 @@ BOOL wlfPanel_AdvSettings::postBuild()
//populateDayCyclePresetsList();
// next/prev buttons
childSetAction("WWnext", onClickWWNext, this);
childSetAction("WWprev", onClickWWPrev, this);
childSetAction("WLnext", onClickWLNext, this);
childSetAction("WLprev", onClickWLPrev, this);
getChild<LLUICtrl>("WWnext")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWWNext, this));
getChild<LLUICtrl>("WWprev")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWWPrev, this));
getChild<LLUICtrl>("WLnext")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWLNext, this));
getChild<LLUICtrl>("WLprev")->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onClickWLPrev, this));
childSetAction("EnvAdvancedSkyButton", onOpenAdvancedSky, NULL);
childSetAction("EnvAdvancedWaterButton", onOpenAdvancedWater, NULL);
getChild<LLUICtrl>("EnvAdvancedSkyButton")->setCommitCallback(boost::bind(LLFloaterWindLight::show));
getChild<LLUICtrl>("EnvAdvancedWaterButton")->setCommitCallback(boost::bind(LLFloaterWater::show));
mTimeSlider = getChild<LLSliderCtrl>("EnvTimeSlider");
mTimeSlider->setCommitCallback(onChangeDayTime);
mTimeSlider->setCommitCallback(boost::bind(&wlfPanel_AdvSettings::onChangeDayTime, this, _2));
updateTimeSlider();
}
@@ -203,21 +203,15 @@ void wlfPanel_AdvSettings::onClickExpandBtn(void* user_data)
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);
if(combo_box->getSimple() == "")
{
return;
}
const std::string& wwset = combo_box->getSelectedValue().asString();
const std::string& wwset = value.asString();
if (wwset.empty()) return;
if (LLWaterParamManager::getInstance()->hasParamSet(wwset))
{
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);
if(combo_box->getSimple() == "")
{
return;
}
const LLWLParamKey key(combo_box->getSelectedValue().asString(), LLEnvKey::SCOPE_LOCAL);
const std::string& wlset = value.asString();
if (wlset.empty()) return;
const LLWLParamKey key(wlset, LLEnvKey::SCOPE_LOCAL);
if (LLWLParamManager::getInstance()->hasParamSet(key))
{
LLEnvManagerNew::instance().setUseSkyPreset(key.name, gSavedSettings.getBOOL("PhoenixInterpolateSky"));
LLEnvManagerNew::instance().setUseSkyPreset(wlset, gSavedSettings.getBOOL("PhoenixInterpolateSky"));
}
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 = self->mWaterPresetCombo->getCurrentIndex();
index++;
if (index == self->mWaterPresetCombo->getItemCount())
S32 index = mWaterPresetCombo->getCurrentIndex();
++index;
if (index == mWaterPresetCombo->getItemCount())
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 = self->mWaterPresetCombo->getCurrentIndex();
S32 index = mWaterPresetCombo->getCurrentIndex();
if (index == 0)
index = self->mWaterPresetCombo->getItemCount();
index--;
self->mWaterPresetCombo->setCurrentByIndex(index);
index = mWaterPresetCombo->getItemCount();
--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 = self->mSkyPresetCombo->getCurrentIndex();
index++;
if (index == self->mSkyPresetCombo->getItemCount())
S32 index = mSkyPresetCombo->getCurrentIndex();
++index;
if (index == mSkyPresetCombo->getItemCount())
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 = self->mSkyPresetCombo->getCurrentIndex();
S32 index = mSkyPresetCombo->getCurrentIndex();
if (index == 0)
index = self->mSkyPresetCombo->getItemCount();
index--;
self->mSkyPresetCombo->setCurrentByIndex(index);
index = mSkyPresetCombo->getItemCount();
--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)
{
LLFloaterWater::show();
}
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);
F32 val = value.asFloat() + 0.25f;
if(val > 1.0)
{
val--;
}
LLWLParamManager::getInstance()->mAnimator.setDayTime((F64)val);
LLWLParamManager::getInstance()->mAnimator.update(LLWLParamManager::getInstance()->mCurParams);
}
void wlfPanel_AdvSettings::populateWaterPresetsList()

View File

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