MCPcopy Create free account
hub / github.com/audacity/audacity / OnTimer

Method OnTimer

src/tracks/ui/PlayIndicatorOverlay.cpp:150–248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150void PlayIndicatorOverlay::OnTimer(Observer::Message)
151{
152 // Ensure that there is an overlay attached to the ruler
153 if (!mPartner) {
154 auto &ruler = AdornedRulerPanel::Get( *mProject );
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
181 using Mode = ProjectWindow::PlaybackScroller::Mode;
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

Callers

nothing calls this directly

Calls 15

GetFunction · 0.85
maxFunction · 0.85
AddOverlayMethod · 0.80
GetLeftOffsetMethod · 0.80
GetRecentStreamTimeMethod · 0.80
GetModeMethod · 0.80
SetHorizontalThumbMethod · 0.80
TimeToPositionMethod · 0.80
IsCapturingMethod · 0.80
between_incexcFunction · 0.70

Tested by

no test coverage detected