mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-19 14:17:41 +02:00
Move scrub click handling into a UIHandle, eliminate OnMouseEvents...
... And the one-shot hack can be simplified away.
This commit is contained in:
parent
153eb63b3e
commit
7cfda551dd
@ -184,8 +184,7 @@ void Scrubber::ScrubPoller::Notify()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Scrubber::Scrubber(AudacityProject *project)
|
Scrubber::Scrubber(AudacityProject *project)
|
||||||
: mInOneShotMode( false )
|
: mScrubToken(-1)
|
||||||
, mScrubToken(-1)
|
|
||||||
, mPaused(true)
|
, mPaused(true)
|
||||||
, mScrubSpeedDisplayCountdown(0)
|
, mScrubSpeedDisplayCountdown(0)
|
||||||
, mScrubStartPosition(-1)
|
, mScrubStartPosition(-1)
|
||||||
|
@ -152,9 +152,6 @@ public:
|
|||||||
void Pause(bool paused);
|
void Pause(bool paused);
|
||||||
bool IsPaused() const;
|
bool IsPaused() const;
|
||||||
void CheckMenuItems();
|
void CheckMenuItems();
|
||||||
// Bug 1508
|
|
||||||
bool IsOneShotSeeking()const { return mInOneShotMode && IsScrubbing();};
|
|
||||||
bool mInOneShotMode;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DoScrub(bool seek);
|
void DoScrub(bool seek);
|
||||||
|
@ -2016,7 +2016,6 @@ enum {
|
|||||||
BEGIN_EVENT_TABLE(AdornedRulerPanel, CellularPanel)
|
BEGIN_EVENT_TABLE(AdornedRulerPanel, CellularPanel)
|
||||||
EVT_PAINT(AdornedRulerPanel::OnPaint)
|
EVT_PAINT(AdornedRulerPanel::OnPaint)
|
||||||
EVT_SIZE(AdornedRulerPanel::OnSize)
|
EVT_SIZE(AdornedRulerPanel::OnSize)
|
||||||
EVT_MOUSE_EVENTS(AdornedRulerPanel::OnMouseEvents)
|
|
||||||
|
|
||||||
// Context menu commands
|
// Context menu commands
|
||||||
EVT_MENU(OnToggleQuickPlayID, AdornedRulerPanel::OnToggleQuickPlay)
|
EVT_MENU(OnToggleQuickPlayID, AdornedRulerPanel::OnToggleQuickPlay)
|
||||||
@ -2231,9 +2230,26 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Result Click
|
Result Click
|
||||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override {
|
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
|
||||||
|
{
|
||||||
auto result = CommonRulerHandle::Click(event, pProject);
|
auto result = CommonRulerHandle::Click(event, pProject);
|
||||||
if (!( result & RefreshCode::Cancelled )) {
|
if (!( result & RefreshCode::Cancelled )) {
|
||||||
|
if (mClicked == Button::Left) {
|
||||||
|
auto &scrubber = pProject->GetScrubber();
|
||||||
|
// only if scrubbing is allowed now
|
||||||
|
bool canScrub =
|
||||||
|
scrubber.CanScrub() &&
|
||||||
|
mParent &&
|
||||||
|
mParent->mShowScrubbing;
|
||||||
|
|
||||||
|
if (!canScrub)
|
||||||
|
return RefreshCode::Cancelled;
|
||||||
|
if (!scrubber.HasMark()) {
|
||||||
|
// Asynchronous scrub poller gets activated here
|
||||||
|
scrubber.MarkScrubStart(
|
||||||
|
event.event.m_x, TracksPrefs::GetPinnedHeadPreference(), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2243,6 +2259,8 @@ private:
|
|||||||
{
|
{
|
||||||
auto result = CommonRulerHandle::Drag(event, pProject);
|
auto result = CommonRulerHandle::Drag(event, pProject);
|
||||||
if (!( result & RefreshCode::Cancelled )) {
|
if (!( result & RefreshCode::Cancelled )) {
|
||||||
|
// Nothing needed here. The scrubber works by polling mouse state
|
||||||
|
// after the start has been marked.
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2256,12 +2274,26 @@ private:
|
|||||||
wxWindow *pParent) override {
|
wxWindow *pParent) override {
|
||||||
auto result = CommonRulerHandle::Release(event, pProject, pParent);
|
auto result = CommonRulerHandle::Release(event, pProject, pParent);
|
||||||
if (!( result & RefreshCode::Cancelled )) {
|
if (!( result & RefreshCode::Cancelled )) {
|
||||||
|
// Nothing needed here either. The scrub poller may have decided to
|
||||||
|
// seek because a drag happened before button up, or it may decide
|
||||||
|
// to start a scrub, as it watches mouse movement after the button up.
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result Cancel(AudacityProject *pProject) override {
|
Result Cancel(AudacityProject *pProject) override
|
||||||
|
{
|
||||||
auto result = CommonRulerHandle::Cancel(pProject);
|
auto result = CommonRulerHandle::Cancel(pProject);
|
||||||
|
|
||||||
|
if (mClicked == Button::Left) {
|
||||||
|
auto &scrubber = pProject->GetScrubber();
|
||||||
|
scrubber.Cancel();
|
||||||
|
|
||||||
|
auto ctb = pProject->GetControlToolBar();
|
||||||
|
wxCommandEvent evt;
|
||||||
|
ctb->OnStop(evt);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2520,7 +2552,8 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString ContinueScrubbingMessage(const Scrubber &scrubber)
|
const wxString ContinueScrubbingMessage(
|
||||||
|
const Scrubber &scrubber, bool clicked)
|
||||||
{
|
{
|
||||||
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
|
/* i18n-hint: These commands assist the user in finding a sound by ear. ...
|
||||||
"Scrubbing" is variable-speed playback, ...
|
"Scrubbing" is variable-speed playback, ...
|
||||||
@ -2532,13 +2565,14 @@ namespace {
|
|||||||
else
|
else
|
||||||
return _("Move to Scrub");
|
return _("Move to Scrub");
|
||||||
#else
|
#else
|
||||||
wxMouseState State = wxGetMouseState();
|
if( clicked ) {
|
||||||
if( State.LeftIsDown() ) {
|
|
||||||
// Since mouse is down, mention dragging first.
|
// Since mouse is down, mention dragging first.
|
||||||
// IsScrubbing is true if Scrubbing OR seeking.
|
// IsScrubbing is true if Scrubbing OR seeking.
|
||||||
if( scrubber.IsOneShotSeeking() )
|
if( scrubber.IsScrubbing() )
|
||||||
|
// User is dragging already, explain.
|
||||||
return _("Drag to Seek. Release to stop seeking.");
|
return _("Drag to Seek. Release to stop seeking.");
|
||||||
else
|
else
|
||||||
|
// User has clicked but not yet moved or released.
|
||||||
return _("Drag to Seek. Release and move to Scrub.");
|
return _("Drag to Seek. Release and move to Scrub.");
|
||||||
}
|
}
|
||||||
// Since mouse is up, mention moving first.
|
// Since mouse is up, mention moving first.
|
||||||
@ -2546,10 +2580,10 @@ namespace {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxString ScrubbingMessage(const Scrubber &scrubber)
|
const wxString ScrubbingMessage(const Scrubber &scrubber, bool clicked)
|
||||||
{
|
{
|
||||||
if (scrubber.HasMark())
|
if (scrubber.HasMark())
|
||||||
return ContinueScrubbingMessage(scrubber);
|
return ContinueScrubbingMessage(scrubber, clicked);
|
||||||
else
|
else
|
||||||
return StartScrubbingMessage(scrubber);
|
return StartScrubbingMessage(scrubber);
|
||||||
}
|
}
|
||||||
@ -2702,45 +2736,6 @@ bool AdornedRulerPanel::IsWithinMarker(int mousePosX, double markerTime)
|
|||||||
return mousePosX >= boundLeft && mousePosX < boundRight;
|
return mousePosX >= boundLeft && mousePosX < boundRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::OnMouseEvents(wxMouseEvent &evt)
|
|
||||||
{
|
|
||||||
// Will always fall through to base class handling
|
|
||||||
evt.Skip();
|
|
||||||
|
|
||||||
const auto position = evt.GetPosition();
|
|
||||||
|
|
||||||
const bool inScrubZone =
|
|
||||||
// only if scrubbing is allowed now
|
|
||||||
mProject->GetScrubber().CanScrub() &&
|
|
||||||
mShowScrubbing &&
|
|
||||||
mScrubZone.Contains(position);
|
|
||||||
|
|
||||||
auto &scrubber = mProject->GetScrubber();
|
|
||||||
|
|
||||||
auto clicked = mQPCell->Clicked();
|
|
||||||
|
|
||||||
if( !clicked && evt.LeftUp() && inScrubZone ) {
|
|
||||||
if( scrubber.IsOneShotSeeking() ){
|
|
||||||
scrubber.mInOneShotMode = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
//wxLogDebug("up");
|
|
||||||
// mouse going up => we shift to scrubbing.
|
|
||||||
scrubber.MarkScrubStart(evt.m_x,
|
|
||||||
TracksPrefs::GetPinnedHeadPreference(), false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ( !clicked && inScrubZone) {
|
|
||||||
// mouse going down => we are (probably) seeking
|
|
||||||
if (evt.LeftDown() && !scrubber.HasMark()) {
|
|
||||||
//wxLogDebug("down");
|
|
||||||
scrubber.mInOneShotMode = !scrubber.IsScrubbing();
|
|
||||||
scrubber.MarkScrubStart(evt.m_x,
|
|
||||||
TracksPrefs::GetPinnedHeadPreference(), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto AdornedRulerPanel::QPHandle::Click
|
auto AdornedRulerPanel::QPHandle::Click
|
||||||
(const TrackPanelMouseEvent &event, AudacityProject *pProject) -> Result
|
(const TrackPanelMouseEvent &event, AudacityProject *pProject) -> Result
|
||||||
{
|
{
|
||||||
@ -2911,7 +2906,7 @@ auto AdornedRulerPanel::ScrubbingHandle::Preview
|
|||||||
-> HitTestPreview
|
-> HitTestPreview
|
||||||
{
|
{
|
||||||
const auto &scrubber = pProject->GetScrubber();
|
const auto &scrubber = pProject->GetScrubber();
|
||||||
auto message = ScrubbingMessage(scrubber);
|
auto message = ScrubbingMessage(scrubber, mClicked == Button::Left);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
message,
|
message,
|
||||||
@ -2938,7 +2933,7 @@ auto AdornedRulerPanel::QPHandle::Preview
|
|||||||
const bool scrubbing = scrubber.HasMark();
|
const bool scrubbing = scrubber.HasMark();
|
||||||
if (scrubbing)
|
if (scrubbing)
|
||||||
// Don't distinguish zones
|
// Don't distinguish zones
|
||||||
message = ScrubbingMessage(scrubber);
|
message = ScrubbingMessage(scrubber, false);
|
||||||
else
|
else
|
||||||
// message = Insert timeline status bar message here
|
// message = Insert timeline status bar message here
|
||||||
;
|
;
|
||||||
|
@ -359,7 +359,6 @@ private:
|
|||||||
void OnPaint(wxPaintEvent &evt);
|
void OnPaint(wxPaintEvent &evt);
|
||||||
void OnSize(wxSizeEvent &evt);
|
void OnSize(wxSizeEvent &evt);
|
||||||
void UpdateRects();
|
void UpdateRects();
|
||||||
void OnMouseEvents(wxMouseEvent &evt);
|
|
||||||
void HandleQPClick(wxMouseEvent &event, wxCoord mousePosX);
|
void HandleQPClick(wxMouseEvent &event, wxCoord mousePosX);
|
||||||
void HandleQPDrag(wxMouseEvent &event, wxCoord mousePosX);
|
void HandleQPDrag(wxMouseEvent &event, wxCoord mousePosX);
|
||||||
void HandleQPRelease(wxMouseEvent &event);
|
void HandleQPRelease(wxMouseEvent &event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user