Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EditCursorOverlay Class Referencefinal

#include <EditCursorOverlay.h>

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

Public Member Functions

 EditCursorOverlay (AudacityProject *project, bool isMaster=true)
 
- Public Member Functions inherited from Overlay
 Overlay ()=default
 
 Overlay (const Overlay &)=delete
 
Overlayoperator= (const Overlay &)=delete
 
virtual ~Overlay ()=0
 
virtual unsigned SequenceNumber () const =0
 This number determines an ordering of overlays, so that those with higher numbers overpaint those with lower numbers that intersect. More...
 
std::pair< wxRect, bool > GetRectangle (wxSize size)
 
virtual std::pair< wxRect, bool > DoGetRectangle (wxSize size)=0
 
virtual void Erase (wxDC &dc, wxDC &src)
 
virtual void Draw (OverlayPanel &panel, wxDC &dc)=0
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 

Private Member Functions

unsigned SequenceNumber () const override
 This number determines an ordering of overlays, so that those with higher numbers overpaint those with lower numbers that intersect. More...
 
std::pair< wxRect, bool > DoGetRectangle (wxSize size) override
 
void Draw (OverlayPanel &panel, wxDC &dc) override
 

Private Attributes

AudacityProjectmProject
 
bool mIsMaster
 
std::shared_ptr< EditCursorOverlaymPartner
 
int mLastCursorX
 
double mCursorTime
 
int mNewCursorX
 

Detailed Description

Definition at line 20 of file EditCursorOverlay.h.

Constructor & Destructor Documentation

◆ EditCursorOverlay()

EditCursorOverlay::EditCursorOverlay ( AudacityProject project,
bool  isMaster = true 
)
explicit

Definition at line 42 of file EditCursorOverlay.cpp.

44 , mIsMaster(isMaster)
45 , mLastCursorX(-1)
46 , mCursorTime(-1)
47 , mNewCursorX(-1)
48{
49}
const auto project
AudacityProject * mProject

Member Function Documentation

◆ DoGetRectangle()

std::pair< wxRect, bool > EditCursorOverlay::DoGetRectangle ( wxSize  size)
overrideprivatevirtual

Implements Overlay.

Definition at line 56 of file EditCursorOverlay.cpp.

57{
58 const auto &viewInfo = ViewInfo::Get( *mProject );
59 const auto &selection = viewInfo.selectedRegion;
60 if (!selection.isPoint()) {
61 mCursorTime = -1.0;
62 mNewCursorX = -1;
63 }
64 else {
65 mCursorTime = selection.t0();
66 mNewCursorX = viewInfo.TimeToPosition(
67 mCursorTime, viewInfo.GetLeftOffset());
68 }
69
70 // Excessive height in case of the ruler, but it matters little.
71 return std::make_pair(
72 mLastCursorX == -1
73 ? wxRect()
74 : wxRect(mLastCursorX, 0, 1, size.GetHeight()),
76 );
77}
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References ViewInfo::Get(), mCursorTime, mLastCursorX, mNewCursorX, mProject, and size.

Here is the call graph for this function:

◆ Draw()

void EditCursorOverlay::Draw ( OverlayPanel panel,
wxDC &  dc 
)
overrideprivatevirtual

Implements Overlay.

Definition at line 80 of file EditCursorOverlay.cpp.

81{
82 if (mIsMaster && !mPartner) {
84 mPartner = std::make_shared<EditCursorOverlay>(mProject, false);
85 ruler.AddOverlay( mPartner );
86 }
87
89 if (mLastCursorX == -1)
90 return;
91
92 const auto &viewInfo = ViewInfo::Get( *mProject );
93
94 const bool
95 onScreen = between_incexc(viewInfo.hpos,
97 viewInfo.GetScreenEndTime());
98
99 if (!onScreen)
100 return;
101
102 auto &trackPanel = TrackPanel::Get( *mProject );
103 //NOTE: point selection cursor drawing over tracks moved to TrackPanel.cpp(see also TrackArt::DrawCursor)
104 /*if (auto tp = dynamic_cast<TrackPanel*>(&panel)) {
105 wxASSERT(mIsMaster);
106 AColor::CursorColor(&dc);
107
108 // Draw cursor in all selected tracks
109 tp->VisitCells( [&]( const wxRect &rect, TrackPanelCell &cell ) {
110 const auto pChannelView = dynamic_cast<ChannelView*>(&cell);
111 if (!pChannelView)
112 return;
113 const auto pChannel = pChannelView->FindChannel();
114 const auto pTrack =
115 dynamic_cast<Track *>(&pChannel->GetChannelGroup());
116 if (pChannel && (pTrack->GetSelected() ||
117 TrackFocus::Get( *mProject ).IsFocused(pTrack)))
118 {
119 // AColor::Line includes both endpoints so use GetBottom()
120 AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom());
121 // ^^^ The whole point of this routine.
122
123 }
124 } );
125 }
126 else if (auto ruler = dynamic_cast<AdornedRulerPanel*>(&panel)) {
127 wxASSERT(!mIsMaster);
128 dc.SetPen(*wxBLACK_PEN);
129 // AColor::Line includes both endpoints so use GetBottom()
130 auto rect = ruler->GetInnerRect();
131 AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom());
132 }
133 else
134 wxASSERT(false);*/
135 if (auto ruler = dynamic_cast<AdornedRulerPanel*>(&panel)) {
136 wxASSERT(!mIsMaster);
137 dc.SetPen(*wxBLACK_PEN);
138 // AColor::Line includes both endpoints so use GetBottom()
139 auto rect = ruler->GetInnerRect();
140 AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom());
141 }
142}
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:194
This is an Audacity Specific ruler panel which additionally has border, selection markers,...
static AdornedRulerPanel & Get(AudacityProject &project)
std::shared_ptr< EditCursorOverlay > mPartner
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234

References anonymous_namespace{EditCursorOverlay.cpp}::between_incexc(), ViewInfo::Get(), AdornedRulerPanel::Get(), TrackPanel::Get(), AColor::Line(), mCursorTime, mIsMaster, mLastCursorX, mNewCursorX, mPartner, mProject, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Here is the call graph for this function:

◆ SequenceNumber()

unsigned EditCursorOverlay::SequenceNumber ( ) const
overrideprivatevirtual

This number determines an ordering of overlays, so that those with higher numbers overpaint those with lower numbers that intersect.

Implements Overlay.

Definition at line 51 of file EditCursorOverlay.cpp.

52{
53 return 20;
54}

Member Data Documentation

◆ mCursorTime

double EditCursorOverlay::mCursorTime
private

Definition at line 38 of file EditCursorOverlay.h.

Referenced by DoGetRectangle(), and Draw().

◆ mIsMaster

bool EditCursorOverlay::mIsMaster
private

Definition at line 34 of file EditCursorOverlay.h.

Referenced by Draw().

◆ mLastCursorX

int EditCursorOverlay::mLastCursorX
private

Definition at line 37 of file EditCursorOverlay.h.

Referenced by DoGetRectangle(), and Draw().

◆ mNewCursorX

int EditCursorOverlay::mNewCursorX
private

Definition at line 39 of file EditCursorOverlay.h.

Referenced by DoGetRectangle(), and Draw().

◆ mPartner

std::shared_ptr<EditCursorOverlay> EditCursorOverlay::mPartner
private

Definition at line 35 of file EditCursorOverlay.h.

Referenced by Draw().

◆ mProject

AudacityProject* EditCursorOverlay::mProject
private

Definition at line 33 of file EditCursorOverlay.h.

Referenced by DoGetRectangle(), and Draw().


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