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
 
int GetChannel () const
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
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 bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
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 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 }

◆ ~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 115 of file NoteTrackButtonHandle.cpp.

116 {
118 }

References RefreshCode::RefreshNone.

◆ Click()

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

Implements UIHandle.

Definition at line 73 of file NoteTrackButtonHandle.cpp.

75 {
77 }

References RefreshCode::RefreshNone.

◆ Drag()

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

Implements UIHandle.

Definition at line 79 of file NoteTrackButtonHandle.cpp.

81 {
83 }

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.

◆ GetChannel()

int NoteTrackButtonHandle::GetChannel ( ) const
inline

Definition at line 42 of file NoteTrackButtonHandle.h.

42 { 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 53 of file NoteTrackButtonHandle.cpp.

57 {
58  wxRect midiRect;
60  if ( TrackInfo::HideTopItem( rect, midiRect ) )
61  return {};
62  if (midiRect.Contains(state.m_x, state.m_y)) {
63  auto channel = pTrack->FindChannel(midiRect, state.m_x, state.m_y);
64  auto result = std::make_shared<NoteTrackButtonHandle>(
65  pTrack, channel, midiRect );
66  result = AssignUIHandlePtr(holder, result);
67  return result;
68  }
69  else
70  return {};
71 }

References AssignUIHandlePtr(), NoteTrack::FindChannel(), NoteTrackControls::GetMidiControlsRect(), and TrackInfo::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 44 of file NoteTrackButtonHandle.cpp.

46 {
47  if (oldState.GetChannel() != newState.GetChannel())
48  // Repaint whenever the highlighted button is different
50  return 0;
51 }

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 85 of file NoteTrackButtonHandle.cpp.

87 {
88  // auto pTrack = pProject->GetTracks()->Lock(mpTrack);
89  auto pTrack = mpTrack.lock();
90  if ( !pTrack )
91  return {};
92  // No special message or cursor
93  return {};
94 }

References mpTrack.

◆ Release()

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

Implements UIHandle.

Definition at line 96 of file NoteTrackButtonHandle.cpp.

98 {
99  using namespace RefreshCode;
100 
101  auto pTrack = TrackList::Get( *pProject ).Lock(mpTrack);
102  if (!pTrack)
103  return Cancelled;
104 
105  const wxMouseEvent &event = evt.event;
106  if (pTrack->LabelClick(mRect, event.m_x, event.m_y,
107  event.Button(wxMOUSE_BTN_RIGHT))) {
108  // No undo items needed??
109  ProjectHistory::Get( *pProject ).ModifyState(false);
110  return RefreshAll;
111  }
112  return RefreshNone;
113 }

References RefreshCode::Cancelled, TrackPanelMouseEvent::event, TrackList::Get(), ProjectHistory::Get(), 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 68 of file NoteTrackButtonHandle.h.

Referenced by GetChannel().

◆ mpTrack

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

Definition at line 67 of file NoteTrackButtonHandle.h.

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

◆ mRect

wxRect NoteTrackButtonHandle::mRect {}
protected

Definition at line 69 of file NoteTrackButtonHandle.h.

Referenced by Release().


The documentation for this class was generated from the following files:
ProjectHistory::ModifyState
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
TrackList::Lock
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1541
RefreshCode::Cancelled
@ Cancelled
Definition: RefreshCode.h:23
UIHandle::mChangeHighlight
Result mChangeHighlight
Definition: UIHandle.h:139
NoteTrackButtonHandle::mpTrack
std::weak_ptr< NoteTrack > mpTrack
Definition: NoteTrackButtonHandle.h:67
NoteTrackButtonHandle::mChannel
int mChannel
Definition: NoteTrackButtonHandle.h:68
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
NoteTrackButtonHandle::mRect
wxRect mRect
Definition: NoteTrackButtonHandle.h:69
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:377
TrackInfo::HideTopItem
AUDACITY_DLL_API bool HideTopItem(const wxRect &rect, const wxRect &subRect, int allowance=0)
Definition: TrackInfo.cpp:208
NoteTrackButtonHandle::GetChannel
int GetChannel() const
Definition: NoteTrackButtonHandle.h:42
NoteTrackControls::GetMidiControlsRect
static void GetMidiControlsRect(const wxRect &rect, wxRect &dest)
Definition: NoteTrackControls.cpp:242
AssignUIHandlePtr
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
NoteTrack::FindChannel
int FindChannel(const wxRect &rect, int mx, int my)
Definition: NoteTrack.cpp:356
RefreshCode
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26