desklink: Make use of BControlLook::ComposeIconSize().

Fixes #16370.
This commit is contained in:
Augustin Cavalier
2022-08-26 18:53:13 -04:00
parent 6970f0fdab
commit 8f3508d9c5
2 changed files with 15 additions and 18 deletions
+8 -13
View File
@@ -13,6 +13,7 @@
#include <Alert.h> #include <Alert.h>
#include <Bitmap.h> #include <Bitmap.h>
#include <Catalog.h> #include <Catalog.h>
#include <ControlLook.h>
#include <Dragger.h> #include <Dragger.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <Message.h> #include <Message.h>
@@ -42,17 +43,13 @@ DeskButton::DeskButton(BRect frame, entry_ref* ref, const char* name,
fActionList(actions), fActionList(actions),
fTitleList(titles) fTitleList(titles)
{ {
#ifdef __HAIKU__ fSegments = new BBitmap(frame, B_RGBA32);
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); BNodeInfo::GetTrackerIcon(&fRef, fSegments, (icon_size)(frame.IntegerWidth() + 1));
#else
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8);
#endif
BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON);
} }
DeskButton::DeskButton(BMessage *message) DeskButton::DeskButton(BMessage *message)
: BView(message) : BView(message)
{ {
message->FindRef("ref", &fRef); message->FindRef("ref", &fRef);
@@ -65,12 +62,10 @@ DeskButton::DeskButton(BMessage *message)
index++; index++;
} }
#ifdef __HAIKU__ fSegments = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)),
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_RGBA32); B_RGBA32);
#else BNodeInfo::GetTrackerIcon(&fRef, fSegments,
fSegments = new BBitmap(BRect(0, 0, 15, 15), B_CMAP8); (icon_size)(fSegments->Bounds().IntegerWidth() + 1));
#endif
BNodeInfo::GetTrackerIcon(&fRef, fSegments, B_MINI_ICON);
} }
+3 -1
View File
@@ -18,6 +18,7 @@
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
#include <ControlLook.h>
#include <Deskbar.h> #include <Deskbar.h>
#include <MimeType.h> #include <MimeType.h>
#include <Roster.h> #include <Roster.h>
@@ -139,7 +140,8 @@ main(int, char **argv)
err = deskbar.AddItem(&ref); err = deskbar.AddItem(&ref);
if (err != B_OK) { if (err != B_OK) {
err = deskbar.AddItem(new DeskButton(BRect(0, 0, 15, 15), err = deskbar.AddItem(new DeskButton(BRect(BPoint(0, 0),
be_control_look->ComposeIconSize(B_MINI_ICON)),
&ref, ref.name, titleList, actionList)); &ref, ref.name, titleList, actionList));
if (err != B_OK) { if (err != B_OK) {
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err)); printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));