EXP-1300 : Fix caret position in bottom bar, fix misplacement when moving within same toolbar, suppress visible caret in some situations, no caret if toolbar empty

meow-7.2.2
Merov Linden 2011-10-11 16:20:02 -07:00
parent 682609d254
commit dacfe7b2bd
2 changed files with 24 additions and 8 deletions

View File

@ -425,12 +425,12 @@ int LLToolBar::getRankFromPosition(S32& x, S32& y)
}
if (it_button != end_button)
{
x = button_rect.mRight + dx;
x = button_rect.mLeft + dx;
y = button_rect.mTop + dy;
}
else
{
x = button_rect.mLeft + dx;
x = button_rect.mRight + dx;
y = button_rect.mBottom + dy;
}
@ -655,6 +655,7 @@ void LLToolBar::draw()
LLUICtrl::draw();
caret->setVisible(FALSE);
mDragAndDropTarget = false;
}
void LLToolBar::reshape(S32 width, S32 height, BOOL called_from_parent)

View File

@ -406,20 +406,35 @@ BOOL LLToolBarView::handleDropTool( void* cargo_data, S32 x, S32 y, LLToolBar* t
if (command)
{
// Convert the (x,y) position in rank in toolbar
int rank = 0;
int new_rank = LLToolBar::RANK_NONE;
if (!toolbar->isReadOnly())
{
rank = toolbar->getRankFromPosition(x,y);
new_rank = toolbar->getRankFromPosition(x,y);
}
// Suppress the command from the toolbars (including the one it's dropped in,
// this will handle move position).
gToolBarView->mToolbarLeft->removeCommand(command_id);
gToolBarView->mToolbarRight->removeCommand(command_id);
gToolBarView->mToolbarBottom->removeCommand(command_id);
int old_rank = LLToolBar::RANK_NONE;
int rank;
if ((rank = gToolBarView->mToolbarLeft->removeCommand(command_id)) != LLToolBar::RANK_NONE)
{
old_rank = rank;
}
if ((rank = gToolBarView->mToolbarRight->removeCommand(command_id)) != LLToolBar::RANK_NONE)
{
old_rank = rank;
}
if ((rank = gToolBarView->mToolbarBottom->removeCommand(command_id)) != LLToolBar::RANK_NONE)
{
old_rank = rank;
}
// Now insert it in the toolbar at the detected rank
if (!toolbar->isReadOnly())
{
toolbar->addCommand(command->id(),rank);
if ((old_rank != LLToolBar::RANK_NONE) && (old_rank < new_rank))
{
new_rank -= 1;
}
toolbar->addCommand(command->id(),new_rank);
}
}
else