BControlLook: Introduce ComposeIconSize().

This takes an int32 (e.g. B_MINI_ICON or another constant) and
then returns a BSize scaled appropriately, the same as ComposeSpacing()
does already for the *_SPACING constants.

This will be used to replace icon size computations throughout the tree.
This commit is contained in:
Augustin Cavalier
2022-08-25 16:45:48 -04:00
parent 089f15adec
commit 874a2a7287
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -102,6 +102,7 @@ public:
virtual float DefaultItemSpacing() const = 0;
static float ComposeSpacing(float spacing);
static BSize ComposeIconSize(int32 size);
virtual uint32 Flags(BControl* control) const = 0;
+12
View File
@@ -45,6 +45,18 @@ BControlLook::ComposeSpacing(float spacing)
}
BSize
BControlLook::ComposeIconSize(int32 size)
{
float scale = be_plain_font->Size() / 12.0f;
if (scale < 1.0f)
scale = 1.0f;
const int32 scaled = size * scale;
return BSize(scaled - 1, scaled - 1);
}
void
BControlLook::DrawLabel(BView* view, const char* label, const BBitmap* icon,
BRect rect, const BRect& updateRect, const rgb_color& base, uint32 flags,