Audacity 3.2.0
Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
AffordanceHandle Class Referenceabstract

#include <AffordanceHandle.h>

Inheritance diagram for AffordanceHandle:
[legend]
Collaboration diagram for AffordanceHandle:
[legend]

Public Member Functions

void Enter (bool forward, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &mouseState, AudacityProject *pProject) override
 
 AffordanceHandle (const std::shared_ptr< Track > &track)
 
Result Click (const TrackPanelMouseEvent &evt, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
- Public Member Functions inherited from TimeShiftHandle
 TimeShiftHandle (std::shared_ptr< Track > pTrack, bool gripHit)
 
TimeShiftHandleoperator= (TimeShiftHandle &&)=default
 
bool IsGripHit () const
 
virtual ~TimeShiftHandle ()
 
std::shared_ptr< const TrackFindTrack () const override
 
void Enter (bool forward, AudacityProject *) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject) override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
Result Cancel (AudacityProject *pProject) override
 
bool StopsOnKeystroke () override
 
bool Clicked () const
 
std::shared_ptr< TrackGetTrack () const
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
virtual std::shared_ptr< const TrackFindTrack () const =0
 
virtual bool IsDragging () const
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Protected Member Functions

virtual Result SelectAt (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
- Protected Member Functions inherited from TimeShiftHandle
bool WasMoved () const
 

Private Member Functions

Result UpdateTrackSelection (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 

Static Private Member Functions

static HitTestPreview HitPreview (const AudacityProject *, bool unsafe, bool moving)
 

Private Attributes

bool mMoving { false }
 
wxPoint mClickPosition { }
 

Static Private Attributes

static constexpr double MoveThreshold { 5.0 }
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Static Public Member Functions inherited from TimeShiftHandle
static UIHandlePtr HitAnywhere (std::weak_ptr< TimeShiftHandle > &holder, const std::shared_ptr< Track > &pTrack, bool gripHit)
 
static UIHandlePtr HitTest (std::weak_ptr< TimeShiftHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< Track > &pTrack)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description


Audacity: A Digital Audio Editor

AffordanceHandle.h

Vitaly Sverchinsky

Definition at line 15 of file AffordanceHandle.h.

Constructor & Destructor Documentation

◆ AffordanceHandle()

AffordanceHandle::AffordanceHandle ( const std::shared_ptr< Track > &  track)

Definition at line 58 of file AffordanceHandle.cpp.

59 : TimeShiftHandle(track, false)
60{
61}
TimeShiftHandle(const TimeShiftHandle &)=delete

Member Function Documentation

◆ Click()

UIHandle::Result AffordanceHandle::Click ( const TrackPanelMouseEvent evt,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 63 of file AffordanceHandle.cpp.

64{
65 auto result = TimeShiftHandle::Click(evt, pProject);
66 mClickPosition = evt.event.GetPosition();
67 return result | RefreshCode::RefreshCell;
68}
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override

References TimeShiftHandle::Click(), TrackPanelMouseEvent::event, mClickPosition, and RefreshCode::RefreshCell.

Referenced by WaveTrackAffordanceHandle::Click().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Drag()

UIHandle::Result AffordanceHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 70 of file AffordanceHandle.cpp.

71{
72 if(!mMoving)
73 {
74 if(std::abs(mClickPosition.x - event.event.m_x) >= MoveThreshold ||
75 std::abs(mClickPosition.y - event.event.m_y) >= MoveThreshold)
76 {
77 mMoving = true;
78 }
79 else
81 }
82 return TimeShiftHandle::Drag(event, pProject);
83}
static constexpr double MoveThreshold
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override

References TimeShiftHandle::Drag(), TrackPanelMouseEvent::event, mClickPosition, mMoving, MoveThreshold, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ Enter()

void AffordanceHandle::Enter ( bool  forward,
AudacityProject pProject 
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 46 of file AffordanceHandle.cpp.

47{
50}
void Enter(bool forward, AudacityProject *) override
void SetChangeHighlight(Result val)
Definition: UIHandle.h:132
@ RefreshLatestCell
Definition: RefreshCode.h:25

References TimeShiftHandle::Enter(), forward, RefreshCode::RefreshCell, RefreshCode::RefreshLatestCell, and UIHandle::SetChangeHighlight().

Here is the call graph for this function:

◆ HitPreview()

HitTestPreview AffordanceHandle::HitPreview ( const AudacityProject ,
bool  unsafe,
bool  moving 
)
staticprivate

Audacity: A Digital Audio Editor

AffordanceHandle.cpp

Vitaly Sverchinsky

Definition at line 25 of file AffordanceHandle.cpp.

26{
27 static wxCursor arrowCursor{ wxCURSOR_ARROW };
28 static auto handOpenCursor =
29 MakeCursor(wxCURSOR_HAND, RearrangeCursorXpm, 16, 16);
30 static auto handClosedCursor =
31 MakeCursor(wxCURSOR_HAND, RearrangingCursorXpm, 16, 16);
32 // i18n-hint Appears on hovering mouse over clip affordance
33 auto message = XO("Drag clips to reposition them."\
34 " Hold Shift and drag to move all clips on the same track.");
35
36 if (unsafe)
37 return { message, &arrowCursor };
38 return {
39 message,
40 (moving
41 ? &*handClosedCursor
43 };
44}
static std::unique_ptr< wxCursor > handOpenCursor
XO("Cut/Copy/Paste")
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
Definition: TrackPanel.cpp:189

References handOpenCursor, MakeCursor(), and XO().

Referenced by Preview().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Preview()

HitTestPreview AffordanceHandle::Preview ( const TrackPanelMouseState mouseState,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 52 of file AffordanceHandle.cpp.

53{
54 const bool unsafe = ProjectAudioIO::Get(*pProject).IsAudioActive();
55 return HitPreview(pProject, unsafe, Clicked());
56}
static HitTestPreview HitPreview(const AudacityProject *, bool unsafe, bool moving)
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
bool Clicked() const

References TimeShiftHandle::Clicked(), ProjectAudioIO::Get(), HitPreview(), and ProjectAudioIO::IsAudioActive().

Here is the call graph for this function:

◆ Release()

UIHandle::Result AffordanceHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 85 of file AffordanceHandle.cpp.

86{
87 auto result = TimeShiftHandle::Release(event, pProject, pParent);
88 if (!WasMoved())
89 result |= UpdateTrackSelection(event, pProject);
90 return result;
91}
Result UpdateTrackSelection(const TrackPanelMouseEvent &event, AudacityProject *pProject)
bool WasMoved() const
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override

References TimeShiftHandle::Release(), UpdateTrackSelection(), and TimeShiftHandle::WasMoved().

Referenced by WaveTrackAffordanceHandle::Release().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SelectAt()

virtual Result AffordanceHandle::SelectAt ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
protectedpure virtual

Implemented in NoteTrackAffordanceHandle, and WaveTrackAffordanceHandle.

Referenced by UpdateTrackSelection().

Here is the caller graph for this function:

◆ UpdateTrackSelection()

UIHandle::Result AffordanceHandle::UpdateTrackSelection ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
private

Definition at line 93 of file AffordanceHandle.cpp.

94{
95 auto& trackList = TrackList::Get(*pProject);
96
97 if(const auto track = trackList.Lock<Track>(GetTrack()))
98 {
99 auto& selectionState = SelectionState::Get(*pProject);
100 selectionState.SelectNone(trackList);
101 selectionState.SelectTrack(*track, true, true);
102
103 return SelectAt(event, pProject);
104 }
105
107}
virtual Result SelectAt(const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
static SelectionState & Get(AudacityProject &project)
std::shared_ptr< Track > GetTrack() const
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References SelectionState::Get(), TrackList::Get(), TimeShiftHandle::GetTrack(), RefreshCode::RefreshNone, and SelectAt().

Referenced by Release().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mClickPosition

wxPoint AffordanceHandle::mClickPosition { }
private

Definition at line 22 of file AffordanceHandle.h.

Referenced by Click(), and Drag().

◆ mMoving

bool AffordanceHandle::mMoving { false }
private

Definition at line 21 of file AffordanceHandle.h.

Referenced by Drag().

◆ MoveThreshold

constexpr double AffordanceHandle::MoveThreshold { 5.0 }
staticconstexprprivate

Definition at line 17 of file AffordanceHandle.h.

Referenced by Drag().


The documentation for this class was generated from the following files: