DiskProbe: improved layout scaling.

* Don't use a fixed size font for the header controls, but one that
  depends on the default plain font size.
* Minor cleanup.
This commit is contained in:
Axel Dörfler
2015-09-08 17:56:22 +02:00
parent 7d8d7785c1
commit bafcf01610
2 changed files with 20 additions and 25 deletions
+8 -10
View File
@@ -33,7 +33,7 @@ static const uint32 kMsgProbeDevice = 'prFl';
OpenWindow::OpenWindow()
:
BWindow(BRect(0, 0, 35, 10), B_TRANSLATE_SYSTEM_NAME("DiskProbe"),
BWindow(BRect(0, 0, 350, 10), B_TRANSLATE_SYSTEM_NAME("DiskProbe"),
B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
@@ -56,18 +56,14 @@ OpenWindow::OpenWindow()
BButton *cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
new BMessage(B_QUIT_REQUESTED));
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING)
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(field)
.AddGroup(B_HORIZONTAL)
.Add(cancelButton)
.Add(probeFileButton)
.AddGlue()
.Add(probeDeviceButton)
.End()
.SetInsets(B_USE_DEFAULT_SPACING)
);
.Add(probeDeviceButton);
CenterOnScreen();
}
@@ -82,7 +78,8 @@ void
OpenWindow::MessageReceived(BMessage *message)
{
switch (message->what) {
case kMsgProbeDevice: {
case kMsgProbeDevice:
{
BMenuItem *item = fDevicesMenu->FindMarked();
if (item == NULL)
break;
@@ -97,7 +94,8 @@ OpenWindow::MessageReceived(BMessage *message)
PostMessage(B_QUIT_REQUESTED);
break;
case B_SIMPLE_DATA: {
case B_SIMPLE_DATA:
{
// if it's a file drop, open it
entry_ref ref;
if (message->FindRef("refs", 0, &ref) == B_OK) {
+6 -9
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2004-2009, Axel Dörfler, [email protected].
* Copyright 2004-2015, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
@@ -490,16 +490,14 @@ HeaderView::HeaderView(const entry_ref *ref, DataEditor &editor)
GridLayout()->AddView(line, 1, 0);
BFont boldFont = *be_bold_font;
boldFont.SetSize(10.0);
BFont plainFont = *be_plain_font;
plainFont.SetSize(10.0);
boldFont.SetSize(plainFont.Size() * 0.83);
plainFont.SetSize(plainFont.Size() * 0.83);
BStringView *stringView = new BStringView(
B_EMPTY_STRING, editor.IsAttribute()
? B_TRANSLATE("Attribute: ")
: editor.IsDevice()
? B_TRANSLATE("Device: ")
: B_TRANSLATE("File: "));
? B_TRANSLATE("Attribute: ") : editor.IsDevice()
? B_TRANSLATE("Device: ") : B_TRANSLATE("File: "));
stringView->SetFont(&boldFont);
line->AddChild(stringView);
@@ -524,7 +522,6 @@ HeaderView::HeaderView(const entry_ref *ref, DataEditor &editor)
get_type_string(buffer, sizeof(buffer), editor.Type());
fTypeControl = new BTextControl(B_EMPTY_STRING, NULL, buffer,
new BMessage(kMsgPositionUpdate));
fTypeControl->SetDivider(0.0);
fTypeControl->SetFont(&plainFont);
fTypeControl->TextView()->SetFontAndColor(&plainFont);
fTypeControl->SetEnabled(false);
@@ -542,7 +539,7 @@ HeaderView::HeaderView(const entry_ref *ref, DataEditor &editor)
BGroupLayoutBuilder(line).AddGlue();
line = new BGroupView(B_HORIZONTAL);
line = new BGroupView(B_HORIZONTAL, B_USE_SMALL_SPACING);
GridLayout()->AddView(line, 1, 1);
stringView = new BStringView(B_EMPTY_STRING, B_TRANSLATE("Block: "));