[Preferences Refactor] Cleanup on llfloaterpreferences

Moves to calling refreshEnabledState directly from LLPanelDisplay instead of bouncing around in LLFloaterPreferences first or using static proxy functions
Cleans up unused cached button pointers and old style static callbacks.
This commit is contained in:
Inusaito Sayori
2014-06-02 23:24:25 -04:00
parent 3c6c7c4138
commit 715c3b8510
4 changed files with 34 additions and 99 deletions

View File

@@ -338,11 +338,6 @@ void LLPreferenceCore::setPersonalInfo(const std::string& visibility, bool im_vi
mPrefsIM->setPersonalInfo(visibility, im_via_email, email);
}
void LLPreferenceCore::refreshEnabledGraphics()
{
mDisplayPanel->refreshEnabledState();
}
//////////////////////////////////////////////
// LLFloaterPreference
@@ -365,23 +360,13 @@ BOOL LLFloaterPreference::postBuild()
return FALSE;
}
mAboutBtn = getChild<LLButton>("About...");
mAboutBtn->setClickedCallback(onClickAbout, this);
mApplyBtn = getChild<LLButton>("Apply");
mApplyBtn->setClickedCallback(onBtnApply, this);
mCancelBtn = getChild<LLButton>("Cancel");
mCancelBtn->setClickedCallback(onBtnCancel, this);
getChild<LLUICtrl>("About...")->setCommitCallback(boost::bind(LLFloaterAbout::show, (void*)0));
getChild<LLUICtrl>("Apply")->setCommitCallback(boost::bind(&LLFloaterPreference::onBtnApply, this));
getChild<LLUICtrl>("Cancel")->setCommitCallback(boost::bind(&LLFloaterPreference::onBtnCancel, this));
getChild<LLUICtrl>("OK")->setCommitCallback(boost::bind(&LLFloaterPreference::onBtnOK, this));
mPreferenceCore = new LLPreferenceCore(getChild<LLTabContainer>("pref core"), getChild<LLButton>("OK"));
mOKBtn = getChild<LLButton>("OK");
mOKBtn->setClickedCallback(onBtnOK, this);
mPreferenceCore = new LLPreferenceCore(
getChild<LLTabContainer>("pref core"),
getChild<LLButton>("OK")
);
sInstance = this;
return TRUE;
@@ -396,13 +381,13 @@ LLFloaterPreference::~LLFloaterPreference()
void LLFloaterPreference::apply()
{
this->mPreferenceCore->apply();
mPreferenceCore->apply();
}
void LLFloaterPreference::cancel()
{
this->mPreferenceCore->cancel();
mPreferenceCore->cancel();
}
@@ -431,19 +416,11 @@ void LLFloaterPreference::show(void*)
}
// static
void LLFloaterPreference::onClickAbout(void*)
{
LLFloaterAbout::show(NULL);
}
// static
void LLFloaterPreference::onBtnOK( void* userdata )
void LLFloaterPreference::onBtnOK()
{
LLFloaterPreference *fp =(LLFloaterPreference *)userdata;
// commit any outstanding text entry
if (fp->hasFocus())
if (hasFocus())
{
LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
if (cur_focus->acceptsTextInput())
@@ -452,17 +429,12 @@ void LLFloaterPreference::onBtnOK( void* userdata )
}
}
if (fp->canClose())
if (canClose())
{
fp->apply();
fp->close(false);
apply();
close(false);
gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile"), TRUE );
std::string crash_settings_filename = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, CRASH_SETTINGS_FILE);
// save all settings, even if equals defaults
// Singu Note: crash settings no longer separate
// gCrashSettings.saveToFile(crash_settings_filename, FALSE);
}
else
{
@@ -473,12 +445,9 @@ void LLFloaterPreference::onBtnOK( void* userdata )
LLPanelLogin::updateLocationSelectorsVisibility();
}
// static
void LLFloaterPreference::onBtnApply( void* userdata )
void LLFloaterPreference::onBtnApply()
{
LLFloaterPreference *fp =(LLFloaterPreference *)userdata;
if (fp->hasFocus())
if (hasFocus())
{
LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
if (cur_focus && cur_focus->acceptsTextInput())
@@ -486,7 +455,7 @@ void LLFloaterPreference::onBtnApply( void* userdata )
cur_focus->onCommit();
}
}
fp->apply();
apply();
LLPanelLogin::updateLocationSelectorsVisibility();
}
@@ -504,10 +473,9 @@ void LLFloaterPreference::onClose(bool app_quitting)
// static
void LLFloaterPreference::onBtnCancel( void* userdata )
void LLFloaterPreference::onBtnCancel()
{
LLFloaterPreference *fp =(LLFloaterPreference *)userdata;
if (fp->hasFocus())
if (hasFocus())
{
LLUICtrl* cur_focus = dynamic_cast<LLUICtrl*>(gFocusMgr.getKeyboardFocus());
if (cur_focus->acceptsTextInput())
@@ -515,7 +483,7 @@ void LLFloaterPreference::onBtnCancel( void* userdata )
cur_focus->onCommit();
}
}
fp->close(); // side effect will also cancel any unsaved changes.
close(); // side effect will also cancel any unsaved changes.
}
@@ -528,11 +496,6 @@ void LLFloaterPreference::updateUserInfo(const std::string& visibility, bool im_
}
}
void LLFloaterPreference::refreshEnabledGraphics()
{
sInstance->mPreferenceCore->refreshEnabledGraphics();
}
//static
void LLFloaterPreference::switchTab(S32 i)
{

View File

@@ -76,9 +76,6 @@ public:
void setPersonalInfo(const std::string& visibility, bool im_via_email, const std::string& email);
static void onTabChanged(LLUICtrl* ctrl);
// refresh all the graphics preferences menus
void refreshEnabledGraphics();
private:
LLTabContainer *mTabContainer;
@@ -113,9 +110,6 @@ public:
// static data update, called from message handler
static void updateUserInfo(const std::string& visibility, bool im_via_email, const std::string& email);
// refresh all the graphics preferences menus
static void refreshEnabledGraphics();
static void switchTab(S32 i);
@@ -129,16 +123,11 @@ protected:
/*virtual*/ void onClose(bool app_quitting);
LLButton* mAboutBtn;
LLButton *mOKBtn;
LLButton *mCancelBtn;
LLButton *mApplyBtn;
bool mExitWithoutSaving;
static void onClickAbout(void*);
static void onBtnOK(void*);
static void onBtnCancel(void*);
static void onBtnApply(void*);
void onBtnOK();
void onBtnCancel();
void onBtnApply();
static LLFloaterPreference* sInstance;
};

View File

@@ -207,7 +207,7 @@ BOOL LLPanelDisplay::postBuild()
mCtrlSliderQuality->setSliderMouseUpCallback(boost::bind(&LLPanelDisplay::onChangeQuality,this,_1));
mCtrlCustomSettings = getChild<LLCheckBoxCtrl>("CustomSettings");
mCtrlCustomSettings->setCommitCallback(boost::bind(&LLPanelDisplay::onChangeCustom));
mCtrlCustomSettings->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
//----------------------------------------------------------------------------
// Enable Bump/Shiny
@@ -216,19 +216,19 @@ BOOL LLPanelDisplay::postBuild()
//----------------------------------------------------------------------------
// Enable Reflections
mCtrlReflectionDetail = getChild<LLComboBox>("ReflectionDetailCombo");
mCtrlReflectionDetail->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlReflectionDetail->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
// WindLight
mCtrlWindLight = getChild<LLCheckBoxCtrl>("WindLightUseAtmosShaders");
mCtrlWindLight->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlWindLight->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
// Deferred
mCtrlDeferred = getChild<LLCheckBoxCtrl>("RenderDeferred");
mCtrlDeferred->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlDeferred->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
mCtrlDeferredDoF = getChild<LLCheckBoxCtrl>("RenderDepthOfField");
mCtrlDeferredDoF->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlDeferredDoF->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
mCtrlShadowDetail = getChild<LLComboBox>("ShadowDetailCombo");
mCtrlShadowDetail->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlShadowDetail->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
//----------------------------------------------------------------------------
// Terrain Scale
@@ -237,13 +237,13 @@ BOOL LLPanelDisplay::postBuild()
//----------------------------------------------------------------------------
// Enable Avatar Shaders
mCtrlAvatarVP = getChild<LLCheckBoxCtrl>("AvatarVertexProgram");
mCtrlAvatarVP->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlAvatarVP->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
//----------------------------------------------------------------------------
// Avatar Render Mode
mCtrlAvatarCloth = getChild<LLCheckBoxCtrl>("AvatarCloth");
mCtrlAvatarImpostors = getChild<LLCheckBoxCtrl>("AvatarImpostors");
mCtrlAvatarImpostors->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlAvatarImpostors->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
//----------------------------------------------------------------------------
// Checkbox for ambient occlusion
@@ -256,7 +256,7 @@ BOOL LLPanelDisplay::postBuild()
//----------------------------------------------------------------------------
// Global Shader Enable
mCtrlShaderEnable = getChild<LLCheckBoxCtrl>("BasicShaders");
mCtrlShaderEnable->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mCtrlShaderEnable->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
//============================================================================
@@ -312,7 +312,7 @@ BOOL LLPanelDisplay::postBuild()
// Hardware tab
mVBO = getChild<LLCheckBoxCtrl>("vbo");
mVBO->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable));
mVBO->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this));
if(gGLManager.mIsATI) //AMD gpus don't go beyond 8x fsaa.
{
@@ -686,19 +686,13 @@ void LLPanelDisplay::apply()
void LLPanelDisplay::onChangeQuality(LLUICtrl* ctrl)
{
LLFloaterPreference::refreshEnabledGraphics();
LLFeatureManager::getInstance()->setGraphicsLevel(ctrl->getValue(), true);
refreshEnabledState();
refresh();
}
void LLPanelDisplay::onChangeCustom()
{
LLFloaterPreference::refreshEnabledGraphics();
}
void LLPanelDisplay::applyResolution()
{
gGL.flush();
char aspect_ratio_text[ASPECT_RATIO_STR_LEN]; /*Flawfinder: ignore*/
if (mCtrlAspectRatio->getCurrentIndex() == -1)
@@ -810,11 +804,6 @@ void LLPanelDisplay::fractionFromDecimal(F32 decimal_val, S32& numerator, S32& d
}
}
void LLPanelDisplay::onVertexShaderEnable()
{
LLFloaterPreference::refreshEnabledGraphics();
}
void LLPanelDisplay::setHardwareDefaults()
{
LLFeatureManager::getInstance()->applyRecommendedSettings();
@@ -822,7 +811,7 @@ void LLPanelDisplay::setHardwareDefaults()
{
controlp->resetToDefault(true);
}
LLFloaterPreference::refreshEnabledGraphics();
refreshEnabledState();
}
void updateSliderText(LLSliderCtrl* slider, LLTextBox* text_box)

View File

@@ -156,9 +156,6 @@ protected:
// if the quality radio buttons are changed
void onChangeQuality(LLUICtrl* caller);
// if the custom settings box is clicked
static void onChangeCustom();
void onCommitAutoDetectAspect(const LLSD& value);
void onCommitWindowedMode();
void updateMeterText();
@@ -166,9 +163,6 @@ protected:
/// callback for defaults
void setHardwareDefaults();
// callback for when client turns on shaders
static void onVertexShaderEnable();
// helper function
static void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator);
};