From b271ff3f4e54e2ddf5b54aba6538c9173e52a08d Mon Sep 17 00:00:00 2001 From: Philippe Saint-Pierre Date: Mon, 25 Jun 2012 18:28:16 -0400 Subject: [PATCH] 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). --- src/apps/soundrecorder/RecorderWindow.cpp | 89 +++++++++++++++-------- src/apps/soundrecorder/RecorderWindow.h | 2 + src/apps/soundrecorder/SoundListView.cpp | 10 +-- 3 files changed, 66 insertions(+), 35 deletions(-) diff --git a/src/apps/soundrecorder/RecorderWindow.cpp b/src/apps/soundrecorder/RecorderWindow.cpp index f5c6e7ceaf..11b5a92997 100644 --- a/src/apps/soundrecorder/RecorderWindow.cpp +++ b/src/apps/soundrecorder/RecorderWindow.cpp @@ -62,7 +62,7 @@ // default window positioning 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 YPOS = 200.0f; @@ -364,7 +364,7 @@ RecorderWindow::InitWindow() fSoundList = new SoundListView(r, B_TRANSLATE("Sound List"), B_FOLLOW_ALL); 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, B_FOLLOW_ALL, 0, false, true, B_FANCY_BORDER); fBottomBox->AddChild(scroller); @@ -374,43 +374,75 @@ RecorderWindow::InitWindow() r.bottom -= 25; r.InsetBy(10, 8); 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->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.left = 8; - r.top = 13; - r.bottom = r.top + 15; + r.top = fontHeight + 6; + r.bottom = r.top + fontHeight + 3; r.right -= 10; fFilename = new BStringView(r, "filename", B_TRANSLATE("File name:")); fFileInfoBox->AddChild(fFilename); - r.top += 13; - r.bottom = r.top + 15; + fFilename->SetFont(&font, B_FONT_SIZE); + 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:")); fFileInfoBox->AddChild(fFormat); - r.top += 13; - r.bottom = r.top + 15; + fFormat->SetFont(&font, B_FONT_SIZE); + fFormat->SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); + + r.top += fontHeight; + r.bottom = r.top + fontHeight + 3; fCompression = new BStringView(r, "compression", B_TRANSLATE("Compression:")); fFileInfoBox->AddChild(fCompression); - r.top += 13; - r.bottom = r.top + 15; + fCompression->SetFont(&font, B_FONT_SIZE); + 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:")); fFileInfoBox->AddChild(fChannels); - r.top += 13; - r.bottom = r.top + 15; + fChannels->SetFont(&font, B_FONT_SIZE); + fChannels->SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); + + r.top += fontHeight; + r.bottom = r.top + fontHeight + 3; fSampleSize = new BStringView(r, "samplesize", B_TRANSLATE("Sample size:")); fFileInfoBox->AddChild(fSampleSize); - r.top += 13; - r.bottom = r.top + 15; + fSampleSize->SetFont(&font, B_FONT_SIZE); + fSampleSize->SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); + + r.top += fontHeight; + r.bottom = r.top + fontHeight + 3; fSampleRate = new BStringView(r, "samplerate", B_TRANSLATE("Sample rate:")); fFileInfoBox->AddChild(fSampleRate); - r.top += 13; - r.bottom = r.top + 15; + fSampleRate->SetFont(&font, B_FONT_SIZE); + 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:")); 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 // buffers with B_MEDIA_RAW_AUDIO format data. @@ -451,12 +483,10 @@ RecorderWindow::InitWindow() } // Create the actual widget - BRect frame(fBottomBox->Bounds()); - r = frame; - r.left = 42; - r.right = (r.left + r.right) / 2; - r.InsetBy(10,10); - r.top = r.bottom - 18; + r = fFileInfoBox->Bounds(); + r.top = r.bottom + 2; + r.bottom = r.top + 18; + r.InsetBy(10, 10); fInputField = new BMenuField(r, "Input", B_TRANSLATE("Input:"), popup); fInputField->SetDivider(fInputField->StringWidth(B_TRANSLATE("Input:")) + 4.0f); @@ -465,9 +495,8 @@ RecorderWindow::InitWindow() fBottomBox->AddChild(fFileInfoBox); fBottomBox->Hide(); - CalcSizes(Frame().Width(), MIN_HEIGHT-161); - ResizeTo(Frame().Width(), MIN_HEIGHT-161); - + CalcSizes(MIN_WIDTH, MIN_HEIGHT); + ResizeTo(Frame().Width(), MIN_HEIGHT); popup->Superitem()->SetLabel(selected_name); @@ -551,12 +580,12 @@ RecorderWindow::MessageReceived(BMessage * message) case VIEW_LIST: if (fUpDownButton->Value() == B_CONTROL_ON) { fBottomBox->Show(); - CalcSizes(Frame().Width(), MIN_HEIGHT); - ResizeTo(Frame().Width(), MIN_HEIGHT); + CalcSizes(MIN_WIDTH, fDeployedHeight); + ResizeTo(Frame().Width(), fDeployedHeight); } else { fBottomBox->Hide(); - CalcSizes(Frame().Width(), MIN_HEIGHT-161); - ResizeTo(Frame().Width(), MIN_HEIGHT-161); + CalcSizes(MIN_WIDTH, MIN_HEIGHT); + ResizeTo(Frame().Width(), MIN_HEIGHT); } break; diff --git a/src/apps/soundrecorder/RecorderWindow.h b/src/apps/soundrecorder/RecorderWindow.h index 34dec3a226..63f6b01c4b 100644 --- a/src/apps/soundrecorder/RecorderWindow.h +++ b/src/apps/soundrecorder/RecorderWindow.h @@ -94,6 +94,8 @@ private: BDirectory fTempDir; int fTempCount; + float fDeployedHeight; + BBox * fBottomBox; BBox * fFileInfoBox; BStringView *fFilename; diff --git a/src/apps/soundrecorder/SoundListView.cpp b/src/apps/soundrecorder/SoundListView.cpp index bd3bcab293..42cab62d92 100644 --- a/src/apps/soundrecorder/SoundListView.cpp +++ b/src/apps/soundrecorder/SoundListView.cpp @@ -34,12 +34,11 @@ void SoundListView::Draw(BRect updateRect) { if (IsEmpty()) { - SetHighColor(235,235,235); - FillRect(Bounds()); + SetLowColor(ViewColor()); + FillRect(Bounds(), B_SOLID_LOW); - SetHighColor(0,0,0); + SetHighColor(ui_color(B_PANEL_TEXT_COLOR)); BFont font(be_bold_font); - font.SetSize(12.0); SetFont(&font); font_height height; font.GetHeight(&height); @@ -58,7 +57,8 @@ void SoundListView::AttachedToWindow() { BListView::AttachedToWindow(); - SetViewColor(255,255,255); + SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), + B_LIGHTEN_1_TINT)); }