A single UIHandle can define multiple rotation states

This commit is contained in:
Paul Licameli 2017-07-12 13:56:16 -04:00
parent 4eece4b0b1
commit b7ae012ece
26 changed files with 66 additions and 30 deletions

View File

@ -950,8 +950,8 @@ void TrackPanel::HandleMotion
// Did not move cell to cell, but did change the target
refreshCode = updateFlags;
if (handle)
handle->Enter();
if (handle != oldHandle)
handle->Enter(true);
}
// UIHANDLE PREVIEW
@ -977,15 +977,30 @@ void TrackPanel::HandleMotion
this, GetRuler(), newTrack.get(), newTrack.get(), refreshCode);
}
bool TrackPanel::HasRotation() const
bool TrackPanel::HasRotation()
{
// Is there a nontrivial TAB key rotation?
return !mUIHandle && mTargets.size() > 1;
if ( mTargets.size() > 1 )
return true;
auto target = Target();
return target && target->HasRotation();
}
void TrackPanel::RotateTarget(bool forward)
{
auto size = mTargets.size();
auto target = Target();
if (target && target->HasRotation()) {
if(target->Rotate(forward))
return;
else if (size == 1 || IsMouseCaptured()) {
// Rotate through the states of this target only.
target->Enter(forward);
return;
}
}
if (size > 1) {
if (forward)
++mTarget;
@ -993,7 +1008,7 @@ void TrackPanel::RotateTarget(bool forward)
mTarget += size - 1;
mTarget %= size;
if (Target())
Target()->Enter();
Target()->Enter(forward);
}
}

View File

@ -549,7 +549,7 @@ protected:
mMouseOverUpdateFlags = 0;
}
bool HasRotation() const;
bool HasRotation();
void RotateTarget(bool forward);

View File

@ -15,10 +15,20 @@ UIHandle::~UIHandle()
{
}
void UIHandle::Enter()
void UIHandle::Enter(bool)
{
}
bool UIHandle::HasRotation() const
{
return false;
}
bool UIHandle::Rotate(bool)
{
return false;
}
void UIHandle::DrawExtras
(DrawingPass, wxDC *, const wxRegion &, const wxRect &)
{

View File

@ -48,8 +48,19 @@ public:
virtual ~UIHandle() = 0;
// Before clicking, the handle is notified that it has been "hit"
// This might put the handle into its first rotated state
// (or last, if forward is false) or mark itself as needing a highlight.
// Default does nothing.
virtual void Enter();
virtual void Enter(bool forward);
// Tell whether the handle has more than one TAB key rotation state.
// Default is always false.
virtual bool HasRotation() const;
// If not previously in the last rotation state (or first if !forward),
// change rotation state and return true; else return false
// Default does nothing and returns false
virtual bool Rotate(bool forward);
// Assume hit test (implemented in other classes) was positive.
// May return Cancelled, overriding the hit test decision and stopping drag.

View File

@ -32,7 +32,7 @@ LabelGlyphHandle::LabelGlyphHandle
{
}
void LabelGlyphHandle::Enter()
void LabelGlyphHandle::Enter(bool)
{
mChangeHighlight = RefreshCode::RefreshCell;
}

View File

@ -54,7 +54,7 @@ public:
virtual ~LabelGlyphHandle();
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -26,7 +26,7 @@ LabelTextHandle::LabelTextHandle
{
}
void LabelTextHandle::Enter()
void LabelTextHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -38,7 +38,7 @@ public:
std::shared_ptr<LabelTrack> GetTrack() const { return mpLT.lock(); }
int GetLabelNum() const { return mLabelNum; }
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -27,7 +27,7 @@ NoteTrackButtonHandle::NoteTrackButtonHandle
{
}
void NoteTrackButtonHandle::Enter()
void NoteTrackButtonHandle::Enter(bool)
{
mChangeHighlight = RefreshCode::RefreshCell;
}

View File

@ -47,7 +47,7 @@ public:
const NoteTrackButtonHandle &newState);
protected:
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -42,7 +42,7 @@ NoteTrackVZoomHandle::NoteTrackVZoomHandle
{
}
void NoteTrackVZoomHandle::Enter()
void NoteTrackVZoomHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -38,7 +38,7 @@ public:
std::shared_ptr<NoteTrack> GetTrack() const { return mpTrack.lock(); }
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -30,7 +30,7 @@ CutlineHandle::CutlineHandle
{
}
void CutlineHandle::Enter()
void CutlineHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -45,7 +45,7 @@ public:
const WaveTrackLocation &GetLocation() { return mLocation; }
std::shared_ptr<WaveTrack> GetTrack() { return mpTrack; }
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -40,7 +40,7 @@ SampleHandle::SampleHandle( const std::shared_ptr<WaveTrack> &pTrack )
{
}
void SampleHandle::Enter()
void SampleHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -46,7 +46,7 @@ public:
std::shared_ptr<WaveTrack> GetTrack() const { return mClickedTrack; }
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -51,7 +51,7 @@ WaveTrackVZoomHandle::WaveTrackVZoomHandle
{
}
void WaveTrackVZoomHandle::Enter()
void WaveTrackVZoomHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -38,7 +38,7 @@ public:
std::shared_ptr<WaveTrack> GetTrack() const { return mpTrack.lock(); }
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -31,7 +31,7 @@ ButtonHandle::~ButtonHandle()
{
}
void ButtonHandle::Enter()
void ButtonHandle::Enter(bool)
{
mChangeHighlight = RefreshCode::RefreshCell;
}

View File

@ -42,7 +42,7 @@ protected:
virtual Result CommitChanges
(const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) = 0;
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -32,7 +32,7 @@ EnvelopeHandle::EnvelopeHandle( Envelope *pEnvelope )
{
}
void EnvelopeHandle::Enter()
void EnvelopeHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -56,7 +56,7 @@ public:
Envelope *GetEnvelope() const { return mEnvelope; }
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -24,7 +24,7 @@ SliderHandle::SliderHandle
{
}
void SliderHandle::Enter()
void SliderHandle::Enter(bool)
{
mChangeHighlight = RefreshCode::RefreshCell;
}

View File

@ -47,7 +47,7 @@ protected:
virtual Result CommitChanges
(const wxMouseEvent &event, AudacityProject *pProject) = 0;
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;

View File

@ -30,7 +30,7 @@ TimeShiftHandle::TimeShiftHandle
{
}
void TimeShiftHandle::Enter()
void TimeShiftHandle::Enter(bool)
{
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;

View File

@ -75,7 +75,7 @@ public:
virtual ~TimeShiftHandle();
void Enter() override;
void Enter(bool forward) override;
Result Click
(const TrackPanelMouseEvent &event, AudacityProject *pProject) override;