From f24fe44df8496579de25dd2b46097f198ab41e9b Mon Sep 17 00:00:00 2001 From: Shyotl Date: Thu, 20 Jun 2013 00:49:02 -0500 Subject: [PATCH] wlfPanel_AdvSettings cleanup. Removed some duplicate code, and register to rlv to catch behavior change instead of polling every draw call. Also now references wlfAdvSettingsPopup setting only during build. --- indra/newview/lloverlaybar.cpp | 21 ++-------- indra/newview/lloverlaybar.h | 4 +- indra/newview/wlfPanel_AdvSettings.cpp | 56 +++++++++++++++----------- indra/newview/wlfPanel_AdvSettings.h | 12 +++++- 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp index fcb924e9f..12077f379 100644 --- a/indra/newview/lloverlaybar.cpp +++ b/indra/newview/lloverlaybar.cpp @@ -153,11 +153,11 @@ LLOverlayBar::LLOverlayBar() LLUICtrlFactory::getInstance()->buildPanel(this, "panel_overlaybar.xml", &factory_map); } -bool updateAdvSettingsPopup(const LLSD &data) +bool LLOverlayBar::updateAdvSettingsPopup() { bool wfl_adv_settings_popup = gSavedSettings.getBOOL("wlfAdvSettingsPopup"); wlfPanel_AdvSettings::updateClass(); - if(LLLayoutStack* layout_stack = gOverlayBar->findChild("overlay_layout_panel")) + if(LLLayoutStack* layout_stack = findChild("overlay_layout_panel")) { LLLayoutPanel* layout_panel = layout_stack->findChild("AdvSettings_container"); if(layout_panel) @@ -218,27 +218,14 @@ BOOL LLOverlayBar::postBuild() sChatVisible = gSavedSettings.getBOOL("ChatVisible"); - LLControlVariable* wfl_adv_settings_popupp = gSavedSettings.getControl("wlfAdvSettingsPopup"); - wfl_adv_settings_popupp->getSignal()->connect(boost::bind(&updateAdvSettingsPopup,_2)); + gSavedSettings.getControl("wlfAdvSettingsPopup")->getSignal()->connect(boost::bind(&LLOverlayBar::updateAdvSettingsPopup,this)); gSavedSettings.getControl("ChatVisible")->getSignal()->connect(boost::bind(&updateChatVisible,_2)); gSavedSettings.getControl("EnableAORemote")->getSignal()->connect(boost::bind(&updateAORemote,_2)); gSavedSettings.getControl("ShowNearbyMediaFloater")->getSignal()->connect(boost::bind(&updateNearbyMediaFloater,_2)); childSetVisible("ao_remote_container", gSavedSettings.getBOOL("EnableAORemote")); - wlfPanel_AdvSettings::updateClass(); - - bool wfl_adv_settings_popup = wfl_adv_settings_popupp->getValue().asBoolean(); - if(LLLayoutStack* layout_stack = findChild("overlay_layout_panel")) - { - LLLayoutPanel* layout_panel = layout_stack->findChild("AdvSettings_container"); - if(layout_panel) - { - layout_stack->collapsePanel(layout_panel,!wfl_adv_settings_popup); - if(wfl_adv_settings_popup) - layout_panel->setTargetDim(layout_panel->getChild("Adv_Settings")->getBoundingRect().getWidth()); - } - } + updateAdvSettingsPopup(); return TRUE; } diff --git a/indra/newview/lloverlaybar.h b/indra/newview/lloverlaybar.h index 1b8cf767d..03ac7ed72 100644 --- a/indra/newview/lloverlaybar.h +++ b/indra/newview/lloverlaybar.h @@ -130,8 +130,8 @@ protected: private: - /*static void updateAdvSettingsPopup(const LLSD &data); - static void updateChatVisible(const LLSD &data);*/ + bool updateAdvSettingsPopup(); + //static void updateChatVisible(const LLSD &data); }; diff --git a/indra/newview/wlfPanel_AdvSettings.cpp b/indra/newview/wlfPanel_AdvSettings.cpp index edba51310..e4fe82d8b 100644 --- a/indra/newview/wlfPanel_AdvSettings.cpp +++ b/indra/newview/wlfPanel_AdvSettings.cpp @@ -53,14 +53,13 @@ #include "llwlparamset.h" #include "llwlparammanager.h" -// [RLVa:KB] -#include "rlvhandler.h" -// [/RLVa:KB] - -wlfPanel_AdvSettings::wlfPanel_AdvSettings() : mBuilt(false) +wlfPanel_AdvSettings::wlfPanel_AdvSettings() : mExpanded(false) { + setVisible(false); setIsChrome(TRUE); setFocusRoot(TRUE); + if(rlv_handler_t::isEnabled()) + gRlvHandler.setBehaviourToggleCallback(boost::bind(&wlfPanel_AdvSettings::onRlvBehaviorChange, this, _1, _2)); } //static @@ -73,42 +72,49 @@ void wlfPanel_AdvSettings::updateClass() void wlfPanel_AdvSettings::build() { - deleteAllChildren(); std::string ButtonState; if (gSavedSettings.getBOOL("wlfAdvSettingsPopup")) { + mExpanded = true; LLUICtrlFactory::getInstance()->buildPanel(this, "wlfPanel_AdvSettings_expanded.xml", &getFactoryMap()); ButtonState = "arrow_down.tga"; } else { + mExpanded = false; LLUICtrlFactory::getInstance()->buildPanel(this, "wlfPanel_AdvSettings.xml", &getFactoryMap()); ButtonState = "arrow_up.tga"; } getChild("expand")->setImageOverlay(ButtonState); } -void wlfPanel_AdvSettings::refresh() +// [RLVa:KB] - Checked: 2013-06-20 +void wlfPanel_AdvSettings::updateRlvVisibility() { -// [RLVa:KB] - Checked: 2009-09-19 - if (rlv_handler_t::isEnabled() && gSavedSettings.getBOOL("wlfAdvSettingsPopup")) - { - if (!findChild("use_estate_wl")) return; // Singu Note: Not certain why, but sometimes none of these exist even though the above setting implies they should - childSetEnabled("use_estate_wl", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("EnvAdvancedWaterButton", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("WLWaterPresetsCombo", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("WWprev", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("WWnext", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("EnvAdvancedSkyButton", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("WLSkyPresetsCombo", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("WLprev", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("WLnext", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - childSetEnabled("EnvTimeSlider", !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV)); - } -// [/RLVa:KB] + if(!mExpanded || !rlv_handler_t::isEnabled()) + return; + + bool enable = !gRlvHandler.hasBehaviour(RLV_BHVR_SETENV); + childSetEnabled("use_estate_wl", enable); + childSetEnabled("EnvAdvancedWaterButton", enable); + childSetEnabled("WLWaterPresetsCombo", enable); + childSetEnabled("WWprev", enable); + childSetEnabled("WWnext", enable); + childSetEnabled("EnvAdvancedSkyButton", enable); + childSetEnabled("WLSkyPresetsCombo", enable); + childSetEnabled("WLprev", enable); + childSetEnabled("WLnext", enable); + childSetEnabled("EnvTimeSlider", enable); } +void wlfPanel_AdvSettings::onRlvBehaviorChange(ERlvBehaviour eBhvr, ERlvParamType eType) +{ + if(eBhvr == RLV_BHVR_SETENV) + updateRlvVisibility(); +} +// [/RLVa:KB] + void wlfPanel_AdvSettings::refreshLists() { LLEnvManagerNew& env_mgr = LLEnvManagerNew::instance(); @@ -139,9 +145,10 @@ void wlfPanel_AdvSettings::refreshLists() BOOL wlfPanel_AdvSettings::postBuild() { + setVisible(true); childSetAction("expand", onClickExpandBtn, this); - if (gSavedSettings.getBOOL("wlfAdvSettingsPopup")) + if (mExpanded) { getChild("use_estate_wl")->setCommitCallback(onUseRegionSettings); @@ -175,6 +182,7 @@ BOOL wlfPanel_AdvSettings::postBuild() mTimeSlider = getChild("EnvTimeSlider"); mTimeSlider->setCommitCallback(onChangeDayTime); updateTimeSlider(); + updateRlvVisibility(); } return TRUE; } diff --git a/indra/newview/wlfPanel_AdvSettings.h b/indra/newview/wlfPanel_AdvSettings.h index f4ecdea58..9228bf88a 100644 --- a/indra/newview/wlfPanel_AdvSettings.h +++ b/indra/newview/wlfPanel_AdvSettings.h @@ -34,6 +34,11 @@ #include "llpanel.h" + +// [RLVa:KB] +#include "rlvhandler.h" +// [/RLVa:KB] + class LLComboBox; class LLSliderCtrl; @@ -45,7 +50,10 @@ public: ~wlfPanel_AdvSettings (); BOOL postBuild(); void draw(); - void refresh(); + + void updateRlvVisibility(); + void onRlvBehaviorChange(ERlvBehaviour eBhvr, ERlvParamType eType); + static void updateClass(); static void onClickExpandBtn(void* user_data); @@ -76,7 +84,7 @@ protected: // LLComboBox* mDayCyclePresetCombo; LLSliderCtrl* mTimeSlider; - bool mBuilt; + bool mExpanded; }; #endif // LL_wlfPanel_AdvSettings_H