Tracker & desklink: Pass -1 to GetTrackerIcon for sizing.
It can just deduce the size from the passed BBitmap if we do this. Simplifies the code somewhat.
This commit is contained in:
@@ -44,7 +44,7 @@ DeskButton::DeskButton(BRect frame, entry_ref* ref, const char* name,
|
|||||||
fTitleList(titles)
|
fTitleList(titles)
|
||||||
{
|
{
|
||||||
fSegments = new BBitmap(frame, B_RGBA32);
|
fSegments = new BBitmap(frame, B_RGBA32);
|
||||||
BNodeInfo::GetTrackerIcon(&fRef, fSegments, (icon_size)(frame.IntegerWidth() + 1));
|
BNodeInfo::GetTrackerIcon(&fRef, fSegments, (icon_size)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,16 +52,16 @@ DeskButton::DeskButton(BMessage *message)
|
|||||||
: BView(message)
|
: BView(message)
|
||||||
{
|
{
|
||||||
message->FindRef("ref", &fRef);
|
message->FindRef("ref", &fRef);
|
||||||
|
|
||||||
BString title, action;
|
BString title, action;
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
while(message->FindString("title", index, &title)==B_OK
|
while(message->FindString("title", index, &title)==B_OK
|
||||||
&& message->FindString("action", index, &action)==B_OK) {
|
&& message->FindString("action", index, &action)==B_OK) {
|
||||||
fTitleList.AddItem(new BString(title));
|
fTitleList.AddItem(new BString(title));
|
||||||
fActionList.AddItem(new BString(action));
|
fActionList.AddItem(new BString(action));
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fSegments = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)),
|
fSegments = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(B_MINI_ICON)),
|
||||||
B_RGBA32);
|
B_RGBA32);
|
||||||
BNodeInfo::GetTrackerIcon(&fRef, fSegments,
|
BNodeInfo::GetTrackerIcon(&fRef, fSegments,
|
||||||
@@ -86,13 +86,13 @@ DeskButton::Instantiate(BMessage *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
DeskButton::Archive(BMessage *data, bool deep) const
|
DeskButton::Archive(BMessage *data, bool deep) const
|
||||||
{
|
{
|
||||||
BView::Archive(data, deep);
|
BView::Archive(data, deep);
|
||||||
|
|
||||||
data->AddRef("ref", &fRef);
|
data->AddRef("ref", &fRef);
|
||||||
|
|
||||||
for (int32 i = 0; i < fTitleList.CountItems()
|
for (int32 i = 0; i < fTitleList.CountItems()
|
||||||
&& i < fActionList.CountItems(); i++) {
|
&& i < fActionList.CountItems(); i++) {
|
||||||
data->AddString("title", *(BString*)fTitleList.ItemAt(i));
|
data->AddString("title", *(BString*)fTitleList.ItemAt(i));
|
||||||
@@ -124,7 +124,7 @@ DeskButton::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ DeskButton::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
DeskButton::Draw(BRect rect)
|
DeskButton::Draw(BRect rect)
|
||||||
{
|
{
|
||||||
BView::Draw(rect);
|
BView::Draw(rect);
|
||||||
@@ -182,7 +182,7 @@ DeskButton::MouseDown(BPoint point)
|
|||||||
}
|
}
|
||||||
|
|
||||||
menu->SetTargetForItems(this);
|
menu->SetTargetForItems(this);
|
||||||
menu->Go(where, true, true, BRect(where - BPoint(4, 4),
|
menu->Go(where, true, true, BRect(where - BPoint(4, 4),
|
||||||
where + BPoint(4, 4)));
|
where + BPoint(4, 4)));
|
||||||
} else if (mouseButtons & B_PRIMARY_MOUSE_BUTTON) {
|
} else if (mouseButtons & B_PRIMARY_MOUSE_BUTTON) {
|
||||||
be_roster->Launch(&fRef);
|
be_roster->Launch(&fRef);
|
||||||
|
|||||||
@@ -281,11 +281,9 @@ IconMenuItem::IconMenuItem(const char* label, BMessage* message,
|
|||||||
fWhich(which)
|
fWhich(which)
|
||||||
{
|
{
|
||||||
if (nodeInfo != NULL) {
|
if (nodeInfo != NULL) {
|
||||||
fDeviceIcon = new BBitmap(BRect(BPoint(0, 0), be_control_look->ComposeIconSize(which)),
|
fDeviceIcon = new BBitmap(BRect(BPoint(0, 0),
|
||||||
kDefaultIconDepth);
|
be_control_look->ComposeIconSize(which)), kDefaultIconDepth);
|
||||||
|
if (nodeInfo->GetTrackerIcon(fDeviceIcon, (icon_size)-1) != B_OK) {
|
||||||
const icon_size size = (icon_size)(fDeviceIcon->Bounds().IntegerWidth() + 1);
|
|
||||||
if (nodeInfo->GetTrackerIcon(fDeviceIcon, size) != B_OK) {
|
|
||||||
delete fDeviceIcon;
|
delete fDeviceIcon;
|
||||||
fDeviceIcon = NULL;
|
fDeviceIcon = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user