1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-29 22:58:39 +02:00

TrackInfo doesn't need TrackPanel to push preference changes to it...

... This frees six more files from cycles, leaving that no-longer biggest s.c.c.
at just seven files now!
This commit is contained in:
Paul Licameli 2019-06-21 13:59:12 -04:00
parent e5baad44d4
commit 38f3ee95c0
2 changed files with 30 additions and 28 deletions

View File

@ -32,9 +32,11 @@ Paul Licameli split from TrackPanel.cpp
#include <wx/dc.h> #include <wx/dc.h>
#include <wx/frame.h> #include <wx/frame.h>
#include <wx/graphics.h>
#include "AColor.h" #include "AColor.h"
#include "AllThemeResources.h" #include "AllThemeResources.h"
#include "Prefs.h"
#include "Project.h" #include "Project.h"
#include "Track.h" #include "Track.h"
#include "TrackPanelDrawingContext.h" #include "TrackPanelDrawingContext.h"
@ -520,30 +522,35 @@ unsigned TrackInfo::DefaultTrackHeight( const TCPLines &topLines )
return (unsigned) std::max( needed, (int) TrackView::DefaultHeight ); return (unsigned) std::max( needed, (int) TrackView::DefaultHeight );
} }
void TrackInfo::UpdatePrefs( wxWindow *pParent ) // Subscribe to preference changes to update static variables
{ static struct MyPrefsListener : PrefsListener {
gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple")); void UpdatePrefs() override
{
gPrefs->Read(wxT("/GUI/Solo"), &gSoloPref, wxT("Simple"));
// Calculation of best font size depends on language, so it should be redone in case // Calculation of best font size depends on language, so it should be redone in case
// the language preference changed. // the language preference changed.
int fontSize = 10; int fontSize = 10;
gFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL); gFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
int allowableWidth = int allowableWidth =
// PRL: was it correct to include the margin? // PRL: was it correct to include the margin?
( kTrackInfoWidth + kLeftMargin ) ( kTrackInfoWidth + kLeftMargin )
- 2; // 2 to allow for left/right borders - 2; // 2 to allow for left/right borders
int textWidth, textHeight; int textWidth;
do { std::unique_ptr<wxGraphicsContext> pContext(
gFont.SetPointSize(fontSize); wxGraphicsContext::Create()
pParent->GetTextExtent(_("Stereo, 999999Hz"), );
&textWidth, pContext->SetFont( gFont, *wxBLACK );
&textHeight, do {
NULL, gFont.SetPointSize(fontSize);
NULL, double dWidth;
&gFont); pContext->GetTextExtent(
fontSize--; _("Stereo, 999999Hz"), &dWidth, nullptr );
} while (textWidth >= allowableWidth); textWidth = (wxCoord)( dWidth + 0.5 );
} fontSize--;
} while (textWidth >= allowableWidth);
}
} sPrefsListener;

View File

@ -70,7 +70,6 @@ is time to refresh some aspect of the screen.
#include "Prefs.h" #include "Prefs.h"
#include "RefreshCode.h" #include "RefreshCode.h"
#include "TrackArtist.h" #include "TrackArtist.h"
#include "TrackInfo.h"
#include "TrackPanelAx.h" #include "TrackPanelAx.h"
#include "WaveTrack.h" #include "WaveTrack.h"
#ifdef EXPERIMENTAL_MIDI_OUT #ifdef EXPERIMENTAL_MIDI_OUT
@ -259,8 +258,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
#pragma warning( default: 4355 ) #pragma warning( default: 4355 )
#endif #endif
{ {
TrackInfo::UpdatePrefs( this );
SetLayoutDirection(wxLayout_LeftToRight); SetLayoutDirection(wxLayout_LeftToRight);
SetLabel(_("Track Panel")); SetLabel(_("Track Panel"));
SetName(_("Track Panel")); SetName(_("Track Panel"));
@ -340,8 +337,6 @@ void TrackPanel::UpdatePrefs()
// frequences may have been changed. // frequences may have been changed.
UpdateVRulers(); UpdateVRulers();
TrackInfo::UpdatePrefs( this );
Refresh(); Refresh();
} }