Skip to content

Commit

Permalink
bootman: add the drive's icon in the drive list
Browse files Browse the repository at this point in the history
* Also check status of GetIcon()
* Delete fDrive, fIcon in destructor

Fixes #7088

Signed-off-by: Jessica Hamilton <jessica.l.hamilton@gmail.com>
  • Loading branch information
Julien Lepiller authored and jessicah committed Sep 18, 2014
1 parent c8990b0 commit 73309d5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/apps/bootmanager/DrivesPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <Path.h>
#include <ScrollView.h>
#include <TextView.h>
#include <Bitmap.h>

#include <StringForSize.h>

Expand Down Expand Up @@ -49,6 +50,7 @@ class DriveItem : public BListItem {

private:
BootDrive* fDrive;
BBitmap* fIcon;
BString fName;
BPath fPath;
BString fSize;
Expand All @@ -73,6 +75,11 @@ DriveItem::DriveItem(const BDiskDevice& device, const BootMenuList& menus)
else
fName = B_TRANSLATE_COMMENT("Hard Drive", "Default disk name");

fIcon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1),
B_RGBA32);
if (device.GetIcon(fIcon, B_LARGE_ICON) != B_OK)
memset(fIcon->Bits(), 0, fIcon->BitsLength());

fDrive = new BootDrive(fPath.Path());

fIsInstalled = fDrive->InstalledMenu(menus) != NULL;
Expand All @@ -85,6 +92,8 @@ DriveItem::DriveItem(const BDiskDevice& device, const BootMenuList& menus)

DriveItem::~DriveItem()
{
delete fDrive;
delete fIcon;
}


Expand Down Expand Up @@ -113,7 +122,7 @@ void
DriveItem::DrawItem(BView* owner, BRect frame, bool complete)
{
owner->PushState();

owner->SetDrawingMode(B_OP_ALPHA);
if (IsSelected() || complete) {
if (IsSelected()) {
owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_2_TINT));
Expand All @@ -131,8 +140,12 @@ DriveItem::DrawItem(BView* owner, BRect frame, bool complete)
else
owner->SetHighColor(black);

// icon
owner->MovePenTo(frame.left + 4, frame.top + 1);
owner->DrawBitmap(fIcon);

// device
owner->MovePenTo(frame.left + 4, frame.top + fSecondBaselineOffset);
owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fSecondBaselineOffset);
owner->DrawString(fPath.Path());

// size
Expand All @@ -145,7 +158,7 @@ DriveItem::DrawItem(BView* owner, BRect frame, bool complete)
boldFont.SetFace(B_BOLD_FACE);
owner->SetFont(&boldFont);

owner->MovePenTo(frame.left + 4, frame.top + fBaselineOffset);
owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fBaselineOffset);
owner->DrawString(fName.String());

if (fCanBeInstalled != B_OK) {
Expand Down

0 comments on commit 73309d5

Please sign in to comment.