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

#include <NoteTrackAffordanceControls.h>

Inheritance diagram for NoteTrackAffordanceControls:
Collaboration diagram for NoteTrackAffordanceControls:

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)
 ~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 &) PROHIBITED
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
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)
CommonTrackCell(const std::shared_ptr< Track > &pTrack)

Member Function Documentation

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 104 of file NoteTrackAffordanceControls.cpp.

106 if (iPass == TrackArtist::PassBackground) {
107 const auto nt = std::static_pointer_cast<const NoteTrack>(FindTrack()->SubstitutePendingChangedTrack());
108 const auto artist = TrackArtist::Get(context);
112 const auto& zoomInfo = *artist->pZoomInfo;
113 auto left = zoomInfo.TimeToPosition(nt->GetOffset(), rect.x);
114 auto right = zoomInfo.TimeToPosition(nt->GetOffset() + nt->GetSeq().get_real_dur(), rect.x);
115 auto clipRect = wxRect(left, rect.y, right - left + 1, rect.height);
117 auto px = context.lastState.m_x;
118 auto py = context.lastState.m_y;
120 auto selected = IsSelected();
121 auto highlight = selected ||
122 (px >= clipRect.GetLeft() && px <= clipRect.GetRight() &&
123 py >= clipRect.GetTop() && py <= clipRect.GetBottom());
125 {
126 wxDCClipper clipper(context.dc, rect);
127 context.dc.SetTextBackground(wxTransparentColor);
128 context.dc.SetTextForeground(theTheme.Colour(clrClipNameText));
129 context.dc.SetFont(wxFont(wxFontInfo()));
130 const auto titleRect = TrackArt::DrawClipAffordance(context.dc, clipRect, highlight, selected);
131 TrackArt::DrawClipTitle(context.dc, titleRect, nt->GetName());
132 }
133 }
THEME_API Theme theTheme
Definition: Theme.cpp:82
static wxBrush labelSelectedBrush
Definition: AColor.h:122
static wxBrush labelUnselectedBrush
Definition: AColor.h:121
std::shared_ptr< Track > FindTrack()
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
AUDACITY_DLL_API wxRect DrawClipAffordance(wxDC &dc, const wxRect &affordanceRect, bool highlight=false, bool selected=false)
Definition: TrackArt.cpp:188
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArt.cpp:422
AUDACITY_DLL_API bool DrawClipTitle(wxDC &dc, const wxRect &titleRect, const wxString &title)
Definition: TrackArt.cpp:239

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 

Implements TrackPanelCell.

Definition at line 66 of file NoteTrackAffordanceControls.cpp.

68 std::vector<UIHandlePtr> results;
70 auto track = FindTrack();
71 const auto nt = std::static_pointer_cast<const NoteTrack>(track->SubstitutePendingChangedTrack());
73 const auto rect = state.rect;
75 auto& zoomInfo = ViewInfo::Get(*pProject);
76 auto left = zoomInfo.TimeToPosition(nt->GetOffset(), rect.x);
77 auto right = zoomInfo.TimeToPosition(nt->GetOffset() + nt->GetSeq().get_real_dur(), rect.x);
78 auto headerRect = wxRect(left, rect.y, right - left, rect.height);
80 auto px = state.state.m_x;
81 auto py = state.state.m_y;
83 if (px >= headerRect.GetLeft() && px <= headerRect.GetRight() &&
84 py >= headerRect.GetTop() && py <= headerRect.GetBottom())
85 {
87 }
89 const auto& settings = ProjectSettings::Get(*pProject);
90 const auto currentTool = settings.GetTool();
91 if (currentTool == ToolCodes::multiTool || currentTool == ToolCodes::selectTool)
92 {
93 results.push_back(
95 mSelectHandle, state, pProject,
96 TrackView::Get(*track).shared_from_this()
97 )
98 );
99 }
101 return results;
static Settings & settings()
Definition: TrackInfo.cpp:87
std::weak_ptr< NoteTrackAffordanceHandle > mAffordanceHandle
std::weak_ptr< SelectHandle > mSelectHandle
static UIHandlePtr HitAnywhere(std::weak_ptr< NoteTrackAffordanceHandle > &holder, const std::shared_ptr< Track > &pTrack)
static ProjectSettings & Get(AudacityProject &project)
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< TrackView > &pTrackView)
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

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

Here is the call graph for this function:

◆ IsSelected()

bool NoteTrackAffordanceControls::IsSelected ( ) const

Definition at line 136 of file NoteTrackAffordanceControls.cpp.

138 if (auto handle = mAffordanceHandle.lock())
139 {
140 return handle->Clicked();
141 }
142 return false;

References mAffordanceHandle.

Referenced by Draw().

Here is the caller graph for this function:

Member Data Documentation

◆ mAffordanceHandle

std::weak_ptr<NoteTrackAffordanceHandle> NoteTrackAffordanceControls::mAffordanceHandle

Definition at line 21 of file NoteTrackAffordanceControls.h.

Referenced by HitTest(), and IsSelected().

◆ mSelectHandle

std::weak_ptr<SelectHandle> NoteTrackAffordanceControls::mSelectHandle

Definition at line 22 of file NoteTrackAffordanceControls.h.

Referenced by HitTest().

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