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/llfloatereditextdaycycle.cpp | 2 +- indra/newview/llfloaterfixedenvironment.cpp | 2 +- indra/newview/llflyoutcombobtn.cpp | 36 ++++++++++++--- indra/newview/llflyoutcombobtn.h | 8 +++- .../default/xui/en/floater_edit_ext_day_cycle.xml | 2 +- .../skins/default/xui/en/menu_save_settings.xml | 54 ++++++++++++++-------- 6 files changed, 76 insertions(+), 28 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 6abb698785..f8c6e135c0 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -173,7 +173,7 @@ BOOL LLFloaterEditExtDayCycle::postBuild() mImportButton = getChild(BTN_IMPORT, true); mLoadFrame = getChild(BTN_LOADFRAME, true); - mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BTN_SAVE, BTN_FLYOUT, XML_FLYOUTMENU_FILE); + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BTN_SAVE, BTN_FLYOUT, XML_FLYOUTMENU_FILE, false); mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); getChild(BTN_CANCEL, true)->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onClickCloseBtn(); }); diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index ece4898935..3fc5a03d3a 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -108,7 +108,7 @@ BOOL LLFloaterFixedEnvironment::postBuild() getChild(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onClickCloseBtn(); }); getChild(BUTTON_NAME_LOAD)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onButtonLoad(); }); - mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BUTTON_NAME_COMMIT, BUTTON_NAME_FLYOUT, XML_FLYOUTMENU_FILE); + mFlyoutControl = new LLFlyoutComboBtnCtrl(this, BUTTON_NAME_COMMIT, BUTTON_NAME_FLYOUT, XML_FLYOUTMENU_FILE, false); mFlyoutControl->setAction([this](LLUICtrl *ctrl, const LLSD &data) { onButtonApply(ctrl, data); }); mFlyoutControl->setMenuItemVisible(ACTION_COMMIT, false); 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) diff --git a/indra/newview/llflyoutcombobtn.h b/indra/newview/llflyoutcombobtn.h index 741ad03a37..b0dd4abadf 100644 --- a/indra/newview/llflyoutcombobtn.h +++ b/indra/newview/llflyoutcombobtn.h @@ -37,7 +37,11 @@ class LLFlyoutComboBtnCtrl { LOG_CLASS(LLFlyoutComboBtnCtrl); public: - LLFlyoutComboBtnCtrl(LLPanel* parent, const std::string &action_button, const std::string &flyout_button, const std::string &menu_file); + LLFlyoutComboBtnCtrl(LLPanel* parent, + const std::string &action_button, + const std::string &flyout_button, + const std::string &menu_file, + bool apply_immediately = true); void setMenuItemEnabled(const std::string &item, bool enabled); void setShownBtnEnabled(bool enabled); @@ -52,6 +56,7 @@ public: protected: void onFlyoutButton(LLUICtrl *, const LLSD &); void onFlyoutItemSelected(LLUICtrl *, const LLSD &); + bool onFlyoutItemCheck(LLUICtrl *, const LLSD &); void onFlyoutAction(LLUICtrl *, const LLSD &); void setSelectedItem(LLMenuItemGL *pitem); @@ -63,6 +68,7 @@ private: std::string mFlyoutButton; std::string mSelectedName; + bool mApplyImmediately; LLUICtrl::commit_signal_t mActionSignal; }; diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index e553948d9d..c8843db28b 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -538,7 +538,7 @@ Select a key frame from the timeline above to edit settings. left="5" top_pad="0" name="save_btn" - width="150" /> + width="156" />