From c238fa3ac5a3f93dcbf95e3cf7a7f8b576ab751c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 8 May 2018 16:57:14 -0700 Subject: Add save/update functionality hooks to fixed editor. --- indra/newview/llflyoutcombobtn.cpp | 127 +++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 indra/newview/llflyoutcombobtn.cpp (limited to 'indra/newview/llflyoutcombobtn.cpp') diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp new file mode 100644 index 0000000000..efe76b5653 --- /dev/null +++ b/indra/newview/llflyoutcombobtn.cpp @@ -0,0 +1,127 @@ +/** + * @file llsaveoutfitcombobtn.cpp + * @brief Represents outfit save/save as combo button. + * + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llflyoutcombobtn.h" +#include "llviewermenu.h" + +LLFlyoutComboBtn::LLFlyoutComboBtn(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : + mParent(parent), + mActionButton(action_button), + mFlyoutButton(flyout_button) +{ + // register action mapping before creating menu + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar; + save_registar.add("FlyoutCombo.Button.Action", [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutItemSelected(ctrl, data); }); + + mParent->childSetAction(flyout_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutButton(ctrl, data); }); + mParent->childSetAction(action_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutAction(ctrl, data); }); + + mFlyoutMenu = LLUICtrlFactory::getInstance()->createFromFile (menu_file, gMenuHolder, + LLViewerMenuHolderGL::child_registry_t::instance()); + + // select the first item in the list. + setSelectedItem(0); +} + +void LLFlyoutComboBtn::setAction(LLUICtrl::commit_callback_t cb) +{ + mActionSignal.connect(cb); +} + + +U32 LLFlyoutComboBtn::getItemCount() +{ + return mFlyoutMenu->getItemCount(); +} + +void LLFlyoutComboBtn::setSelectedItem(S32 itemno) +{ + LLMenuItemGL *pitem = mFlyoutMenu->getItem(itemno); + setSelectedItem(pitem); +} + +void LLFlyoutComboBtn::setSelectedItem(const std::string &item) +{ + LLMenuItemGL *pitem = mFlyoutMenu->getChild(item, false); + setSelectedItem(pitem); +} + +void LLFlyoutComboBtn::setSelectedItem(LLMenuItemGL *pitem) +{ + if (!pitem) + { + LL_WARNS("INTERFACE") << "NULL item selected" << LL_ENDL; + return; + } + + mSelectedName = pitem->getName(); + + LLButton *action_button = mParent->getChild(mActionButton); + action_button->setEnabled(pitem->getEnabled()); + action_button->setLabel(pitem->getLabel()); +} + +void LLFlyoutComboBtn::setMenuItemEnabled(const std::string& item, bool enabled) +{ + mFlyoutMenu->setItemEnabled(item, enabled); + if (item == mSelectedName) + { + mParent->getChildView(mActionButton)->setEnabled(enabled); + } +} + +void LLFlyoutComboBtn::setShownBtnEnabled(bool enabled) +{ + mParent->getChildView(mActionButton)->setEnabled(enabled); +} + +void LLFlyoutComboBtn::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) +{ + S32 x, y; + LLUI::getMousePositionLocal(mParent, &x, &y); + + mFlyoutMenu->updateParent(LLMenuGL::sMenuContainer); + LLMenuGL::showPopup(mParent, mFlyoutMenu, x, y); +} + +void LLFlyoutComboBtn::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) +{ + LLMenuItemGL *pmenuitem = static_cast(ctrl); + setSelectedItem(pmenuitem); + + onFlyoutAction(pmenuitem, data); +} + +void LLFlyoutComboBtn::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) +{ + LLMenuItemGL *pmenuitem = mFlyoutMenu->getChild(mSelectedName); + + if (!mActionSignal.empty()) + mActionSignal(pmenuitem, data); +} + -- cgit v1.2.3 From b6ba9dd565b59e516571445e56f9dafe3bdf4061 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 22 May 2018 20:32:56 +0300 Subject: MAINT-8344 Day Cycle Editor (part 4, finalization) --- indra/newview/llflyoutcombobtn.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'indra/newview/llflyoutcombobtn.cpp') diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp index efe76b5653..a736fcafa3 100644 --- a/indra/newview/llflyoutcombobtn.cpp +++ b/indra/newview/llflyoutcombobtn.cpp @@ -1,5 +1,5 @@ /** - * @file llsaveoutfitcombobtn.cpp + * @file llflyoutcombobtn.cpp * @brief Represents outfit save/save as combo button. * * $LicenseInfo:firstyear=2010&license=viewerlgpl$ @@ -29,7 +29,7 @@ #include "llflyoutcombobtn.h" #include "llviewermenu.h" -LLFlyoutComboBtn::LLFlyoutComboBtn(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : +LLFlyoutComboBtnCtrl::LLFlyoutComboBtnCtrl(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : mParent(parent), mActionButton(action_button), mFlyoutButton(flyout_button) @@ -48,30 +48,30 @@ LLFlyoutComboBtn::LLFlyoutComboBtn(LLPanel* parent, const std::string &action_bu setSelectedItem(0); } -void LLFlyoutComboBtn::setAction(LLUICtrl::commit_callback_t cb) +void LLFlyoutComboBtnCtrl::setAction(LLUICtrl::commit_callback_t cb) { mActionSignal.connect(cb); } -U32 LLFlyoutComboBtn::getItemCount() +U32 LLFlyoutComboBtnCtrl::getItemCount() { return mFlyoutMenu->getItemCount(); } -void LLFlyoutComboBtn::setSelectedItem(S32 itemno) +void LLFlyoutComboBtnCtrl::setSelectedItem(S32 itemno) { LLMenuItemGL *pitem = mFlyoutMenu->getItem(itemno); setSelectedItem(pitem); } -void LLFlyoutComboBtn::setSelectedItem(const std::string &item) +void LLFlyoutComboBtnCtrl::setSelectedItem(const std::string &item) { LLMenuItemGL *pitem = mFlyoutMenu->getChild(item, false); setSelectedItem(pitem); } -void LLFlyoutComboBtn::setSelectedItem(LLMenuItemGL *pitem) +void LLFlyoutComboBtnCtrl::setSelectedItem(LLMenuItemGL *pitem) { if (!pitem) { @@ -86,7 +86,7 @@ void LLFlyoutComboBtn::setSelectedItem(LLMenuItemGL *pitem) action_button->setLabel(pitem->getLabel()); } -void LLFlyoutComboBtn::setMenuItemEnabled(const std::string& item, bool enabled) +void LLFlyoutComboBtnCtrl::setMenuItemEnabled(const std::string& item, bool enabled) { mFlyoutMenu->setItemEnabled(item, enabled); if (item == mSelectedName) @@ -95,12 +95,12 @@ void LLFlyoutComboBtn::setMenuItemEnabled(const std::string& item, bool enabled) } } -void LLFlyoutComboBtn::setShownBtnEnabled(bool enabled) +void LLFlyoutComboBtnCtrl::setShownBtnEnabled(bool enabled) { mParent->getChildView(mActionButton)->setEnabled(enabled); } -void LLFlyoutComboBtn::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) +void LLFlyoutComboBtnCtrl::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) { S32 x, y; LLUI::getMousePositionLocal(mParent, &x, &y); @@ -109,7 +109,7 @@ void LLFlyoutComboBtn::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) LLMenuGL::showPopup(mParent, mFlyoutMenu, x, y); } -void LLFlyoutComboBtn::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) +void LLFlyoutComboBtnCtrl::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) { LLMenuItemGL *pmenuitem = static_cast(ctrl); setSelectedItem(pmenuitem); @@ -117,7 +117,7 @@ void LLFlyoutComboBtn::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data) onFlyoutAction(pmenuitem, data); } -void LLFlyoutComboBtn::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) +void LLFlyoutComboBtnCtrl::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) { LLMenuItemGL *pmenuitem = mFlyoutMenu->getChild(mSelectedName); -- cgit v1.2.3 From 1716129fd23ff35e030808406af1a8f796dc4b01 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 17 Aug 2018 12:35:42 -0700 Subject: MAINT-8826, MAINT-8990, MAINT-9002, MAINT-7703: Rework for environment pannels in Region/Estate and Parcel. Enable/disable by permission. Edit the correct environment. Dirty flags for changes. Estate owner disallow switch. --- indra/newview/llflyoutcombobtn.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llflyoutcombobtn.cpp') diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp index a736fcafa3..d1a8b46c92 100644 --- a/indra/newview/llflyoutcombobtn.cpp +++ b/indra/newview/llflyoutcombobtn.cpp @@ -100,6 +100,11 @@ void LLFlyoutComboBtnCtrl::setShownBtnEnabled(bool enabled) mParent->getChildView(mActionButton)->setEnabled(enabled); } +void LLFlyoutComboBtnCtrl::setMenuItemVisible(const std::string &item, bool visible) +{ + mFlyoutMenu->setItemVisible(item, visible); +} + void LLFlyoutComboBtnCtrl::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) { S32 x, y; -- cgit v1.2.3 From a4c49904c67e123df0d8e1f68714cf13acfa1ffc Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 3 Sep 2018 19:32:22 +0300 Subject: MAINT-8989 Menu updates button instead of executing command --- indra/newview/llflyoutcombobtn.cpp | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'indra/newview/llflyoutcombobtn.cpp') diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp index d1a8b46c92..b008ee13be 100644 --- a/indra/newview/llflyoutcombobtn.cpp +++ b/indra/newview/llflyoutcombobtn.cpp @@ -29,14 +29,21 @@ #include "llflyoutcombobtn.h" #include "llviewermenu.h" -LLFlyoutComboBtnCtrl::LLFlyoutComboBtnCtrl(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file) : - mParent(parent), +LLFlyoutComboBtnCtrl::LLFlyoutComboBtnCtrl(LLPanel* parent, + const std::string &action_button, + const std::string &flyout_button, + const std::string &menu_file, + bool apply_immediately) : + mParent(parent), mActionButton(action_button), - mFlyoutButton(flyout_button) + mFlyoutButton(flyout_button), + mApplyImmediately(apply_immediately) { - // register action mapping before creating menu - LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar; + // register action mapping before creating menu + LLUICtrl::CommitCallbackRegistry::ScopedRegistrar save_registar; save_registar.add("FlyoutCombo.Button.Action", [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutItemSelected(ctrl, data); }); + LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enabled_rgistar; + enabled_rgistar.add("FlyoutCombo.Button.Check", [this](LLUICtrl *ctrl, const LLSD &data) { return onFlyoutItemCheck(ctrl, data); }); mParent->childSetAction(flyout_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutButton(ctrl, data); }); mParent->childSetAction(action_button, [this](LLUICtrl *ctrl, const LLSD &data) { onFlyoutAction(ctrl, data); }); @@ -119,7 +126,24 @@ void LLFlyoutComboBtnCtrl::onFlyoutItemSelected(LLUICtrl *ctrl, const LLSD &data LLMenuItemGL *pmenuitem = static_cast(ctrl); setSelectedItem(pmenuitem); - onFlyoutAction(pmenuitem, data); + if (mApplyImmediately) + { + onFlyoutAction(pmenuitem, data); + } +} + +bool LLFlyoutComboBtnCtrl::onFlyoutItemCheck(LLUICtrl *ctrl, const LLSD &data) +{ + if (mApplyImmediately) + { + return false; + } + else + { + LLMenuItemGL *pmenuitem = static_cast(ctrl); + + return pmenuitem->getName() == mSelectedName; + } } void LLFlyoutComboBtnCtrl::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data) -- cgit v1.2.3 From 64e45b5b6ef8ded7bbea1b376e5bf2cbb0d6f5a4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 4 Jan 2019 17:10:28 -0800 Subject: SL-10041, SL-9758: Environment tab is disabled(shows can't do this) when EM does not allow parcel override. "Commit" button now reads "Apply to Parcel" or "Apply to Region" as needed. --- indra/newview/llflyoutcombobtn.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/newview/llflyoutcombobtn.cpp') diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp index b008ee13be..48bfb85072 100644 --- a/indra/newview/llflyoutcombobtn.cpp +++ b/indra/newview/llflyoutcombobtn.cpp @@ -112,6 +112,12 @@ void LLFlyoutComboBtnCtrl::setMenuItemVisible(const std::string &item, bool visi mFlyoutMenu->setItemVisible(item, visible); } + +void LLFlyoutComboBtnCtrl::setMenuItemLabel(const std::string &item, const std::string &label) +{ + mFlyoutMenu->setItemLabel(item, label); +} + void LLFlyoutComboBtnCtrl::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) { S32 x, y; -- cgit v1.2.3 From e9c0a93f99c4e6a4844da1a93ac261c4b206b79b Mon Sep 17 00:00:00 2001 From: Dave Houlton Date: Thu, 14 Nov 2019 15:19:55 -0700 Subject: Fix merge-related compile errors --- indra/newview/llflyoutcombobtn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llflyoutcombobtn.cpp') diff --git a/indra/newview/llflyoutcombobtn.cpp b/indra/newview/llflyoutcombobtn.cpp index 48bfb85072..e4f1d9fcaa 100644 --- a/indra/newview/llflyoutcombobtn.cpp +++ b/indra/newview/llflyoutcombobtn.cpp @@ -121,7 +121,7 @@ void LLFlyoutComboBtnCtrl::setMenuItemLabel(const std::string &item, const std:: void LLFlyoutComboBtnCtrl::onFlyoutButton(LLUICtrl *ctrl, const LLSD &data) { S32 x, y; - LLUI::getMousePositionLocal(mParent, &x, &y); + LLUI::getInstance()->getMousePositionLocal(mParent, &x, &y); mFlyoutMenu->updateParent(LLMenuGL::sMenuContainer); LLMenuGL::showPopup(mParent, mFlyoutMenu, x, y); -- cgit v1.2.3