diff options
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 97dc1e3316..ea11750e38 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -114,6 +114,8 @@ LLToolBar::LLToolBar(const LLToolBar::Params& p) mHandleDropCallback(NULL), mButtonAddSignal(NULL), mButtonEnterSignal(NULL), + mButtonLeaveSignal(NULL), + mButtonRemoveSignal(NULL), mDragAndDropTarget(false) { mButtonParams[LLToolBarEnums::BTNTYPE_ICONS_WITH_TEXT] = p.button_icon_and_text; @@ -125,6 +127,8 @@ LLToolBar::~LLToolBar() delete mPopupMenuHandle.get(); delete mButtonAddSignal; delete mButtonEnterSignal; + delete mButtonLeaveSignal; + delete mButtonRemoveSignal; } void LLToolBar::createContextMenu() @@ -272,6 +276,11 @@ int LLToolBar::removeCommand(const LLCommandId& commandId) ++rank; } + if (mButtonRemoveSignal) + { + (*mButtonRemoveSignal)(*it_button); + } + // Delete the button and erase the command and button records delete (*it_button); mButtonCommands.erase(it_command); @@ -922,16 +931,34 @@ LLToolBarButton* LLToolBar::createButton(const LLCommandId& id) return button; } +boost::signals2::connection connectSignal(LLToolBar::button_signal_t*& signal, const LLToolBar::button_signal_t::slot_type& cb) +{ + if (!signal) + { + signal = new LLToolBar::button_signal_t(); + } + + return signal->connect(cb); +} + boost::signals2::connection LLToolBar::setButtonAddCallback(const button_signal_t::slot_type& cb) { - if (!mButtonAddSignal) mButtonAddSignal = new button_signal_t(); - return mButtonAddSignal->connect(cb); + return connectSignal(mButtonAddSignal, cb); } boost::signals2::connection LLToolBar::setButtonEnterCallback(const button_signal_t::slot_type& cb) { - if (!mButtonEnterSignal) mButtonEnterSignal = new button_signal_t(); - return mButtonEnterSignal->connect(cb); + return connectSignal(mButtonEnterSignal, cb); +} + +boost::signals2::connection LLToolBar::setButtonLeaveCallback(const button_signal_t::slot_type& cb) +{ + return connectSignal(mButtonLeaveSignal, cb); +} + +boost::signals2::connection LLToolBar::setButtonRemoveCallback(const button_signal_t::slot_type& cb) +{ + return connectSignal(mButtonRemoveSignal, cb); } BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, @@ -1067,6 +1094,17 @@ void LLToolBarButton::onMouseEnter(S32 x, S32 y, MASK mask) } } +void LLToolBarButton::onMouseLeave(S32 x, S32 y, MASK mask) +{ + LLButton::onMouseLeave(x, y, mask); + + LLToolBar* parent_toolbar = getParentByType<LLToolBar>(); + if (parent_toolbar && parent_toolbar->mButtonLeaveSignal) + { + (*(parent_toolbar->mButtonLeaveSignal))(this); + } +} + void LLToolBarButton::onMouseCaptureLost() { mIsDragged = false; |