DiskProbe: Use BControlLook::ComposeIconSize() and adjust font size computation.

This commit is contained in:
Augustin Cavalier
2022-08-26 18:25:04 -04:00
parent 46ed1da36a
commit a57ccf381f
+15 -8
View File
@@ -18,6 +18,7 @@
#include <Box.h> #include <Box.h>
#include <Button.h> #include <Button.h>
#include <Catalog.h> #include <Catalog.h>
#include <ControlLook.h>
#include <Clipboard.h> #include <Clipboard.h>
#include <Directory.h> #include <Directory.h>
#include <Entry.h> #include <Entry.h>
@@ -235,7 +236,9 @@ IconView::IconView(const entry_ref* ref, bool isDevice)
fBitmap(NULL) fBitmap(NULL)
{ {
UpdateIcon(); UpdateIcon();
SetExplicitSize(BSize(32, 32));
if (fBitmap != NULL)
SetExplicitSize(fBitmap->Bounds().Size());
} }
@@ -270,8 +273,10 @@ IconView::Draw(BRect updateRect)
void void
IconView::UpdateIcon() IconView::UpdateIcon()
{ {
if (fBitmap == NULL) if (fBitmap == NULL) {
fBitmap = new BBitmap(BRect(0, 0, 31, 31), B_RGBA32); fBitmap = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_LARGE_ICON)),
B_RGBA32);
}
if (fBitmap != NULL) { if (fBitmap != NULL) {
status_t status = B_ERROR; status_t status = B_ERROR;
@@ -279,8 +284,10 @@ IconView::UpdateIcon()
if (fIsDevice) { if (fIsDevice) {
BPath path(&fRef); BPath path(&fRef);
status = get_device_icon(path.Path(), fBitmap, B_LARGE_ICON); status = get_device_icon(path.Path(), fBitmap, B_LARGE_ICON);
} else } else {
status = BNodeInfo::GetTrackerIcon(&fRef, fBitmap); status = BNodeInfo::GetTrackerIcon(&fRef, fBitmap,
(icon_size)(fBitmap->Bounds().IntegerWidth() + 1));
}
if (status != B_OK) { if (status != B_OK) {
// Try to get generic icon // Try to get generic icon
@@ -412,8 +419,8 @@ HeaderView::HeaderView(const entry_ref* ref, DataEditor& editor)
BFont boldFont = *be_bold_font; BFont boldFont = *be_bold_font;
BFont plainFont = *be_plain_font; BFont plainFont = *be_plain_font;
boldFont.SetSize(plainFont.Size() * 0.83); boldFont.SetSize(ceilf(plainFont.Size() * 0.83));
plainFont.SetSize(plainFont.Size() * 0.83); plainFont.SetSize(ceilf(plainFont.Size() * 0.83));
BStringView* stringView = new BStringView( BStringView* stringView = new BStringView(
B_EMPTY_STRING, editor.IsAttribute() B_EMPTY_STRING, editor.IsAttribute()
@@ -1078,7 +1085,7 @@ ProbeView::ProbeView(entry_ref* ref, const char* attribute,
fEditor.SetTo(*ref, attribute); fEditor.SetTo(*ref, attribute);
int32 baseType = kHexBase; int32 baseType = kHexBase;
float fontSize = 12.0f; float fontSize = be_plain_font->Size();
if (settings != NULL) { if (settings != NULL) {
settings->FindInt32("base_type", &baseType); settings->FindInt32("base_type", &baseType);
settings->FindFloat("font_size", &fontSize); settings->FindFloat("font_size", &fontSize);