From 34b9c722e96c2aa7b1123cbaf15298d893a380a7 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Sat, 14 Dec 2024 22:21:19 -0700 Subject: [PATCH] CommandsWindow: ask be_control_look for the proper icon sizes --- Source/CommandsWindow.cpp | 17 +++++++++-------- Source/CommandsWindow.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/CommandsWindow.cpp b/Source/CommandsWindow.cpp index f711340..74b405b 100644 --- a/Source/CommandsWindow.cpp +++ b/Source/CommandsWindow.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -63,12 +64,12 @@ CommandsWindow::CommandsWindow(BString& title) scrollView->SetExplicitMaxSize(BSize(250, B_SIZE_UNSET)); fToolbar = new BToolBar(); - fToolbar->AddAction(kNewCommandAction, this, _ResourceBitmap("EntryAdd", 16, 16), + fToolbar->AddAction(kNewCommandAction, this, _ResourceBitmap("EntryAdd", be_control_look->ComposeIconSize(16)), B_TRANSLATE("Create a new command entry"), B_TRANSLATE("New")); - fToolbar->AddAction(kDeleteCommandAction, this, _ResourceBitmap("EntryDelete", 16, 16), + fToolbar->AddAction(kDeleteCommandAction, this, _ResourceBitmap("EntryDelete", be_control_look->ComposeIconSize(16)), B_TRANSLATE("Delete the selected command entry"), B_TRANSLATE("Delete")); fToolbar->AddGlue(); - fToolbar->AddAction(kUserGuideAction, this, _ResourceBitmap("UserGuide", 16, 16), + fToolbar->AddAction(kUserGuideAction, this, _ResourceBitmap("UserGuide", be_control_look->ComposeIconSize(16)), B_TRANSLATE("Open the user guide"), B_TRANSLATE("User Guide")); fNameControl = new BTextControl(B_TRANSLATE("Name:"), NULL, NULL); @@ -421,22 +422,22 @@ CommandsWindow::_InitControls() BBitmap* -CommandsWindow::_ResourceBitmap(const char* name, float width, float height) +CommandsWindow::_ResourceBitmap(const char* name, BSize size) { BResources* resources = be_app->AppResources(); if (resources == NULL) return NULL; - size_t size; - const void* data = resources->LoadResource(B_VECTOR_ICON_TYPE, name, &size); + size_t dataSize; + const void* data = resources->LoadResource(B_VECTOR_ICON_TYPE, name, &dataSize); if (data == NULL) return NULL; - BBitmap* bitmap = new BBitmap(BRect(0, 0, width - 1, height - 1), B_RGBA32); + BBitmap* bitmap = new BBitmap(BRect(0, 0, size.width, size.height), B_RGBA32); if (bitmap == NULL) return NULL; - if (BIconUtils::GetVectorIcon((const uint8*)data, size, bitmap) != B_OK) { + if (BIconUtils::GetVectorIcon((const uint8*)data, dataSize, bitmap) != B_OK) { delete bitmap; return NULL; } diff --git a/Source/CommandsWindow.h b/Source/CommandsWindow.h index 6750d8d..6098101 100644 --- a/Source/CommandsWindow.h +++ b/Source/CommandsWindow.h @@ -40,7 +40,7 @@ class CommandsWindow : public BWindow { void _RefsReceived(BMessage* message); status_t _LoadCommands(); status_t _SaveCommands(); - BBitmap* _ResourceBitmap(const char* name, float width, float height); + BBitmap* _ResourceBitmap(const char* name, BSize size); BButton* fBrowseButton; BButton* fShowButton;