1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 17:14:07 +01:00

Scrubbing phase 2. Scrub starts with click on the indicator in the ruler...

... and works in any of the six tools.

Click and drag in select tool during scrub works just as when not scrubbing.

Seeks now only if you left-click or drag in the ruler, but this may change.

Mouse motion anywhere on the screen controls scrub as before.

No mouse clicks in TrackPanel are used by scrubbing.

The Ctrl-Click in TrackPanel is now unused.  Should 2.1.0 behavior be restored?
That was click to quick play, redundant with click in the (lower part of) the
ruler.
This commit is contained in:
Paul Licameli
2016-04-24 19:02:13 -04:00
parent 4deb90c633
commit cd57e0a26c
6 changed files with 154 additions and 136 deletions

View File

@@ -180,7 +180,7 @@ namespace {
}
void Scrubber::MarkScrubStart(
const wxMouseEvent &event
wxCoord xx
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, bool smoothScrolling
#endif
@@ -189,8 +189,6 @@ void Scrubber::MarkScrubStart(
{
UncheckAllMenuItems();
const wxCoord xx = event.m_x;
// Don't actually start scrubbing, but collect some information
// needed for the decision to start scrubbing later when handling
// drag events.
@@ -204,7 +202,6 @@ void Scrubber::MarkScrubStart(
ControlToolBar * const ctb = mProject->GetControlToolBar();
ctb->SetPlay(true, ControlToolBar::PlayAppearance::Scrub);
ctb->UpdateStatusBar(mProject);
mProject->GetTrackPanel()->HandleCursor(event);
CheckMenuItem();
}
@@ -299,9 +296,11 @@ void Scrubber::ContinueScrubbing()
// Seek only when the pointer is in the panel. Else, scrub.
const wxMouseState state(::wxGetMouseState());
TrackPanel *const trackPanel = mProject->GetTrackPanel();
const wxPoint position = trackPanel->ScreenToClient(state.GetPosition());
const bool inPanel = trackPanel->GetRect().Contains(position);
const bool seek = inPanel && (mScrubSeekPress || PollIsSeeking());
// Decide whether to skip play, because either mouse is down now,
// or there was a left click event. (This is then a delayed reaction, in a
// timer callback, to a left click event detected elsewhere.)
const bool seek = PollIsSeeking() || mScrubSeekPress;
{
// Show the correct status for seeking.
@@ -312,6 +311,7 @@ void Scrubber::ContinueScrubbing()
mAlwaysSeeking = backup;
}
const wxPoint position = trackPanel->ScreenToClient(state.GetPosition());
// When we don't have focus, enqueue silent scrubs until we regain focus.
bool result = false;
if (!mScrubHasFocus)
@@ -615,9 +615,7 @@ void Scrubber::DoScrub(bool scroll, bool seek)
if (!wasScrubbing) {
auto tp = mProject->GetTrackPanel();
wxCoord xx = tp->ScreenToClient(::wxGetMouseState().GetPosition()).x;
wxMouseEvent evt;
evt.SetX(xx);
MarkScrubStart(evt, scroll, seek);
MarkScrubStart(xx, scroll, seek);
}
else if(!match) {
mSmoothScrollingScrub = scroll;
@@ -677,6 +675,12 @@ std::vector<wxString> Scrubber::GetAllUntranslatedStatusStrings()
return move(results);
}
bool Scrubber::CanScrub() const
{
auto cm = mProject->GetCommandManager();
return cm->GetEnabled(menuItems[0].name);
}
void Scrubber::AddMenuItems()
{
auto cm = mProject->GetCommandManager();

View File

@@ -28,7 +28,7 @@ public:
~Scrubber();
void MarkScrubStart(
const wxMouseEvent &event
wxCoord xx
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, bool smoothScrolling
#endif
@@ -52,6 +52,8 @@ public:
bool IsScrubbing() const;
bool IsScrollScrubbing() const // If true, implies HasStartedScrubbing()
{ return mSmoothScrollingScrub; }
bool IsAlwaysSeeking() const
{ return mAlwaysSeeking; }
bool ShouldDrawScrubSpeed();
double FindScrubSpeed(bool seeking, double time) const;
@@ -62,6 +64,8 @@ public:
void SetSeeking() { mScrubSeekPress = true; }
bool PollIsSeeking();
// This returns the same as the enabled state of the menu items:
bool CanScrub() const;
void AddMenuItems();
void OnScrub();