summaryrefslogtreecommitdiff
path: root/indra/llui/lltoolbar.cpp
diff options
context:
space:
mode:
authorLeslie Linden <leslie@lindenlab.com>2011-11-14 14:44:13 -0800
committerLeslie Linden <leslie@lindenlab.com>2011-11-14 14:44:13 -0800
commit76caf0238cb98c1abf69d56e122c71a1208b0d72 (patch)
tree4f4a77ff8f11e7cc0a0f7af437b8699f0d035727 /indra/llui/lltoolbar.cpp
parentb403a9da23a2df73a657bfa835a3706a261af2fb (diff)
parentc24645f7b51ea27e1686bbe72470a9f3c09fc676 (diff)
Merge
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r--indra/llui/lltoolbar.cpp47
1 files changed, 38 insertions, 9 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp
index 287e3e2b41..e7642ae190 100644
--- a/indra/llui/lltoolbar.cpp
+++ b/indra/llui/lltoolbar.cpp
@@ -109,6 +109,7 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p)
mPadBetween(p.pad_between),
mMinGirth(p.min_girth),
mPopupMenuHandle(),
+ mRightMouseTargetButton(NULL),
mStartDragItemCallback(NULL),
mHandleDragItemCallback(NULL),
mHandleDropCallback(NULL),
@@ -139,6 +140,7 @@ void LLToolBar::createContextMenu()
LLUICtrl::CommitCallbackRegistry::ScopedRegistrar commit_reg;
commit_reg.add("Toolbars.EnableSetting", boost::bind(&LLToolBar::onSettingEnable, this, _2));
+ commit_reg.add("Toolbars.RemoveSelectedCommand", boost::bind(&LLToolBar::onRemoveSelectedCommand, this));
LLUICtrl::EnableCallbackRegistry::ScopedRegistrar enable_reg;
enable_reg.add("Toolbars.CheckSetting", boost::bind(&LLToolBar::isSettingChecked, this, _2));
@@ -397,6 +399,20 @@ BOOL LLToolBar::handleRightMouseDown(S32 x, S32 y, MASK mask)
if (handle_it_here)
{
+ // Determine which button the mouse was over during the click in case the context menu action
+ // is intended to affect the button.
+ BOOST_FOREACH(LLToolBarButton* button, mButtons)
+ {
+ LLRect button_rect;
+ button->localRectToOtherView(button->getLocalRect(), &button_rect, this);
+
+ if (button_rect.pointInRect(x, y))
+ {
+ mRightMouseTargetButton = button;
+ break;
+ }
+ }
+
createContextMenu();
LLContextMenu * menu = (LLContextMenu *) mPopupMenuHandle.get();
@@ -446,6 +462,18 @@ void LLToolBar::onSettingEnable(const LLSD& userdata)
}
}
+void LLToolBar::onRemoveSelectedCommand()
+{
+ llassert(!mReadOnly);
+
+ if (mRightMouseTargetButton)
+ {
+ removeCommand(mRightMouseTargetButton->getCommandId());
+
+ mRightMouseTargetButton = NULL;
+ }
+}
+
void LLToolBar::setButtonType(LLToolBarEnums::ButtonType button_type)
{
bool regenerate_buttons = (mButtonType != button_type);
@@ -524,11 +552,11 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
S32 mid_point = (button_rect.mRight + button_rect.mLeft) / 2;
if (button_panel_x < mid_point)
{
- mDragx = button_rect.mLeft - mPadLeft;
- mDragy = button_rect.mTop + mPadTop;
- }
- else
- {
+ mDragx = button_rect.mLeft - mPadLeft;
+ mDragy = button_rect.mTop + mPadTop;
+ }
+ else
+ {
rank++;
mDragx = button_rect.mRight + mPadRight - 1;
mDragy = button_rect.mTop + mPadTop;
@@ -555,12 +583,12 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
{
// We hit passed the end of the list so put the insertion point at the end
if (orientation == LLLayoutStack::HORIZONTAL)
- {
+ {
mDragx = button_rect.mRight + mPadRight;
mDragy = button_rect.mTop + mPadTop;
- }
- else
- {
+ }
+ else
+ {
mDragx = button_rect.mLeft - mPadLeft;
mDragy = button_rect.mBottom - mPadBottom;
}
@@ -836,6 +864,7 @@ void LLToolBar::createButtons()
}
mButtons.clear();
mButtonMap.clear();
+ mRightMouseTargetButton = NULL;
BOOST_FOREACH(LLCommandId& command_id, mButtonCommands)
{