Ticket #7088: 0001-add-the-drive-s-icon-in-front-of-its-name-in-drive-l.patch

File 0001-add-the-drive-s-icon-in-front-of-its-name-in-drive-l.patch, 2.5 KB (added by frizer23, 10 years ago)
  • src/apps/bootmanager/DrivesPage.cpp

    From e2b356bf228fb0b589677e59776fa8066971d720 Mon Sep 17 00:00:00 2001
    From: Julien Lepiller <julien@lepiller.eu>
    Date: Wed, 23 Apr 2014 00:16:06 +0200
    Subject: [PATCH] =?UTF-8?q?add=20the=20drive=E2=80=99s=20icon=20in=20front?=
     =?UTF-8?q?=20of=20its=20name=20in=20drive=20list?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     src/apps/bootmanager/DrivesPage.cpp | 16 +++++++++++++---
     1 file changed, 13 insertions(+), 3 deletions(-)
    
    diff --git a/src/apps/bootmanager/DrivesPage.cpp b/src/apps/bootmanager/DrivesPage.cpp
    index d96dc33..e98ce2d 100644
    a b  
    1515#include <Path.h>
    1616#include <ScrollView.h>
    1717#include <TextView.h>
     18#include <Bitmap.h>
    1819
    1920#include <StringForSize.h>
    2021
    protected:  
    4950
    5051private:
    5152            BootDrive*          fDrive;
     53            BBitmap*            fIcon;
    5254            BString             fName;
    5355            BPath               fPath;
    5456            BString             fSize;
    DriveItem::DriveItem(const BDiskDevice& device, const BootMenuList& menus)  
    7375    else
    7476        fName = B_TRANSLATE_COMMENT("Hard Drive", "Default disk name");
    7577
     78    fIcon = new BBitmap(BRect(0, 0, B_LARGE_ICON - 1, B_LARGE_ICON - 1),
     79        B_RGBA32);
     80    device.GetIcon(fIcon, B_LARGE_ICON);
     81
    7682    fDrive = new BootDrive(fPath.Path());
    7783
    7884    fIsInstalled = fDrive->InstalledMenu(menus) != NULL;
    void  
    113119DriveItem::DrawItem(BView* owner, BRect frame, bool complete)
    114120{
    115121    owner->PushState();
    116 
     122    owner->SetDrawingMode(B_OP_ALPHA);
    117123    if (IsSelected() || complete) {
    118124        if (IsSelected()) {
    119125            owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_2_TINT));
    DriveItem::DrawItem(BView* owner, BRect frame, bool complete)  
    130136        owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
    131137    else
    132138        owner->SetHighColor(black);
     139   
     140    // icon
     141    owner->MovePenTo(frame.left + 4, frame.top + 1);
     142    owner->DrawBitmap(fIcon);
    133143
    134144    // device
    135     owner->MovePenTo(frame.left + 4, frame.top + fSecondBaselineOffset);
     145    owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fSecondBaselineOffset);
    136146    owner->DrawString(fPath.Path());
    137147
    138148    // size
    DriveItem::DrawItem(BView* owner, BRect frame, bool complete)  
    145155    boldFont.SetFace(B_BOLD_FACE);
    146156    owner->SetFont(&boldFont);
    147157
    148     owner->MovePenTo(frame.left + 4, frame.top + fBaselineOffset);
     158    owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fBaselineOffset);
    149159    owner->DrawString(fName.String());
    150160
    151161    if (fCanBeInstalled != B_OK) {