From 789091541eab09129029862379a4173507bac7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 9 Jan 2008 00:30:24 +0000 Subject: [PATCH] * cache the result of visiting the partitions * make sure the colors are bright enough git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23294 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/drivesetup/DiskView.cpp | 36 +++++++++++------------ src/preferences/drivesetup/DiskView.h | 4 ++- src/preferences/drivesetup/MainWindow.cpp | 1 - 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/preferences/drivesetup/DiskView.cpp b/src/preferences/drivesetup/DiskView.cpp index 944e6c7b88..f45ffba45d 100644 --- a/src/preferences/drivesetup/DiskView.cpp +++ b/src/preferences/drivesetup/DiskView.cpp @@ -60,13 +60,13 @@ struct PartitionBox { }; -class PartitionDrawer : public BDiskDeviceVisitor { +class DiskView::PartitionDrawer : public BDiskDeviceVisitor { public: - PartitionDrawer(BView* view, partition_id selectedPartition) + PartitionDrawer(BView* view) : fView(view) , fBoxMap() , fColorIndex(0) - , fSelectedPartition(selectedPartition) + , fSelectedPartition(-1) { } @@ -103,6 +103,11 @@ public: return false; } + void SetSelectedPartition(partition_id id) + { + fSelectedPartition = id; + } + void Draw(BView* view) { PartitionBoxMap::Iterator iterator = fBoxMap.GetIterator(); @@ -150,12 +155,12 @@ public: DiskView::DiskView(const BRect& frame, uint32 resizeMode) : Inherited(frame, "diskview", resizeMode, B_WILL_DRAW) , fDisk(NULL) - , fSelectedParition(-1) + , fPartitionDrawer(new PartitionDrawer(this)) { for (int32 i = 0; i < kMaxPartitionColors; i++) { - kPartitionColors[i].red = (i * 1675) & 0xff; - kPartitionColors[i].green = (i * 318) & 0xff; - kPartitionColors[i].blue = (i * 9328) & 0xff; + kPartitionColors[i].red = 120 + ((i * 1675) & 120); + kPartitionColors[i].green = 120 + ((i * 318) & 120); + kPartitionColors[i].blue = 120 + ((i * 9328) & 120); kPartitionColors[i].alpha = 255; } } @@ -164,6 +169,7 @@ DiskView::DiskView(const BRect& frame, uint32 resizeMode) DiskView::~DiskView() { SetDisk(NULL, -1); + delete fPartitionDrawer; } @@ -179,25 +185,19 @@ DiskView::Draw(BRect updateRect) return; } - // TODO: render the partitions (use PartitionDrawer to iterate our disk) - SetHighColor(255, 255, 120); - FillRect(bounds); - - PartitionDrawer drawer(this, fSelectedParition); - BDiskDeviceRoster roster; - roster.VisitEachPartition(&drawer, fDisk); - - drawer.Draw(this); + fPartitionDrawer->Draw(this); } void DiskView::SetDisk(BDiskDevice* disk, partition_id selectedPartition) { -printf("DiskView::SetDisk(%p, %ld)\n", disk, selectedPartition); delete fDisk; fDisk = disk; - fSelectedParition = selectedPartition; + fPartitionDrawer->SetSelectedPartition(selectedPartition); + + BDiskDeviceRoster roster; + roster.VisitEachPartition(fPartitionDrawer, fDisk); Invalidate(); } diff --git a/src/preferences/drivesetup/DiskView.h b/src/preferences/drivesetup/DiskView.h index 64172ea597..05cd5d29a8 100644 --- a/src/preferences/drivesetup/DiskView.h +++ b/src/preferences/drivesetup/DiskView.h @@ -24,7 +24,9 @@ public: partition_id selectedPartition); private: BDiskDevice* fDisk; - partition_id fSelectedParition; + + class PartitionDrawer; + PartitionDrawer* fPartitionDrawer; }; diff --git a/src/preferences/drivesetup/MainWindow.cpp b/src/preferences/drivesetup/MainWindow.cpp index 5850f792d7..652f89f50b 100644 --- a/src/preferences/drivesetup/MainWindow.cpp +++ b/src/preferences/drivesetup/MainWindow.cpp @@ -165,7 +165,6 @@ MainWindow::MessageReceived(BMessage* message) break; case MSG_PARTITION_ROW_SELECTED: - printf("MSG_PARTITION_ROW_SELECTED\n"); _AdaptToSelectedPartition(); break;