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

#include <PlayIndicatorOverlay.h>

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

Public Member Functions

 PlayIndicatorOverlay (AudacityProject *project)
 
- Public Member Functions inherited from PlayIndicatorOverlayBase
 PlayIndicatorOverlayBase (AudacityProject *project, bool isMaster)
 
virtual ~PlayIndicatorOverlayBase ()
 
void Update (int newIndicatorX)
 
- 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

void OnTimer (Observer::Message)
 

Private Attributes

std::shared_ptr< PlayIndicatorOverlayBasemPartner
 
Observer::Subscription mSubscription
 

Additional Inherited Members

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

Detailed Description

Definition at line 49 of file PlayIndicatorOverlay.h.

Constructor & Destructor Documentation

◆ PlayIndicatorOverlay()

PlayIndicatorOverlay::PlayIndicatorOverlay ( AudacityProject project)
explicit

Definition at line 145 of file PlayIndicatorOverlay.cpp.

147{
150}
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
PlayIndicatorOverlayBase(AudacityProject *project, bool isMaster)
AudacityProject *const mProject
Observer::Subscription mSubscription
void OnTimer(Observer::Message)
PlaybackScroller & GetPlaybackScroller()
static ProjectWindow & Get(AudacityProject &project)

References ProjectWindow::Get(), ProjectWindow::GetPlaybackScroller(), PlayIndicatorOverlayBase::mProject, mSubscription, OnTimer(), and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

Member Function Documentation

◆ OnTimer()

void PlayIndicatorOverlay::OnTimer ( Observer::Message  )
private

Definition at line 152 of file PlayIndicatorOverlay.cpp.

153{
154 // Ensure that there is an overlay attached to the ruler
155 if (!mPartner) {
157 mPartner = std::make_shared<PlayIndicatorOverlayBase>(mProject, false);
158 ruler.AddOverlay( mPartner );
159 }
160
161 const auto &viewInfo = ViewInfo::Get( *mProject );
162 auto width = viewInfo.GetTracksUsableWidth();
163
164 if (!ProjectAudioIO::Get( *mProject ).IsAudioActive()) {
165 mNewIndicatorX = -1;
166 mNewIsCapturing = false;
167 const auto &scrubber = Scrubber::Get( *mProject );
168 if (scrubber.HasMark()) {
169 auto position = scrubber.GetScrubStartPosition();
170 const auto offset = viewInfo.GetLeftOffset();
171 if(position >= viewInfo.GetLeftOffset() &&
172 position < offset + width)
173 mNewIndicatorX = position;
174 }
175 }
176 else {
177 auto &viewport = Viewport::Get(*mProject);
178 auto &window = ProjectWindow::Get( *mProject );
179 auto &scroller = window.GetPlaybackScroller();
180 // Calculate the horizontal position of the indicator
181 const double playPos = scroller.GetRecentStreamTime();
182
184 const Mode mode = scroller.GetMode();
185 const bool pinned = ( mode == Mode::Pinned || mode == Mode::Right );
186
187 // Use a small tolerance to avoid flicker of play head pinned all the way
188 // left or right
189 const auto tolerance = pinned
190 ? 1.5 * std::chrono::duration<double>{kTimerInterval}.count()
191 : 0;
192 bool onScreen = playPos >= 0.0 &&
193 between_incexc(viewInfo.hpos - tolerance,
194 playPos,
195 viewInfo.GetScreenEndTime() + tolerance);
196
197 auto gAudioIO = AudioIO::Get();
198 const auto &scrubber = Scrubber::Get( *mProject );
199
200 // BG: Scroll screen if option is set
201 if( viewInfo.bUpdateTrackIndicator &&
202 playPos >= 0 && !onScreen ) {
203 // msmeyer: But only if not playing looped or in one-second mode
204 // PRL: and not scrolling with play/record head fixed
205 auto mode = ProjectAudioManager::Get( *mProject ).GetLastPlayMode();
206 if (!pinned &&
207 mode != PlayMode::oneSecondPlay &&
208 !gAudioIO->IsPaused() &&
209 // Bug 2656 allow scrolling when paused in
210 // scrubbing/play-at-speed.
211 // ONLY do this additional test if scrubbing/play-at-speed
212 // is active.
213 (!scrubber.IsScrubbing() || !scrubber.IsPaused())
214 )
215 {
216 auto newPos = playPos;
217 if (playPos < viewInfo.hpos) {
218 // This is possible when scrubbing backwards.
219 // We want to page leftward by (at least) a whole screen, not
220 // just a little bit equal to the scrubbing poll interval
221 // duration.
222 newPos = viewInfo.OffsetTimeByPixels( newPos, -width );
223 newPos = std::max(newPos, viewport.ScrollingLowerBoundTime());
224 }
225 viewport.SetHorizontalThumb(newPos);
226 // Might yet be off screen, check it
227 onScreen = playPos >= 0.0 &&
228 between_incexc(viewInfo.hpos,
229 playPos,
230 viewInfo.GetScreenEndTime());
231 }
232 }
233
234 // Always update scrollbars even if not scrolling the window. This is
235 // important when NEW audio is recorded, because this can change the
236 // length of the project and therefore the appearance of the scrollbar.
237 viewport.UpdateScrollbarsForTracks();
238
239 if (onScreen)
241 viewInfo.TimeToPosition(playPos, viewInfo.GetLeftOffset());
242 else
243 mNewIndicatorX = -1;
244
245 mNewIsCapturing = gAudioIO->IsCapturing();
246 }
247
248 if(mPartner)
249 mPartner->Update(mNewIndicatorX);
250}
constexpr auto kTimerInterval
static AdornedRulerPanel & Get(AudacityProject &project)
static AudioIO * Get()
Definition: AudioIO.cpp:126
std::shared_ptr< PlayIndicatorOverlayBase > mPartner
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectAudioManager & Get(AudacityProject &project)
PlayMode GetLastPlayMode() const
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:188
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
static Viewport & Get(AudacityProject &project)
Definition: Viewport.cpp:32

References anonymous_namespace{PlayIndicatorOverlay.cpp}::between_incexc(), AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), Viewport::Get(), AdornedRulerPanel::Get(), ProjectAudioManager::Get(), ProjectWindow::Get(), Scrubber::Get(), ProjectAudioManager::GetLastPlayMode(), ProjectAudioIO::IsAudioActive(), kTimerInterval, PlayIndicatorOverlayBase::mNewIndicatorX, PlayIndicatorOverlayBase::mNewIsCapturing, mPartner, PlayIndicatorOverlayBase::mProject, oneSecondPlay, and anonymous_namespace{TimeTrackVRulerControls.cpp}::ruler().

Referenced by PlayIndicatorOverlay().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mPartner

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

Definition at line 58 of file PlayIndicatorOverlay.h.

Referenced by OnTimer().

◆ mSubscription

Observer::Subscription PlayIndicatorOverlay::mSubscription
private

Definition at line 59 of file PlayIndicatorOverlay.h.

Referenced by PlayIndicatorOverlay().


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