From 715c3b8510bbfdb4cb8fc89432a3d403310947e4 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Mon, 2 Jun 2014 23:24:25 -0400 Subject: [PATCH] [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. --- indra/newview/llfloaterpreference.cpp | 75 +++++++-------------------- indra/newview/llfloaterpreference.h | 17 ++---- indra/newview/llpaneldisplay.cpp | 35 +++++-------- indra/newview/llpaneldisplay.h | 6 --- 4 files changed, 34 insertions(+), 99 deletions(-) diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index b6d3d5e81..a452d1368 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -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("About..."); - mAboutBtn->setClickedCallback(onClickAbout, this); - - mApplyBtn = getChild("Apply"); - mApplyBtn->setClickedCallback(onBtnApply, this); - - mCancelBtn = getChild("Cancel"); - mCancelBtn->setClickedCallback(onBtnCancel, this); + getChild("About...")->setCommitCallback(boost::bind(LLFloaterAbout::show, (void*)0)); + getChild("Apply")->setCommitCallback(boost::bind(&LLFloaterPreference::onBtnApply, this)); + getChild("Cancel")->setCommitCallback(boost::bind(&LLFloaterPreference::onBtnCancel, this)); + getChild("OK")->setCommitCallback(boost::bind(&LLFloaterPreference::onBtnOK, this)); + + mPreferenceCore = new LLPreferenceCore(getChild("pref core"), getChild("OK")); - mOKBtn = getChild("OK"); - mOKBtn->setClickedCallback(onBtnOK, this); - - mPreferenceCore = new LLPreferenceCore( - getChild("pref core"), - getChild("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(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(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(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) { diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index ea6a0e0fd..e16f40cb6 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -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; }; diff --git a/indra/newview/llpaneldisplay.cpp b/indra/newview/llpaneldisplay.cpp index a4de73c52..3e4d7574a 100644 --- a/indra/newview/llpaneldisplay.cpp +++ b/indra/newview/llpaneldisplay.cpp @@ -207,7 +207,7 @@ BOOL LLPanelDisplay::postBuild() mCtrlSliderQuality->setSliderMouseUpCallback(boost::bind(&LLPanelDisplay::onChangeQuality,this,_1)); mCtrlCustomSettings = getChild("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("ReflectionDetailCombo"); - mCtrlReflectionDetail->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable)); + mCtrlReflectionDetail->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this)); // WindLight mCtrlWindLight = getChild("WindLightUseAtmosShaders"); - mCtrlWindLight->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable)); + mCtrlWindLight->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this)); // Deferred mCtrlDeferred = getChild("RenderDeferred"); - mCtrlDeferred->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable)); + mCtrlDeferred->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this)); mCtrlDeferredDoF = getChild("RenderDepthOfField"); - mCtrlDeferredDoF->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable)); + mCtrlDeferredDoF->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this)); mCtrlShadowDetail = getChild("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("AvatarVertexProgram"); - mCtrlAvatarVP->setCommitCallback(boost::bind(&LLPanelDisplay::onVertexShaderEnable)); + mCtrlAvatarVP->setCommitCallback(boost::bind(&LLPanelDisplay::refreshEnabledState, this)); //---------------------------------------------------------------------------- // Avatar Render Mode mCtrlAvatarCloth = getChild("AvatarCloth"); mCtrlAvatarImpostors = getChild("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("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("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) diff --git a/indra/newview/llpaneldisplay.h b/indra/newview/llpaneldisplay.h index 6d291f605..93fed532f 100644 --- a/indra/newview/llpaneldisplay.h +++ b/indra/newview/llpaneldisplay.h @@ -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); };