# HG changeset patch # User Chris Cannam # Date 1236116883 0 # Node ID 2c20290076182965956eae5e25064d60b4dc2da1 # Parent 0bd09fb9e584313802feb86834168eabaeaf47c3 * "ffwd-similar" * stop when ffwding to end diff -r 0bd09fb9e584 -r 2c2029007618 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Fri Feb 27 13:59:42 2009 +0000 +++ b/framework/MainWindowBase.cpp Tue Mar 03 21:48:03 2009 +0000 @@ -2030,6 +2030,7 @@ } else { size_t resolution = 0; + if (pane) frame = pane->alignFromReference(frame); if (layer->snapToFeatureFrame(m_paneStack->getCurrentPane(), frame, resolution, Layer::SnapRight)) { if (pane) frame = pane->alignToReference(frame); @@ -2045,6 +2046,13 @@ } m_viewManager->setPlaybackFrame(frame); + + if (frame == getMainModel()->getEndFrame() && + m_playSource && + m_playSource->isPlaying() && + !m_viewManager->getPlayLoopMode()) { + stop(); + } } void @@ -2068,6 +2076,44 @@ } void +MainWindowBase::ffwdSimilar() +{ + if (!getMainModel()) return; + + Layer *layer = getSnapLayer(); + if (!layer) { ffwd(); return; } + + Pane *pane = m_paneStack->getCurrentPane(); + size_t sr = getMainModel()->getSampleRate(); + + int frame = m_viewManager->getPlaybackFrame(); + + size_t resolution = 0; + if (pane) frame = pane->alignFromReference(frame); + if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), + frame, resolution, Layer::SnapRight)) { + if (pane) frame = pane->alignToReference(frame); + } else { + frame = getMainModel()->getEndFrame(); + } + + if (frame < 0) frame = 0; + + if (m_viewManager->getPlaySelectionMode()) { + frame = m_viewManager->constrainFrameToSelection(size_t(frame)); + } + + m_viewManager->setPlaybackFrame(frame); + + if (frame == getMainModel()->getEndFrame() && + m_playSource && + m_playSource->isPlaying() && + !m_viewManager->getPlayLoopMode()) { + stop(); + } +} + +void MainWindowBase::rewind() { if (!getMainModel()) return; @@ -2086,9 +2132,7 @@ RealTime ct = RealTime::frame2RealTime(frame, sr); ct = ct - RealTime::fromSeconds(0.25); if (ct < RealTime::zeroTime) ct = RealTime::zeroTime; -// std::cerr << "rewind: frame " << frame << " -> "; frame = RealTime::realTime2Frame(ct, sr); -// std::cerr << frame << std::endl; } if (!layer) { @@ -2102,9 +2146,9 @@ } else { size_t resolution = 0; + if (pane) frame = pane->alignFromReference(frame); if (layer->snapToFeatureFrame(m_paneStack->getCurrentPane(), frame, resolution, Layer::SnapLeft)) { - if (pane) frame = pane->alignToReference(frame); } else { frame = getMainModel()->getStartFrame(); @@ -2134,6 +2178,37 @@ m_viewManager->setPlaybackFrame(frame); } +void +MainWindowBase::rewindSimilar() +{ + if (!getMainModel()) return; + + Layer *layer = getSnapLayer(); + if (!layer) { rewind(); return; } + + Pane *pane = m_paneStack->getCurrentPane(); + size_t sr = getMainModel()->getSampleRate(); + + int frame = m_viewManager->getPlaybackFrame(); + + size_t resolution = 0; + if (pane) frame = pane->alignFromReference(frame); + if (layer->snapToSimilarFeature(m_paneStack->getCurrentPane(), + frame, resolution, Layer::SnapLeft)) { + if (pane) frame = pane->alignToReference(frame); + } else { + frame = getMainModel()->getStartFrame(); + } + + if (frame < 0) frame = 0; + + if (m_viewManager->getPlaySelectionMode()) { + frame = m_viewManager->constrainFrameToSelection(size_t(frame)); + } + + m_viewManager->setPlaybackFrame(frame); +} + Layer * MainWindowBase::getSnapLayer() const { diff -r 0bd09fb9e584 -r 2c2029007618 framework/MainWindowBase.h --- a/framework/MainWindowBase.h Fri Feb 27 13:59:42 2009 +0000 +++ b/framework/MainWindowBase.h Tue Mar 03 21:48:03 2009 +0000 @@ -180,6 +180,9 @@ virtual void rewindStart(); virtual void stop(); + virtual void ffwdSimilar(); + virtual void rewindSimilar(); + virtual void deleteCurrentPane(); virtual void deleteCurrentLayer(); virtual void editCurrentLayer();