From 99e4ca5fc7ca65a0ebf028127c6afe3ab2659f90 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 4 Jul 2020 17:57:06 -0400 Subject: [PATCH] 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.) --- src/kits/interface/Alert.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kits/interface/Alert.cpp b/src/kits/interface/Alert.cpp index f924604184..7658eba2be 100644 --- a/src/kits/interface/Alert.cpp +++ b/src/kits/interface/Alert.cpp @@ -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);