Audacity  3.0.3
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)
 
 ~CommonTrackCell ()
 
virtual void CopyTo (Track &track) const
 
std::shared_ptr< TrackDoFindTrack () override
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 
virtual void WriteXMLAttributes (XMLWriter &) const
 
virtual bool HandleXMLAttribute (const wxChar *attr, const wxChar *value)
 
- 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 std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
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 wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 
- Static Public Member Functions inherited from CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- 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
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 59 of file NoteTrackAffordanceControls.cpp.

60  : CommonTrackCell(pTrack)
61 {
62 
63 }

Member Function Documentation

◆ Draw()

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

Reimplemented from TrackPanelDrawable.

Definition at line 102 of file NoteTrackAffordanceControls.cpp.

103 {
104  if (iPass == TrackArtist::PassBackground) {
105  const auto nt = std::static_pointer_cast<const NoteTrack>(FindTrack()->SubstitutePendingChangedTrack());
106  const auto artist = TrackArtist::Get(context);
107 
109 
110  const auto& zoomInfo = *artist->pZoomInfo;
111  auto left = zoomInfo.TimeToPosition(nt->GetOffset(), rect.x);
112  auto right = zoomInfo.TimeToPosition(nt->GetOffset() + nt->GetSeq().get_real_dur(), rect.x);
113  auto clipRect = wxRect(left, rect.y, right - left + 1, rect.height);
114 
115  auto px = context.lastState.m_x;
116  auto py = context.lastState.m_y;
117 
118  auto selected = IsSelected();
119  auto highlight = selected ||
120  (px >= clipRect.GetLeft() && px <= clipRect.GetRight() &&
121  py >= clipRect.GetTop() && py <= clipRect.GetBottom());
122 
123  {
124  wxDCClipper clipper(context.dc, rect);
125  context.dc.SetTextBackground(wxTransparentColor);
126  context.dc.SetTextForeground(theTheme.Colour(clrClipNameText));
127  context.dc.SetFont(wxFont(wxFontInfo()));
128  TrackArt::DrawClipAffordance(context.dc, clipRect, nt->GetName(), highlight, selected);
129  }
130  }
131 }

References ThemeBase::Colour(), TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), TrackArt::DrawClipAffordance(), 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 65 of file NoteTrackAffordanceControls.cpp.

66 {
67  std::vector<UIHandlePtr> results;
68 
69  auto track = FindTrack();
70  const auto nt = std::static_pointer_cast<const NoteTrack>(track->SubstitutePendingChangedTrack());
71 
72  const auto rect = state.rect;
73 
74  auto& zoomInfo = ViewInfo::Get(*pProject);
75  auto left = zoomInfo.TimeToPosition(nt->GetOffset(), rect.x);
76  auto right = zoomInfo.TimeToPosition(nt->GetOffset() + nt->GetSeq().get_real_dur(), rect.x);
77  auto headerRect = wxRect(left, rect.y, right - left, rect.height);
78 
79  auto px = state.state.m_x;
80  auto py = state.state.m_y;
81 
82  if (px >= headerRect.GetLeft() && px <= headerRect.GetRight() &&
83  py >= headerRect.GetTop() && py <= headerRect.GetBottom())
84  {
86  }
87 
88  const auto& settings = ProjectSettings::Get(*pProject);
89  const auto currentTool = settings.GetTool();
90  if (currentTool == ToolCodes::multiTool || currentTool == ToolCodes::selectTool)
91  {
92  results.push_back(
94  mSelectHandle, state, pProject, std::static_pointer_cast<TrackView>(track->GetTrackView())
95  )
96  );
97  }
98 
99  return results;
100 }

References CommonTrackPanelCell::FindTrack(), ViewInfo::Get(), ProjectSettings::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 133 of file NoteTrackAffordanceControls.cpp.

134 {
135  if (auto handle = mAffordanceHandle.lock())
136  {
137  return handle->Clicked();
138  }
139  return false;
140 }

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:
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
AColor::labelUnselectedBrush
static wxBrush labelUnselectedBrush
Definition: AColor.h:110
ToolCodes::selectTool
@ selectTool
Definition: ProjectSettings.h:40
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:44
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
NoteTrackAffordanceControls::mAffordanceHandle
std::weak_ptr< NoteTrackAffordanceHandle > mAffordanceHandle
Definition: NoteTrackAffordanceControls.h:21
TrackPanelMouseState::rect
const wxRect & rect
Definition: TrackPanelMouseEvent.h:39
TrackArt::DrawClipAffordance
AUDACITY_DLL_API void DrawClipAffordance(wxDC &dc, const wxRect &affordanceRect, const wxString &title, bool highlight=false, bool selected=false)
Definition: TrackArtist.cpp:302
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:79
ToolCodes::multiTool
@ multiTool
Definition: ProjectSettings.h:44
CommonTrackCell::CommonTrackCell
CommonTrackCell(const std::shared_ptr< Track > &pTrack)
Definition: CommonTrackPanelCell.cpp:132
TrackPanelDrawingContext::lastState
wxMouseState lastState
Definition: TrackPanelDrawingContext.h:25
AColor::labelSelectedBrush
static wxBrush labelSelectedBrush
Definition: AColor.h:111
NoteTrackAffordanceControls::IsSelected
bool IsSelected() const
Definition: NoteTrackAffordanceControls.cpp:133
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
TrackArt::DrawBackgroundWithSelection
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArtist.cpp:528
SelectHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< TrackView > &pTrackView)
Definition: SelectHandle.cpp:362
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
NoteTrackAffordanceHandle::HitAnywhere
static UIHandlePtr HitAnywhere(std::weak_ptr< NoteTrackAffordanceHandle > &holder, const std::shared_ptr< Track > &pTrack)
Definition: NoteTrackAffordanceControls.cpp:40
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
TrackArtist::PassBackground
@ PassBackground
Definition: TrackArtist.h:86
TrackPanelMouseState::state
wxMouseState & state
Definition: TrackPanelMouseEvent.h:38
NoteTrackAffordanceControls::mSelectHandle
std::weak_ptr< SelectHandle > mSelectHandle
Definition: NoteTrackAffordanceControls.h:22