TeamMonitor: Use BControlLook::ComposeIconSize.

And DefaultLabelSpacing, too. Fixes appearance on HiDPI.
This commit is contained in:
Augustin Cavalier 2022-08-31 16:17:19 -04:00
parent 1f0c87711b
commit e6ab6daf98
3 changed files with 17 additions and 17 deletions

View File

@ -10,6 +10,7 @@
#include <string.h> #include <string.h>
#include <ControlLook.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <LocaleRoster.h> #include <LocaleRoster.h>
#include <NodeInfo.h> #include <NodeInfo.h>
@ -17,9 +18,6 @@
#include <View.h> #include <View.h>
static const int32 kItemMargin = 2;
bool gLocalizedNamePreferred; bool gLocalizedNamePreferred;
@ -27,8 +25,8 @@ TeamListItem::TeamListItem(team_info &teamInfo)
: :
fTeamInfo(teamInfo), fTeamInfo(teamInfo),
fAppInfo(), fAppInfo(),
fMiniIcon(BRect(0, 0, 15, 15), B_RGBA32), fMiniIcon(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)), B_RGBA32),
fLargeIcon(BRect(0, 0, 31, 31), B_RGBA32), fLargeIcon(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_LARGE_ICON)), B_RGBA32),
fFound(false), fFound(false),
fRefusingToQuit(false) fRefusingToQuit(false)
{ {
@ -38,8 +36,8 @@ TeamListItem::TeamListItem(team_info &teamInfo)
fPath = BPath(info.name); fPath = BPath(info.name);
BNode node(info.name); BNode node(info.name);
BNodeInfo nodeInfo(&node); BNodeInfo nodeInfo(&node);
nodeInfo.GetTrackerIcon(&fMiniIcon, B_MINI_ICON); nodeInfo.GetTrackerIcon(&fMiniIcon, (icon_size)-1);
nodeInfo.GetTrackerIcon(&fLargeIcon, B_LARGE_ICON); nodeInfo.GetTrackerIcon(&fLargeIcon, (icon_size)-1);
} }
if (be_roster->GetRunningAppInfo(fTeamInfo.team, &fAppInfo) != B_OK) if (be_roster->GetRunningAppInfo(fTeamInfo.team, &fAppInfo) != B_OK)
@ -87,14 +85,15 @@ TeamListItem::DrawItem(BView* owner, BRect frame, bool complete)
frame.left += 4; frame.left += 4;
BRect iconFrame(frame); BRect iconFrame(frame);
iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15, iconFrame.Set(iconFrame.left, iconFrame.top + 1,
iconFrame.top + 16); iconFrame.left + fMiniIcon.Bounds().Width(),
iconFrame.top + fMiniIcon.Bounds().Height() + 1);
owner->SetDrawingMode(B_OP_ALPHA); owner->SetDrawingMode(B_OP_ALPHA);
owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
owner->DrawBitmap(&fMiniIcon, iconFrame); owner->DrawBitmap(&fMiniIcon, iconFrame);
owner->SetDrawingMode(B_OP_COPY); owner->SetDrawingMode(B_OP_COPY);
frame.left += 16; frame.left += fMiniIcon.Bounds().Width();
if (fRefusingToQuit) if (fRefusingToQuit)
owner->SetHighColor(IsSelected() ? kHighlightRed : kRed); owner->SetHighColor(IsSelected() ? kHighlightRed : kRed);
else { else {
@ -107,7 +106,8 @@ TeamListItem::DrawItem(BView* owner, BRect frame, bool complete)
font_height finfo; font_height finfo;
font.GetHeight(&finfo); font.GetHeight(&finfo);
owner->SetFont(&font); owner->SetFont(&font);
owner->MovePenTo(frame.left + 8, frame.top + ((frame.Height() owner->MovePenTo(frame.left + (fMiniIcon.Bounds().Width() / 2),
frame.top + ((frame.Height()
- (finfo.ascent + finfo.descent + finfo.leading)) / 2) - (finfo.ascent + finfo.descent + finfo.leading)) / 2)
+ finfo.ascent); + finfo.ascent);
@ -118,10 +118,11 @@ TeamListItem::DrawItem(BView* owner, BRect frame, bool complete)
} }
/*static*/ int32 int32
TeamListItem::MinimalHeight() TeamListItem::MinimalHeight()
{ {
return 16 + kItemMargin; return fMiniIcon.Bounds().Height() +
(int32)(be_control_look->DefaultLabelSpacing() / 3.0f);
} }
@ -131,6 +132,7 @@ TeamListItem::Update(BView* owner, const BFont* font)
// we need to override the update method so we can make sure // we need to override the update method so we can make sure
// the list item size doesn't change // the list item size doesn't change
BListItem::Update(owner, font); BListItem::Update(owner, font);
if (Height() < MinimalHeight()) if (Height() < MinimalHeight())
SetHeight(MinimalHeight()); SetHeight(MinimalHeight());
} }

View File

@ -44,7 +44,7 @@ public:
void SetRefusingToQuit(bool refusing); void SetRefusingToQuit(bool refusing);
bool IsRefusingToQuit(); bool IsRefusingToQuit();
static int32 MinimalHeight(); int32 MinimalHeight();
private: private:
team_info fTeamInfo; team_info fTeamInfo;

View File

@ -709,7 +709,7 @@ TeamDescriptionView::SetItem(TeamListItem* item)
fQuitOverdue->Hide(); fQuitOverdue->Hide();
} }
fIconView->SetIcon(item->Path()->Path()); fIconView->SetIcon(item->LargeIcon());
} }
if (fLayout == NULL) if (fLayout == NULL)
@ -722,5 +722,3 @@ TeamDescriptionView::SetItem(TeamListItem* item)
Invalidate(); Invalidate();
} }