1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-22 23:30:07 +02:00

Add transport menu items for scrubbing and seeking...

This commit is contained in:
Paul Licameli 2016-04-21 12:16:51 -04:00
commit e681439000
5 changed files with 68 additions and 12 deletions

View File

@ -818,6 +818,17 @@ void AudacityProject::CreateMenusAndCommands()
c->AddItem(wxT("PlayLooped"), _("&Loop Play"), FN(OnPlayLooped), wxT("Shift+Space"),
WaveTracksExistFlag | AudioIONotBusyFlag | CanStopAudioStreamFlag,
WaveTracksExistFlag | AudioIONotBusyFlag | CanStopAudioStreamFlag);
// Scrubbing sub-menu
{
c->BeginSubMenu(_("Scru&bbing"));
c->AddItem(wxT("Scrub"), _("&Scrub"), FN(OnScrub));
c->AddItem(wxT("ScrollScrub"), _("Sc&rolling Scrub"), FN(OnScrollScrub));
c->AddItem(wxT("Seek"), _("See&k"), FN(OnSeek));
c->AddItem(wxT("ScrollSeek"), _("Scrollin&g Seek"), FN(OnScrollSeek));
c->EndSubMenu();
}
c->AddItem(wxT("Pause"), _("&Pause"), FN(OnPause), wxT("P"),
c->GetDefaultFlags() | AudioStreamNotScrubbingFlag,
c->GetDefaultMask() | AudioStreamNotScrubbingFlag);
@ -2253,6 +2264,36 @@ void AudacityProject::OnPlayCutPreview()
GetControlToolBar()->PlayCurrentRegion(false, true);
}
namespace {
inline void DoScrub(AudacityProject *project, bool scroll, bool seek)
{
auto tp = project->GetTrackPanel();
wxCoord xx = tp->ScreenToClient(::wxGetMouseState().GetPosition()).x;
wxMouseEvent evt;
project->GetScrubber().MarkScrubStart(evt, scroll, seek);
}
}
void AudacityProject::OnScrub()
{
DoScrub(this, false, false);
}
void AudacityProject::OnScrollScrub()
{
DoScrub(this, true, false);
}
void AudacityProject::OnSeek()
{
DoScrub(this, false, true);
}
void AudacityProject::OnScrollSeek()
{
DoScrub(this, true, true);
}
void AudacityProject::OnPlayStop()
{
ControlToolBar *toolbar = GetControlToolBar();

View File

@ -88,6 +88,11 @@ void OnPlayBeforeAndAfterSelectionEnd();
void OnPlayLooped();
void OnPlayCutPreview();
void OnScrub();
void OnScrollScrub();
void OnSeek();
void OnScrollSeek();
// Wave track control
void OnTrackPan();

View File

@ -1962,6 +1962,7 @@ void TrackPanel::SelectionHandleClick(wxMouseEvent & event,
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, event.LeftDClick()
#endif
, false
);
return;
}

View File

@ -34,11 +34,6 @@ enum {
};
namespace {
bool PollIsSeeking()
{
return ::wxGetMouseState().LeftIsDown();
}
double FindScrubbingSpeed(const ViewInfo &viewInfo, double maxScrubSpeed, double screen, double timeAtMouse)
{
// Map a time (which was mapped from a mouse position)
@ -144,6 +139,7 @@ void Scrubber::MarkScrubStart(
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, bool smoothScrolling
#endif
, bool alwaysSeeking
)
{
const wxCoord xx = event.m_x;
@ -154,6 +150,7 @@ void Scrubber::MarkScrubStart(
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
mSmoothScrollingScrub = smoothScrolling;
#endif
mAlwaysSeeking = alwaysSeeking;
mScrubStartPosition = xx;
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
@ -202,10 +199,12 @@ bool Scrubber::MaybeStartScrubbing(const wxMouseEvent &event)
options.scrubStartClockTimeMillis = mScrubStartClockTimeMillis;
options.minScrubStutter = 0.2;
#if 0
// Take the starting speed limit from the transcription toolbar,
// but it may be varied during the scrub.
mMaxScrubSpeed = options.maxScrubSpeed =
if (!mAlwaysSeeking) {
// Take the starting speed limit from the transcription toolbar,
// but it may be varied during the scrub.
mMaxScrubSpeed = options.maxScrubSpeed =
p->GetTranscriptionToolBar()->GetPlaySpeed();
}
#else
// That idea seems unpopular... just make it one
mMaxScrubSpeed = options.maxScrubSpeed = 1.0;
@ -488,7 +487,7 @@ void ScrubbingOverlay::OnTimer(wxCommandEvent &event)
::wxGetMousePosition(&xx, &yy);
trackPanel->ScreenToClient(&xx, &yy);
const bool seeking = PollIsSeeking();
const bool seeking = scrubber.PollIsSeeking();
// Find the text
const double maxScrubSpeed = GetScrubber().GetMaxScrubSpeed();
@ -543,4 +542,10 @@ Scrubber &ScrubbingOverlay::GetScrubber()
{
return mProject->GetScrubber();
}
bool Scrubber::PollIsSeeking()
{
return mAlwaysSeeking || ::wxGetMouseState().LeftIsDown();
}
#endif

View File

@ -31,6 +31,8 @@ public:
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, bool smoothScrolling
#endif
, bool alwaysSeeking // if false, can switch seeking or scrubbing
// by mouse button state
);
// Returns true iff the event should be considered consumed by this:
bool MaybeStartScrubbing(const wxMouseEvent &event);
@ -55,6 +57,10 @@ public:
void HandleScrollWheel(int steps);
void SetSeeking() { mScrubSeekPress = true; }
bool PollIsSeeking();
private:
void OnActivateOrDeactivateApp(wxActivateEvent & event);
private:
int mScrubToken;
@ -65,14 +71,12 @@ private:
double mMaxScrubSpeed;
bool mScrubSeekPress;
bool mSmoothScrollingScrub;
bool mAlwaysSeeking{};
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
int mLogMaxScrubSpeed;
#endif
private:
void OnActivateOrDeactivateApp(wxActivateEvent & event);
AudacityProject *mProject;
};