From 0bed89419f254f15a04cb242e43b8117b29a2190 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 8 Jun 2015 09:50:43 -0400 Subject: [PATCH] More for bug 1014: stop scrubbing when switching out of select tool... ... Verified that this works for presses on tool buttons, and keys A, D, F1, ..., F6. Also fix conditional compilation with EXPERIMENTAL_SCRUBBING_BASIC not defined. --- src/Experimental.h | 16 ++++++++-------- src/TrackPanel.cpp | 10 ++++++++-- src/TrackPanel.h | 2 ++ src/toolbars/ToolsToolBar.cpp | 29 ++++++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/Experimental.h b/src/Experimental.h index cbdefb7bd..3f271f1f2 100644 --- a/src/Experimental.h +++ b/src/Experimental.h @@ -172,14 +172,14 @@ // Paul Licameli (PRL) 16 Apr 2015 // Support for scrubbing in the AudioIO engine, without calls to it #define EXPERIMENTAL_SCRUBBING_SUPPORT - -// The following enable parts of the scrubbing user interface. -// You must define EXPERIMENTAL_SCRUBBING_SUPPORT if you enable this: -#define EXPERIMENTAL_SCRUBBING_BASIC -// You must define EXPERIMENTAL_SCRUBBING_BASIC if you enable this: -#define EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL -// You must define EXPERIMENTAL_SCRUBBING_BASIC if you enable this: -#define EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL +#ifdef EXPERIMENTAL_SCRUBBING_SUPPORT + // The following enable parts of the scrubbing user interface. + #define EXPERIMENTAL_SCRUBBING_BASIC + #ifdef EXPERIMENTAL_SCRUBBING_BASIC + #define EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL + #define EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL + #endif +#endif // Paul Licameli (PRL) 24 May 2015 // Allow scrolling up to one half of a screenful beyond either end of the project, diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 209eff2ff..8ae4f3712 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1952,9 +1952,13 @@ void TrackPanel::SetCursorAndTipWhenSelectTool( Track * t, // choose boundaries only in snapping tolerance, // and may choose center. // But don't change the cursor when scrubbing. - SelectionBoundary boundary = IsScrubbing() + SelectionBoundary boundary = +#ifdef EXPERIMENTAL_SCRUBBING_BASIC + IsScrubbing() ? SBNone - : ChooseBoundary(event, t, r, !bShiftDown, !bShiftDown); + : +#endif + ChooseBoundary(event, t, r, !bShiftDown, !bShiftDown); #ifdef USE_MIDI // The MIDI HitTest will only succeed if we are on a midi track, so @@ -6852,6 +6856,7 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event) return; } +#ifdef EXPERIMENTAL_SCRUBBING_BASIC if ((!pTrack || pTrack->GetKind() == Track::Wave) && IsScrubbing()) { @@ -6862,6 +6867,7 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event) else if (event.LeftIsDown()) return; } +#endif if (pTrack && (pTrack->GetKind() == Track::Wave) && (mMouseCapture == IsUncaptured || mMouseCapture == IsOverCutLine || diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 3b7510f24..80800b03c 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -316,7 +316,9 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel { ); bool MaybeStartScrubbing(wxMouseEvent &event); bool ContinueScrubbing(wxCoord position, bool hasFocus, bool seek); +public: bool StopScrubbing(); +protected: #endif virtual void SelectionHandleClick(wxMouseEvent &event, diff --git a/src/toolbars/ToolsToolBar.cpp b/src/toolbars/ToolsToolBar.cpp index e3d3998c9..a25276e71 100644 --- a/src/toolbars/ToolsToolBar.cpp +++ b/src/toolbars/ToolsToolBar.cpp @@ -33,6 +33,7 @@ #include "../Audacity.h" +#include "ToolsToolBar.h" // For compilers that support precompilation, includes "wx/wx.h". #include @@ -46,12 +47,14 @@ #include #include "MeterToolBar.h" -#include "ToolsToolBar.h" #include "../Prefs.h" #include "../AllThemeResources.h" #include "../ImageManipulation.h" #include "../Project.h" +#ifdef EXPERIMENTAL_SCRUBBING_BASIC +#include "../TrackPanel.h" +#endif #include "../Theme.h" #include "../widgets/AButton.h" @@ -215,6 +218,18 @@ void ToolsToolBar::SetCurrentTool(int tool, bool show) //In multi-mode the current tool is shown by the //cursor icon. The buttons are not updated. +#ifdef EXPERIMENTAL_SCRUBBING_BASIC + if (tool != selectTool) { + AudacityProject *p = GetActiveProject(); + if (p) { + TrackPanel *tp = p->GetTrackPanel(); + if (tp) { + tp->StopScrubbing(); + } + } + } +#endif + bool leavingMulticlipMode = IsDown(multiTool) && show && tool != multiTool; @@ -278,6 +293,18 @@ void ToolsToolBar::OnTool(wxCommandEvent & evt) else mTool[i]->PopUp(); +#ifdef EXPERIMENTAL_SCRUBBING_BASIC + if (0 != mCurrentTool) { + AudacityProject *p = GetActiveProject(); + if (p) { + TrackPanel *tp = p->GetTrackPanel(); + if (tp) { + tp->StopScrubbing(); + } + } + } +#endif + RedrawAllProjects(); gPrefs->Write(wxT("/GUI/ToolBars/Tools/MultiToolActive"),