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

Function MoveWhenAudioInactive

src/menus/SelectMenus.cpp:209–266  ·  view source on GitHub ↗

Moving a cursor, and collapsed selection.

Source from the content-addressed store, hash-verified

207
208// Moving a cursor, and collapsed selection.
209void MoveWhenAudioInactive
210(AudacityProject &project, double seekStep, TimeUnit timeUnit)
211{
212 auto &viewInfo = ViewInfo::Get(project);
213 auto &trackPanel = TrackPanel::Get(project);
214 auto &tracks = TrackList::Get(project);
215 auto &ruler = AdornedRulerPanel::Get(project);
216 const auto &settings = ProjectSnap::Get(project);
217 auto &viewport = Viewport::Get(project);
218
219 // If TIME_UNIT_SECONDS, snap-to will be off.
220 auto snapMode = settings.GetSnapMode();
221
222 // Move the cursor
223 // Already in cursor mode?
224 if (viewInfo.selectedRegion.isPoint())
225 {
226 double newT = OffsetTime(
227 project, viewInfo.selectedRegion.t0(), seekStep, timeUnit, snapMode);
228 // constrain.
229 newT = std::max(0.0, newT);
230 // Move
231 viewInfo.selectedRegion.setT0(
232 newT,
233 false); // do not swap selection boundaries
234 viewInfo.selectedRegion.collapseToT0();
235
236 // Move the visual cursor, avoiding an unnecessary complete redraw
237 trackPanel.DrawOverlays(false);
238 ruler.DrawOverlays(false);
239 }
240 else
241 {
242 // Transition to cursor mode.
243 constexpr auto maySwapBoundaries = false;
244 if (seekStep < 0)
245 {
246 if (snapMode != SnapMode::SNAP_OFF)
247 viewInfo.selectedRegion.setT0(
248 settings.SnapTime(viewInfo.selectedRegion.t0()).time,
249 maySwapBoundaries);
250 viewInfo.selectedRegion.collapseToT0();
251 }
252 else
253 {
254 if (snapMode != SnapMode::SNAP_OFF)
255 viewInfo.selectedRegion.setT1(
256 settings.SnapTime(viewInfo.selectedRegion.t1()).time,
257 maySwapBoundaries);
258 viewInfo.selectedRegion.collapseToT1();
259 }
260 trackPanel.Refresh(false);
261 }
262
263 // Make sure NEW position is in view
264 viewport.ScrollIntoView(viewInfo.selectedRegion.t1());
265 return;
266}

Callers 2

SeekWhenAudioInactiveFunction · 0.85
DoCursorMoveFunction · 0.85

Calls 12

GetFunction · 0.85
OffsetTimeFunction · 0.85
maxFunction · 0.85
GetSnapModeMethod · 0.80
setT0Method · 0.80
collapseToT0Method · 0.80
DrawOverlaysMethod · 0.80
SnapTimeMethod · 0.80
setT1Method · 0.80
collapseToT1Method · 0.80
ScrollIntoViewMethod · 0.80
RefreshMethod · 0.45

Tested by

no test coverage detected