From 6a49f2947f05963c577a1644c16a8affc779da63 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Wed, 28 Sep 2011 16:25:32 -0700 Subject: EXP-1234 WIP experimental drag and drop --- indra/llui/lltoolbarview.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'indra/llui/lltoolbarview.cpp') diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp index b374a0bfc4..0c3a6bd0ac 100644 --- a/indra/llui/lltoolbarview.cpp +++ b/indra/llui/lltoolbarview.cpp @@ -55,7 +55,10 @@ LLToolBarView::LLToolBarView(const LLToolBarView::Params& p) : LLUICtrl(p), mToolbarLeft(NULL), mToolbarRight(NULL), - mToolbarBottom(NULL) + mToolbarBottom(NULL), + mDragButton(NULL), + mMouseX(0), + mMouseY(0) { } @@ -283,4 +286,40 @@ void LLToolBarView::draw() //gl_rect_2d(right_rect, back_color_vert, TRUE); LLUICtrl::draw(); + + if (mDragButton) + { + S32 cursor_x, cursor_y; + mDragButton->setOrigin(mMouseX - mDragButton->getRect().getWidth(), mMouseY - mDragButton->getRect().getHeight()); + drawChild(mDragButton); + } +} + +void LLToolBarView::startDrag(LLToolBarButton* button) +{ + mDragButton = button; + addChild(mDragButton); + gFocusMgr.setMouseCapture(this); +} + +BOOL LLToolBarView::handleHover(S32 x, S32 y, MASK mask) +{ + mMouseX = x; + mMouseY = y; + return LLUICtrl::handleHover(x, y, mask); +} + +BOOL LLToolBarView::handleMouseUp(S32 x, S32 y, MASK mask) +{ + if (hasMouseCapture()) + { + gFocusMgr.setMouseCapture(NULL); + } + return LLUICtrl::handleMouseUp(x, y, mask); +} + +void LLToolBarView::onMouseCaptureLost() +{ + delete mDragButton; + mDragButton = NULL; } -- cgit v1.2.3