Bug1342: Loop-play (and other things) before scrub (and other things)...

... should not disable auto-scrolling of the window during playback.
This commit is contained in:
Paul Licameli 2016-04-18 17:50:17 -04:00
parent a3a5a243c2
commit d5915491b3
10 changed files with 37 additions and 41 deletions

View File

@ -2076,9 +2076,9 @@ void AudacityProject::OnPlayOneSecond()
return;
double pos = mTrackPanel->GetMostRecentXPos();
mLastPlayMode = oneSecondPlay;
GetControlToolBar()->PlayPlayRegion
(SelectedRegion(pos - 0.5, pos + 0.5), GetDefaultPlayOptions());
(SelectedRegion(pos - 0.5, pos + 0.5), GetDefaultPlayOptions(),
PlayMode::oneSecondPlay);
}
@ -2115,14 +2115,13 @@ void AudacityProject::OnPlayToSelection()
// where the cursor is.
// TODO: have 'playing attributes' such as 'with_autoscroll'
// rather than modes, since that's how we're now using the modes.
mLastPlayMode = oneSecondPlay;
// An alternative, commented out below, is to disable autoscroll
// only when playing a short region, less than or equal to a second.
// mLastPlayMode = ((t1-t0) > 1.0) ? normalPlay : oneSecondPlay;
GetControlToolBar()->PlayPlayRegion
(SelectedRegion(t0, t1), GetDefaultPlayOptions());
(SelectedRegion(t0, t1), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}
// The next 4 functions provide a limited version of the
@ -2137,9 +2136,7 @@ void AudacityProject::OnPlayBeforeSelectionStart()
double beforeLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}
void AudacityProject::OnPlayAfterSelectionStart()
@ -2152,12 +2149,11 @@ void AudacityProject::OnPlayAfterSelectionStart()
double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions(),
PlayMode::oneSecondPlay);
else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t0 + afterLen), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t0 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}
void AudacityProject::OnPlayBeforeSelectionEnd()
@ -2170,12 +2166,11 @@ void AudacityProject::OnPlayBeforeSelectionEnd()
double beforeLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewBeforeLen"), &beforeLen, 2.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1), GetDefaultPlayOptions(),
PlayMode::oneSecondPlay);
else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}
@ -2188,9 +2183,7 @@ void AudacityProject::OnPlayAfterSelectionEnd()
double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1, t1 + afterLen), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1, t1 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}
void AudacityProject::OnPlayBeforeAndAfterSelectionStart()
@ -2205,12 +2198,10 @@ void AudacityProject::OnPlayBeforeAndAfterSelectionStart()
double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < afterLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t1), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t1), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0 + afterLen), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0 - beforeLen, t0 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}
void AudacityProject::OnPlayBeforeAndAfterSelectionEnd()
@ -2225,12 +2216,10 @@ void AudacityProject::OnPlayBeforeAndAfterSelectionEnd()
double afterLen;
gPrefs->Read(wxT("/AudioIO/CutPreviewAfterLen"), &afterLen, 1.0);
mLastPlayMode = oneSecondPlay; // this disables auto scrolling, as in OnPlayToSelection()
if ( t1 - t0 > 0.0 && t1 - t0 < beforeLen )
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1 + afterLen), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t0, t1 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
else
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1 + afterLen), GetDefaultPlayOptions());
GetControlToolBar()->PlayPlayRegion(SelectedRegion(t1 - beforeLen, t1 + afterLen), GetDefaultPlayOptions(), PlayMode::oneSecondPlay);
}

View File

@ -1723,7 +1723,7 @@ void MixerBoard::OnTimer(wxCommandEvent &event)
if (mProject->IsAudioActive())
{
UpdateMeters(gAudioIO->GetStreamTime(),
(mProject->mLastPlayMode == loopedPlay));
(mProject->mLastPlayMode == PlayMode::loopedPlay));
}
// Let other listeners get the notification

View File

@ -117,10 +117,10 @@ extern AProjectArray gAudacityProjects;
WX_DEFINE_ARRAY(wxMenu *, MenuArray);
enum PlayMode {
enum class PlayMode : int {
normalPlay,
oneSecondPlay,
loopedPlay
oneSecondPlay, // Disables auto-scrolling
loopedPlay // Disables auto-scrolling
};
enum StatusBarField {
@ -494,7 +494,7 @@ public:
void WriteXMLHeader(XMLWriter &xmlFile);
PlayMode mLastPlayMode{ normalPlay };
PlayMode mLastPlayMode{ PlayMode::normalPlay };
ViewInfo mViewInfo;
// Audio IO callback methods

View File

@ -3429,7 +3429,7 @@ void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
mProject->GetControlToolBar()->PlayPlayRegion
(SelectedRegion(mPlayPos, mRegion.t1()),
mProject->GetDefaultPlayOptions());
mProject->GetDefaultPlayOptions(), PlayMode::normalPlay);
}
}

View File

@ -475,6 +475,7 @@ bool ControlToolBar::IsRecordDown()
int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
const AudioIOStartStreamOptions &options,
PlayMode mode,
bool cutpreview, /* = false */
bool backwards, /* = false */
bool playWhiteSpace /* = false */)
@ -518,6 +519,8 @@ int ControlToolBar::PlayPlayRegion(const SelectedRegion &selectedRegion,
return -1; // Should never happen, but...
}
p->mLastPlayMode = mode;
bool hasaudio = false;
TrackListIterator iter(t);
for (Track *trk = iter.First(); trk; trk = iter.Next()) {
@ -673,10 +676,6 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
if (p)
{
if (looped)
p->mLastPlayMode = loopedPlay;
else
p->mLastPlayMode = normalPlay;
double playRegionStart, playRegionEnd;
p->GetPlayRegion(&playRegionStart, &playRegionEnd);
@ -686,7 +685,9 @@ void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
if (cutpreview)
options.timeTrack = NULL;
PlayPlayRegion(SelectedRegion(playRegionStart, playRegionEnd),
options, cutpreview);
options,
(looped ? PlayMode::loopedPlay : PlayMode::normalPlay),
cutpreview);
}
}

View File

@ -34,6 +34,9 @@ class TimeTrack;
struct AudioIOStartStreamOptions;
class SelectedRegion;
// Defined in Project.h
enum class PlayMode : int;
// In the GUI, ControlToolBar appears as the "Transport Toolbar". "Control Toolbar" is historic.
class ControlToolBar final : public ToolBar {
@ -74,6 +77,7 @@ class ControlToolBar final : public ToolBar {
// Return the Audio IO token or -1 for failure
int PlayPlayRegion(const SelectedRegion &selectedRegion,
const AudioIOStartStreamOptions &options,
PlayMode playMode,
bool cutpreview = false, bool backwards = false,
// Allow t0 and t1 to be beyond end of tracks
bool playWhiteSpace = false);

View File

@ -462,6 +462,7 @@ void TranscriptionToolBar::PlayAtSpeed(bool looped, bool cutPreview)
p->GetControlToolBar()->PlayPlayRegion
(SelectedRegion(playRegionStart, playRegionEnd),
options,
PlayMode::normalPlay,
cutPreview);
}
}

View File

@ -132,8 +132,8 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
// BG: Scroll screen if option is set
// msmeyer: But only if not playing looped or in one-second mode
if (viewInfo.bUpdateTrackIndicator &&
mProject->mLastPlayMode != loopedPlay &&
mProject->mLastPlayMode != oneSecondPlay &&
mProject->mLastPlayMode != PlayMode::loopedPlay &&
mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
playPos >= 0 &&
!onScreen &&
!gAudioIO->IsPaused())

View File

@ -216,7 +216,8 @@ bool Scrubber::MaybeStartScrubbing(const wxMouseEvent &event)
#endif
mScrubSpeedDisplayCountdown = 0;
mScrubToken =
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options, cutPreview, backwards);
ctb->PlayPlayRegion(SelectedRegion(time0, time1), options,
PlayMode::normalPlay, cutPreview, backwards);
}
}
else

View File

@ -2288,7 +2288,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
options.timeTrack = NULL;
ctb->PlayPlayRegion((SelectedRegion(start, end)),
options,
options, PlayMode::normalPlay,
evt.ControlDown(),
false,
true);