summaryrefslogtreecommitdiff
path: root/indra/llui/lltoolbar.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r--indra/llui/lltoolbar.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 2fb9f249d4..8249df3e9d 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -123,12 +123,16 @@ void LLToolBar::createContextMenu()
{
if (!mPopupMenuHandle.get())
{
+ // Setup bindings specific to this instance for the context menu options
+
LLUICtrl::CommitCallbackRegistry::Registrar& commit_reg = LLUICtrl::CommitCallbackRegistry::defaultRegistrar();
commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2));
LLUICtrl::EnableCallbackRegistry::Registrar& enable_reg = LLUICtrl::EnableCallbackRegistry::defaultRegistrar();
enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2));
+ // Create the context menu
+
LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>("menu_toolbars.xml", LLMenuGL::sMenuContainer, LLMenuHolderGL::child_registry_t::instance());
if (menu)
@@ -141,6 +145,10 @@ void LLToolBar::createContextMenu()
{
llwarns << "Unable to load toolbars context menu." << llendl;
}
+
+ // Remove this instance's bindings
+ commit_reg.remove("Toolbars.EnableSetting");
+ enable_reg.remove("Toolbars.CheckSetting");
}
}
@@ -187,12 +195,6 @@ void LLToolBar::initFromParams(const LLToolBar::Params& p)
mCenteringStack->addChild(LLUICtrlFactory::create<LLLayoutPanel>(border_panel_p));
- BOOST_FOREACH (const LLCommandId::Params& command_id, p.commands)
- {
- mButtonCommands.push_back(command_id);
- }
- createButtons();
-
mNeedsLayout = true;
}
@@ -202,8 +204,11 @@ bool LLToolBar::addCommand(const LLCommandId& commandId)
bool add_command = (command != NULL);
- mButtonCommands.push_back(commandId);
- createButtons();
+ if (add_command)
+ {
+ mButtonCommands.push_back(commandId);
+ createButtons();
+ }
return add_command;
}
@@ -251,11 +256,13 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
if (handle_it_here)
{
createContextMenu();
+
LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get();
if (menu)
{
menu->show(x, y);
+
LLMenuGL::showPopup(this, menu, x, y);
}
}