1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-03 17:19:43 +02:00

Consolidate the code that starts and stops play/rec head scrolling

This commit is contained in:
Paul Licameli 2016-05-29 14:28:06 -04:00
parent d62442827c
commit fecc6f53e4
5 changed files with 61 additions and 37 deletions

View File

@ -751,8 +751,7 @@ void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
auto p = GetActiveProject();
if (doubleClicked)
p->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Centered);
StartScrolling();
else {
if (!CanStopAudioStream())
return;
@ -792,11 +791,11 @@ void ControlToolBar::PlayDefault()
void ControlToolBar::StopPlaying(bool stopStream /* = true*/)
{
StopScrolling();
AudacityProject *project = GetActiveProject();
if(project) {
project->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Off);
// Let scrubbing code do some appearance change
project->GetScrubber().StopScrubbing();
}
@ -857,22 +856,7 @@ void ControlToolBar::OnRecord(wxCommandEvent &evt)
mRecord->ClearDoubleClicked();
if (doubleClicked) {
// Display a fixed recording head while scrolling the waves continuously.
// If you overdub, you may want to anticipate some context in existing tracks,
// so center the head. If not, put it rightmost to display as much wave as we can.
const auto project = GetActiveProject();
bool duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
if (duplex) {
// See if there is really anything being overdubbed
if (gAudioIO->GetNumPlaybackChannels() == 0)
// No.
duplex = false;
}
using Mode = AudacityProject::PlaybackScroller::Mode;
project->GetPlaybackScroller().Activate(duplex ? Mode::Centered : Mode::Right);
StartScrolling();
return;
}
@ -1278,3 +1262,42 @@ void ControlToolBar::UpdateStatusBar(AudacityProject *pProject)
{
pProject->GetStatusBar()->SetStatusText(StateForStatusBar(), stateStatusBarField);
}
void ControlToolBar::StartScrolling()
{
using Mode = AudacityProject::PlaybackScroller::Mode;
const auto project = GetActiveProject();
if (project) {
auto mode = Mode::Centered;
if (gAudioIO->GetNumCaptureChannels() > 0) {
// recording
// Display a fixed recording head while scrolling the waves continuously.
// If you overdub, you may want to anticipate some context in existing tracks,
// so center the head. If not, put it rightmost to display as much wave as we can.
bool duplex;
gPrefs->Read(wxT("/AudioIO/Duplex"), &duplex, true);
if (duplex) {
// See if there is really anything being overdubbed
if (gAudioIO->GetNumPlaybackChannels() == 0)
// No.
duplex = false;
}
if (!duplex)
mode = Mode::Right;
}
project->GetPlaybackScroller().Activate(mode);
}
}
void ControlToolBar::StopScrolling()
{
const auto project = GetActiveProject();
if(project)
project->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Off);
}

View File

@ -106,6 +106,10 @@ class ControlToolBar final : public ToolBar {
int WidthForStatusBar(wxStatusBar* const);
void UpdateStatusBar(AudacityProject *pProject);
// Starting and stopping of scrolling display
void StartScrolling();
void StopScrolling();
private:
AButton *MakeButton(teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled,

View File

@ -480,8 +480,7 @@ void TranscriptionToolBar::OnPlaySpeed(wxCommandEvent & WXUNUSED(event))
button->ClearDoubleClicked();
if (doubleClicked) {
GetActiveProject()->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Centered);
GetActiveProject()->GetControlToolBar()->StartScrolling();
// Pop up the button
SetButton(false, button);

View File

@ -508,8 +508,6 @@ void Scrubber::StopScrubbing()
UncheckAllMenuItems();
mScrubStartPosition = -1;
mProject->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Off);
mDragging = false;
if (!IsScrubbing())
@ -784,20 +782,21 @@ bool Scrubber::PollIsSeeking()
void Scrubber::ActivateScroller()
{
using Mode = AudacityProject::PlaybackScroller::Mode;
mProject->GetPlaybackScroller().Activate(mSmoothScrollingScrub
? Mode::Centered
:
const auto ctb = mProject->GetControlToolBar();
if (mSmoothScrollingScrub)
ctb->StartScrolling();
else {
#ifdef __WXMAC__
// PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
// doing this causes wheel rotation events (mapped from the double finger vertical
// swipe) to be delivered more uniformly to the application, so that spped control
// works better.
Mode::Refresh
// PRL: cause many "unnecessary" refreshes. For reasons I don't understand,
// doing this causes wheel rotation events (mapped from the double finger vertical
// swipe) to be delivered more uniformly to the application, so that speed control
// works better.
mProject->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Refresh);
#else
Mode::Off
ctb->StopScrolling();
#endif
);
}
}
void Scrubber::DoScrub(bool scroll, bool seek)

View File

@ -2404,8 +2404,7 @@ void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
void AdornedRulerPanel::HandleQPDoubleClick(wxMouseEvent &evt, wxCoord mousePosX)
{
mProject->GetPlaybackScroller().Activate
(AudacityProject::PlaybackScroller::Mode::Centered);
mProject->GetControlToolBar()->StartScrolling();
}
void AdornedRulerPanel::HandleQPClick(wxMouseEvent &evt, wxCoord mousePosX)