Mercurial > hg > sonic-visualiser
diff main/MainWindow.cpp @ 147:140ea2569bcc
* Make ffwd/rewind constrained to the selection if Play Selection is on
author | Chris Cannam |
---|---|
date | Wed, 06 Jun 2007 14:42:41 +0000 |
parents | 56c00f977cac |
children | e2f13213c2f1 |
line wrap: on
line diff
--- a/main/MainWindow.cpp Fri Jun 01 13:56:35 2007 +0000 +++ b/main/MainWindow.cpp Wed Jun 06 14:42:41 2007 +0000 @@ -3294,6 +3294,16 @@ if (!layer->snapToFeatureFrame(pane, frame, resolution, Layer::SnapRight)) { frame = getMainModel()->getEndFrame(); } + + if (m_viewManager->getPlaySelectionMode()) { + MultiSelection::SelectionList sl = m_viewManager->getSelections(); + if (!sl.empty()) { + MultiSelection::SelectionList::iterator i = sl.end(); + --i; + size_t selectionEndFrame = i->getEndFrame(); + if (frame > selectionEndFrame) frame = selectionEndFrame; + } + } m_viewManager->setPlaybackFrame(frame); } @@ -3302,7 +3312,20 @@ MainWindow::ffwdEnd() { if (!getMainModel()) return; - m_viewManager->setPlaybackFrame(getMainModel()->getEndFrame()); + + size_t frame = getMainModel()->getEndFrame(); + + if (m_viewManager->getPlaySelectionMode()) { + MultiSelection::SelectionList sl = m_viewManager->getSelections(); + if (!sl.empty()) { + MultiSelection::SelectionList::iterator i = sl.end(); + --i; + size_t selectionEndFrame = i->getEndFrame(); + if (frame > selectionEndFrame) frame = selectionEndFrame; + } + } + + m_viewManager->setPlaybackFrame(frame); } void @@ -3325,7 +3348,15 @@ if (!layer->snapToFeatureFrame(pane, frame, resolution, Layer::SnapLeft)) { frame = getMainModel()->getEndFrame(); } - + + if (m_viewManager->getPlaySelectionMode()) { + MultiSelection::SelectionList sl = m_viewManager->getSelections(); + if (!sl.empty()) { + size_t selectionStartFrame = sl.begin()->getStartFrame(); + if (frame < selectionStartFrame) frame = selectionStartFrame; + } + } + m_viewManager->setPlaybackFrame(frame); } @@ -3333,7 +3364,18 @@ MainWindow::rewindStart() { if (!getMainModel()) return; - m_viewManager->setPlaybackFrame(getMainModel()->getStartFrame()); + + size_t frame = getMainModel()->getStartFrame(); + + if (m_viewManager->getPlaySelectionMode()) { + MultiSelection::SelectionList sl = m_viewManager->getSelections(); + if (!sl.empty()) { + size_t selectionStartFrame = sl.begin()->getStartFrame(); + if (frame < selectionStartFrame) frame = selectionStartFrame; + } + } + + m_viewManager->setPlaybackFrame(frame); } void