Logo Search packages:      
Sourcecode: kdenlive version File versions

GenTime SnapToGrid::getSnappedTime ( const GenTime time  )  const

Returns a snapped time compared to the specified GenTime. In the case of their being multiple cursors, it is assumed that the time specified is that which the first cursor time in the list will move to. The returned time takes into account clip begin/end times (if they are turned on), seek times (if they are turned on), and frame borders (if they are turned on).

Returns a snapped time compared to the specified GenTime. In the case of their being multiple cursors, it is assumed that the time specified is that which the first cursor time in the list will move to. The returned time takes into account clip begin/end times (if they are turned on), seek times (if they are turned on), and frame borders (if they are turned on).

Definition at line 89 of file snaptogrid.cpp.

References createInternalSnapList(), m_framesPerSecond, m_internalSnapList, m_internalSnapTracker, GenTime::roundNearestFrame(), and GenTime::seconds().

Referenced by TrackPanelSpacerFunction::mouseMoved(), TrackPanelKeyFrameFunction::mouseMoved(), TrackPanelClipRollFunction::mouseMoved(), and TrackPanelClipResizeFunction::mouseMoved().

{
    GenTime result = time;

    if (isDirty()) {
      createInternalSnapList();
      m_isDirty = false;
    }

    if (m_internalSnapTracker != m_internalSnapList.end()) {
      QValueListConstIterator < GenTime > itt = m_internalSnapTracker;
      ++itt;
      while (itt != m_internalSnapList.end()) {
          double newTime = fabs(((*itt) - time).seconds());
          double oldTime =
            fabs(((*m_internalSnapTracker) - time).seconds());
          if (newTime > oldTime)
            break;

          m_internalSnapTracker = itt;
          ++itt;
      }

      itt = m_internalSnapTracker;
      --itt;
      while (m_internalSnapTracker != m_internalSnapList.begin()) {
          double newTime = fabs(((*itt) - time).seconds());
          double oldTime =
            fabs(((*m_internalSnapTracker) - time).seconds());
          if (newTime > oldTime)
            break;

          m_internalSnapTracker = itt;
          --itt;
      }

      double diff = fabs(((*m_internalSnapTracker) - result).seconds());
      if (diff < m_snapTolerance.seconds()) {
          result = *m_internalSnapTracker;
      }
    }

    if (m_snapToFrame) {
      result.roundNearestFrame(m_framesPerSecond);
    }

    return result;
}


Generated by  Doxygen 1.6.0   Back to index