From 046ee21e725b513fd9de4a3906548126160b3392 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Wed, 4 Mar 2020 13:52:10 -0500 Subject: [PATCH] Move GetEditClipsCanMove to global function in TracksBehaviorsPrefs.cpp --- src/Prefs.cpp | 15 --------------- src/Prefs.h | 1 - src/WaveTrack.cpp | 7 ++++--- src/effects/Generator.cpp | 3 ++- src/prefs/TracksBehaviorsPrefs.cpp | 15 +++++++++++++++ src/prefs/TracksBehaviorsPrefs.h | 3 +++ 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/Prefs.cpp b/src/Prefs.cpp index 3d28869cd..0031ed716 100755 --- a/src/Prefs.cpp +++ b/src/Prefs.cpp @@ -189,21 +189,6 @@ AudacityPrefs::AudacityPrefs(const wxString& appName, -// Bug 825 is essentially that SyncLock requires EditClipsCanMove. -// SyncLock needs rethinking, but meanwhile this function -// fixes the issues of Bug 825 by allowing clips to move when in -// SyncLock. -bool AudacityPrefs::GetEditClipsCanMove() -{ - bool mIsSyncLocked; - gPrefs->Read(wxT("/GUI/SyncLockTracks"), &mIsSyncLocked, false); - if( mIsSyncLocked ) - return true; - bool editClipsCanMove; - Read(wxT("/GUI/EditClipCanMove"), &editClipsCanMove, true); - return editClipsCanMove; -} - void InitPreferences( const wxFileName &configFileName ) { wxString appName = wxTheApp->GetAppName(); diff --git a/src/Prefs.h b/src/Prefs.h index 723bd400e..c14f02bb3 100644 --- a/src/Prefs.h +++ b/src/Prefs.h @@ -64,7 +64,6 @@ public: const wxString& globalFilename = {}, long style = wxCONFIG_USE_LOCAL_FILE | wxCONFIG_USE_GLOBAL_FILE, const wxMBConv& conv = wxConvAuto()); - bool GetEditClipsCanMove(); // Set and Get values of the version major/minor/micro keys in audacity.cfg when Audacity first opens void SetVersionKeysInit( int major, int minor, int micro) diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index b8d83e693..602e5cddb 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -57,6 +57,7 @@ Track classes. #include "prefs/QualityPrefs.h" #include "prefs/SpectrogramSettings.h" #include "prefs/TracksPrefs.h" +#include "prefs/TracksBehaviorsPrefs.h" #include "prefs/WaveformSettings.h" #include "InconsistencyException.h" @@ -940,7 +941,7 @@ void WaveTrack::HandleClear(double t0, double t1, if (t1 < t0) THROW_INCONSISTENCY_EXCEPTION; - bool editClipCanMove = gPrefs->GetEditClipsCanMove(); + bool editClipCanMove = GetEditClipsCanMove(); WaveClipPointers clipsToDelete; WaveClipHolders clipsToAdd; @@ -1113,7 +1114,7 @@ void WaveTrack::SyncLockAdjust(double oldT1, double newT1) void WaveTrack::Paste(double t0, const Track *src) // WEAK-GUARANTEE { - bool editClipCanMove = gPrefs->GetEditClipsCanMove(); + bool editClipCanMove = GetEditClipsCanMove(); bool bOk = src && src->TypeSwitch< bool >( [&](const WaveTrack *other) { @@ -2356,7 +2357,7 @@ void WaveTrack::ExpandCutLine(double cutLinePosition, double* cutlineStart, double* cutlineEnd) // STRONG-GUARANTEE { - bool editClipCanMove = gPrefs->GetEditClipsCanMove(); + bool editClipCanMove = GetEditClipsCanMove(); // Find clip which contains this cut line double start = 0, end = 0; diff --git a/src/effects/Generator.cpp b/src/effects/Generator.cpp index ff0064798..6d0c89272 100644 --- a/src/effects/Generator.cpp +++ b/src/effects/Generator.cpp @@ -20,6 +20,7 @@ #include "../Prefs.h" #include "../ViewInfo.h" #include "../WaveTrack.h" +#include "../prefs/TracksBehaviorsPrefs.h" #include "TimeWarper.h" @@ -43,7 +44,7 @@ bool Generator::Process() [&](WaveTrack *track, const Track::Fallthrough &fallthrough) { if (!track->GetSelected()) return fallthrough(); - bool editClipCanMove = gPrefs->GetEditClipsCanMove(); + bool editClipCanMove = GetEditClipsCanMove(); //if we can't move clips, and we're generating into an empty space, //make sure there's room. diff --git a/src/prefs/TracksBehaviorsPrefs.cpp b/src/prefs/TracksBehaviorsPrefs.cpp index 5da8861b4..2f0c1ef5f 100644 --- a/src/prefs/TracksBehaviorsPrefs.cpp +++ b/src/prefs/TracksBehaviorsPrefs.cpp @@ -143,3 +143,18 @@ PrefsPanel::Registration sAttachment{ "TracksBehaviors", { "Tracks" } }; } + +// Bug 825 is essentially that SyncLock requires EditClipsCanMove. +// SyncLock needs rethinking, but meanwhile this function +// fixes the issues of Bug 825 by allowing clips to move when in +// SyncLock. +bool GetEditClipsCanMove() +{ + bool mIsSyncLocked; + gPrefs->Read(wxT("/GUI/SyncLockTracks"), &mIsSyncLocked, false); + if( mIsSyncLocked ) + return true; + bool editClipsCanMove; + gPrefs->Read(wxT("/GUI/EditClipCanMove"), &editClipsCanMove, true); + return editClipsCanMove; +} diff --git a/src/prefs/TracksBehaviorsPrefs.h b/src/prefs/TracksBehaviorsPrefs.h index c15d28665..1a7ba226b 100644 --- a/src/prefs/TracksBehaviorsPrefs.h +++ b/src/prefs/TracksBehaviorsPrefs.h @@ -42,4 +42,7 @@ class TracksBehaviorsPrefs final : public PrefsPanel }; extern ChoiceSetting TracksBehaviorsSolo; + +bool GetEditClipsCanMove(); + #endif