# HG changeset patch # User Chris Cannam # Date 1402573691 -3600 # Node ID 9fd1bdf214dd5a30aca916af922f9f8d6cbab187 # Parent cf1e8a1abb7be96bdda96746febcf8987bf8c067 Play pointer: when user drags pane during playback such that the pointer is no longer visible, accept that and stop trying to track it until pointer naturally comes back within visible area diff -r cf1e8a1abb7b -r 9fd1bdf214dd view/View.cpp --- a/view/View.cpp Thu Jun 12 12:27:41 2014 +0100 +++ b/view/View.cpp Thu Jun 12 12:48:11 2014 +0100 @@ -53,6 +53,7 @@ m_followPan(true), m_followZoom(true), m_followPlay(PlaybackScrollPage), + m_followPlayIsDetached(false), m_playPointerFrame(0), m_showProgress(showProgress), m_cache(0), @@ -992,6 +993,12 @@ ((QApplication::mouseButtons() != Qt::NoButton) || (QApplication::keyboardModifiers() & Qt::AltModifier)); + bool pointerInVisibleArea = + long(m_playPointerFrame) >= getStartFrame() && + (m_playPointerFrame < getEndFrame() || + // include old pointer location so we know to refresh when moving out + oldPlayPointerFrame < getEndFrame()); + switch (m_followPlay) { case PlaybackScrollContinuous: @@ -1001,56 +1008,73 @@ break; case PlaybackScrollPage: - { - int xold = getXForFrame(oldPlayPointerFrame); - update(xold - 4, 0, 9, height()); - - long w = getEndFrame() - getStartFrame(); - w -= w/5; - long sf = (m_playPointerFrame / w) * w - w/8; - - if (m_manager && - m_manager->isPlaying() && - m_manager->getPlaySelectionMode()) { - MultiSelection::SelectionList selections = m_manager->getSelections(); - if (!selections.empty()) { - size_t selectionStart = selections.begin()->getStartFrame(); - if (sf < long(selectionStart) - w / 10) { - sf = long(selectionStart) - w / 10; - } - } - } + + if (!pointerInVisibleArea && somethingGoingOn) { + + m_followPlayIsDetached = true; + + } else if (!pointerInVisibleArea && m_followPlayIsDetached) { + + // do nothing; we aren't tracking until the pointer comes back in + + } else { + + int xold = getXForFrame(oldPlayPointerFrame); + update(xold - 4, 0, 9, height()); + + long w = getEndFrame() - getStartFrame(); + w -= w/5; + long sf = (m_playPointerFrame / w) * w - w/8; + + if (m_manager && + m_manager->isPlaying() && + m_manager->getPlaySelectionMode()) { + MultiSelection::SelectionList selections = m_manager->getSelections(); + if (!selections.empty()) { + size_t selectionStart = selections.begin()->getStartFrame(); + if (sf < long(selectionStart) - w / 10) { + sf = long(selectionStart) - w / 10; + } + } + } #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame " - << getStartFrame() << endl; + cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame " + << getStartFrame() << endl; #endif - // We don't consider scrolling unless the pointer is outside - // the clearly visible range already - - int xnew = getXForFrame(m_playPointerFrame); + // We don't consider scrolling unless the pointer is outside + // the central visible range already + + int xnew = getXForFrame(m_playPointerFrame); #ifdef DEBUG_VIEW_WIDGET_PAINT - cerr << "xnew = " << xnew << ", width = " << width() << endl; + cerr << "xnew = " << xnew << ", width = " << width() << endl; #endif - if (xnew < width()/8 || xnew > (width()*7)/8) { - if (!somethingGoingOn) { - long offset = getFrameForX(width()/2) - getStartFrame(); - long newCentre = sf + offset; - bool changed = setCentreFrame(newCentre, false); - if (changed) { - xold = getXForFrame(oldPlayPointerFrame); - update(xold - 4, 0, 9, height()); - } - } - } - - update(xnew - 4, 0, 9, height()); - - break; - } + bool shouldScroll = (xnew > (width() * 7) / 8); + + if (!m_followPlayIsDetached && (xnew < width() / 8)) { + shouldScroll = true; + } + + if (xnew > width() / 8) { + m_followPlayIsDetached = false; + } + + if (!somethingGoingOn && shouldScroll) { + long offset = getFrameForX(width()/2) - getStartFrame(); + long newCentre = sf + offset; + bool changed = setCentreFrame(newCentre, false); + if (changed) { + xold = getXForFrame(oldPlayPointerFrame); + update(xold - 4, 0, 9, height()); + } + } + + update(xnew - 4, 0, 9, height()); + } + break; case PlaybackIgnore: if (long(m_playPointerFrame) >= getStartFrame() && diff -r cf1e8a1abb7b -r 9fd1bdf214dd view/View.h --- a/view/View.h Thu Jun 12 12:27:41 2014 +0100 +++ b/view/View.h Thu Jun 12 12:48:11 2014 +0100 @@ -352,6 +352,7 @@ bool m_followPan; bool m_followZoom; PlaybackFollowMode m_followPlay; + bool m_followPlayIsDetached; size_t m_playPointerFrame; bool m_lightBackground; bool m_showProgress;