From de3ad593131b4ad0a46b2b7663d7bbe246d14a4e Mon Sep 17 00:00:00 2001 From: Jackburton79 Date: Tue, 19 Nov 2024 17:52:24 +0100 Subject: [PATCH] Fix icon size miscalculation. We should rework it a bit and simplify --- src/project/ProjectItem.cpp | 2 +- src/ui/IconCache.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/project/ProjectItem.cpp b/src/project/ProjectItem.cpp index 4fe8af10..2b7f43e6 100644 --- a/src/project/ProjectItem.cpp +++ b/src/project/ProjectItem.cpp @@ -102,7 +102,7 @@ ProjectItem::DrawItem(BView* owner, BRect bounds, bool complete) { DrawItemPrepare(owner, bounds, complete); - const float iconSize = be_control_look->ComposeIconSize(B_MINI_ICON).Height(); + const float iconSize = be_control_look->ComposeIconSize(B_MINI_ICON).IntegerHeight() - 1; BRect iconRect = DrawIcon(owner, bounds, iconSize); if (fOpenedInEditor) diff --git a/src/ui/IconCache.cpp b/src/ui/IconCache.cpp index 7845b139..059ee486 100644 --- a/src/ui/IconCache.cpp +++ b/src/ui/IconCache.cpp @@ -23,6 +23,7 @@ IconCache::IconCache() const BBitmap* IconCache::GetIcon(const entry_ref *ref) { + // TODO: Rework GetIcon() to include icon size as a parameter BNode node(ref); const BNodeInfo nodeInfo(&node); char mimeType[B_MIME_TYPE_LENGTH]; @@ -43,9 +44,11 @@ IconCache::GetIcon(const entry_ref *ref) return it->second; } else { LogTrace("IconCache: could not find an icon in cache for %s", mimeTypePtr); + // TODO: we calculate icon size here, but we should pass it as a parameter + // to GetIcon(), because it's done in StyledItem::DrawIcon, too const BSize composedSize = be_control_look->ComposeIconSize(B_MINI_ICON); - const icon_size iconSize = icon_size(composedSize.IntegerWidth() - 1); - const BRect rect(0, 0, iconSize, composedSize.IntegerHeight() - 1); + const icon_size iconSize = icon_size(composedSize.IntegerHeight()); + const BRect rect(0, 0, iconSize - 1, iconSize - 1); BBitmap *icon = new BBitmap(rect, B_RGBA32); status_t status = nodeInfo.GetTrackerIcon(icon, iconSize); sInstance.fCache.emplace(mimeTypePtr, icon);