1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 07:59:27 +02:00

1. Consolidate linking enable/disable logic b/w Edit Toolbar and Menu

2. Save user's preference for enabling linking

3. fix a bug by which changes to global prefs like SWPlaythrough were not
visually reflected in other open projects.
This commit is contained in:
BusinessmanProgrammerSteve 2010-03-13 17:40:17 +00:00
parent 6860fca483
commit 2b3a50bd09
5 changed files with 40 additions and 20 deletions

View File

@ -1479,6 +1479,13 @@ void AudacityProject::SelectAllIfNone()
OnSelectAll();
}
void AudacityProject::ModifyAllProjectToolbarMenus()
{
AProjectArray::iterator i;
for (i = gAudacityProjects.begin(); i != gAudacityProjects.end(); ++i) {
(*i)->ModifyToolbarMenus();
}
}
void AudacityProject::ModifyToolbarMenus()
{
@ -1523,6 +1530,8 @@ void AudacityProject::ModifyToolbarMenus()
mCommandManager.Check(wxT("Duplex"), active);
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"),&active, false);
mCommandManager.Check(wxT("SWPlaythrough"), active);
gPrefs->Read(wxT("/GUI/LinkTracks"), &active, true);
SetStickyFlag(active);
mCommandManager.Check(wxT("StickyLabels"), mStickyFlag);
}
@ -1900,7 +1909,7 @@ void AudacityProject::OnToggleSoundActivated()
bool pause;
gPrefs->Read(wxT("/AudioIO/SoundActivatedRecord"), &pause, false);
gPrefs->Write(wxT("/AudioIO/SoundActivatedRecord"), !pause);
ModifyToolbarMenus();
ModifyAllProjectToolbarMenus();
}
void AudacityProject::OnTogglePlayRecording()
@ -1908,7 +1917,7 @@ void AudacityProject::OnTogglePlayRecording()
bool Duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &Duplex, false);
gPrefs->Write(wxT("/AudioIO/Duplex"), !Duplex);
ModifyToolbarMenus();
ModifyAllProjectToolbarMenus();
}
void AudacityProject::OnToggleSWPlaythrough()
@ -1916,7 +1925,7 @@ void AudacityProject::OnToggleSWPlaythrough()
bool SWPlaythrough;
gPrefs->Read(wxT("/AudioIO/SWPlaythrough"), &SWPlaythrough, false);
gPrefs->Write(wxT("/AudioIO/SWPlaythrough"), !SWPlaythrough);
ModifyToolbarMenus();
ModifyAllProjectToolbarMenus();
}
#ifdef AUTOMATED_INPUT_LEVEL_ADJUSTMENT
@ -1925,7 +1934,7 @@ void AudacityProject::OnToogleAutomatedInputLevelAdjustment()
bool AVEnabled;
gPrefs->Read(wxT("/AudioIO/AutomatedInputLevelAdjustment"), &AVEnabled, false);
gPrefs->Write(wxT("/AudioIO/AutomatedInputLevelAdjustment"), !AVEnabled);
ModifyToolbarMenus();
ModifyAllProjectToolbarMenus();
}
#endif
@ -5091,10 +5100,12 @@ int AudacityProject::DoAddLabel(double left, double right)
void AudacityProject::OnStickyLabel()
{
SetStickyFlag(!GetStickyFlag());
EditToolBar *toolbar = GetEditToolBar();
toolbar->EnableDisableButtons();
GetTrackPanel()->Refresh(false);
bool linkTracks;
gPrefs->Read(wxT("/GUI/LinkTracks"), &linkTracks, true);
gPrefs->Write(wxT("/GUI/LinkTracks"), !linkTracks);
// Toolbar, project "sticky flag" handled within
ModifyAllProjectToolbarMenus();
}
void AudacityProject::OnAddLabel()

View File

@ -37,6 +37,8 @@ void AddEffectsToMenu(CommandManager* c, const EffectSet& effects);
void CreateRecentFilesMenu(CommandManager *c);
void ModifyUndoMenus();
void ModifyToolbarMenus();
// Calls ModifyToolbarMenus() on all projects
void ModifyAllProjectToolbarMenus();
int GetFocusedFrame();
wxUint32 GetUpdateFlags();

View File

@ -813,7 +813,9 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
mViewInfo.bRedrawWaveform = false;
mLockPlayRegion = false;
SetStickyFlag(true);
bool linkTracks;
gPrefs->Read(wxT("/GUI/LinkTracks"), &linkTracks, true);
SetStickyFlag(linkTracks);
CreateMenusAndCommands();
@ -4440,6 +4442,15 @@ bool AudacityProject::IsSticky()
#endif
}
void AudacityProject::SetStickyFlag(bool flag)
{
if (flag != mStickyFlag) {
mStickyFlag = flag;
if (GetTrackPanel())
GetTrackPanel()->Refresh(false);
}
}
void AudacityProject::HandleTrackMute(Track *t, const bool exclusive)
{
// "exclusive" mute means mute the chosen track and unmute all others.

View File

@ -284,7 +284,7 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
void EditClipboardByLabel( WaveTrack::EditDestFunction action );
bool IsSticky();
bool GetStickyFlag() { return mStickyFlag; };
void SetStickyFlag(bool flag) { mStickyFlag = flag; };
void SetStickyFlag(bool flag);
// "exclusive" mute means mute the chosen track and unmute all others.
void HandleTrackMute(Track *t, const bool exclusive);

View File

@ -50,6 +50,7 @@
#include "../AudioIO.h"
#include "../ImageManipulation.h"
#include "../Internat.h"
#include "../Prefs.h"
#include "../Project.h"
#include "../Theme.h"
#include "../UndoManager.h"
@ -240,15 +241,7 @@ void EditToolBar::OnButton(wxCommandEvent &event)
break;
#ifdef EXPERIMENTAL_LINKING
case ETBLinkID:
if (!busy){
p->OnStickyLabel();
if (p->GetStickyFlag())
mButtons[ETBLinkID]->PushDown();
else
mButtons[ETBLinkID]->PopUp();
p->ModifyToolbarMenus();
p->GetTrackPanel()->Refresh(false);
}
if (!busy) p->OnStickyLabel();
return;//avoiding the call to SetButton()
#endif
case ETBZoomInID:
@ -313,7 +306,10 @@ void EditToolBar::EnableDisableButtons()
mButtons[ETBPasteID]->SetEnabled(p->Clipboard());
#ifdef EXPERIMENTAL_LINKING
if (p->GetStickyFlag())
bool linkTracks;
gPrefs->Read(wxT("/GUI/LinkTracks"), &linkTracks, true);
if (linkTracks)
mButtons[ETBLinkID]->PushDown();
else
mButtons[ETBLinkID]->PopUp();