Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
NoteTrackAffordanceControls Class Reference

#include <NoteTrackAffordanceControls.h>

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

Public Member Functions

 NoteTrackAffordanceControls (const std::shared_ptr< Track > &pTrack)
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject) override
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
bool IsSelected () const
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 Construct from a track. More...
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
void Reparent (const std::shared_ptr< Track > &parent) override
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &)=delete
 
TrackPanelCelloperator= (const TrackPanelCell &)=delete
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- 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)
 
- Public Member Functions inherited from TrackAttachment
virtual ~TrackAttachment ()
 
virtual void CopyTo (Track &track) const
 Copy state, for undo/redo purposes. More...
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 Object may be shared among tracks but hold a special back-pointer to one of them; reassign it. More...
 
virtual void WriteXMLAttributes (XMLWriter &) const
 Serialize persistent attributes. More...
 
virtual bool HandleXMLAttribute (const std::string_view &attr, const XMLAttributeValueView &valueView)
 Deserialize an attribute, returning true if recognized. More...
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Private Attributes

std::weak_ptr< NoteTrackAffordanceHandlemAffordanceHandle
 
std::weak_ptr< SelectHandlemSelectHandle
 

Additional Inherited Members

- 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 inherited from CommonTrackPanelCell
virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Detailed Description

Definition at line 19 of file NoteTrackAffordanceControls.h.

Constructor & Destructor Documentation

◆ NoteTrackAffordanceControls()

NoteTrackAffordanceControls::NoteTrackAffordanceControls ( const std::shared_ptr< Track > &  pTrack)

Definition at line 60 of file NoteTrackAffordanceControls.cpp.

61 : CommonTrackCell{ pTrack }
62{
63
64}

Member Function Documentation

◆ Draw()

void NoteTrackAffordanceControls::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overridevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 108 of file NoteTrackAffordanceControls.cpp.

109{
110
111 if (iPass == TrackArtist::PassBackground) {
112 const auto artist = TrackArtist::Get(context);
113 const auto &pendingTracks = *artist->pPendingTracks;
114
115 const auto track = FindTrack();
116 if (!track)
117 return;
118 const auto &nt = static_cast<const NoteTrack&>(
119 pendingTracks.SubstitutePendingChangedTrack(*track));
120
123
124 const auto& zoomInfo = *artist->pZoomInfo;
125 auto left = zoomInfo.TimeToPosition(nt.GetStartTime(), rect.x);
126 auto right = zoomInfo.TimeToPosition(
127 nt.GetStartTime() + nt.GetSeq().get_real_dur(), rect.x);
128 auto clipRect = wxRect(left, rect.y, right - left + 1, rect.height);
129
130 auto px = context.lastState.m_x;
131 auto py = context.lastState.m_y;
132
133 auto selected = IsSelected();
134 auto highlight = selected ||
135 (px >= clipRect.GetLeft() && px <= clipRect.GetRight() &&
136 py >= clipRect.GetTop() && py <= clipRect.GetBottom());
137
138 {
139 wxDCClipper clipper(context.dc, rect);
140 context.dc.SetTextBackground(wxTransparentColor);
141 context.dc.SetTextForeground(theTheme.Colour(clrClipNameText));
142 context.dc.SetFont(wxFont(wxFontInfo()));
143 const auto titleRect = TrackArt::DrawClipAffordance(context.dc, clipRect, highlight, selected);
144 TrackArt::DrawClipTitle(context.dc, titleRect, nt.GetName());
145 }
146 }
147}
THEME_API Theme theTheme
Definition: Theme.cpp:82
static wxBrush labelSelectedBrush
Definition: AColor.h:123
static wxBrush labelUnselectedBrush
Definition: AColor.h:122
std::shared_ptr< Track > FindTrack()
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:78
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:81
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true, bool useBeatsAlternateColor=false)
Helper: draws background with selection rect.
Definition: TrackArt.cpp:648
AUDACITY_DLL_API bool DrawClipTitle(wxDC &dc, const wxRect &affordanceRect, const wxString &title)
Definition: TrackArt.cpp:289
AUDACITY_DLL_API wxRect DrawClipAffordance(wxDC &dc, const wxRect &clipRect, bool highlight=false, bool selected=false)
Definition: TrackArt.cpp:223

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), TrackArt::DrawClipAffordance(), TrackArt::DrawClipTitle(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), IsSelected(), AColor::labelSelectedBrush, AColor::labelUnselectedBrush, TrackPanelDrawingContext::lastState, TrackArtist::PassBackground, and theTheme.

Here is the call graph for this function:

◆ HitTest()

std::vector< UIHandlePtr > NoteTrackAffordanceControls::HitTest ( const TrackPanelMouseState state,
const AudacityProject pProject 
)
overridevirtual

Implements TrackPanelCell.

Definition at line 66 of file NoteTrackAffordanceControls.cpp.

67{
68 std::vector<UIHandlePtr> results;
69
70 auto track = std::static_pointer_cast<NoteTrack>(FindTrack());
71 if (!track)
72 return {};
73 const auto &nt = static_cast<const NoteTrack&>(
75
76 const auto rect = state.rect;
77
78 auto& zoomInfo = ViewInfo::Get(*pProject);
79 auto left = zoomInfo.TimeToPosition(nt.GetStartTime(), rect.x);
80 auto right = zoomInfo.TimeToPosition(
81 nt.GetStartTime() + nt.GetSeq().get_real_dur(), rect.x);
82 auto headerRect = wxRect(left, rect.y, right - left, rect.height);
83
84 auto px = state.state.m_x;
85 auto py = state.state.m_y;
86
87 if (px >= headerRect.GetLeft() && px <= headerRect.GetRight() &&
88 py >= headerRect.GetTop() && py <= headerRect.GetBottom())
89 {
91 }
92
93 const auto& settings = ProjectSettings::Get(*pProject);
94 const auto currentTool = settings.GetTool();
95 if (currentTool == ToolCodes::multiTool || currentTool == ToolCodes::selectTool)
96 {
97 results.push_back(
99 mSelectHandle, state, pProject,
100 ChannelView::Get(*track).shared_from_this()
101 )
102 );
103 }
104
105 return results;
106}
static Settings & settings()
Definition: TrackInfo.cpp:51
static ChannelView & Get(Channel &channel)
std::weak_ptr< NoteTrackAffordanceHandle > mAffordanceHandle
std::weak_ptr< SelectHandle > mSelectHandle
static UIHandlePtr HitAnywhere(std::weak_ptr< NoteTrackAffordanceHandle > &holder, const std::shared_ptr< Track > &pTrack)
Track & SubstitutePendingChangedTrack(Track &track) const
static PendingTracks & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< ChannelView > &pChannelView)
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References CommonTrackPanelCell::FindTrack(), ViewInfo::Get(), PendingTracks::Get(), ProjectSettings::Get(), ChannelView::Get(), NoteTrackAffordanceHandle::HitAnywhere(), SelectHandle::HitTest(), mAffordanceHandle, mSelectHandle, ToolCodes::multiTool, TrackPanelMouseState::rect, ToolCodes::selectTool, settings(), TrackPanelMouseState::state, and PendingTracks::SubstitutePendingChangedTrack().

Here is the call graph for this function:

◆ IsSelected()

bool NoteTrackAffordanceControls::IsSelected ( ) const

Definition at line 149 of file NoteTrackAffordanceControls.cpp.

150{
151 if (auto handle = mAffordanceHandle.lock())
152 {
153 return handle->Clicked();
154 }
155 return false;
156}

References mAffordanceHandle.

Referenced by Draw().

Here is the caller graph for this function:

Member Data Documentation

◆ mAffordanceHandle

std::weak_ptr<NoteTrackAffordanceHandle> NoteTrackAffordanceControls::mAffordanceHandle
private

Definition at line 21 of file NoteTrackAffordanceControls.h.

Referenced by HitTest(), and IsSelected().

◆ mSelectHandle

std::weak_ptr<SelectHandle> NoteTrackAffordanceControls::mSelectHandle
private

Definition at line 22 of file NoteTrackAffordanceControls.h.

Referenced by HitTest().


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