Merged in andreykproductengine/maint-eep2 (pull request #68)

MAINT-8989 Menu updates button instead of executing command
meow-7.2.2
Rider Linden 2018-09-04 16:22:01 +00:00
commit d1d248973d
6 changed files with 76 additions and 28 deletions

View File

@ -173,7 +173,7 @@ BOOL LLFloaterEditExtDayCycle::postBuild()
mImportButton = getChild<LLButton>(BTN_IMPORT, true);
mLoadFrame = getChild<LLButton>(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<LLButton>(BTN_CANCEL, true)->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &data) { onClickCloseBtn(); });

View File

@ -108,7 +108,7 @@ BOOL LLFloaterFixedEnvironment::postBuild()
getChild<LLButton>(BUTTON_NAME_CANCEL)->setClickedCallback([this](LLUICtrl *, const LLSD &) { onClickCloseBtn(); });
getChild<LLButton>(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);

View File

@ -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<LLMenuItemGL*>(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<LLMenuItemGL*>(ctrl);
return pmenuitem->getName() == mSelectedName;
}
}
void LLFlyoutComboBtnCtrl::onFlyoutAction(LLUICtrl *ctrl, const LLSD &data)

View File

@ -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;
};

View File

@ -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" />
<button
follows="top|left"

View File

@ -5,46 +5,64 @@
mouse_opaque="false"
name="save_settings_menu"
width="120">
<menu_item_call
<menu_item_check
name="save_settings"
label="Save">
<menu_item_call.on_click
<menu_item_check.on_check
function="FlyoutCombo.Button.Check"
userdata="save" />
<menu_item_check.on_click
function="FlyoutCombo.Button.Action"
userdata="save"/>
</menu_item_call>
<menu_item_call
</menu_item_check>
<menu_item_check
name="save_as_new_settings"
label="Save As">
<menu_item_call.on_click
<menu_item_check.on_check
function="FlyoutCombo.Button.Check"
userdata="saveas" />
<menu_item_check.on_click
function="FlyoutCombo.Button.Action"
userdata="saveas" />
</menu_item_call>
<menu_item_call
</menu_item_check>
<menu_item_check
name="commit_changes"
label="Commit">
<menu_item_call.on_click
<menu_item_check.on_check
function="FlyoutCombo.Button.Check"
userdata="commit" />
<menu_item_check.on_click
function="FlyoutCombo.Button.Action"
userdata="commit" />
</menu_item_call>
<menu_item_call
</menu_item_check>
<menu_item_check
name="apply_local"
label="Apply Only To Myself">
<menu_item_call.on_click
<menu_item_check.on_check
function="FlyoutCombo.Button.Check"
userdata="local" />
<menu_item_check.on_click
function="FlyoutCombo.Button.Action"
userdata="local" />
</menu_item_call>
<menu_item_call
</menu_item_check>
<menu_item_check
name="apply_parcel"
label="Apply To Parcel">
<menu_item_call.on_click
<menu_item_check.on_check
function="FlyoutCombo.Button.Check"
userdata="parcel" />
<menu_item_check.on_click
function="FlyoutCombo.Button.Action"
userdata="parcel" />
</menu_item_call>
<menu_item_call
</menu_item_check>
<menu_item_check
name="apply_region"
label="Apply To Region">
<menu_item_call.on_click
<menu_item_check.on_check
function="FlyoutCombo.Button.Check"
userdata="region" />
<menu_item_check.on_click
function="FlyoutCombo.Button.Action"
userdata="region" />
</menu_item_call>
</menu_item_check>
</toggleable_menu>