Skip to content

Commit

Permalink
Fix icon size miscalculation.
Browse files Browse the repository at this point in the history
We should rework it a bit and simplify
  • Loading branch information
jackburton79 committed Nov 19, 2024
1 parent 72affac commit de3ad59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/project/ProjectItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions src/ui/IconCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
Expand Down

0 comments on commit de3ad59

Please sign in to comment.