Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PlayIndicatorOverlay Class Referencefinal

#include <PlayIndicatorOverlay.h>

Inheritance diagram for PlayIndicatorOverlay:
PlayIndicatorOverlayBase Overlay

Public Member Functions

 PlayIndicatorOverlay (AudacityProject *project)
 
virtual ~PlayIndicatorOverlay ()
 
- Public Member Functions inherited from PlayIndicatorOverlayBase
 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)
 

Private Member Functions

void OnTimer (wxCommandEvent &event)
 

Private Attributes

std::unique_ptr
< PlayIndicatorOverlayBase
mPartner
 

Additional Inherited Members

- Protected Attributes inherited from PlayIndicatorOverlayBase
AudacityProject *const mProject
 
const bool mIsMaster
 
int mLastIndicatorX { -1 }
 
int mNewIndicatorX { -1 }
 

Detailed Description

Definition at line 43 of file PlayIndicatorOverlay.h.

Constructor & Destructor Documentation

PlayIndicatorOverlay::PlayIndicatorOverlay ( AudacityProject project)

Definition at line 104 of file PlayIndicatorOverlay.cpp.

References PlayIndicatorOverlayBase::mProject, and OnTimer().

105 : PlayIndicatorOverlayBase(project, true)
106 {
107  mProject->Bind(EVT_TRACK_PANEL_TIMER,
109  this);
110 }
PlayIndicatorOverlayBase(AudacityProject *project, bool isMaster)
AudacityProject *const mProject
void OnTimer(wxCommandEvent &event)
PlayIndicatorOverlay::~PlayIndicatorOverlay ( )
virtual

Definition at line 112 of file PlayIndicatorOverlay.cpp.

References AudacityProject::GetRulerPanel(), mPartner, PlayIndicatorOverlayBase::mProject, and OverlayPanel::RemoveOverlay().

113 {
114  if (mPartner) {
115  auto ruler = mProject->GetRulerPanel();
116  if(ruler)
117  ruler->RemoveOverlay(mPartner.get());
118  }
119 }
std::unique_ptr< PlayIndicatorOverlayBase > mPartner
bool RemoveOverlay(Overlay *pOverlay)
AudacityProject *const mProject
AdornedRulerPanel * GetRulerPanel()
Definition: Project.cpp:1439

Member Function Documentation

void PlayIndicatorOverlay::OnTimer ( wxCommandEvent &  event)
private

Definition at line 121 of file PlayIndicatorOverlay.cpp.

References ViewInfo::bUpdateTrackIndicator, gAudioIO, AudacityProject::PlaybackScroller::GetMode(), AudacityProject::GetPlaybackScroller(), AudacityProject::GetRulerPanel(), AudacityProject::GetScreenEndTime(), AudacityProject::GetScrubber(), Scrubber::GetScrubStartPosition(), AudacityProject::GetTrackPanel(), AudacityProject::GetViewInfo(), ZoomInfo::h, AudacityProject::IsAudioActive(), AudioIO::IsPaused(), loopedPlay, AudacityProject::mLastPlayMode, PlayIndicatorOverlayBase::mNewIndicatorX, mPartner, PlayIndicatorOverlayBase::mProject, ViewInfo::mRecentStreamTime, oneSecondPlay, AudacityProject::PlaybackScroller::Right, ZoomInfo::TimeToPosition(), AudacityProject::TP_DisplaySelection(), AudacityProject::TP_RedrawScrollbars(), and AudacityProject::TP_ScrollWindow().

Referenced by PlayIndicatorOverlay().

122 {
123  // Let other listeners get the notification
124  event.Skip();
125 
126  // Ensure that there is an overlay attached to the ruler
127  if (!mPartner) {
128  auto ruler = mProject->GetRulerPanel();
129  if (ruler) {
130  mPartner = std::make_unique<PlayIndicatorOverlayBase>(mProject, false);
131  ruler->AddOverlay(mPartner.get());
132  }
133  }
134 
135  auto trackPanel = mProject->GetTrackPanel();
136 
137  if (!mProject->IsAudioActive()) {
138  mNewIndicatorX = -1;
139  const auto &scrubber = mProject->GetScrubber();
140  if (scrubber.HasStartedScrubbing()) {
141  auto position = scrubber.GetScrubStartPosition();
142  int width;
143  trackPanel->GetTracksUsableArea(&width, nullptr);
144  const auto offset = trackPanel->GetLeftOffset();
145  if(position >= trackPanel->GetLeftOffset() &&
146  position < offset + width)
147  mNewIndicatorX = position;
148  }
149  }
150  else {
151  ViewInfo &viewInfo = mProject->GetViewInfo();
152 
153  // Calculate the horizontal position of the indicator
154  const double playPos = viewInfo.mRecentStreamTime;
155 
156  bool onScreen = playPos >= 0.0 &&
157  between_incexc(viewInfo.h,
158  playPos,
160 
161  // This displays the audio time, too...
163 
164  // BG: Scroll screen if option is set
165  // msmeyer: But only if not playing looped or in one-second mode
166  // PRL: and not scrolling with play/record head fixed right
167  if (viewInfo.bUpdateTrackIndicator &&
172  playPos >= 0 &&
173  !onScreen &&
174  !gAudioIO->IsPaused())
175  {
176  mProject->TP_ScrollWindow(playPos);
177  // Might yet be off screen, check it
178  onScreen = playPos >= 0.0 &&
179  between_incexc(viewInfo.h,
180  playPos,
182  }
183 
184  // Always update scrollbars even if not scrolling the window. This is
185  // important when NEW audio is recorded, because this can change the
186  // length of the project and therefore the appearance of the scrollbar.
188 
189  if (onScreen)
190  mNewIndicatorX = viewInfo.TimeToPosition(playPos, trackPanel->GetLeftOffset());
191  else
192  mNewIndicatorX = -1;
193  }
194 
195  if(mPartner)
196  mPartner->Update(mNewIndicatorX);
197 }
bool bUpdateTrackIndicator
Definition: ViewInfo.h:182
ViewInfo is used mainly to hold the zooming, selection and scroll information. It also has some statu...
Definition: ViewInfo.h:141
Scrubber & GetScrubber()
Definition: Project.h:801
std::unique_ptr< PlayIndicatorOverlayBase > mPartner
double h
Definition: ViewInfo.h:47
void TP_RedrawScrollbars() override
Definition: Project.cpp:5438
AudacityProject *const mProject
void TP_ScrollWindow(double scrollto) override
Definition: Project.cpp:1856
AdornedRulerPanel * GetRulerPanel()
Definition: Project.cpp:1439
bool IsPaused()
Find out if playback / recording is currently paused.
Definition: AudioIO.cpp:2857
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ViewInfo.cpp:59
bool IsAudioActive() const
Definition: Project.cpp:1454
PlayMode mLastPlayMode
Definition: Project.h:557
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
PlaybackScroller & GetPlaybackScroller()
Definition: Project.h:832
double GetScreenEndTime() const
Definition: Menus.cpp:6731
double mRecentStreamTime
Definition: ViewInfo.h:189
TrackPanel * GetTrackPanel()
Definition: Project.h:307
void TP_DisplaySelection() override
Definition: Project.cpp:5367
wxCoord GetScrubStartPosition() const
Definition: Scrubbing.h:90
const ViewInfo & GetViewInfo() const
Definition: Project.h:207

Member Data Documentation

std::unique_ptr<PlayIndicatorOverlayBase> PlayIndicatorOverlay::mPartner
private

Definition at line 52 of file PlayIndicatorOverlay.h.

Referenced by OnTimer(), and ~PlayIndicatorOverlay().


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