Skip to content
Snippets Groups Projects
Commit c14aa1b6 authored by Merov Linden's avatar Merov Linden
Browse files

EXP-1331 : Avoid showing the caret if the tool is dragged over itself

parent 40ebe180
No related branches found
No related tags found
No related merge requests found
...@@ -418,6 +418,7 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) ...@@ -418,6 +418,7 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
while (it_button != end_button) while (it_button != end_button)
{ {
button_rect = (*it_button)->getRect(); button_rect = (*it_button)->getRect();
mDragCommand = (*it_button)->mId;
S32 point_x, point_y; S32 point_x, point_y;
if (orientation == LLLayoutStack::HORIZONTAL) if (orientation == LLLayoutStack::HORIZONTAL)
{ {
...@@ -436,7 +437,6 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) ...@@ -436,7 +437,6 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
{ {
break; break;
} }
mDragCommand = (*it_button)->mId;
rank++; rank++;
++it_button; ++it_button;
} }
...@@ -480,6 +480,27 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y) ...@@ -480,6 +480,27 @@ int LLToolBar::getRankFromPosition(S32 x, S32 y)
return rank; 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() void LLToolBar::updateLayoutAsNeeded()
{ {
if (!mNeedsLayout) return; if (!mNeedsLayout) return;
...@@ -826,10 +847,12 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, ...@@ -826,10 +847,12 @@ BOOL LLToolBar::handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
LLAssetType::EType type = inv_item->getType(); LLAssetType::EType type = inv_item->getType();
if (type == LLAssetType::AT_WIDGET) if (type == LLAssetType::AT_WIDGET)
{ {
LLCommandId dragged_command(inv_item->getUUID());
int orig_rank = getRankFromPosition(dragged_command);
mDragRank = getRankFromPosition(x, y); mDragRank = getRankFromPosition(x, y);
// Don't DaD if we're dragging a command on itself // Don't DaD if we're dragging a command on itself
mDragAndDropTarget = (mDragCommand.uuid() != inv_item->getUUID()); 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; 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 /* Do the following if you want to animate the button itself
LLCommandId dragged_command(inv_item->getUUID()); LLCommandId dragged_command(inv_item->getUUID());
removeCommand(dragged_command); removeCommand(dragged_command);
......
...@@ -157,6 +157,7 @@ class LLToolBar ...@@ -157,6 +157,7 @@ class LLToolBar
void draw(); void draw();
void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE); void reshape(S32 width, S32 height, BOOL called_from_parent = TRUE);
int getRankFromPosition(S32 x, S32 y); int getRankFromPosition(S32 x, S32 y);
int getRankFromPosition(const LLCommandId& id);
BOOL handleRightMouseDown(S32 x, S32 y, MASK mask); BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop, virtual BOOL handleDragAndDrop(S32 x, S32 y, MASK mask, BOOL drop,
EDragAndDropType cargo_type, EDragAndDropType cargo_type,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment