1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-05 22:28:57 +02:00

Computing best font size for TrackInfo is redone when preferences change

This commit is contained in:
Paul Licameli 2016-05-01 17:55:48 -04:00
parent 16261a2a11
commit e7477746df
2 changed files with 28 additions and 15 deletions

View File

@ -796,6 +796,9 @@ void TrackPanel::UpdatePrefs()
// All vertical rulers must be recalculated since the minimum and maximum
// frequences may have been changed.
UpdateVRulers();
mTrackInfo.UpdatePrefs();
Refresh();
}
@ -8774,21 +8777,7 @@ TrackInfo::TrackInfo(TrackPanel * pParentIn)
PAN_SLIDER);
mPanCaptured->SetDefaultValue(0.0);
int fontSize = 10;
mFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
int allowableWidth = GetTrackInfoWidth() - 2; // 2 to allow for left/right borders
int textWidth, textHeight;
do {
mFont.SetPointSize(fontSize);
pParent->GetTextExtent(_("Stereo, 999999Hz"),
&textWidth,
&textHeight,
NULL,
NULL,
&mFont);
fontSize--;
} while (textWidth >= allowableWidth);
UpdatePrefs();
}
TrackInfo::~TrackInfo()
@ -9169,6 +9158,28 @@ LWSlider * TrackInfo::PanSlider(WaveTrack *t, bool captured) const
return captured ? mPanCaptured : mPan;
}
void TrackInfo::UpdatePrefs()
{
// Calculation of best font size depends on language, so it should be redone in case
// the language preference changed.
int fontSize = 10;
mFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
int allowableWidth = GetTrackInfoWidth() - 2; // 2 to allow for left/right borders
int textWidth, textHeight;
do {
mFont.SetPointSize(fontSize);
pParent->GetTextExtent(_("Stereo, 999999Hz"),
&textWidth,
&textHeight,
NULL,
NULL,
&mFont);
fontSize--;
} while (textWidth >= allowableWidth);
}
TrackPanelCellIterator::TrackPanelCellIterator(TrackPanel *trackPanel, bool begin)
: mPanel(trackPanel)
, mIter(trackPanel->GetProject())

View File

@ -121,6 +121,8 @@ public:
#endif
private:
void UpdatePrefs();
TrackPanel * pParent;
wxFont mFont;
LWSlider *mGainCaptured;