mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 14:48:39 +02:00
Merge: Scrub with ctrl-left clicks, not middle drags; also fix bug 937
This commit is contained in:
commit
f7df5d2a02
@ -604,7 +604,7 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
|
|||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
mScrubToken = -1;
|
mScrubToken = -1;
|
||||||
mScrubStartClockTimeMillis = -1;
|
mScrubStartClockTimeMillis = -1;
|
||||||
mScrubStartPosition = 0;
|
mScrubStartPosition = -1;
|
||||||
mMaxScrubSpeed = 1.0;
|
mMaxScrubSpeed = 1.0;
|
||||||
mScrubSpeedDisplayCountdown = 0;
|
mScrubSpeedDisplayCountdown = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -2128,30 +2128,10 @@ void TrackPanel::HandleSelect(wxMouseEvent & event)
|
|||||||
wxRect r;
|
wxRect r;
|
||||||
Track *t = FindTrack(event.m_x, event.m_y, false, false, &r);
|
Track *t = FindTrack(event.m_x, event.m_y, false, false, &r);
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
|
||||||
if (
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
|
||||||
event.MiddleDClick() ||
|
|
||||||
#endif
|
|
||||||
event.MiddleDown()) {
|
|
||||||
if (IsScrubbing())
|
|
||||||
StopScrubbing();
|
|
||||||
// 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 = event.MiddleDClick();
|
|
||||||
#endif
|
|
||||||
mScrubStartPosition = event.m_x;
|
|
||||||
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
|
|
||||||
mMouseCapture = IsSelecting;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// AS: Ok, did the user just click the mouse, release the mouse,
|
// AS: Ok, did the user just click the mouse, release the mouse,
|
||||||
// or drag?
|
// or drag?
|
||||||
if (event.LeftDown()) {
|
if (event.LeftDown() ||
|
||||||
|
(event.LeftDClick() && event.CmdDown())) {
|
||||||
// AS: Now, did they click in a track somewhere? If so, we want
|
// AS: Now, did they click in a track somewhere? If so, we want
|
||||||
// to extend the current selection or start a new selection,
|
// to extend the current selection or start a new selection,
|
||||||
// depending on the shift key. If not, cancel all selections.
|
// depending on the shift key. If not, cancel all selections.
|
||||||
@ -2179,7 +2159,11 @@ void TrackPanel::HandleSelect(wxMouseEvent & event)
|
|||||||
mFreqSelMode = FREQ_SEL_INVALID;
|
mFreqSelMode = FREQ_SEL_INVALID;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} else if (event.LeftDClick() && !event.ShiftDown()) {
|
} else if (event.LeftDClick() && !event.ShiftDown()
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
|
&& !event.CmdDown()
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
if (!mCapturedTrack) {
|
if (!mCapturedTrack) {
|
||||||
wxRect r;
|
wxRect r;
|
||||||
mCapturedTrack =
|
mCapturedTrack =
|
||||||
@ -2241,6 +2225,8 @@ void TrackPanel::HandleSelect(wxMouseEvent & event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Made obsolete by scrubbing:
|
||||||
|
#ifndef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
void TrackPanel::StartOrJumpPlayback(wxMouseEvent &event)
|
void TrackPanel::StartOrJumpPlayback(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
AudacityProject *p = GetActiveProject();
|
AudacityProject *p = GetActiveProject();
|
||||||
@ -2276,23 +2262,9 @@ void TrackPanel::StartOrJumpPlayback(wxMouseEvent &event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
|
||||||
bool TrackPanel::IsScrubbing()
|
|
||||||
{
|
|
||||||
if (mScrubToken <= 0)
|
|
||||||
return false;
|
|
||||||
else if (mScrubToken == GetProject()->GetAudioIOToken())
|
|
||||||
return true;
|
|
||||||
else {
|
|
||||||
// Some other command might have stopped scrub play before we
|
|
||||||
// reached StopScrubbing()! But that is okay.
|
|
||||||
mScrubToken = -1;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
double TrackPanel::FindScrubSpeed(double timeAtMouse) const
|
double TrackPanel::FindScrubSpeed(double timeAtMouse) const
|
||||||
{
|
{
|
||||||
@ -2335,12 +2307,48 @@ double TrackPanel::FindScrubSpeed(double timeAtMouse) const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
|
bool TrackPanel::IsScrubbing()
|
||||||
|
{
|
||||||
|
if (mScrubToken <= 0)
|
||||||
|
return false;
|
||||||
|
else if (mScrubToken == GetProject()->GetAudioIOToken())
|
||||||
|
return true;
|
||||||
|
else {
|
||||||
|
// Some other command might have stopped scrub play before we
|
||||||
|
// reached StopScrubbing()! But that is okay.
|
||||||
|
mScrubToken = -1;
|
||||||
|
mScrubStartPosition = -1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TrackPanel::ToggleScrubbing(
|
||||||
|
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.
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
|
mSmoothScrollingScrub = smoothScrolling;
|
||||||
|
#endif
|
||||||
|
mScrubStartPosition = xx;
|
||||||
|
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event)
|
bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
if (IsScrubbing())
|
if (IsScrubbing())
|
||||||
return false;
|
return false;
|
||||||
else
|
else if (mScrubStartPosition >= 0) {
|
||||||
{
|
|
||||||
const bool busy = gAudioIO->IsBusy();
|
const bool busy = gAudioIO->IsBusy();
|
||||||
if (busy && gAudioIO->GetNumCaptureChannels() > 0)
|
if (busy && gAudioIO->GetNumCaptureChannels() > 0)
|
||||||
// Do not stop recording
|
// Do not stop recording
|
||||||
@ -2354,8 +2362,7 @@ bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event)
|
|||||||
double maxTime = p->GetTracks()->GetEndTime();
|
double maxTime = p->GetTracks()->GetEndTime();
|
||||||
double time0 = std::min(maxTime, PositionToTime(mScrubStartPosition, GetLeftOffset()));
|
double time0 = std::min(maxTime, PositionToTime(mScrubStartPosition, GetLeftOffset()));
|
||||||
double time1 = std::min(maxTime, PositionToTime(position, GetLeftOffset()));
|
double time1 = std::min(maxTime, PositionToTime(position, GetLeftOffset()));
|
||||||
if (time1 != time0)
|
if (time1 != time0) {
|
||||||
{
|
|
||||||
if (busy)
|
if (busy)
|
||||||
ctb->StopPlaying();
|
ctb->StopPlaying();
|
||||||
|
|
||||||
@ -2383,13 +2390,17 @@ bool TrackPanel::MaybeStartScrubbing(wxMouseEvent &event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
// Wait to test again
|
||||||
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
|
mScrubStartClockTimeMillis = ::wxGetLocalTimeMillis();
|
||||||
|
|
||||||
if (IsScrubbing()) {
|
if (IsScrubbing()) {
|
||||||
mMouseCapture = IsMiddleButtonScrubbing;
|
//mMouseCapture = IsMiddleButtonScrubbing;
|
||||||
CaptureMouse();
|
//CaptureMouse();
|
||||||
}
|
}
|
||||||
return IsScrubbing();
|
return IsScrubbing();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackPanel::ContinueScrubbing(wxCoord position, bool maySkip)
|
bool TrackPanel::ContinueScrubbing(wxCoord position, bool maySkip)
|
||||||
@ -2424,6 +2435,7 @@ bool TrackPanel::StopScrubbing()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mScrubToken = -1;
|
mScrubToken = -1;
|
||||||
|
mScrubStartPosition = -1;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
mSmoothScrollingScrub = false;
|
mSmoothScrollingScrub = false;
|
||||||
@ -2554,22 +2566,37 @@ void TrackPanel::SelectionHandleClick(wxMouseEvent & event,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Redundant now that we have a more comprehensive Quick-Play in the Timeline
|
|
||||||
// A control-click will set just the indicator to the clicked spot,
|
|
||||||
// and turn playback on.
|
|
||||||
else if(event.CmdDown()
|
else if(event.CmdDown()
|
||||||
#ifdef USE_MIDI
|
#ifdef USE_MIDI
|
||||||
&& !stretch
|
&& !stretch
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
|
if (
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
|
event.LeftDClick() ||
|
||||||
|
#endif
|
||||||
|
event.LeftDown()) {
|
||||||
|
ToggleScrubbing(
|
||||||
|
event.m_x
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
|
, event.LeftDClick()
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
StartOrJumpPlayback(event);
|
StartOrJumpPlayback(event);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
// Not starting a drag
|
// Not starting a drag
|
||||||
SetCapturedTrack(NULL, IsUncaptured);
|
SetCapturedTrack(NULL, IsUncaptured);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//Make sure you are within the selected track
|
//Make sure you are within the selected track
|
||||||
bool startNewSelection = true;
|
bool startNewSelection = true;
|
||||||
@ -3308,6 +3335,19 @@ void TrackPanel::Stretch(int mouseXCoordinate, int trackLeftEdge,
|
|||||||
/// handle it here.
|
/// handle it here.
|
||||||
void TrackPanel::SelectionHandleDrag(wxMouseEvent & event, Track *clickedTrack)
|
void TrackPanel::SelectionHandleDrag(wxMouseEvent & event, Track *clickedTrack)
|
||||||
{
|
{
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
|
if (IsScrubbing()) {
|
||||||
|
// May need a screen update.
|
||||||
|
if (mAutoScrolling)
|
||||||
|
UpdateSelectionDisplay();
|
||||||
|
}
|
||||||
|
else if (mScrubStartPosition >= 0) {
|
||||||
|
MaybeStartScrubbing(event);
|
||||||
|
// Do nothing more, don't change selection
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// AS: If we're not in the process of selecting (set in
|
// AS: If we're not in the process of selecting (set in
|
||||||
// the SelectionHandleClick above), fuhggeddaboudit.
|
// the SelectionHandleClick above), fuhggeddaboudit.
|
||||||
if (mMouseCapture!=IsSelecting)
|
if (mMouseCapture!=IsSelecting)
|
||||||
@ -3317,20 +3357,6 @@ void TrackPanel::SelectionHandleDrag(wxMouseEvent & event, Track *clickedTrack)
|
|||||||
if (!event.Dragging() && !mAutoScrolling)
|
if (!event.Dragging() && !mAutoScrolling)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
|
||||||
if (IsScrubbing()) {
|
|
||||||
// May need a screen update, but do nothing else. Don't change selection.
|
|
||||||
if (mAutoScrolling)
|
|
||||||
UpdateSelectionDisplay();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (event.MiddleIsDown()) {
|
|
||||||
MaybeStartScrubbing(event);
|
|
||||||
// Do nothing more, don't change selection
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (event.CmdDown()) {
|
if (event.CmdDown()) {
|
||||||
// Ctrl-drag has no meaning, fuhggeddaboudit
|
// Ctrl-drag has no meaning, fuhggeddaboudit
|
||||||
return;
|
return;
|
||||||
@ -6520,18 +6546,6 @@ void TrackPanel::OnMouseEvent(wxMouseEvent & event)
|
|||||||
case IsAdjustingLabel:
|
case IsAdjustingLabel:
|
||||||
HandleLabelTrackMouseEvent((LabelTrack *)mCapturedTrack, mCapturedRect, event);
|
HandleLabelTrackMouseEvent((LabelTrack *)mCapturedTrack, mCapturedRect, event);
|
||||||
break;
|
break;
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
|
||||||
case IsMiddleButtonScrubbing:
|
|
||||||
if (event.MiddleUp()) {
|
|
||||||
if (IsScrubbing()) {
|
|
||||||
StopScrubbing();
|
|
||||||
if (HasCapture())
|
|
||||||
ReleaseMouse();
|
|
||||||
mMouseCapture = IsUncaptured;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default: //includes case of IsUncaptured
|
default: //includes case of IsUncaptured
|
||||||
HandleTrackSpecificMouseEvent(event);
|
HandleTrackSpecificMouseEvent(event);
|
||||||
break;
|
break;
|
||||||
@ -7335,10 +7349,13 @@ void TrackPanel::DrawEverythingElse(wxDC * dc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
if (IsScrubbing())
|
if (IsScrubbing())
|
||||||
DrawScrubSpeed(*dc);
|
DrawScrubSpeed(*dc);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
void TrackPanel::DrawScrubSpeed(wxDC &dc)
|
void TrackPanel::DrawScrubSpeed(wxDC &dc)
|
||||||
{
|
{
|
||||||
// Don't draw it during stutter play with shift down
|
// Don't draw it during stutter play with shift down
|
||||||
@ -7405,6 +7422,7 @@ void TrackPanel::DrawScrubSpeed(wxDC &dc)
|
|||||||
dc.DrawText(text, xx, yy);
|
dc.DrawText(text, xx, yy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Draw zooming indicator that shows the region that will
|
/// Draw zooming indicator that shows the region that will
|
||||||
/// be zoomed into when the user clicks and drags with a
|
/// be zoomed into when the user clicks and drags with a
|
||||||
|
@ -321,13 +321,24 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel {
|
|||||||
// AS: Selection handling
|
// AS: Selection handling
|
||||||
virtual void HandleSelect(wxMouseEvent & event);
|
virtual void HandleSelect(wxMouseEvent & event);
|
||||||
virtual void SelectionHandleDrag(wxMouseEvent &event, Track *pTrack);
|
virtual void SelectionHandleDrag(wxMouseEvent &event, Track *pTrack);
|
||||||
|
|
||||||
|
// Made obsolete by scrubbing:
|
||||||
|
#ifndef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
void StartOrJumpPlayback(wxMouseEvent &event);
|
void StartOrJumpPlayback(wxMouseEvent &event);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
double FindScrubSpeed(double timeAtMouse) const;
|
double FindScrubSpeed(double timeAtMouse) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
|
bool IsScrubbing();
|
||||||
|
void ToggleScrubbing(
|
||||||
|
wxCoord xx
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_SMOOTH_SCROLL
|
||||||
|
, bool smoothScrolling
|
||||||
|
#endif
|
||||||
|
);
|
||||||
bool MaybeStartScrubbing(wxMouseEvent &event);
|
bool MaybeStartScrubbing(wxMouseEvent &event);
|
||||||
bool ContinueScrubbing(wxCoord position, bool maySkip);
|
bool ContinueScrubbing(wxCoord position, bool maySkip);
|
||||||
bool StopScrubbing();
|
bool StopScrubbing();
|
||||||
@ -532,7 +543,9 @@ protected:
|
|||||||
const wxRect & clip);
|
const wxRect & clip);
|
||||||
virtual void DrawOutside(Track *t, wxDC *dc, const wxRect & rec,
|
virtual void DrawOutside(Track *t, wxDC *dc, const wxRect & rec,
|
||||||
const wxRect &trackRect);
|
const wxRect &trackRect);
|
||||||
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
void DrawScrubSpeed(wxDC &dc);
|
void DrawScrubSpeed(wxDC &dc);
|
||||||
|
#endif
|
||||||
virtual void DrawZooming(wxDC* dc, const wxRect & clip);
|
virtual void DrawZooming(wxDC* dc, const wxRect & clip);
|
||||||
|
|
||||||
virtual void HighlightFocusedTrack (wxDC* dc, const wxRect &r);
|
virtual void HighlightFocusedTrack (wxDC* dc, const wxRect &r);
|
||||||
@ -772,9 +785,7 @@ protected:
|
|||||||
IsStretching,
|
IsStretching,
|
||||||
#endif
|
#endif
|
||||||
IsZooming,
|
IsZooming,
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
|
||||||
IsMiddleButtonScrubbing,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MouseCaptureEnum mMouseCapture;
|
enum MouseCaptureEnum mMouseCapture;
|
||||||
@ -791,7 +802,6 @@ protected:
|
|||||||
int mMoveDownThreshold;
|
int mMoveDownThreshold;
|
||||||
|
|
||||||
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
#ifdef EXPERIMENTAL_SCRUBBING_BASIC
|
||||||
bool IsScrubbing();
|
|
||||||
int mScrubToken;
|
int mScrubToken;
|
||||||
wxLongLong mScrubStartClockTimeMillis;
|
wxLongLong mScrubStartClockTimeMillis;
|
||||||
wxCoord mScrubStartPosition;
|
wxCoord mScrubStartPosition;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user