SoundRecorder: UI fixes
* Remove several hard-coded colors * Reduce slightly the font size in the file info panel (#6909). * Don't hardcode the font height, compute it * Fix a bug where deploying the bottom panel makes the current window width the new minimum width * Don't hardcode the bottom panel's height, compute it (allows better font size tolerance).
This commit is contained in:
parent
14fc8a0138
commit
b271ff3f4e
@ -62,7 +62,7 @@
|
|||||||
|
|
||||||
// default window positioning
|
// default window positioning
|
||||||
static const float MIN_WIDTH = 400.0f;
|
static const float MIN_WIDTH = 400.0f;
|
||||||
static const float MIN_HEIGHT = 336.0f;
|
static const float MIN_HEIGHT = 175.0f;
|
||||||
static const float XPOS = 100.0f;
|
static const float XPOS = 100.0f;
|
||||||
static const float YPOS = 200.0f;
|
static const float YPOS = 200.0f;
|
||||||
|
|
||||||
@ -364,7 +364,7 @@ RecorderWindow::InitWindow()
|
|||||||
fSoundList = new SoundListView(r, B_TRANSLATE("Sound List"),
|
fSoundList = new SoundListView(r, B_TRANSLATE("Sound List"),
|
||||||
B_FOLLOW_ALL);
|
B_FOLLOW_ALL);
|
||||||
fSoundList->SetSelectionMessage(new BMessage(SOUND_SELECTED));
|
fSoundList->SetSelectionMessage(new BMessage(SOUND_SELECTED));
|
||||||
fSoundList->SetViewColor(216, 216, 216);
|
fSoundList->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||||
BScrollView *scroller = new BScrollView("scroller", fSoundList,
|
BScrollView *scroller = new BScrollView("scroller", fSoundList,
|
||||||
B_FOLLOW_ALL, 0, false, true, B_FANCY_BORDER);
|
B_FOLLOW_ALL, 0, false, true, B_FANCY_BORDER);
|
||||||
fBottomBox->AddChild(scroller);
|
fBottomBox->AddChild(scroller);
|
||||||
@ -374,43 +374,75 @@ RecorderWindow::InitWindow()
|
|||||||
r.bottom -= 25;
|
r.bottom -= 25;
|
||||||
r.InsetBy(10, 8);
|
r.InsetBy(10, 8);
|
||||||
r.top -= 1;
|
r.top -= 1;
|
||||||
fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
fFileInfoBox = new BBox(r, "fileinfo", B_FOLLOW_LEFT);
|
||||||
fFileInfoBox->SetLabel(B_TRANSLATE("File info"));
|
fFileInfoBox->SetLabel(B_TRANSLATE("File info"));
|
||||||
|
|
||||||
|
fFileInfoBox->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
BFont font = be_plain_font;
|
||||||
|
font.SetSize(font.Size() * 0.92f);
|
||||||
|
font_height height;
|
||||||
|
font.GetHeight(&height);
|
||||||
|
float fontHeight = height.ascent + height.leading + height.descent;
|
||||||
|
|
||||||
r = fFileInfoBox->Bounds();
|
r = fFileInfoBox->Bounds();
|
||||||
r.left = 8;
|
r.left = 8;
|
||||||
r.top = 13;
|
r.top = fontHeight + 6;
|
||||||
r.bottom = r.top + 15;
|
r.bottom = r.top + fontHeight + 3;
|
||||||
r.right -= 10;
|
r.right -= 10;
|
||||||
fFilename = new BStringView(r, "filename", B_TRANSLATE("File name:"));
|
fFilename = new BStringView(r, "filename", B_TRANSLATE("File name:"));
|
||||||
fFileInfoBox->AddChild(fFilename);
|
fFileInfoBox->AddChild(fFilename);
|
||||||
r.top += 13;
|
fFilename->SetFont(&font, B_FONT_SIZE);
|
||||||
r.bottom = r.top + 15;
|
fFilename->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
r.top += fontHeight;
|
||||||
|
r.bottom = r.top + fontHeight + 3;
|
||||||
fFormat = new BStringView(r, "format", B_TRANSLATE("Format:"));
|
fFormat = new BStringView(r, "format", B_TRANSLATE("Format:"));
|
||||||
fFileInfoBox->AddChild(fFormat);
|
fFileInfoBox->AddChild(fFormat);
|
||||||
r.top += 13;
|
fFormat->SetFont(&font, B_FONT_SIZE);
|
||||||
r.bottom = r.top + 15;
|
fFormat->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
r.top += fontHeight;
|
||||||
|
r.bottom = r.top + fontHeight + 3;
|
||||||
fCompression = new BStringView(r, "compression",
|
fCompression = new BStringView(r, "compression",
|
||||||
B_TRANSLATE("Compression:"));
|
B_TRANSLATE("Compression:"));
|
||||||
fFileInfoBox->AddChild(fCompression);
|
fFileInfoBox->AddChild(fCompression);
|
||||||
r.top += 13;
|
fCompression->SetFont(&font, B_FONT_SIZE);
|
||||||
r.bottom = r.top + 15;
|
fCompression->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
r.top += fontHeight;
|
||||||
|
r.bottom = r.top + fontHeight + 3;
|
||||||
fChannels = new BStringView(r, "channels", B_TRANSLATE("Channels:"));
|
fChannels = new BStringView(r, "channels", B_TRANSLATE("Channels:"));
|
||||||
fFileInfoBox->AddChild(fChannels);
|
fFileInfoBox->AddChild(fChannels);
|
||||||
r.top += 13;
|
fChannels->SetFont(&font, B_FONT_SIZE);
|
||||||
r.bottom = r.top + 15;
|
fChannels->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
r.top += fontHeight;
|
||||||
|
r.bottom = r.top + fontHeight + 3;
|
||||||
fSampleSize = new BStringView(r, "samplesize",
|
fSampleSize = new BStringView(r, "samplesize",
|
||||||
B_TRANSLATE("Sample size:"));
|
B_TRANSLATE("Sample size:"));
|
||||||
fFileInfoBox->AddChild(fSampleSize);
|
fFileInfoBox->AddChild(fSampleSize);
|
||||||
r.top += 13;
|
fSampleSize->SetFont(&font, B_FONT_SIZE);
|
||||||
r.bottom = r.top + 15;
|
fSampleSize->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
r.top += fontHeight;
|
||||||
|
r.bottom = r.top + fontHeight + 3;
|
||||||
fSampleRate = new BStringView(r, "samplerate",
|
fSampleRate = new BStringView(r, "samplerate",
|
||||||
B_TRANSLATE("Sample rate:"));
|
B_TRANSLATE("Sample rate:"));
|
||||||
fFileInfoBox->AddChild(fSampleRate);
|
fFileInfoBox->AddChild(fSampleRate);
|
||||||
r.top += 13;
|
fSampleRate->SetFont(&font, B_FONT_SIZE);
|
||||||
r.bottom = r.top + 15;
|
fSampleRate->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
r.top += fontHeight;
|
||||||
|
r.bottom = r.top + fontHeight + 3;
|
||||||
fDuration = new BStringView(r, "duration", B_TRANSLATE("Duration:"));
|
fDuration = new BStringView(r, "duration", B_TRANSLATE("Duration:"));
|
||||||
fFileInfoBox->AddChild(fDuration);
|
fFileInfoBox->AddChild(fDuration);
|
||||||
|
fDuration->SetFont(&font, B_FONT_SIZE);
|
||||||
|
fDuration->SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
|
|
||||||
|
fFileInfoBox->ResizeTo(fFileInfoBox->Frame().Width(),
|
||||||
|
r.bottom + fontHeight / 2.0f);
|
||||||
|
fDeployedHeight = MIN_HEIGHT + fFileInfoBox->Bounds().Height() + 40.0f;
|
||||||
|
|
||||||
// Input selection lists all available physical inputs that produce
|
// Input selection lists all available physical inputs that produce
|
||||||
// buffers with B_MEDIA_RAW_AUDIO format data.
|
// buffers with B_MEDIA_RAW_AUDIO format data.
|
||||||
@ -451,12 +483,10 @@ RecorderWindow::InitWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the actual widget
|
// Create the actual widget
|
||||||
BRect frame(fBottomBox->Bounds());
|
r = fFileInfoBox->Bounds();
|
||||||
r = frame;
|
r.top = r.bottom + 2;
|
||||||
r.left = 42;
|
r.bottom = r.top + 18;
|
||||||
r.right = (r.left + r.right) / 2;
|
r.InsetBy(10, 10);
|
||||||
r.InsetBy(10,10);
|
|
||||||
r.top = r.bottom - 18;
|
|
||||||
fInputField = new BMenuField(r, "Input", B_TRANSLATE("Input:"), popup);
|
fInputField = new BMenuField(r, "Input", B_TRANSLATE("Input:"), popup);
|
||||||
fInputField->SetDivider(fInputField->StringWidth(B_TRANSLATE("Input:"))
|
fInputField->SetDivider(fInputField->StringWidth(B_TRANSLATE("Input:"))
|
||||||
+ 4.0f);
|
+ 4.0f);
|
||||||
@ -465,9 +495,8 @@ RecorderWindow::InitWindow()
|
|||||||
fBottomBox->AddChild(fFileInfoBox);
|
fBottomBox->AddChild(fFileInfoBox);
|
||||||
|
|
||||||
fBottomBox->Hide();
|
fBottomBox->Hide();
|
||||||
CalcSizes(Frame().Width(), MIN_HEIGHT-161);
|
CalcSizes(MIN_WIDTH, MIN_HEIGHT);
|
||||||
ResizeTo(Frame().Width(), MIN_HEIGHT-161);
|
ResizeTo(Frame().Width(), MIN_HEIGHT);
|
||||||
|
|
||||||
|
|
||||||
popup->Superitem()->SetLabel(selected_name);
|
popup->Superitem()->SetLabel(selected_name);
|
||||||
|
|
||||||
@ -551,12 +580,12 @@ RecorderWindow::MessageReceived(BMessage * message)
|
|||||||
case VIEW_LIST:
|
case VIEW_LIST:
|
||||||
if (fUpDownButton->Value() == B_CONTROL_ON) {
|
if (fUpDownButton->Value() == B_CONTROL_ON) {
|
||||||
fBottomBox->Show();
|
fBottomBox->Show();
|
||||||
CalcSizes(Frame().Width(), MIN_HEIGHT);
|
CalcSizes(MIN_WIDTH, fDeployedHeight);
|
||||||
ResizeTo(Frame().Width(), MIN_HEIGHT);
|
ResizeTo(Frame().Width(), fDeployedHeight);
|
||||||
} else {
|
} else {
|
||||||
fBottomBox->Hide();
|
fBottomBox->Hide();
|
||||||
CalcSizes(Frame().Width(), MIN_HEIGHT-161);
|
CalcSizes(MIN_WIDTH, MIN_HEIGHT);
|
||||||
ResizeTo(Frame().Width(), MIN_HEIGHT-161);
|
ResizeTo(Frame().Width(), MIN_HEIGHT);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -94,6 +94,8 @@ private:
|
|||||||
BDirectory fTempDir;
|
BDirectory fTempDir;
|
||||||
int fTempCount;
|
int fTempCount;
|
||||||
|
|
||||||
|
float fDeployedHeight;
|
||||||
|
|
||||||
BBox * fBottomBox;
|
BBox * fBottomBox;
|
||||||
BBox * fFileInfoBox;
|
BBox * fFileInfoBox;
|
||||||
BStringView *fFilename;
|
BStringView *fFilename;
|
||||||
|
@ -34,12 +34,11 @@ void
|
|||||||
SoundListView::Draw(BRect updateRect)
|
SoundListView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
if (IsEmpty()) {
|
if (IsEmpty()) {
|
||||||
SetHighColor(235,235,235);
|
SetLowColor(ViewColor());
|
||||||
FillRect(Bounds());
|
FillRect(Bounds(), B_SOLID_LOW);
|
||||||
|
|
||||||
SetHighColor(0,0,0);
|
SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
|
||||||
BFont font(be_bold_font);
|
BFont font(be_bold_font);
|
||||||
font.SetSize(12.0);
|
|
||||||
SetFont(&font);
|
SetFont(&font);
|
||||||
font_height height;
|
font_height height;
|
||||||
font.GetHeight(&height);
|
font.GetHeight(&height);
|
||||||
@ -58,7 +57,8 @@ void
|
|||||||
SoundListView::AttachedToWindow()
|
SoundListView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
BListView::AttachedToWindow();
|
BListView::AttachedToWindow();
|
||||||
SetViewColor(255,255,255);
|
SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||||
|
B_LIGHTEN_1_TINT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user