From d3c0c94e170af04974fddda75ad10230aaea30c6 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sun, 1 May 2016 17:28:08 -0400 Subject: [PATCH] Better choice of font size for time ruler pushbuttons --- src/widgets/Ruler.cpp | 52 ++++++++++++++++++++++++++++++++++--------- src/widgets/Ruler.h | 7 +++++- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 579e29a2a..d5c47ec09 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -1827,8 +1827,7 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* parent, mPlayRegionDragsSelection = (gPrefs->Read(wxT("/QuickPlay/DragSelection"), 0L) == 1)? true : false; mQuickPlayEnabled = !!gPrefs->Read(wxT("/QuickPlay/QuickPlayEnabled"), 1L); - int fontSize = 10; - mButtonFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); + mButtonFont.Create(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); UpdatePrefs(); @@ -1897,6 +1896,38 @@ void AdornedRulerPanel::UpdatePrefs() UpdateRects(); RegenerateTooltips(); + + mButtonFontSize = -1; +} + +wxFont &AdornedRulerPanel::GetButtonFont() const +{ + if (mButtonFontSize < 0) { + mButtonFontSize = 10; + + bool done; + do { + done = true; + mButtonFont.SetPointSize(mButtonFontSize); + wxCoord width, height; + for (unsigned ii = 0; + done && ii < static_cast(Button::NumButtons); ++ii) { + auto button = static_cast