Mercurial > hg > tony
changeset 356:0b08d860081b
changed the way the cursor works
author | matthiasm |
---|---|
date | Wed, 18 Jun 2014 10:13:12 +0100 |
parents | 11ba706b1e7a |
children | d511868c1ffe |
files | .hgsubstate src/MainWindow.cpp src/MainWindow.h |
diffstat | 3 files changed, 74 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsubstate Mon Jun 16 16:26:09 2014 +0100 +++ b/.hgsubstate Wed Jun 18 10:13:12 2014 +0100 @@ -1,6 +1,6 @@ e32a354434aa5fa7440efa17b716aacd761049fa chp 236814e07bd07473958c1ff89103124536a0c3c8 dataquay -062f0e49187789937b6162d2904b1af20872ed5e pyin +e637cf9160029c6d429bf89fedca157619ca8da8 pyin 553a5f65ef64811747a6613f759622d655db63c1 sv-dependency-builds f5c914661f6fdc7f05c2c980b0d21350d5933428 svapp 3efc20c59a947a137ed7fc715b2a3b0de6c02200 svcore
--- a/src/MainWindow.cpp Mon Jun 16 16:26:09 2014 +0100 +++ b/src/MainWindow.cpp Wed Jun 18 10:13:12 2014 +0100 @@ -3285,5 +3285,73 @@ settings.endGroup(); } - - +void +MainWindow::ffwd() +{ + if (!getMainModel()) return; + + int frame = m_viewManager->getPlaybackFrame(); + ++frame; + + size_t sr = getMainModel()->getSampleRate(); + + // The step is supposed to scale and be as wide as a step of + // m_defaultFfwdRwdStep seconds at zoom level 512 and sr = 44100 + size_t framesPerPixel = m_viewManager->getGlobalZoom(); + size_t defaultZoom = (512 * 44100) / sr; + + float scaler = (framesPerPixel * 1.0f) / defaultZoom; + + + frame = RealTime::realTime2Frame + (RealTime::frame2RealTime(frame, sr) + m_defaultFfwdRwdStep * scaler, sr); + if (frame > int(getMainModel()->getEndFrame())) { + 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 == (int)getMainModel()->getEndFrame() && + m_playSource && + m_playSource->isPlaying() && + !m_viewManager->getPlayLoopMode()) { + stop(); + } +} + +void +MainWindow::rewind() +{ + if (!getMainModel()) return; + + int frame = m_viewManager->getPlaybackFrame(); + if (frame > 0) --frame; + + size_t sr = getMainModel()->getSampleRate(); + + // The step is supposed to scale and be as wide as a step of + // m_defaultFfwdRwdStep seconds at zoom level 512 and sr = 44100 + size_t framesPerPixel = m_viewManager->getGlobalZoom(); + size_t defaultZoom = (512 * 44100) / sr; + + float scaler = (framesPerPixel * 1.0f) / defaultZoom; + frame = RealTime::realTime2Frame + (RealTime::frame2RealTime(frame, sr) - m_defaultFfwdRwdStep * scaler, sr); + if (frame < int(getMainModel()->getStartFrame())) { + frame = getMainModel()->getStartFrame(); + } + + if (frame < 0) frame = 0; + + if (m_viewManager->getPlaySelectionMode()) { + frame = m_viewManager->constrainFrameToSelection(size_t(frame)); + } + + m_viewManager->setPlaybackFrame(frame); +}