1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +02:00

Merge: Bug989, and scrub UI uses left button to seek, not Shift key

Reverted "Bug990 (seek key reponsiveness), and, change Scrub UI again, so Ctrl key seeks."
This commit is contained in:
Paul Licameli 2015-05-29 20:35:14 -04:00
commit 74bcf3221a
4 changed files with 38 additions and 44 deletions

View File

@ -608,7 +608,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
mMaxScrubSpeed = 1.0; mMaxScrubSpeed = 1.0;
mScrubSpeedDisplayCountdown = 0; mScrubSpeedDisplayCountdown = 0;
mScrubHasFocus = false; mScrubHasFocus = false;
mScrubSeekKeypress = false; mScrubSeekPress = false;
#endif #endif
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
@ -1037,18 +1037,17 @@ void TrackPanel::OnTimer()
// Thus scrubbing relies mostly on periodic polling of mouse and keys, // Thus scrubbing relies mostly on periodic polling of mouse and keys,
// not event notifications. But there are a few event handlers that // not event notifications. But there are a few event handlers that
// leave messages for this routine, in mScrubSeekKeypress and in mScrubHasFocus. // leave messages for this routine, in mScrubSeekPress and in mScrubHasFocus.
if (IsScrubbing()) if (IsScrubbing())
{ {
wxCoord position = ::wxGetMouseState().GetX(); wxMouseState state(::wxGetMouseState());
// Detect key state here, or use the record of key transition wxCoord position = state.GetX();
// made elsewhere. const bool seek = mScrubSeekPress || state.LeftIsDown();
const bool seek = mScrubSeekKeypress || IsScrubSeekKeyDown();
ScreenToClient(&position, NULL); ScreenToClient(&position, NULL);
if (ContinueScrubbing(position, mScrubHasFocus, seek)) if (ContinueScrubbing(position, mScrubHasFocus, seek))
// Successfully enqueued one stutter mScrubSeekPress = false;
mScrubSeekKeypress = false; // else, if seek requested, try again at a later time when we might
// else if seeking, try again at the next round. // enqueue a long enough stutter
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
if (mSmoothScrollingScrub) if (mSmoothScrollingScrub)
@ -1637,14 +1636,6 @@ void TrackPanel::HandleShiftKey(bool down)
void TrackPanel::HandleControlKey(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; mLastMouseEvent.m_controlDown = down;
HandleCursorForLastMouseEvent(); HandleCursorForLastMouseEvent();
} }
@ -2323,11 +2314,6 @@ double TrackPanel::FindScrubSpeed(double timeAtMouse) const
#endif #endif
#ifdef EXPERIMENTAL_SCRUBBING_BASIC #ifdef EXPERIMENTAL_SCRUBBING_BASIC
bool TrackPanel::IsScrubSeekKeyDown()
{
return ::wxGetMouseState().CmdDown();
}
bool TrackPanel::IsScrubbing() bool TrackPanel::IsScrubbing()
{ {
if (mScrubToken <= 0) if (mScrubToken <= 0)
@ -2344,25 +2330,21 @@ bool TrackPanel::IsScrubbing()
} }
} }
void TrackPanel::ToggleScrubbing( void TrackPanel::MarkScrubStart(
wxCoord xx wxCoord xx
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, bool smoothScrolling , bool smoothScrolling
#endif #endif
) )
{ {
if (IsScrubbing()) // Don't actually start scrubbing, but collect some information
StopScrubbing(); // needed for the decision to start scrubbing later when handling
else { // 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 #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
mSmoothScrollingScrub = smoothScrolling; mSmoothScrollingScrub = smoothScrolling;
#endif #endif
mScrubStartPosition = xx; mScrubStartPosition = xx;
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis(); mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
}
} }
bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event) bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event)
@ -2605,7 +2587,7 @@ void TrackPanel::SelectionHandleClick(wxMouseEvent & event,
event.LeftDClick() || event.LeftDClick() ||
#endif #endif
event.LeftDown()) { event.LeftDown()) {
ToggleScrubbing( MarkScrubStart(
event.m_x event.m_x
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, event.LeftDClick() , event.LeftDClick()
@ -6877,6 +6859,17 @@ void TrackPanel::HandleTrackSpecificMouseEvent(wxMouseEvent & event)
return; 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) && if (pTrack && (pTrack->GetKind() == Track::Wave) &&
(mMouseCapture == IsUncaptured || mMouseCapture == IsOverCutLine || (mMouseCapture == IsUncaptured || mMouseCapture == IsOverCutLine ||
mMouseCapture == WasOverCutLine)) mMouseCapture == WasOverCutLine))
@ -7397,7 +7390,7 @@ void TrackPanel::DrawScrubSpeed(wxDC &dc)
return; return;
// Don't draw it during stutter play with shift down // Don't draw it during stutter play with shift down
if (!IsScrubSeekKeyDown() && ( if (!::wxGetMouseState().ShiftDown() && (
mScrubSpeedDisplayCountdown > 0 mScrubSpeedDisplayCountdown > 0

View File

@ -305,9 +305,8 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
#endif #endif
#ifdef EXPERIMENTAL_SCRUBBING_BASIC #ifdef EXPERIMENTAL_SCRUBBING_BASIC
static bool IsScrubSeekKeyDown();
bool IsScrubbing(); bool IsScrubbing();
void ToggleScrubbing( void MarkScrubStart(
wxCoord xx wxCoord xx
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
, bool smoothScrolling , bool smoothScrolling
@ -782,8 +781,8 @@ protected:
wxCoord mScrubStartPosition; wxCoord mScrubStartPosition;
double mMaxScrubSpeed; double mMaxScrubSpeed;
int mScrubSpeedDisplayCountdown; int mScrubSpeedDisplayCountdown;
bool mScrubHasFocus; // To do: rely on wxWindow::HasFocus() instead, wx verions 2.9.0+ bool mScrubHasFocus;
bool mScrubSeekKeypress; bool mScrubSeekPress;
#endif #endif
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL

View File

@ -105,11 +105,13 @@ void MousePrefs::CreateList()
AddItem(_("Shift-Left-Click"), _("Select"), _("Extend Selection Range")); AddItem(_("Shift-Left-Click"), _("Select"), _("Extend Selection Range"));
AddItem(_("Left-Double-Click"), _("Select"), _("Select Clip or Entire Track")); AddItem(_("Left-Double-Click"), _("Select"), _("Select Clip or Entire Track"));
#ifdef EXPERIMENTAL_SCRUBBING_BASIC #ifdef EXPERIMENTAL_SCRUBBING_BASIC
AddItem(_("Ctrl-Left-Click"), _("Select"), _("Scrub")); AddItem(_("Ctrl-Left-Click"), _("Select"), _("Scrub"));
AddItem(_("Ctrl"), _("Select"), _("Seek (while scrubbing)")); AddItem(_("Ctrl-Left-Drag"), _("Select"), _("Seek"));
#endif #endif
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL #ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
AddItem(_("Ctrl-Left-Double-Click"), _("Select"), _("Scroll-Scrub")); AddItem(_("Ctrl-Left-Double-Click"), _("Select"), _("Scroll-scrub"));
#endif
#ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
AddItem(_("Wheel-Rotate"), _("Select"), _("Change scrub speed")); AddItem(_("Wheel-Rotate"), _("Select"), _("Change scrub speed"));
#endif #endif

View File

@ -85,9 +85,9 @@ ToolsToolBar::ToolsToolBar()
mMessageOfTool[selectTool] = mMessageOfTool[selectTool] =
#if defined(__WXMAC__) #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 to scrub, Command-Double-Click to scroll-scrub, Command-drag to seek")
#else #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 to scrub, Ctrl-Double-Click to scroll-scrub, Ctrl-drag to seek")
#endif #endif
; ;