From 9f2dfbc70b55cabe7acedc87a09aae5ccff522da Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 29 May 2015 19:45:43 -0400 Subject: [PATCH 1/2] Revert "Bug990 (seek key reponsiveness), and, change Scrub UI again, so Ctrl key seeks." This reverts commit 841bca36ea321e6ea92578dd6668bc4011f1d30b. --- src/TrackPanel.cpp | 35 ++++++----------------------------- src/TrackPanel.h | 6 ++---- src/prefs/MousePrefs.cpp | 6 +++--- src/toolbars/ToolsToolBar.cpp | 4 ++-- 4 files changed, 13 insertions(+), 38 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 047fa5b41..7cc9ea37a 100755 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -608,7 +608,6 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, mMaxScrubSpeed = 1.0; mScrubSpeedDisplayCountdown = 0; mScrubHasFocus = false; - mScrubSeekKeypress = false; #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL @@ -1034,21 +1033,12 @@ void TrackPanel::OnTimer() // Call ContinueScrubbing() here rather than in SelectionHandleDrag() // so that even without drag events, we can instruct the play head to // keep approaching the mouse cursor, when its maximum speed is limited. - - // Thus scrubbing relies mostly on periodic polling of mouse and keys, - // not event notifications. But there are a few event handlers that - // leave messages for this routine, in mScrubSeekKeypress and in mScrubHasFocus. if (IsScrubbing()) { - wxCoord position = ::wxGetMouseState().GetX(); - // Detect key state here, or use the record of key transition - // made elsewhere. - const bool seek = mScrubSeekKeypress || IsScrubSeekKeyDown(); + wxMouseState state = ::wxGetMouseState(); + wxCoord position = state.GetX(); ScreenToClient(&position, NULL); - if (ContinueScrubbing(position, mScrubHasFocus, seek)) - // Successfully enqueued one stutter - mScrubSeekKeypress = false; - // else if seeking, try again at the next round. + ContinueScrubbing(position, state.ShiftDown()); #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL if (mSmoothScrollingScrub) @@ -1637,14 +1627,6 @@ void TrackPanel::HandleShiftKey(bool down) void TrackPanel::HandleControlKey(bool down) { -#ifdef EXPERIMENTAL_SCRUBBING_BASIC - // Scrubbing is mostly not event driven, it uses periodic polling and tests - // key state. But it might otherwise miss a fast keypress and release, - // so this is not redundant: - if (down && IsScrubbing()) - mScrubSeekKeypress = true; -#endif - mLastMouseEvent.m_controlDown = down; HandleCursorForLastMouseEvent(); } @@ -2323,11 +2305,6 @@ double TrackPanel::FindScrubSpeed(double timeAtMouse) const #endif #ifdef EXPERIMENTAL_SCRUBBING_BASIC -bool TrackPanel::IsScrubSeekKeyDown() -{ - return ::wxGetMouseState().CmdDown(); -} - bool TrackPanel::IsScrubbing() { if (mScrubToken <= 0) @@ -2434,10 +2411,10 @@ bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event) return false; } -bool TrackPanel::ContinueScrubbing(wxCoord position, bool hasFocus, bool maySkip) +bool TrackPanel::ContinueScrubbing(wxCoord position, bool maySkip) { // When we don't have focus, enqueue silent scrubs until we regain focus. - if (!hasFocus) + if (!mScrubHasFocus) return gAudioIO->EnqueueScrubBySignedSpeed(0, mMaxScrubSpeed, maySkip); const double newEnd = PositionToTime(position, GetLeftOffset()); @@ -7397,7 +7374,7 @@ void TrackPanel::DrawScrubSpeed(wxDC &dc) return; // Don't draw it during stutter play with shift down - if (!IsScrubSeekKeyDown() && ( + if (!::wxGetMouseState().ShiftDown() && ( mScrubSpeedDisplayCountdown > 0 diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 278856b21..6de1bc21c 100755 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -305,7 +305,6 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel { #endif #ifdef EXPERIMENTAL_SCRUBBING_BASIC - static bool IsScrubSeekKeyDown(); bool IsScrubbing(); void ToggleScrubbing( wxCoord xx @@ -314,7 +313,7 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel { #endif ); bool MaybeStartScrubbing(wxMouseEvent &event); - bool ContinueScrubbing(wxCoord position, bool hasFocus, bool maySkip); + bool ContinueScrubbing(wxCoord position, bool maySkip); bool StopScrubbing(); #endif @@ -782,8 +781,7 @@ protected: wxCoord mScrubStartPosition; double mMaxScrubSpeed; int mScrubSpeedDisplayCountdown; - bool mScrubHasFocus; // To do: rely on wxWindow::HasFocus() instead, wx verions 2.9.0+ - bool mScrubSeekKeypress; + bool mScrubHasFocus; #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL diff --git a/src/prefs/MousePrefs.cpp b/src/prefs/MousePrefs.cpp index fd8668e45..56f9085ff 100644 --- a/src/prefs/MousePrefs.cpp +++ b/src/prefs/MousePrefs.cpp @@ -105,11 +105,11 @@ void MousePrefs::CreateList() AddItem(_("Shift-Left-Click"), _("Select"), _("Extend Selection Range")); AddItem(_("Left-Double-Click"), _("Select"), _("Select Clip or Entire Track")); #ifdef EXPERIMENTAL_SCRUBBING_BASIC - AddItem(_("Ctrl-Left-Click"), _("Select"), _("Scrub")); - AddItem(_("Ctrl"), _("Select"), _("Seek (while scrubbing)")); + AddItem(_("Ctrl-Left-Click"), _("Select"), _("Scrub")); + AddItem(_("Shift-Ctrl-Left-Click"), _("Select"), _("Seek")); #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL - AddItem(_("Ctrl-Left-Double-Click"), _("Select"), _("Scroll-Scrub")); + AddItem(_("Ctrl-Left-Double-Click"), _("Select"), _("Smooth Scrolling Scrub")); AddItem(_("Wheel-Rotate"), _("Select"), _("Change scrub speed")); #endif diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index 2ae8dfb27..8a48f8a45 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -85,9 +85,9 @@ ToolsToolBar::ToolsToolBar() mMessageOfTool[selectTool] = #if defined(__WXMAC__) - _("Click and drag to select audio, Command-Click to scrub, Command-Double-Click to scroll-scrub, Command to seek while scrubbing") + _("Click and drag to select audio, Command-Click and drag to scrub, Shift-Command-Click and drag to seek") #else - _("Click and drag to select audio, Ctrl-Click to scrub, Ctrl-Double-Click to scroll-scrub, Ctrl to seek while scrubbing") + _("Click and drag to select audio, Ctrl-Click and drag to scrub, Shift-Ctrl-Click and drag to seek") #endif ; From 8d2a29d376594690b3a625341b7c840828b49551 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 29 May 2015 20:13:42 -0400 Subject: [PATCH 2/2] Bug989, and scrub UI uses left button to seek, not Shift key Updated mouse preferences and status bar message accordingly Also, use the term "Scroll-scrub" in status bar and mouse preferences --- src/TrackPanel.cpp | 48 +++++++++++++++++++++++------------ src/TrackPanel.h | 5 ++-- src/prefs/MousePrefs.cpp | 8 +++--- src/toolbars/ToolsToolBar.cpp | 4 +-- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 7cc9ea37a..0f70d8072 100755 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -608,6 +608,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id, mMaxScrubSpeed = 1.0; mScrubSpeedDisplayCountdown = 0; mScrubHasFocus = false; + mScrubSeekPress = false; #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL @@ -1033,12 +1034,20 @@ void TrackPanel::OnTimer() // Call ContinueScrubbing() here rather than in SelectionHandleDrag() // so that even without drag events, we can instruct the play head to // keep approaching the mouse cursor, when its maximum speed is limited. + + // Thus scrubbing relies mostly on periodic polling of mouse and keys, + // not event notifications. But there are a few event handlers that + // leave messages for this routine, in mScrubSeekPress and in mScrubHasFocus. if (IsScrubbing()) { - wxMouseState state = ::wxGetMouseState(); + wxMouseState state(::wxGetMouseState()); wxCoord position = state.GetX(); + const bool seek = mScrubSeekPress || state.LeftIsDown(); ScreenToClient(&position, NULL); - ContinueScrubbing(position, state.ShiftDown()); + if (ContinueScrubbing(position, mScrubHasFocus, seek)) + mScrubSeekPress = false; + // else, if seek requested, try again at a later time when we might + // enqueue a long enough stutter #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL if (mSmoothScrollingScrub) @@ -2321,25 +2330,21 @@ bool TrackPanel::IsScrubbing() } } -void TrackPanel::ToggleScrubbing( +void TrackPanel::MarkScrubStart( wxCoord xx #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL , bool smoothScrolling #endif ) { - if (IsScrubbing()) - StopScrubbing(); - else { - // Don't actually start scrubbing, but collect some information - // needed for the decision to start scrubbing later when handling - // drag events. + // Don't actually start scrubbing, but collect some information + // needed for the decision to start scrubbing later when handling + // drag events. #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL - mSmoothScrollingScrub = smoothScrolling; + mSmoothScrollingScrub = smoothScrolling; #endif - mScrubStartPosition = xx; - mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis(); - } + mScrubStartPosition = xx; + mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis(); } bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event) @@ -2411,10 +2416,10 @@ bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event) return false; } -bool TrackPanel::ContinueScrubbing(wxCoord position, bool maySkip) +bool TrackPanel::ContinueScrubbing(wxCoord position, bool hasFocus, bool maySkip) { // When we don't have focus, enqueue silent scrubs until we regain focus. - if (!mScrubHasFocus) + if (!hasFocus) return gAudioIO->EnqueueScrubBySignedSpeed(0, mMaxScrubSpeed, maySkip); const double newEnd = PositionToTime(position, GetLeftOffset()); @@ -2582,7 +2587,7 @@ void TrackPanel::SelectionHandleClick(wxMouseEvent & event, event.LeftDClick() || #endif event.LeftDown()) { - ToggleScrubbing( + MarkScrubStart( event.m_x #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL , event.LeftDClick() @@ -6854,6 +6859,17 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event) return; } + if ((!pTrack || + pTrack->GetKind() == Track::Wave) && + IsScrubbing()) { + if (event.LeftDown()) { + mScrubSeekPress = true; + return; + } + else if (event.LeftIsDown()) + return; + } + if (pTrack && (pTrack->GetKind() == Track::Wave) && (mMouseCapture == IsUncaptured || mMouseCapture == IsOverCutLine || mMouseCapture == WasOverCutLine)) diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 6de1bc21c..41b951cb1 100755 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -306,14 +306,14 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel { #ifdef EXPERIMENTAL_SCRUBBING_BASIC bool IsScrubbing(); - void ToggleScrubbing( + void MarkScrubStart( wxCoord xx #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL , bool smoothScrolling #endif ); bool MaybeStartScrubbing(wxMouseEvent &event); - bool ContinueScrubbing(wxCoord position, bool maySkip); + bool ContinueScrubbing(wxCoord position, bool hasFocus, bool maySkip); bool StopScrubbing(); #endif @@ -782,6 +782,7 @@ protected: double mMaxScrubSpeed; int mScrubSpeedDisplayCountdown; bool mScrubHasFocus; + bool mScrubSeekPress; #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL diff --git a/src/prefs/MousePrefs.cpp b/src/prefs/MousePrefs.cpp index 56f9085ff..4618ddf39 100644 --- a/src/prefs/MousePrefs.cpp +++ b/src/prefs/MousePrefs.cpp @@ -105,11 +105,13 @@ void MousePrefs::CreateList() AddItem(_("Shift-Left-Click"), _("Select"), _("Extend Selection Range")); AddItem(_("Left-Double-Click"), _("Select"), _("Select Clip or Entire Track")); #ifdef EXPERIMENTAL_SCRUBBING_BASIC - AddItem(_("Ctrl-Left-Click"), _("Select"), _("Scrub")); - AddItem(_("Shift-Ctrl-Left-Click"), _("Select"), _("Seek")); + AddItem(_("Ctrl-Left-Click"), _("Select"), _("Scrub")); + AddItem(_("Ctrl-Left-Drag"), _("Select"), _("Seek")); #endif #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL - AddItem(_("Ctrl-Left-Double-Click"), _("Select"), _("Smooth Scrolling Scrub")); + AddItem(_("Ctrl-Left-Double-Click"), _("Select"), _("Scroll-scrub")); +#endif +#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL AddItem(_("Wheel-Rotate"), _("Select"), _("Change scrub speed")); #endif diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index 8a48f8a45..e3d3998c9 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -85,9 +85,9 @@ ToolsToolBar::ToolsToolBar() mMessageOfTool[selectTool] = #if defined(__WXMAC__) - _("Click and drag to select audio, Command-Click and drag to scrub, Shift-Command-Click and drag to seek") + _("Click and drag to select audio, Command-Click to scrub, Command-Double-Click to scroll-scrub, Command-drag to seek") #else - _("Click and drag to select audio, Ctrl-Click and drag to scrub, Shift-Ctrl-Click and drag to seek") + _("Click and drag to select audio, Ctrl-Click to scrub, Ctrl-Double-Click to scroll-scrub, Ctrl-drag to seek") #endif ;