summaryrefslogtreecommitdiff
path: root/indra/llui/lltoolbar.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-10-14 16:47:43 -0700
committerMerov Linden <merov@lindenlab.com>2011-10-14 16:47:43 -0700
commit4c6f04c50225a4a5494974c3a6e13bee76cfbb6f (patch)
tree5e0356c0fd66837582a3f01f71e65e004c2db84d /indra/llui/lltoolbar.cpp
parent93ed1489a5da6781c6bdd5ee2263e6b6147835c8 (diff)
EXP-1363 : Fix caret position in multiple lines or columns situation
Diffstat (limited to 'indra/llui/lltoolbar.cpp')
-rw-r--r--indra/llui/lltoolbar.cpp67
1 files changed, 45 insertions, 22 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);