DriveSetup: improved default window size.
* The default width will no longer make the parameters and partition type columns visible. * Fixed default size of those two columns -- I did not notice that the column state was being restored before, and thought it would just be another oddity of BColumnListView :-) * Since MainWindow maintains its size pretty much itself, the constructor no longer gets a BRect. * The window will now also be resized vertically to make space for all the partitions (only affects first launch without settings file). * Also made the window a bit higher by default.
This commit is contained in:
parent
b7733e0655
commit
a206dee38e
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 Haiku Inc. All rights reserved.
|
||||
* Copyright 2002-2013 Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
@ -36,7 +36,7 @@ DriveSetup::~DriveSetup()
|
||||
void
|
||||
DriveSetup::ReadyToRun()
|
||||
{
|
||||
fWindow = new MainWindow(BRect(50, 50, 600, 450));
|
||||
fWindow = new MainWindow();
|
||||
if (_RestoreSettings() != B_OK)
|
||||
fWindow->ApplyDefaultSettings();
|
||||
fWindow->Show();
|
||||
|
@ -3,11 +3,11 @@
|
||||
* Distributed under the terms of the MIT license.
|
||||
*
|
||||
* Authors:
|
||||
* Erik Jaesler <ejakowatz@users.sourceforge.net>
|
||||
* Ithamar R. Adema <ithamar@unet.nl>
|
||||
* Ingo Weinhold <ingo_weinhold@gmx.de>
|
||||
* Stephan Aßmus <superstippi@gmx.de>
|
||||
* Axel Dörfler, axeld@pinc-software.de.
|
||||
* Erik Jaesler <ejakowatz@users.sourceforge.net>
|
||||
* Ingo Weinhold <ingo_weinhold@gmx.de>
|
||||
*/
|
||||
|
||||
|
||||
@ -193,10 +193,10 @@ enum {
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
MainWindow::MainWindow(BRect frame)
|
||||
MainWindow::MainWindow()
|
||||
:
|
||||
BWindow(frame, B_TRANSLATE_SYSTEM_NAME("DriveSetup"), B_DOCUMENT_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
|
||||
BWindow(BRect(50, 50, 600, 500), B_TRANSLATE_SYSTEM_NAME("DriveSetup"),
|
||||
B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
|
||||
fCurrentDisk(NULL),
|
||||
fCurrentPartitionID(-1),
|
||||
fSpaceIDMap()
|
||||
@ -440,17 +440,26 @@ MainWindow::ApplyDefaultSettings()
|
||||
fListView->ResizeAllColumnsToPreferred();
|
||||
|
||||
// Adjust window size for convenience
|
||||
float enlargeBy = fListView->PreferredSize().width
|
||||
BScreen screen(this);
|
||||
float windowWidth = Frame().Width();
|
||||
float windowHeight = Frame().Height();
|
||||
|
||||
float enlargeWidthBy = fListView->PreferredSize().width
|
||||
- fListView->Bounds().Width();
|
||||
if (enlargeBy > 0.0f) {
|
||||
BScreen screen(this);
|
||||
float windowWidth = Frame().Width() + enlargeBy;
|
||||
if (windowWidth > screen.Frame().Width() - 20.0f)
|
||||
windowWidth = screen.Frame().Width() - 20.0f;
|
||||
float enlargeHeightBy = fListView->PreferredSize().height
|
||||
- fListView->Bounds().Height();
|
||||
|
||||
ResizeTo(windowWidth, Frame().Height());
|
||||
}
|
||||
if (enlargeWidthBy > 0.0f)
|
||||
windowWidth += enlargeWidthBy;
|
||||
if (enlargeHeightBy > 0.0f)
|
||||
windowHeight += enlargeHeightBy;
|
||||
|
||||
if (windowWidth > screen.Frame().Width() - 20.0f)
|
||||
windowWidth = screen.Frame().Width() - 20.0f;
|
||||
if (windowHeight > screen.Frame().Height() - 20.0f)
|
||||
windowHeight = screen.Frame().Height() - 20.0f;
|
||||
|
||||
ResizeTo(windowWidth, windowHeight);
|
||||
CenterOnScreen();
|
||||
|
||||
Unlock();
|
||||
|
@ -31,7 +31,7 @@ enum {
|
||||
|
||||
class MainWindow : public BWindow {
|
||||
public:
|
||||
MainWindow(BRect frame);
|
||||
MainWindow();
|
||||
virtual ~MainWindow();
|
||||
|
||||
// BWindow interface
|
||||
|
@ -341,9 +341,9 @@ PartitionListView::PartitionListView(const BRect& frame, uint32 resizeMode)
|
||||
B_TRUNCATE_MIDDLE), kMountedAtColumn);
|
||||
AddColumn(new PartitionColumn(B_TRANSLATE("Size"), 100, 50, 500,
|
||||
B_TRUNCATE_END, B_ALIGN_RIGHT), kSizeColumn);
|
||||
AddColumn(new PartitionColumn(B_TRANSLATE("Parameters"), 200, 50, 500,
|
||||
AddColumn(new PartitionColumn(B_TRANSLATE("Parameters"), 100, 50, 500,
|
||||
B_TRUNCATE_END), kParametersColumn);
|
||||
AddColumn(new PartitionColumn(B_TRANSLATE("Partition type"), 100, 50, 500,
|
||||
AddColumn(new PartitionColumn(B_TRANSLATE("Partition type"), 200, 50, 500,
|
||||
B_TRUNCATE_END), kPartitionTypeColumn);
|
||||
|
||||
SetSortingEnabled(false);
|
||||
@ -466,6 +466,17 @@ PartitionListView::AddSpace(partition_id parentID, partition_id id,
|
||||
}
|
||||
|
||||
|
||||
BSize
|
||||
PartitionListView::PreferredSize()
|
||||
{
|
||||
// Remove default size for parameters + partition type column
|
||||
BSize size = BColumnListView::PreferredSize();
|
||||
size.width -= ColumnAt(kParametersColumn)->Width()
|
||||
+ ColumnAt(kPartitionTypeColumn)->Width();
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
PartitionListView::_InsertIndexForOffset(PartitionListRow* parent,
|
||||
off_t offset) const
|
||||
|
@ -104,6 +104,8 @@ public:
|
||||
PartitionListRow* AddSpace(partition_id parent,
|
||||
partition_id id, off_t offset, off_t size);
|
||||
|
||||
virtual BSize PreferredSize();
|
||||
|
||||
private:
|
||||
int32 _InsertIndexForOffset(PartitionListRow* parent,
|
||||
off_t offset) const;
|
||||
|
Loading…
Reference in New Issue
Block a user