diff options
-rw-r--r-- | indra/llui/lltoolbar.cpp | 67 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 1 | ||||
-rw-r--r-- | indra/newview/lltoolbarview.cpp | 8 |
3 files changed, 52 insertions, 24 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index 7fcd1da7b1..97cf583a3c 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -401,6 +401,11 @@ void LLToolBar::resizeButtonsInRow(std::vector<LLToolBarButton*>& buttons_in_row // Various drag data are stored in the toolbar object though are not exposed outside (and shouldn't). int LLToolBar::getRankFromPosition(S32 x, S32 y) { + if (mButtons.empty()) + { + return RANK_NONE; + } + int rank = 0; // Convert the toolbar coord into button panel coords @@ -417,21 +422,9 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) LLRect button_rect; while (it_button != end_button) { - button_rect = (*it_button)->getRect(); - mDragCommand = (*it_button)->mId; - S32 point_x, point_y; - if (orientation == LLLayoutStack::HORIZONTAL) - { - // Horizontal - point_x = (button_rect.mRight + button_rect.mLeft) / 2; - point_y = button_rect.mBottom - mPadBottom; - } - else - { - // Vertical - point_x = button_rect.mRight + mPadRight; - point_y = (button_rect.mTop + button_rect.mBottom) / 2; - } + button_rect = (*it_button)->getRect(); + S32 point_x = button_rect.mRight + mPadRight; + S32 point_y = button_rect.mBottom - mPadBottom; if ((button_panel_x < point_x) && (button_panel_y > point_y)) { @@ -445,19 +438,49 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) // (different depending on toolbar orientation) if (rank < mButtons.size()) { - mDragx = button_rect.mLeft - mPadLeft; - mDragy = button_rect.mTop + mPadTop; + if (orientation == LLLayoutStack::HORIZONTAL) + { + // Horizontal + 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 + { + rank++; + mDragx = button_rect.mRight + mPadRight - 1; + mDragy = button_rect.mTop + mPadTop; + } + } + else + { + // Vertical + S32 mid_point = (button_rect.mTop + button_rect.mBottom) / 2; + if (button_panel_y > mid_point) + { + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mTop + mPadTop; + } + else + { + rank++; + mDragx = button_rect.mLeft - mPadLeft; + mDragy = button_rect.mBottom - mPadBottom + 1; + } + } } else { // 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; } @@ -849,7 +872,7 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, mDragRank = getRankFromPosition(x, y); // Don't DaD if we're dragging a command on itself mDragAndDropTarget = ((orig_rank != RANK_NONE) && ((mDragRank == orig_rank) || ((mDragRank-1) == orig_rank)) ? false : true); - llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; + //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", dragged uui = " << inv_item->getUUID() << llendl; /* Do the following if you want to animate the button itself LLCommandId dragged_command(inv_item->getUUID()); removeCommand(dragged_command); diff --git a/indra/llui/lltoolbar.h b/indra/llui/lltoolbar.h index 3be252298d..e78c99cb37 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -200,7 +200,6 @@ protected: S32 mDragx, mDragy, mDragGirth; - LLCommandId mDragCommand; public: // Methods used in loading and saving toolbar settings diff --git a/indra/newview/lltoolbarview.cpp b/indra/newview/lltoolbarview.cpp index b43c4e80fa..21e682f072 100644 --- a/indra/newview/lltoolbarview.cpp +++ b/indra/newview/lltoolbarview.cpp @@ -416,24 +416,30 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t // Suppress the command from the toolbars (including the one it's dropped in, // this will handle move position). int old_rank = LLToolBar::RANK_NONE; + LLToolBar* old_toolbar = NULL; int rank; if ((rank = gToolBarView->mToolbarLeft->removeCommand(command_id)) != LLToolBar::RANK_NONE) { old_rank = rank; + old_toolbar = gToolBarView->mToolbarLeft; } if ((rank = gToolBarView->mToolbarRight->removeCommand(command_id)) != LLToolBar::RANK_NONE) { old_rank = rank; + old_toolbar = gToolBarView->mToolbarRight; } if ((rank = gToolBarView->mToolbarBottom->removeCommand(command_id)) != LLToolBar::RANK_NONE) { old_rank = rank; + old_toolbar = gToolBarView->mToolbarBottom; } // Now insert it in the toolbar at the detected rank if (!toolbar->isReadOnly()) { - if ((old_rank != LLToolBar::RANK_NONE) && (old_rank < new_rank)) + if ((old_toolbar == toolbar) && (old_rank != LLToolBar::RANK_NONE) && (old_rank < new_rank)) { + // If we just removed the command from the same toolbar, we need to consider that it might + // change the target rank. new_rank -= 1; } toolbar->addCommand(command->id(),new_rank); |