Fix first replicant wrapping bug on wide clock
In this commit:
a44504a168
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
This commit is contained in:
parent
aa19dd0236
commit
bc08a7d6c8
|
@ -1159,21 +1159,16 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
|
||||||
} else
|
} else
|
||||||
loc.x += 1; // keeps everything lined up nicely
|
loc.x += 1; // keeps everything lined up nicely
|
||||||
|
|
||||||
if (index <= 0)
|
|
||||||
return loc;
|
|
||||||
|
|
||||||
if (fMultiRowMode) {
|
if (fMultiRowMode) {
|
||||||
// try to find free space in every row
|
// try to find free space in every row
|
||||||
for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
|
for (int32 row = 0; ; loc.y += kMaxReplicantHeight + kIconGap, row++) {
|
||||||
// determine free space in this row
|
// determine free space in this row
|
||||||
BRect rowRect(loc.x, loc.y,
|
BRect rowRect(loc.x, loc.y,
|
||||||
loc.x + static_cast<TBarApp*>(be_app)->Settings()->width
|
loc.x + static_cast<TBarApp*>(be_app)->Settings()->width
|
||||||
- kClockMargin,
|
- kTrayPadding - kDragWidth - kGutter,
|
||||||
loc.y + kMaxReplicantHeight);
|
loc.y + kMaxReplicantHeight);
|
||||||
if (row == 0 && !fTime->IsHidden()) {
|
if (row == 0 && !fTime->IsHidden())
|
||||||
rowRect.right -= kClockMargin + fTime->Frame().Width()
|
rowRect.right -= kClockMargin + fTime->Frame().Width();
|
||||||
+ kTrayPadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
BRect replicantRect = rowRect;
|
BRect replicantRect = rowRect;
|
||||||
for (int32 i = 0; i < index; i++) {
|
for (int32 i = 0; i < index; i++) {
|
||||||
|
@ -1186,13 +1181,19 @@ TReplicantTray::LocationForReplicant(int32 index, float replicantWidth)
|
||||||
replicantRect.left = view->Frame().right + kIconGap + 1;
|
replicantRect.left = view->Frame().right + kIconGap + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (replicantRect.Width() >= replicantWidth) {
|
// calculated left position, add replicantWidth to get right position
|
||||||
// the icon fits in this row
|
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();
|
loc = replicantRect.LeftTop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check next row
|
||||||
}
|
}
|
||||||
} else {
|
} else if (index > 0) {
|
||||||
// get the last replicant added for placement reference
|
// get the last replicant added for placement reference
|
||||||
BView* view = NULL;
|
BView* view = NULL;
|
||||||
fShelf->ReplicantAt(index - 1, &view);
|
fShelf->ReplicantAt(index - 1, &view);
|
||||||
|
|
Loading…
Reference in New Issue