Fixed UI issues:
* Centered "file" text control and "select" button vertically. * Made "file" text control smaller, so it is not overlapped by "select" button. * Updated the scroll bar proportions in the "partitions" list. * Positioned rows in "partitions" list correctly so they do not overlap. * Increased row height, so the text control always fits into it. * Centered "show" check box vertically. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35851 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -101,19 +101,20 @@ FileSelectionPage::_BuildUI(const char* description)
|
|||||||
BString file;
|
BString file;
|
||||||
fSettings->FindString("file", &file);
|
fSettings->FindString("file", &file);
|
||||||
|
|
||||||
// TODO align text and button
|
fSelect = new BButton(rect, "select", TR_CMT("Select", "Button"),
|
||||||
|
new BMessage(kMsgOpenFilePanel),
|
||||||
|
B_FOLLOW_RIGHT);
|
||||||
|
fSelect->ResizeToPreferred();
|
||||||
|
|
||||||
|
float selectLeft = rect.right - fSelect->Bounds().Width();
|
||||||
|
rect.right = selectLeft - kFileButtonDistance;
|
||||||
fFile = new BTextControl(rect, "file",
|
fFile = new BTextControl(rect, "file",
|
||||||
TR_CMT("File:", "Text control label"),
|
TR_CMT("File:", "Text control label"),
|
||||||
file.String(), new BMessage());
|
file.String(), new BMessage());
|
||||||
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
|
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
|
||||||
AddChild(fFile);
|
AddChild(fFile);
|
||||||
|
|
||||||
fSelect = new BButton(rect, "select", TR_CMT("Select", "Button"),
|
fSelect->MoveTo(selectLeft, 0);
|
||||||
new BMessage(kMsgOpenFilePanel),
|
|
||||||
B_FOLLOW_RIGHT);
|
|
||||||
fSelect->ResizeToPreferred();
|
|
||||||
float left = rect.right - fSelect->Frame().Width();
|
|
||||||
fSelect->MoveTo(left, 0);
|
|
||||||
AddChild(fSelect);
|
AddChild(fSelect);
|
||||||
|
|
||||||
_Layout();
|
_Layout();
|
||||||
@@ -127,14 +128,27 @@ FileSelectionPage::_Layout()
|
|||||||
|
|
||||||
float left = fFile->Frame().left;
|
float left = fFile->Frame().left;
|
||||||
float top = fDescription->Frame().bottom + kTextDistance;
|
float top = fDescription->Frame().bottom + kTextDistance;
|
||||||
fFile->MoveTo(left, top);
|
|
||||||
|
// center "file" text field and "select" button vertically
|
||||||
|
float selectTop = top;
|
||||||
|
float fileTop = top;
|
||||||
|
float fileHeight = fFile->Bounds().Height();
|
||||||
|
float selectHeight = fSelect->Bounds().Height();
|
||||||
|
if (fileHeight < selectHeight) {
|
||||||
|
int delta = (int)((selectHeight - fileHeight + 1) / 2);
|
||||||
|
fileTop += delta;
|
||||||
|
} else {
|
||||||
|
int delta = (int)((fileHeight - selectHeight + 1) / 2);
|
||||||
|
selectTop += delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
fFile->MoveTo(left, fileTop);
|
||||||
|
|
||||||
float width = fSelect->Frame().left - kFileButtonDistance - left;
|
float width = fSelect->Frame().left - kFileButtonDistance - left;
|
||||||
float height = fFile->Frame().Height();
|
fFile->ResizeTo(width, fileHeight);
|
||||||
fFile->ResizeTo(width, height);
|
|
||||||
|
|
||||||
left = fSelect->Frame().left;
|
left = fSelect->Frame().left;
|
||||||
fSelect->MoveTo(left, top);
|
fSelect->MoveTo(left, selectTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,17 +143,31 @@ PartitionsPage::_Layout()
|
|||||||
float height = Bounds().bottom - top;
|
float height = Bounds().bottom - top;
|
||||||
fPartitionsScrollView->ResizeTo(width, height);
|
fPartitionsScrollView->ResizeTo(width, height);
|
||||||
|
|
||||||
|
// update scroll bar range and proportion
|
||||||
BScrollBar* scrollbar = fPartitionsScrollView->ScrollBar(B_HORIZONTAL);
|
BScrollBar* scrollbar = fPartitionsScrollView->ScrollBar(B_HORIZONTAL);
|
||||||
float max = fPartitionsWidth - fPartitions->Bounds().IntegerWidth();
|
float viewWidth = fPartitions->Bounds().IntegerWidth();
|
||||||
|
float max = fPartitionsWidth - viewWidth;
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
max = 0;
|
max = 0;
|
||||||
scrollbar->SetRange(0, max);
|
scrollbar->SetRange(0, max);
|
||||||
|
float proportion;
|
||||||
|
if (fPartitionsWidth <= viewWidth)
|
||||||
|
proportion = 1.0;
|
||||||
|
else
|
||||||
|
proportion = viewWidth / fPartitionsWidth;
|
||||||
|
scrollbar->SetProportion(proportion);
|
||||||
|
|
||||||
scrollbar = fPartitionsScrollView->ScrollBar(B_VERTICAL);
|
scrollbar = fPartitionsScrollView->ScrollBar(B_VERTICAL);
|
||||||
max = fPartitionsHeight - fPartitions->Bounds().IntegerHeight();
|
float viewHeight = fPartitions->Bounds().IntegerHeight();
|
||||||
|
max = fPartitionsHeight - viewHeight;
|
||||||
if (max < 0)
|
if (max < 0)
|
||||||
max = 0;
|
max = 0;
|
||||||
scrollbar->SetRange(0, max);
|
scrollbar->SetRange(0, max);
|
||||||
|
if (fPartitionsHeight <= viewHeight)
|
||||||
|
proportion = 1.0;
|
||||||
|
else
|
||||||
|
proportion = viewHeight / fPartitionsHeight;
|
||||||
|
scrollbar->SetProportion(proportion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,14 +180,22 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
|||||||
{
|
{
|
||||||
const int32 inset = 1;
|
const int32 inset = 1;
|
||||||
|
|
||||||
|
|
||||||
font_height fontHeight;
|
font_height fontHeight;
|
||||||
be_plain_font->GetHeight(&fontHeight);
|
be_plain_font->GetHeight(&fontHeight);
|
||||||
|
|
||||||
const int32 height = (int32)(6 + 2*inset + fontHeight.ascent + fontHeight.descent);
|
int32 textControlHeight;
|
||||||
|
{
|
||||||
|
BTextControl control(BRect(0, 0, 100, 100), "", "", "", NULL);
|
||||||
|
control.ResizeToPreferred();
|
||||||
|
textControlHeight = control.Bounds().IntegerHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
const int32 textHeight = (int32)(fontHeight.ascent + fontHeight.descent);
|
||||||
|
const int32 height = (int32)(2*inset
|
||||||
|
+ max_c(textControlHeight, textHeight));
|
||||||
const int32 kDistance = (int32)(ceil(be_plain_font->StringWidth("x")));
|
const int32 kDistance = (int32)(ceil(be_plain_font->StringWidth("x")));
|
||||||
|
|
||||||
// show | name | type | size | path
|
// show | name | type | size | path
|
||||||
int32 showWidth = 0;
|
int32 showWidth = 0;
|
||||||
int32 nameWidth = 0;
|
int32 nameWidth = 0;
|
||||||
int32 typeWidth = 0;
|
int32 typeWidth = 0;
|
||||||
@@ -181,8 +203,8 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
|||||||
int32 pathWidth = 0;
|
int32 pathWidth = 0;
|
||||||
_ComputeColumnWidths(showWidth, nameWidth, typeWidth, sizeWidth, pathWidth);
|
_ComputeColumnWidths(showWidth, nameWidth, typeWidth, sizeWidth, pathWidth);
|
||||||
|
|
||||||
int32 totalWidth = showWidth + nameWidth + typeWidth + sizeWidth + pathWidth +
|
int32 totalWidth = showWidth + nameWidth + typeWidth + sizeWidth
|
||||||
2*inset + 4 * kDistance;
|
+ pathWidth + 2 * inset + 4 * kDistance;
|
||||||
|
|
||||||
int32 rowNumber = 0;
|
int32 rowNumber = 0;
|
||||||
|
|
||||||
@@ -207,10 +229,10 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
|||||||
// create row for partition data
|
// create row for partition data
|
||||||
BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0);
|
BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0);
|
||||||
row->SetViewColor(((rowNumber % 2) == 0) ? kEvenRowColor : kOddRowColor);
|
row->SetViewColor(((rowNumber % 2) == 0) ? kEvenRowColor : kOddRowColor);
|
||||||
view->AddChild(row);
|
view->AddChild(row);
|
||||||
frame.OffsetBy(0, height);
|
frame.OffsetBy(0, height + 1);
|
||||||
|
|
||||||
// box
|
// check box
|
||||||
BRect rect(row->Bounds());
|
BRect rect(row->Bounds());
|
||||||
rect.InsetBy(inset, inset);
|
rect.InsetBy(inset, inset);
|
||||||
rect.right = rect.left + showWidth;
|
rect.right = rect.left + showWidth;
|
||||||
@@ -218,8 +240,13 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
|||||||
_CreateControlMessage(kMessageShow, i));
|
_CreateControlMessage(kMessageShow, i));
|
||||||
if (show)
|
if (show)
|
||||||
checkBox->SetValue(1);
|
checkBox->SetValue(1);
|
||||||
|
// center vertically
|
||||||
|
checkBox->ResizeToPreferred();
|
||||||
|
const int32 showHeight = checkBox->Bounds().IntegerHeight();
|
||||||
|
if (showHeight < height)
|
||||||
|
checkBox->MoveTo(inset, (int)((height - showHeight + 1) / 2));
|
||||||
row->AddChild(checkBox);
|
row->AddChild(checkBox);
|
||||||
rect.OffsetBy(showWidth + kDistance, 0);
|
rect.OffsetBy(showWidth + kDistance, 0);
|
||||||
|
|
||||||
// name
|
// name
|
||||||
rect.right = rect.left + nameWidth;
|
rect.right = rect.left + nameWidth;
|
||||||
@@ -235,7 +262,6 @@ PartitionsPage::_FillPartitionsView(BView* view)
|
|||||||
row->AddChild(typeView);
|
row->AddChild(typeView);
|
||||||
rect.OffsetBy(typeWidth + kDistance, 0);
|
rect.OffsetBy(typeWidth + kDistance, 0);
|
||||||
|
|
||||||
|
|
||||||
// size
|
// size
|
||||||
BString sizeText;
|
BString sizeText;
|
||||||
_CreateSizeText(size, &sizeText);
|
_CreateSizeText(size, &sizeText);
|
||||||
@@ -264,32 +290,24 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
|
|||||||
BCheckBox checkBox(BRect(0, 0, 100, 100), "show", "", new BMessage());
|
BCheckBox checkBox(BRect(0, 0, 100, 100), "show", "", new BMessage());
|
||||||
checkBox.ResizeToPreferred();
|
checkBox.ResizeToPreferred();
|
||||||
showWidth = checkBox.Bounds().IntegerWidth();
|
showWidth = checkBox.Bounds().IntegerWidth();
|
||||||
// reserve space for about 16 characters
|
// reserve space for about 16 characters
|
||||||
nameWidth = (int32)ceil(be_plain_font->StringWidth("oooooooooooooooo"));
|
nameWidth = (int32)ceil(be_plain_font->StringWidth("oooooooooooooooo"));
|
||||||
|
|
||||||
const int32 kTextControlInsets = 6;
|
|
||||||
const int32 kStringViewInsets = 2;
|
const int32 kStringViewInsets = 2;
|
||||||
|
|
||||||
BMessage message;
|
BMessage message;
|
||||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) {
|
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) {
|
||||||
// get partition data
|
// get partition data
|
||||||
BString name;
|
|
||||||
BString type;
|
BString type;
|
||||||
BString path;
|
BString path;
|
||||||
int64 size;
|
int64 size;
|
||||||
message.FindString("name", &name);
|
|
||||||
message.FindString("type", &type);
|
message.FindString("type", &type);
|
||||||
message.FindString("path", &path);
|
message.FindString("path", &path);
|
||||||
message.FindInt64("size", &size);
|
message.FindInt64("size", &size);
|
||||||
BString sizeText;
|
BString sizeText;
|
||||||
_CreateSizeText(size, &sizeText);
|
_CreateSizeText(size, &sizeText);
|
||||||
|
|
||||||
int32 width = (int32)ceil(be_plain_font->StringWidth(name.String())) +
|
int32 width = (int32)ceil(be_plain_font->StringWidth(type.String())) +
|
||||||
kTextControlInsets;
|
|
||||||
if (nameWidth < width)
|
|
||||||
nameWidth = width;
|
|
||||||
|
|
||||||
width = (int32)ceil(be_plain_font->StringWidth(type.String())) +
|
|
||||||
kStringViewInsets;
|
kStringViewInsets;
|
||||||
if (typeWidth < width)
|
if (typeWidth < width)
|
||||||
typeWidth = width;
|
typeWidth = width;
|
||||||
|
|||||||
Reference in New Issue
Block a user