Tracker: Adjusted highlight boxes to better fit the icon label

* also fixes a glitch where label outline was sometimes cropped on some files

Change-Id: I24ab4808ac97a6ad7e24d605d1d892d5ce1c0080
Reviewed-on: https://review.haiku-os.org/c/haiku/+/11248
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Máximo Castañeda <[email protected]>
Haiku-Format: Haiku-format Bot <[email protected]>
This commit is contained in:
Fehér László
2026-07-11 11:06:47 +00:00
committed by Máximo Castañeda
parent d259e3e162
commit c807e52c53
3 changed files with 18 additions and 25 deletions
+3 -4
View File
@@ -941,7 +941,7 @@ BPose::CalcRect(const BPoseView* poseView) const
BTextWidget* widget = WidgetFor(poseView->FirstColumn()->AttrHash());
BPoint location = Location(poseView);
BRect rect(_IconRect(poseView, location));
float textWidth = (widget != NULL ? widget->TextWidth(poseView) : 0);
float textWidth = (widget != NULL ? widget->TextWidth(poseView) + 4 : 0);
if (poseView->ViewMode() == kIconMode) {
// icon mode
@@ -949,14 +949,13 @@ BPose::CalcRect(const BPoseView* poseView) const
rect.left += roundf((rect.Width() - textWidth) / 2.f);
rect.right = rect.left + ceilf(textWidth);
}
rect.bottom = rect.top + ceilf(poseView->IconPoseHeight()) + 3;
} else {
// mini icon mode
if (widget != NULL)
rect.right += kMiniIconSeparator + ceilf(textWidth);
rect.bottom = rect.top + ceilf(poseView->IconPoseHeight()) + 1;
}
rect.bottom = rect.top + ceilf(poseView->IconPoseHeight());
return rect;
}
+2 -2
View File
@@ -1049,12 +1049,12 @@ BPoseView::SetIconPoseHeight()
switch (ViewMode()) {
case kIconMode:
// IconSize should already be set in MessageReceived()
fIconPoseHeight = IconSizeInt() + sFontHeight + 1;
fIconPoseHeight = IconSizeInt() + sFontHeight;
break;
case kMiniIconMode:
fViewState->SetIconSize(B_MINI_ICON);
fIconPoseHeight = std::max((float)IconSizeInt(), sFontHeight + 1);
fIconPoseHeight = std::max((float)IconSizeInt(), sFontHeight);
break;
case kListMode:
+13 -19
View File
@@ -150,15 +150,18 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
BRect rect;
float viewWidth;
poseLoc.x = roundf(poseLoc.x);
poseLoc.y = roundf(poseLoc.y);
if (view->ViewMode() == kListMode) {
viewWidth = ceilf(std::min(column->Width(), textWidth));
viewWidth = roundf(std::min(column->Width(), textWidth));
poseLoc.x += column->Offset();
switch (fAlignment) {
case B_ALIGN_LEFT:
rect.left = poseLoc.x;
rect.right = rect.left + viewWidth;
rect.right = rect.left + viewWidth - 1;
break;
case B_ALIGN_CENTER:
@@ -166,12 +169,12 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
if (rect.left < 0)
rect.left = 0;
rect.right = rect.left + viewWidth;
rect.right = rect.left + viewWidth - 1;
break;
case B_ALIGN_RIGHT:
rect.right = poseLoc.x + column->Width();
rect.left = rect.right - viewWidth;
rect.left = rect.right - viewWidth + 1;
if (rect.left < 0)
rect.left = 0;
break;
@@ -182,29 +185,25 @@ BTextWidget::CalcRectCommon(BPoint poseLoc, const BColumn* column,
}
rect.bottom = poseLoc.y + roundf((view->ListElemHeight() + view->FontHeight()) / 2.f);
rect.top = rect.bottom - view->FontHeight();
rect.top = rect.bottom - view->FontHeight() + 1;
} else {
float iconSize = (float)view->IconSizeInt();
textWidth = floorf(textWidth);
// prevent drawing artifacts from selection rect drawing an extra pixel
if (view->ViewMode() == kIconMode) {
// icon mode
viewWidth = ceilf(std::min(view->StringWidth("M") * 30, textWidth));
viewWidth = roundf(std::min(view->StringWidth("M") * 30, textWidth));
rect.left = poseLoc.x + roundf((iconSize - viewWidth) / 2.f);
rect.bottom = poseLoc.y + ceilf(view->IconPoseHeight());
rect.top = rect.bottom - view->FontHeight();
} else {
// mini icon mode
viewWidth = ceilf(textWidth);
viewWidth = roundf(textWidth);
rect.left = poseLoc.x + iconSize + kMiniIconSeparator;
rect.bottom = poseLoc.y + roundf((iconSize + view->FontHeight()) / 2.f);
rect.top = poseLoc.y;
}
rect.right = rect.left + viewWidth;
rect.top = rect.bottom - view->FontHeight() + 1;
rect.right = rect.left + viewWidth - 1;
}
return rect;
@@ -667,12 +666,7 @@ BTextWidget::Draw(BRect eraseRect, BRect textRect, BPoseView* view, BView* drawV
drawView->SetDrawingMode(B_OP_COPY);
}
BRect invertRect(textRect);
invertRect.left = ceilf(invertRect.left);
invertRect.top = ceilf(invertRect.top);
invertRect.right = floorf(invertRect.right);
invertRect.bottom = floorf(invertRect.bottom);
drawView->FillRect(invertRect, B_SOLID_LOW);
drawView->FillRect(textRect, B_SOLID_LOW);
// High color is set to inverted low, then the whole thing is
// inverted again so that the background color "shines through".