diff --git a/indra/newview/llfloatersidepanelcontainer.cpp b/indra/newview/llfloatersidepanelcontainer.cpp index 047580b8fa5a53465c8eabcc3da52cd62f3b9ba7..2892371d89b8bb936a0fa1a4e1f579c11ced51fb 100644 --- a/indra/newview/llfloatersidepanelcontainer.cpp +++ b/indra/newview/llfloatersidepanelcontainer.cpp @@ -36,9 +36,6 @@ #include "llpaneloutfitedit.h" #include "llsidepanelappearance.h" -//static -const std::string LLFloaterSidePanelContainer::sMainPanelName("main_panel"); - // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 LLFloaterSidePanelContainer::validate_signal_t LLFloaterSidePanelContainer::mValidateSignal; // [/RLVa:KB] @@ -56,9 +53,15 @@ LLFloaterSidePanelContainer::~LLFloaterSidePanelContainer() LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::GLOBAL, this); } +BOOL LLFloaterSidePanelContainer::postBuild() +{ + mMainPanel = getChild<LLPanel>(sMainPanelName); + return TRUE; +} + void LLFloaterSidePanelContainer::onOpen(const LLSD& key) { - getChild<LLPanel>(sMainPanelName)->onOpen(key); + mMainPanel->onOpen(key); } void LLFloaterSidePanelContainer::closeFloater(bool app_quitting) @@ -70,7 +73,7 @@ void LLFloaterSidePanelContainer::closeFloater(bool app_quitting) LLFloater *parent = gFloaterView->getParentFloater(panel_outfit_edit); if (parent == this ) { - LLSidepanelAppearance* panel_appearance = dynamic_cast<LLSidepanelAppearance*>(getPanel("appearance")); + LLSidepanelAppearance* panel_appearance = dynamic_cast<LLSidepanelAppearance*>(mMainPanel); if ( panel_appearance ) { LLPanelEditWearable *edit_wearable_ptr = panel_appearance->getWearable(); @@ -94,14 +97,14 @@ void LLFloaterSidePanelContainer::closeFloater(bool app_quitting) } } -LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_name, const LLSD& params) +LLPanel* LLFloaterSidePanelContainer::openChildPanel(std::string_view panel_name, const LLSD& params) { LLView* view = findChildView(panel_name, true); if (!view) return NULL; if (!getVisible()) { - openFloater(); + openFloater(); } LLPanel* panel = NULL; @@ -109,7 +112,7 @@ LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_na LLSideTrayPanelContainer* container = dynamic_cast<LLSideTrayPanelContainer*>(view->getParent()); if (container) { - container->openPanel(panel_name, params); + container->openPanel(std::string(panel_name), params); panel = container->getCurrentPanel(); } else if ((panel = dynamic_cast<LLPanel*>(view)) != NULL) @@ -121,18 +124,18 @@ LLPanel* LLFloaterSidePanelContainer::openChildPanel(const std::string& panel_na } // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 -bool LLFloaterSidePanelContainer::canShowPanel(const std::string& floater_name, const LLSD& key) +bool LLFloaterSidePanelContainer::canShowPanel(std::string_view floater_name, const LLSD& key) { return mValidateSignal(floater_name, sMainPanelName, key); } -bool LLFloaterSidePanelContainer::canShowPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +bool LLFloaterSidePanelContainer::canShowPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key) { return mValidateSignal(floater_name, panel_name, key); } // [/RLVa:KB] -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); // if (floaterp) @@ -144,7 +147,7 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key) +void LLFloaterSidePanelContainer::showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); // if (floaterp) @@ -156,25 +159,37 @@ void LLFloaterSidePanelContainer::showPanel(const std::string& floater_name, con } } -LLPanel* LLFloaterSidePanelContainer::getPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::getPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::getTypedInstance<LLFloaterSidePanelContainer>(floater_name); - if (floaterp) { - return floaterp->findChild<LLPanel>(panel_name, true); + if (panel_name == sMainPanelName) + { + return floaterp->mMainPanel; + } + else + { + return floaterp->findChild<LLPanel>(panel_name, true); + } } return NULL; } -LLPanel* LLFloaterSidePanelContainer::findPanel(const std::string& floater_name, const std::string& panel_name) +LLPanel* LLFloaterSidePanelContainer::findPanel(std::string_view floater_name, std::string_view panel_name) { LLFloaterSidePanelContainer* floaterp = LLFloaterReg::findTypedInstance<LLFloaterSidePanelContainer>(floater_name); - if (floaterp) { - return floaterp->findChild<LLPanel>(panel_name, true); + if (panel_name == sMainPanelName) + { + return floaterp->mMainPanel; + } + else + { + return floaterp->findChild<LLPanel>(panel_name, true); + } } return NULL; diff --git a/indra/newview/llfloatersidepanelcontainer.h b/indra/newview/llfloatersidepanelcontainer.h index 0a94a28e747c9783781b6ebf9c046cc276b8b21b..1d2d6be2e11d2924eebf7d9b2dda9d990d207bea 100644 --- a/indra/newview/llfloatersidepanelcontainer.h +++ b/indra/newview/llfloatersidepanelcontainer.h @@ -30,6 +30,8 @@ #include "llfloater.h" +class LLPanel; + /** * Class LLFloaterSidePanelContainer * @@ -43,32 +45,34 @@ class LLFloaterSidePanelContainer final : public LLFloater { private: - static const std::string sMainPanelName; - + static inline constexpr std::string_view sMainPanelName = "main_panel"; + LLPanel* mMainPanel = nullptr; public: LLFloaterSidePanelContainer(const LLSD& key, const Params& params = getDefaultParams()); ~LLFloaterSidePanelContainer(); + /*virtual*/ BOOL postBuild(); + /*virtual*/ void onOpen(const LLSD& key); /*virtual*/ void closeFloater(bool app_quitting = false); void cleanup() { destroy(); } - LLPanel* openChildPanel(const std::string& panel_name, const LLSD& params); + LLPanel* openChildPanel(std::string_view panel_name, const LLSD& params); // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 - static bool canShowPanel(const std::string& floater_name, const LLSD& key); - static bool canShowPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); + static bool canShowPanel(std::string_view floater_name, const LLSD& key); + static bool canShowPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key); // [/RLVa:KB] - static void showPanel(const std::string& floater_name, const LLSD& key); + static void showPanel(std::string_view floater_name, const LLSD& key); - static void showPanel(const std::string& floater_name, const std::string& panel_name, const LLSD& key); + static void showPanel(std::string_view floater_name, std::string_view panel_name, const LLSD& key); - static LLPanel* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); - static LLPanel* findPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName); + static LLPanel* findPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName); /** * Gets the panel of given type T (doesn't show it or do anything else with it). @@ -78,7 +82,12 @@ class LLFloaterSidePanelContainer final : public LLFloater * @returns a pointer to the panel of given type T. */ template <typename T> - static T* getPanel(const std::string& floater_name, const std::string& panel_name = sMainPanelName) + static T* findPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) + { + return dynamic_cast<T*>(findPanel(floater_name, panel_name)); + } + template <typename T> + static T* getPanel(std::string_view floater_name, std::string_view panel_name = sMainPanelName) { T* panel = dynamic_cast<T*>(getPanel(floater_name, panel_name)); if (!panel) @@ -91,7 +100,7 @@ class LLFloaterSidePanelContainer final : public LLFloater // [RLVa:KB] - Checked: 2012-02-07 (RLVa-1.4.5) | Added: RLVa-1.4.5 // Used to determine whether a sidepanel can be shown public: - typedef boost::signals2::signal<bool(const std::string&, const std::string&, const LLSD&), boost_boolean_combiner> validate_signal_t; + typedef boost::signals2::signal<bool(std::string_view, std::string_view, const LLSD&), boost_boolean_combiner> validate_signal_t; static boost::signals2::connection setValidateCallback(const validate_signal_t::slot_type& cb) { return mValidateSignal.connect(cb); } private: static validate_signal_t mValidateSignal;