1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 14:20:06 +02:00

Fix MixerBoard Theming

Fixed so that updates to theme are applied immediately.  Previously theming only worked properly after a restart with the new theme.  Paul found that you could create a Chimera MixerBoard with a track in each of the four different themes.

I chose to completely recreate the MixerBoard on a prefs update, rather than the more fiddly detail of retheming each component of it.
This commit is contained in:
James Crook 2017-06-22 11:52:56 +01:00
parent a0eba9fb95
commit 86901a00a1
3 changed files with 49 additions and 2 deletions

View File

@ -344,6 +344,8 @@ NoteTrack *MixerTrackCluster::GetNote() const
void MixerTrackCluster::UpdatePrefs()
{
this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
if (mMeter)
mMeter->UpdatePrefs(); // in case meter range has changed
HandleResize(); // in case prefs "/GUI/Solo" changed
@ -936,10 +938,33 @@ MixerBoard::~MixerBoard()
this);
}
void MixerBoard::UpdatePrefs()
{
mProject->RecreateMixerBoard();
// Old approach modified things in situ.
// However with a theme change there is so much to modify, it is easier
// to recreate.
#if 0
mScrolledWindow->SetBackgroundColour( theTheme.Colour( clrMedium ) );
if( mImageMuteUp ){
mImageMuteUp.reset();
mImageMuteOver.reset();
mImageMuteDown.reset();
mImageMuteDownWhileSolo.reset();
mImageMuteDisabled.reset();
mImageSoloUp.reset();
mImageSoloOver.reset();
mImageSoloDown.reset();
mImageSoloDisabled.reset();
}
for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.GetCount(); nClusterIndex++)
mMixerTrackClusters[nClusterIndex]->UpdatePrefs();
Refresh();
#endif
}
// Reassign mixer input strips (MixerTrackClusters) to Track Clusters
@ -1519,6 +1544,7 @@ MixerBoardFrame::~MixerBoardFrame()
{
}
// event handlers
void MixerBoardFrame::OnCloseWindow(wxCloseEvent &WXUNUSED(event))
{

View File

@ -4604,6 +4604,25 @@ void AudacityProject::UpdateMixerBoard()
//mMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(), (mLastPlayMode == loopedPlay));
}
void AudacityProject::RecreateMixerBoard( )
{
wxASSERT( mMixerBoard );
wxASSERT( mMixerBoardFrame );
wxPoint pos = mMixerBoard->GetPosition();
wxSize siz = mMixerBoard->GetSize();
wxSize siz2 = mMixerBoardFrame->GetSize();
//wxLogDebug("Got rid of board %p", mMixerBoard );
mMixerBoard->Destroy();
mMixerBoard = NULL;
mMixerBoard = safenew MixerBoard(this, mMixerBoardFrame, pos, siz);
mMixerBoardFrame->mMixerBoard = mMixerBoard;
//wxLogDebug("Created new board %p", mMixerBoard );
mMixerBoard->UpdateTrackClusters();
mMixerBoard->SetSize( siz );
mMixerBoardFrame->SetSize( siz2 );
}
//
// Clipboard methods
//

View File

@ -562,7 +562,9 @@ public:
public:
void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after
// a crash, as it can take many seconds for large (eg. 10 track-hours) projects
private:
void RecreateMixerBoard();
private:
void PopState(const UndoState &state);
void UpdateLyrics();
@ -653,8 +655,8 @@ private:
HistoryWindow *mHistoryWindow{};
LyricsWindow* mLyricsWindow{};
MixerBoard* mMixerBoard{};
MixerBoardFrame* mMixerBoardFrame{};
MixerBoard* mMixerBoard{};
Destroy_ptr<FreqWindow> mFreqWindow;
Destroy_ptr<ContrastDialog> mContrastDialog;