Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
NoteTrackButtonHandle Class Reference

#include <NoteTrackButtonHandle.h>

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

Public Member Functions

 NoteTrackButtonHandle (const std::shared_ptr< NoteTrack > &pTrack, int channel, const wxRect &rect)
 
NoteTrackButtonHandleoperator= (const NoteTrackButtonHandle &)=default
 
virtual ~NoteTrackButtonHandle ()
 
std::shared_ptr< NoteTrackGetTrack () const
 
std::shared_ptr< const TrackFindTrack () const override
 
int GetChannel () 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)
 

Static Public Member Functions

static UIHandlePtr HitTest (std::weak_ptr< NoteTrackButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< NoteTrack > &pTrack)
 
static UIHandle::Result NeedChangeHighlight (const NoteTrackButtonHandle &oldState, const NoteTrackButtonHandle &newState)
 
- 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 Member Functions

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
 

Protected Attributes

std::weak_ptr< NoteTrackmpTrack
 
int mChannel { -1 }
 
wxRect mRect {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Private Member Functions

 NoteTrackButtonHandle (const NoteTrackButtonHandle &)
 
 NoteTrackButtonHandle ()
 

Static Private Member Functions

static NoteTrackButtonHandleInstance ()
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 

Detailed Description

Definition at line 21 of file NoteTrackButtonHandle.h.

Constructor & Destructor Documentation

◆ NoteTrackButtonHandle() [1/3]

NoteTrackButtonHandle::NoteTrackButtonHandle ( const NoteTrackButtonHandle )
private

◆ NoteTrackButtonHandle() [2/3]

NoteTrackButtonHandle::NoteTrackButtonHandle ( )
private

◆ NoteTrackButtonHandle() [3/3]

NoteTrackButtonHandle::NoteTrackButtonHandle ( const std::shared_ptr< NoteTrack > &  pTrack,
int  channel,
const wxRect &  rect 
)
explicit

Definition at line 26 of file NoteTrackButtonHandle.cpp.

29 : mpTrack{ pTrack }
30 , mChannel{ channel }
31 , mRect{ rect }
32{
33}
std::weak_ptr< NoteTrack > mpTrack

◆ ~NoteTrackButtonHandle()

NoteTrackButtonHandle::~NoteTrackButtonHandle ( )
virtual

Definition at line 40 of file NoteTrackButtonHandle.cpp.

41{
42}

Member Function Documentation

◆ Cancel()

UIHandle::Result NoteTrackButtonHandle::Cancel ( AudacityProject pProject)
overrideprotectedvirtual

Implements UIHandle.

Definition at line 151 of file NoteTrackButtonHandle.cpp.

152{
154}

References RefreshCode::RefreshNone.

◆ Click()

UIHandle::Result NoteTrackButtonHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overrideprotectedvirtual

Implements UIHandle.

Definition at line 109 of file NoteTrackButtonHandle.cpp.

111{
113}

References RefreshCode::RefreshNone.

◆ Drag()

UIHandle::Result NoteTrackButtonHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overrideprotectedvirtual

Implements UIHandle.

Definition at line 115 of file NoteTrackButtonHandle.cpp.

117{
119}

References RefreshCode::RefreshNone.

◆ Enter()

void NoteTrackButtonHandle::Enter ( bool  forward,
AudacityProject  
)
overrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 35 of file NoteTrackButtonHandle.cpp.

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

◆ FindTrack()

std::shared_ptr< const Track > NoteTrackButtonHandle::FindTrack ( ) const
overridevirtual
Returns
pointer to associated track, if any

Implements UIHandle.

Definition at line 44 of file NoteTrackButtonHandle.cpp.

45{
46 return mpTrack.lock();
47}

References mpTrack.

◆ GetChannel()

int NoteTrackButtonHandle::GetChannel ( ) const
inline

Definition at line 43 of file NoteTrackButtonHandle.h.

43{ return mChannel; }

References mChannel.

Referenced by NeedChangeHighlight().

Here is the caller graph for this function:

◆ GetTrack()

std::shared_ptr< NoteTrack > NoteTrackButtonHandle::GetTrack ( ) const
inline

Definition at line 41 of file NoteTrackButtonHandle.h.

41{ return mpTrack.lock(); }

References mpTrack.

Referenced by anonymous_namespace{NoteTrackControls.cpp}::MidiControlsDrawFunction().

Here is the caller graph for this function:

◆ HitTest()

UIHandlePtr NoteTrackButtonHandle::HitTest ( std::weak_ptr< NoteTrackButtonHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const std::shared_ptr< NoteTrack > &  pTrack 
)
static

Definition at line 89 of file NoteTrackButtonHandle.cpp.

93{
94 wxRect midiRect;
96 if ( CommonTrackInfo::HideTopItem( rect, midiRect ) )
97 return {};
98 if (midiRect.Contains(state.m_x, state.m_y)) {
99 auto channel = FindChannelNumber(midiRect, state.m_x, state.m_y);
100 auto result = std::make_shared<NoteTrackButtonHandle>(
101 pTrack, channel, midiRect );
102 result = AssignUIHandlePtr(holder, result);
103 return result;
104 }
105 else
106 return {};
107}
static int FindChannelNumber(const wxRect &rect, int mx, int my)
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
static void GetMidiControlsRect(const wxRect &rect, wxRect &dest)
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)

References AssignUIHandlePtr(), FindChannelNumber(), NoteTrackControls::GetMidiControlsRect(), and CommonTrackInfo::HideTopItem().

Referenced by NoteTrackControls::HitTest().

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

◆ Instance()

static NoteTrackButtonHandle & NoteTrackButtonHandle::Instance ( )
staticprivate

◆ NeedChangeHighlight()

UIHandle::Result NoteTrackButtonHandle::NeedChangeHighlight ( const NoteTrackButtonHandle oldState,
const NoteTrackButtonHandle newState 
)
static

Definition at line 49 of file NoteTrackButtonHandle.cpp.

51{
52 if (oldState.GetChannel() != newState.GetChannel())
53 // Repaint whenever the highlighted button is different
55 return 0;
56}

References GetChannel(), and RefreshCode::RefreshCell.

Here is the call graph for this function:

◆ operator=()

NoteTrackButtonHandle & NoteTrackButtonHandle::operator= ( const NoteTrackButtonHandle )
default

◆ Preview()

HitTestPreview NoteTrackButtonHandle::Preview ( const TrackPanelMouseState state,
AudacityProject pProject 
)
overrideprotectedvirtual

Implements UIHandle.

Definition at line 121 of file NoteTrackButtonHandle.cpp.

123{
124 // auto pTrack = pProject->GetTracks()->Lock(mpTrack);
125 auto pTrack = mpTrack.lock();
126 if ( !pTrack )
127 return {};
128 // No special message or cursor
129 return {};
130}

References mpTrack.

◆ Release()

UIHandle::Result NoteTrackButtonHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overrideprotectedvirtual

Implements UIHandle.

Definition at line 132 of file NoteTrackButtonHandle.cpp.

134{
135 using namespace RefreshCode;
136
137 auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
138 if (!pTrack)
139 return Cancelled;
140
141 const wxMouseEvent &event = evt.event;
142 if (LabelClick(*pTrack, mRect, event.m_x, event.m_y,
143 event.Button(wxMOUSE_BTN_RIGHT))) {
144 // No undo items needed??
145 ProjectHistory::Get( *pProject ).ModifyState(false);
146 return RefreshAll;
147 }
148 return RefreshNone;
149}
static bool LabelClick(NoteTrack &track, const wxRect &rect, int mx, int my, bool right)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1079
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References Cancelled, TrackPanelMouseEvent::event, ProjectHistory::Get(), TrackList::Get(), LabelClick(), TrackList::Lock(), ProjectHistory::ModifyState(), mpTrack, mRect, RefreshCode::RefreshAll, and RefreshCode::RefreshNone.

Here is the call graph for this function:

Member Data Documentation

◆ mChannel

int NoteTrackButtonHandle::mChannel { -1 }
protected

Definition at line 69 of file NoteTrackButtonHandle.h.

Referenced by GetChannel().

◆ mpTrack

std::weak_ptr<NoteTrack> NoteTrackButtonHandle::mpTrack
protected

Definition at line 68 of file NoteTrackButtonHandle.h.

Referenced by FindTrack(), GetTrack(), Preview(), and Release().

◆ mRect

wxRect NoteTrackButtonHandle::mRect {}
protected

Definition at line 70 of file NoteTrackButtonHandle.h.

Referenced by Release().


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