| 259 | } |
| 260 | |
| 261 | SnapResults 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 | } |
no test coverage detected