Exemplo n.º 1
0
bool SnapManager::Snap(Track *currentTrack,
                       double t,
                       bool rightEdge,
                       double *outT,
                       bool *snappedPoint,
                       bool *snappedTime)
{
   // Check to see if we need to reinitialize
   Reinit();

   // First snap to points in mSnapPoints
   *outT = t;
   *snappedPoint = SnapToPoints(currentTrack, t, rightEdge, outT);

   // Now snap to the time grid
   *snappedTime = false;
   if (mSnapToTime)
   {
      if (*snappedPoint)
      {
         // Since mSnapPoints only contains points on the grid, we're done
         *snappedTime = true;
      }
      else
      {
         // Snap time to the grid
         mConverter.ValueToControls(t, GetActiveProject()->GetSnapTo() == SNAP_NEAREST);
         mConverter.ControlsToValue();
         *outT = mConverter.GetValue();
         *snappedTime = true;
      }
   }

   return *snappedPoint || *snappedTime;
}
Exemplo n.º 2
0
SnapResults SnapManager::Snap
(Track *currentTrack, double t, bool rightEdge)
{

   SnapResults results;
   // Check to see if we need to reinitialize
   Reinit();

   results.timeSnappedTime = results.outTime = t;
   results.outCoord = mZoomInfo->TimeToPosition(t);

   // First snap to points in mSnapPoints
   results.snappedPoint =
      SnapToPoints(currentTrack, t, rightEdge, &results.outTime);

   if (mSnapToTime) {
      // Find where it would snap time to the grid
      mConverter.ValueToControls(t, GetActiveProject()->GetSnapTo() == SNAP_NEAREST);
      mConverter.ControlsToValue();
      results.timeSnappedTime = mConverter.GetValue();
   }

   results.snappedTime = false;
   if (mSnapToTime)
   {
      if (results.snappedPoint)
      {
         // Since mSnapPoints only contains points on the grid, we're done
         results.snappedTime = true;
      }
      else
      {
         results.outTime = results.timeSnappedTime;
         results.snappedTime = true;
      }
   }

   if (results.Snapped())
      results.outCoord = mZoomInfo->TimeToPosition(results.outTime);

   return results;
}