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 143 of file PlayIndicatorOverlay.cpp.

145{
148}
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 150 of file PlayIndicatorOverlay.cpp.

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

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: