BAlert: Use factional scaling for icons.

The behavior of not making the icons smaller than their default
pixel size is (for now) kept, but when making them larger,
fractional scaling is now used.

This makes alerts look much better on my system, which has a font
size of 18 (i.e. 150% normal, so 32px -> 48px.)
This commit is contained in:
Augustin Cavalier
2020-07-04 17:57:06 -04:00
parent 89fd39f42a
commit 99e4ca5fc7
+5 -4
View File
@@ -90,10 +90,11 @@ static const int kWindowMinWidth = 310;
static const int kWindowOffsetMinWidth = 335;
static inline int32
static inline float
icon_layout_scale()
{
return max_c(1, ((int32)be_plain_font->Size() + 15) / 16);
float scale = be_plain_font->Size() / 12;
return max_c(1, scale);
}
@@ -756,7 +757,7 @@ TAlertView::Archive(BMessage* archive, bool deep) const
void
TAlertView::GetPreferredSize(float* _width, float* _height)
{
int32 scale = icon_layout_scale();
float scale = icon_layout_scale();
if (_width != NULL) {
if (fIconBitmap != NULL)
@@ -788,7 +789,7 @@ TAlertView::Draw(BRect updateRect)
// Here's the fun stuff
BRect stripeRect = Bounds();
int32 iconLayoutScale = icon_layout_scale();
float iconLayoutScale = icon_layout_scale();
stripeRect.right = kIconStripeWidth * iconLayoutScale;
SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
FillRect(stripeRect);