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 &) PROHIBITED
 
Overlayoperator= (const Overlay &) PROHIBITED
 
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.

146: PlayIndicatorOverlayBase(project, true)
147{
150}
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 &window = ProjectWindow::Get( *mProject );
178 auto &scroller = window.GetPlaybackScroller();
179 // Calculate the horizontal position of the indicator
180 const double playPos = scroller.GetRecentStreamTime();
181
183 const Mode mode = scroller.GetMode();
184 const bool pinned = ( mode == Mode::Pinned || mode == Mode::Right );
185
186 // Use a small tolerance to avoid flicker of play head pinned all the way
187 // left or right
188 const auto tolerance = pinned
189 ? 1.5 * std::chrono::duration<double>{kTimerInterval}.count()
190 : 0;
191 bool onScreen = playPos >= 0.0 &&
192 between_incexc(viewInfo.h - tolerance,
193 playPos,
194 viewInfo.GetScreenEndTime() + tolerance);
195
196 auto gAudioIO = AudioIO::Get();
197 const auto &scrubber = Scrubber::Get( *mProject );
198
199 // BG: Scroll screen if option is set
200 if( viewInfo.bUpdateTrackIndicator &&
201 playPos >= 0 && !onScreen ) {
202 // msmeyer: But only if not playing looped or in one-second mode
203 // PRL: and not scrolling with play/record head fixed
204 auto mode = ProjectAudioManager::Get( *mProject ).GetLastPlayMode();
205 if (!pinned &&
206 mode != PlayMode::oneSecondPlay &&
207 !gAudioIO->IsPaused() &&
208 // Bug 2656 allow scrolling when paused in
209 // scrubbing/play-at-speed.
210 // ONLY do this additional test if scrubbing/play-at-speed
211 // is active.
212 (!scrubber.IsScrubbing() || !scrubber.IsPaused())
213 )
214 {
215 auto newPos = playPos;
216 if (playPos < viewInfo.h) {
217 // This is possible when scrubbing backwards.
218 // We want to page leftward by (at least) a whole screen, not
219 // just a little bit equal to the scrubbing poll interval
220 // duration.
221 newPos = viewInfo.OffsetTimeByPixels( newPos, -width );
222 newPos = std::max( newPos, window.ScrollingLowerBoundTime() );
223 }
224 window.TP_ScrollWindow(newPos);
225 // Might yet be off screen, check it
226 onScreen = playPos >= 0.0 &&
227 between_incexc(viewInfo.h,
228 playPos,
229 viewInfo.GetScreenEndTime());
230 }
231 }
232
233 // Always update scrollbars even if not scrolling the window. This is
234 // important when NEW audio is recorded, because this can change the
235 // length of the project and therefore the appearance of the scrollbar.
236 window.TP_RedrawScrollbars();
237
238 if (onScreen)
240 viewInfo.TimeToPosition(playPos, viewInfo.GetLeftOffset());
241 else
242 mNewIndicatorX = -1;
243
244 mNewIsCapturing = gAudioIO->IsCapturing();
245 }
246
247 if(mPartner)
248 mPartner->Update(mNewIndicatorX);
249}
constexpr auto kTimerInterval
static AdornedRulerPanel & Get(AudacityProject &project)
static AudioIO * Get()
Definition: AudioIO.cpp:147
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:187
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References anonymous_namespace{PlayIndicatorOverlay.cpp}::between_incexc(), AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::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: