1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-10 17:37:45 +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

@ -344,6 +344,8 @@ NoteTrack *MixerTrackCluster::GetNote() const
void MixerTrackCluster::UpdatePrefs() void MixerTrackCluster::UpdatePrefs()
{ {
this->SetBackgroundColour( theTheme.Colour( clrMedium ) );
mStaticText_TrackName->SetForegroundColour(theTheme.Colour(clrTrackPanelText));
if (mMeter) if (mMeter)
mMeter->UpdatePrefs(); // in case meter range has changed mMeter->UpdatePrefs(); // in case meter range has changed
HandleResize(); // in case prefs "/GUI/Solo" changed HandleResize(); // in case prefs "/GUI/Solo" changed
@ -936,10 +938,33 @@ MixerBoard::~MixerBoard()
this); this);
} }
void MixerBoard::UpdatePrefs() 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++) for (unsigned int nClusterIndex = 0; nClusterIndex < mMixerTrackClusters.GetCount(); nClusterIndex++)
mMixerTrackClusters[nClusterIndex]->UpdatePrefs(); mMixerTrackClusters[nClusterIndex]->UpdatePrefs();
Refresh();
#endif
} }
// Reassign mixer input strips (MixerTrackClusters) to Track Clusters // Reassign mixer input strips (MixerTrackClusters) to Track Clusters
@ -1519,6 +1544,7 @@ MixerBoardFrame::~MixerBoardFrame()
{ {
} }
// event handlers // event handlers
void MixerBoardFrame::OnCloseWindow(wxCloseEvent &WXUNUSED(event)) void MixerBoardFrame::OnCloseWindow(wxCloseEvent &WXUNUSED(event))
{ {

@ -4604,6 +4604,25 @@ void AudacityProject::UpdateMixerBoard()
//mMixerBoard->UpdateMeters(gAudioIO->GetStreamTime(), (mLastPlayMode == loopedPlay)); //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 // Clipboard methods
// //

@ -562,7 +562,9 @@ public:
public: public:
void ModifyState(bool bWantsAutoSave); // if true, writes auto-save file. Should set only if you really want the state change restored after 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 // 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 PopState(const UndoState &state);
void UpdateLyrics(); void UpdateLyrics();
@ -653,8 +655,8 @@ private:
HistoryWindow *mHistoryWindow{}; HistoryWindow *mHistoryWindow{};
LyricsWindow* mLyricsWindow{}; LyricsWindow* mLyricsWindow{};
MixerBoard* mMixerBoard{};
MixerBoardFrame* mMixerBoardFrame{}; MixerBoardFrame* mMixerBoardFrame{};
MixerBoard* mMixerBoard{};
Destroy_ptr<FreqWindow> mFreqWindow; Destroy_ptr<FreqWindow> mFreqWindow;
Destroy_ptr<ContrastDialog> mContrastDialog; Destroy_ptr<ContrastDialog> mContrastDialog;