From bc08a7d6c8f1a158ef2f8659a12857dc2a457a38 Mon Sep 17 00:00:00 2001 From: John Scipione Date: Thu, 16 Nov 2017 15:19:54 -0800 Subject: [PATCH] Fix first replicant wrapping bug on wide clock In this commit: a44504a168548e129e58eeace336a6a2315257ad Deskbar: Refactor TRelicantTray::LocationForReplicant() I made the following assumption that: * if index == 0 return right away, no calculation required. But this assumes that the first replicant will always fit on the same line as the clock which doesn't work if you have a wide clock. Update to always calculate the position even of the first replicant in vertical (multi-row) mode. In horizontal mode we still skip some calculations for the index 0 case. Also I was using kClockMargin (12px) for the right margin, the right margin should be only 8px: 5px for the dragger plus 3px more for kTrayPadding. Finally we add in the width of the clock and extra clock margin iif we're on first row and clock is not hidden. Fixes (hopefully the last of) #8641 --- src/apps/deskbar/StatusView.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/apps/deskbar/StatusView.cpp b/src/apps/deskbar/StatusView.cpp index b1b8bee669..8c99421cc3 100644 --- a/src/apps/deskbar/StatusView.cpp +++ b/src/apps/deskbar/StatusView.cpp @@ -1159,21 +1159,16 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth) } else loc.x += 1; // keeps everything lined up nicely - if (index <= 0) - return loc; - if (fMultiRowMode) { // try to find free space in every row for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) { // determine free space in this row BRect rowRect(loc.x, loc.y, loc.x + static_cast(be_app)->Settings()->width - - kClockMargin, + - kTrayPadding - kDragWidth - kGutter, loc.y + kMaxReplicantHeight); - if (row == 0 && !fTime->IsHidden()) { - rowRect.right -= kClockMargin + fTime->Frame().Width() - + kTrayPadding; - } + if (row == 0 && !fTime->IsHidden()) + rowRect.right -= kClockMargin + fTime->Frame().Width(); BRect replicantRect = rowRect; for (int32 i = 0; i < index; i++) { @@ -1186,13 +1181,19 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth) replicantRect.left = view->Frame().right + kIconGap + 1; } - if (replicantRect.Width() >= replicantWidth) { - // the icon fits in this row + // calculated left position, add replicantWidth to get right position + replicantRect.right = replicantRect.left + replicantWidth; + + // check if replicant fits in this row + if (replicantRect.right < rowRect.right) { + // replicant fits in this row loc = replicantRect.LeftTop(); break; } + + // check next row } - } else { + } else if (index > 0) { // get the last replicant added for placement reference BView* view = NULL; fShelf->ReplicantAt(index - 1, &view);