Mercurial > hg > svapp
changeset 166:2c2029007618
* "ffwd-similar"
* stop when ffwding to end
author | Chris Cannam |
---|---|
date | Tue, 03 Mar 2009 21:48:03 +0000 |
parents | 0bd09fb9e584 |
children | 7fff1bb8cc3d |
files | framework/MainWindowBase.cpp framework/MainWindowBase.h |
diffstat | 2 files changed, 81 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 {
--- 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();