desklink: Size custom items based on Deskbar's current icon size.

Fixes #18757.
This commit is contained in:
Augustin Cavalier 2024-01-30 14:18:29 -05:00
parent b2720cd3d9
commit a162e7af99
2 changed files with 9 additions and 5 deletions

View File

@ -62,10 +62,11 @@ DeskButton::DeskButton(BMessage *message)
index++;
}
fSegments = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)),
B_RGBA32);
BNodeInfo::GetTrackerIcon(&fRef, fSegments,
(icon_size)(fSegments->Bounds().IntegerWidth() + 1));
BRect bounds;
message->FindRect("bounds", &bounds);
fSegments = new BBitmap(bounds, B_RGBA32);
BNodeInfo::GetTrackerIcon(&fRef, fSegments, (icon_size)-1);
}
@ -99,6 +100,8 @@ DeskButton::Archive(BMessage *data, bool deep) const
data->AddString("action", *(BString*)fActionList.ItemAt(i));
}
data->AddRect("bounds", fSegments->Bounds());
data->AddString("add_on", kAppSignature);
return B_NO_ERROR;
}

View File

@ -140,8 +140,9 @@ main(int, char **argv)
err = deskbar.AddItem(&ref);
if (err != B_OK) {
const float height = deskbar.MaxItemHeight();
err = deskbar.AddItem(new DeskButton(BRect(BPoint(0, 0),
be_control_look->ComposeIconSize(B_MINI_ICON)),
BSize(height, height)),
&ref, ref.name, titleList, actionList));
if (err != B_OK) {
printf("desklink: Deskbar refuses link to '%s': %s\n", argv[i], strerror(err));