diff options
author | Merov Linden <merov@lindenlab.com> | 2011-10-12 19:48:13 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2011-10-12 19:48:13 -0700 |
commit | c14aa1b64e1190ff4bd7deef864d5393988e7f91 (patch) | |
tree | 0204c77da456e44ab2c296ff7fd7fd0075c5e942 | |
parent | 40ebe180a6592381804555d1c9e8df84bf35345a (diff) |
EXP-1331 : Avoid showing the caret if the tool is dragged over itself
-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 21eeed1d27..5e025f6a45 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; @@ -826,10 +847,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 7f8ae4f839..49750a9ac2 100644 --- a/indra/llui/lltoolbar.h +++ b/indra/llui/lltoolbar.h @@ -157,6 +157,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, |