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

Method Snap

libraries/lib-snapping/Snap.cpp:261–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261SnapResults SnapManager::Snap
262(Track *currentTrack, double t, bool rightEdge)
263{
264
265 SnapResults results;
266 // Check to see if we need to reinitialize
267 Reinit();
268
269 results.timeSnappedTime = results.outTime = t;
270 results.outCoord = mZoomInfo->TimeToPosition(t);
271
272 // First snap to points in mSnapPoints
273 results.snappedPoint =
274 SnapToPoints(currentTrack, t, rightEdge, &results.outTime);
275
276 if (mSnapToTime) {
277 // Find where it would snap time to the grid
278 results.timeSnappedTime = ProjectSnap::Get(*mProject).SnapTime(t).time;
279 }
280
281 results.snappedTime = false;
282 if (mSnapToTime)
283 {
284 if (results.snappedPoint)
285 {
286 // Since mSnapPoints only contains points on the grid, we're done
287 results.snappedTime = true;
288 }
289 else
290 {
291 results.outTime = results.timeSnappedTime;
292 results.snappedTime = true;
293 }
294 }
295
296 if (results.Snapped())
297 results.outCoord = mZoomInfo->TimeToPosition(results.outTime);
298
299 return results;
300}

Callers 5

HandleSnappingMethod · 0.45
DragMethod · 0.45
AdjustToSnapFunction · 0.45
SelectHandleMethod · 0.45
AdjustSelectionMethod · 0.45

Calls 4

GetFunction · 0.85
TimeToPositionMethod · 0.80
SnapTimeMethod · 0.80
SnappedMethod · 0.80

Tested by

no test coverage detected