diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llui/lltoolbar.cpp | 29 | ||||
-rw-r--r-- | indra/llui/lltoolbar.h | 1 |
2 files changed, 27 insertions, 3 deletions
diff --git a/indra/llui/lltoolbar.cpp b/indra/llui/lltoolbar.cpp index e67e18872c..3ea0968bfc 100644 --- a/indra/llui/lltoolbar.cpp +++ b/indra/llui/lltoolbar.cpp @@ -418,6 +418,7 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) while (it_button != end_button) { button_rect = (*it_button)->getRect(); + mDragCommand = (*it_button)->mId; S32 point_x, point_y; if (orientation == LLLayoutStack::HORIZONTAL) { @@ -436,7 +437,6 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) { break; } - mDragCommand = (*it_button)->mId; rank++; ++it_button; } @@ -480,6 +480,27 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) return rank; } +int LLToolBar::getRankFromPosition(const LLCommandId& id) +{ + if (!hasCommand(id)) + { + return RANK_NONE; + } + int rank = 0; + std::list<LLToolBarButton*>::iterator it_button = mButtons.begin(); + std::list<LLToolBarButton*>::iterator end_button = mButtons.end(); + while (it_button != end_button) + { + if ((*it_button)->mId == id) + { + break; + } + rank++; + ++it_button; + } + return rank; +} + void LLToolBar::updateLayoutAsNeeded() { if (!mNeedsLayout) return; @@ -823,10 +844,12 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, LLAssetType::EType type = inv_item->getType(); if (type == LLAssetType::AT_WIDGET) { + LLCommandId dragged_command(inv_item->getUUID()); + int orig_rank = getRankFromPosition(dragged_command); mDragRank = getRankFromPosition(x, y); // Don't DaD if we're dragging a command on itself - mDragAndDropTarget = (mDragCommand.uuid() != inv_item->getUUID()); - //llinfos << "Merov debug : DaD, rank = " << mDragRank << ", hit uuid = " << mDragCommand.uuid() << ", dragged uui = " << inv_item->getUUID() << llendl; + mDragAndDropTarget = ((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; /* 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 8d38bc0234..3be252298d 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -161,6 +161,7 @@ public: void draw(); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); int getRankFromPosition(S32 x, S32 y); + int getRankFromPosition(const LLCommandId& id); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, EDragAndDropType cargo_type, |