diff options
-rw-r--r-- | indra/llui/lltoolbar.cpp | 47 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_toolbars.xml | 8 |
3 files changed, 49 insertions, 10 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) { diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 8c25c43f1a..51fe23ddd1 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -63,6 +63,7 @@ public: BOOL handleMouseDown(S32 x, S32 y, MASK mask); BOOL handleHover(S32 x, S32 y, MASK mask); + void reshape(S32 width, S32 height, BOOL called_from_parent = true); void setEnabled(BOOL enabled); void setCommandId(const LLCommandId& id) { mId = id; } @@ -233,6 +234,7 @@ private: void resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row, S32 max_row_girth); BOOL isSettingChecked(const LLSD& userdata); void onSettingEnable(const LLSD& userdata); + void onRemoveSelectedCommand(); private: // static layout state @@ -270,6 +272,8 @@ private: LLPanel* mButtonPanel; LLHandle<class LLContextMenu> mPopupMenuHandle; + LLToolBarButton* mRightMouseTargetButton; + bool mNeedsLayout; bool mModified; diff --git a/indra/newview/skins/default/xui/en/menu_toolbars.xml b/indra/newview/skins/default/xui/en/menu_toolbars.xml index 7384114d7d..fbe40a7244 100644 --- a/indra/newview/skins/default/xui/en/menu_toolbars.xml +++ b/indra/newview/skins/default/xui/en/menu_toolbars.xml @@ -3,9 +3,15 @@ layout="topleft" name="Toolbars Popup" visible="false"> + <menu_item_call label="Remove this button" + layout="topleft" + name="Remove button"> + <menu_item_call.on_click function="Toolbars.RemoveSelectedCommand" /> + </menu_item_call> + <menu_item_separator layout="topleft" /> <menu_item_call label="Toolbar buttons..." layout="topleft" - name="Chose Buttons"> + name="Choose Buttons"> <menu_item_call.on_click function="Floater.Show" parameter="toybox" /> </menu_item_call> |