Audacity  2.3.1
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
PlayIndicatorOverlayBase Class Reference

#include <PlayIndicatorOverlay.h>

Inheritance diagram for PlayIndicatorOverlayBase:
Overlay PlayIndicatorOverlay

Public Member Functions

 PlayIndicatorOverlayBase (AudacityProject *project, bool isMaster)
 
virtual ~PlayIndicatorOverlayBase ()
 
void Update (int newIndicatorX)
 
- Public Member Functions inherited from Overlay
virtual ~Overlay ()=0
 
std::pair< wxRect, bool > GetRectangle (wxSize size)
 
virtual void Erase (wxDC &dc, wxDC &src)
 

Protected Attributes

AudacityProject *const mProject
 
const bool mIsMaster
 
int mLastIndicatorX { -1 }
 
int mNewIndicatorX { -1 }
 
bool mNewIsCapturing { false }
 
bool mLastIsCapturing { false }
 

Private Member Functions

std::pair< wxRect, bool > DoGetRectangle (wxSize size) override
 
void Draw (OverlayPanel &panel, wxDC &dc) override
 

Detailed Description

Definition at line 22 of file PlayIndicatorOverlay.h.

Constructor & Destructor Documentation

PlayIndicatorOverlayBase::PlayIndicatorOverlayBase ( AudacityProject project,
bool  isMaster 
)

Definition at line 35 of file PlayIndicatorOverlay.cpp.

36 : mProject(project)
37 , mIsMaster(isMaster)
38 {
39 }
AudacityProject *const mProject
PlayIndicatorOverlayBase::~PlayIndicatorOverlayBase ( )
virtual

Definition at line 41 of file PlayIndicatorOverlay.cpp.

42 {
43 }

Member Function Documentation

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

Implements Overlay.

Definition at line 45 of file PlayIndicatorOverlay.cpp.

References IndicatorMediumWidth, mIsMaster, mLastIndicatorX, mLastIsCapturing, mNewIndicatorX, and mNewIsCapturing.

46 {
47  auto width = mIsMaster ? 1 : IndicatorMediumWidth;
48 
49  // May be excessive height, but little matter
50  wxRect rect(mLastIndicatorX - width / 2, 0, width, size.GetHeight());
51  return {
52  rect,
55  };
56 }
void PlayIndicatorOverlayBase::Draw ( OverlayPanel panel,
wxDC &  dc 
)
overrideprivatevirtual

Implements Overlay.

Definition at line 59 of file PlayIndicatorOverlay.cpp.

References gAudioIO, AudacityProject::GetRulerPanel(), AColor::IndicatorColor(), IndicatorMediumWidth, AudioIO::IsCapturing(), AColor::Line(), mIsMaster, mLastIndicatorX, mLastIsCapturing, mNewIndicatorX, mNewIsCapturing, mProject, Track::TypeSwitch(), and AdornedRulerPanel::UpdateButtonStates().

60 {
61  // Set play/record color
62  bool rec = gAudioIO->IsCapturing();
63  AColor::IndicatorColor(&dc, !rec);
64 
65  if (mIsMaster
67  // Detect transition to recording during punch and roll; make ruler
68  // change its button color too
69  const auto ruler = mProject->GetRulerPanel();
70  ruler->UpdateButtonStates();
71  ruler->Refresh();
72  }
74 
76  if (!between_incexc(0, mLastIndicatorX, dc.GetSize().GetWidth()))
77  return;
78 
79  if(auto tp = dynamic_cast<TrackPanel*>(&panel)) {
80  wxASSERT(mIsMaster);
81 
82  // Draw indicator in all visible tracks
83  tp->VisitCells( [&]( const wxRect &rect, TrackPanelCell &cell ) {
84  const auto pTrack = dynamic_cast<Track*>(&cell);
85  if (pTrack) pTrack->TypeSwitch(
86  [](LabelTrack *) {
87  // Don't draw the indicator in label tracks
88  },
89  [&](Track *) {
90  // Draw the NEW indicator in its NEW location
91  // AColor::Line includes both endpoints so use GetBottom()
92  AColor::Line(dc,
94  rect.GetTop(),
96  rect.GetBottom());
97  }
98  );
99  } );
100  }
101  else if(auto ruler = dynamic_cast<AdornedRulerPanel*>(&panel)) {
102  wxASSERT(!mIsMaster);
103 
104  ruler->DoDrawIndicator(&dc, mLastIndicatorX, !rec, IndicatorMediumWidth, false, false);
105  }
106  else
107  wxASSERT(false);
108 }
R TypeSwitch(const Functions &...functions)
Definition: Track.h:630
bool IsCapturing() const
Definition: AudioIO.cpp:5790
AudacityProject *const mProject
static void IndicatorColor(wxDC *dc, bool bIsNotRecording)
Definition: AColor.cpp:367
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:113
AdornedRulerPanel * GetRulerPanel()
Definition: Project.cpp:1518
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:191
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
AudioIO * gAudioIO
Definition: AudioIO.cpp:491
void PlayIndicatorOverlayBase::Update ( int  newIndicatorX)
inline

Definition at line 28 of file PlayIndicatorOverlay.h.

References mNewIndicatorX.

28 { mNewIndicatorX = newIndicatorX; }

Member Data Documentation

const bool PlayIndicatorOverlayBase::mIsMaster
protected

Definition at line 37 of file PlayIndicatorOverlay.h.

Referenced by DoGetRectangle(), and Draw().

int PlayIndicatorOverlayBase::mLastIndicatorX { -1 }
protected

Definition at line 38 of file PlayIndicatorOverlay.h.

Referenced by DoGetRectangle(), and Draw().

bool PlayIndicatorOverlayBase::mLastIsCapturing { false }
protected

Definition at line 41 of file PlayIndicatorOverlay.h.

Referenced by DoGetRectangle(), and Draw().

int PlayIndicatorOverlayBase::mNewIndicatorX { -1 }
protected

Definition at line 39 of file PlayIndicatorOverlay.h.

Referenced by DoGetRectangle(), Draw(), PlayIndicatorOverlay::OnTimer(), and Update().

bool PlayIndicatorOverlayBase::mNewIsCapturing { false }
protected

Definition at line 40 of file PlayIndicatorOverlay.h.

Referenced by DoGetRectangle(), Draw(), and PlayIndicatorOverlay::OnTimer().

AudacityProject* const PlayIndicatorOverlayBase::mProject
protected

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