Mercurial > hg > svgui
comparison view/View.cpp @ 789:9fd1bdf214dd tonioni
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
author | Chris Cannam |
---|---|
date | Thu, 12 Jun 2014 12:48:11 +0100 |
parents | b4acab502786 |
children | b076cefaf708 |
comparison
equal
deleted
inserted
replaced
788:cf1e8a1abb7b | 789:9fd1bdf214dd |
---|---|
51 m_centreFrame(0), | 51 m_centreFrame(0), |
52 m_zoomLevel(1024), | 52 m_zoomLevel(1024), |
53 m_followPan(true), | 53 m_followPan(true), |
54 m_followZoom(true), | 54 m_followZoom(true), |
55 m_followPlay(PlaybackScrollPage), | 55 m_followPlay(PlaybackScrollPage), |
56 m_followPlayIsDetached(false), | |
56 m_playPointerFrame(0), | 57 m_playPointerFrame(0), |
57 m_showProgress(showProgress), | 58 m_showProgress(showProgress), |
58 m_cache(0), | 59 m_cache(0), |
59 m_cacheCentreFrame(0), | 60 m_cacheCentreFrame(0), |
60 m_cacheZoomLevel(1024), | 61 m_cacheZoomLevel(1024), |
990 | 991 |
991 bool somethingGoingOn = | 992 bool somethingGoingOn = |
992 ((QApplication::mouseButtons() != Qt::NoButton) || | 993 ((QApplication::mouseButtons() != Qt::NoButton) || |
993 (QApplication::keyboardModifiers() & Qt::AltModifier)); | 994 (QApplication::keyboardModifiers() & Qt::AltModifier)); |
994 | 995 |
996 bool pointerInVisibleArea = | |
997 long(m_playPointerFrame) >= getStartFrame() && | |
998 (m_playPointerFrame < getEndFrame() || | |
999 // include old pointer location so we know to refresh when moving out | |
1000 oldPlayPointerFrame < getEndFrame()); | |
1001 | |
995 switch (m_followPlay) { | 1002 switch (m_followPlay) { |
996 | 1003 |
997 case PlaybackScrollContinuous: | 1004 case PlaybackScrollContinuous: |
998 if (!somethingGoingOn) { | 1005 if (!somethingGoingOn) { |
999 setCentreFrame(m_playPointerFrame, false); | 1006 setCentreFrame(m_playPointerFrame, false); |
1000 } | 1007 } |
1001 break; | 1008 break; |
1002 | 1009 |
1003 case PlaybackScrollPage: | 1010 case PlaybackScrollPage: |
1004 { | 1011 |
1005 int xold = getXForFrame(oldPlayPointerFrame); | 1012 if (!pointerInVisibleArea && somethingGoingOn) { |
1006 update(xold - 4, 0, 9, height()); | 1013 |
1007 | 1014 m_followPlayIsDetached = true; |
1008 long w = getEndFrame() - getStartFrame(); | 1015 |
1009 w -= w/5; | 1016 } else if (!pointerInVisibleArea && m_followPlayIsDetached) { |
1010 long sf = (m_playPointerFrame / w) * w - w/8; | 1017 |
1011 | 1018 // do nothing; we aren't tracking until the pointer comes back in |
1012 if (m_manager && | 1019 |
1013 m_manager->isPlaying() && | 1020 } else { |
1014 m_manager->getPlaySelectionMode()) { | 1021 |
1015 MultiSelection::SelectionList selections = m_manager->getSelections(); | 1022 int xold = getXForFrame(oldPlayPointerFrame); |
1016 if (!selections.empty()) { | 1023 update(xold - 4, 0, 9, height()); |
1017 size_t selectionStart = selections.begin()->getStartFrame(); | 1024 |
1018 if (sf < long(selectionStart) - w / 10) { | 1025 long w = getEndFrame() - getStartFrame(); |
1019 sf = long(selectionStart) - w / 10; | 1026 w -= w/5; |
1020 } | 1027 long sf = (m_playPointerFrame / w) * w - w/8; |
1021 } | 1028 |
1022 } | 1029 if (m_manager && |
1030 m_manager->isPlaying() && | |
1031 m_manager->getPlaySelectionMode()) { | |
1032 MultiSelection::SelectionList selections = m_manager->getSelections(); | |
1033 if (!selections.empty()) { | |
1034 size_t selectionStart = selections.begin()->getStartFrame(); | |
1035 if (sf < long(selectionStart) - w / 10) { | |
1036 sf = long(selectionStart) - w / 10; | |
1037 } | |
1038 } | |
1039 } | |
1023 | 1040 |
1024 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1041 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1025 cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame " | 1042 cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame " |
1026 << getStartFrame() << endl; | 1043 << getStartFrame() << endl; |
1027 #endif | 1044 #endif |
1028 | 1045 |
1029 // We don't consider scrolling unless the pointer is outside | 1046 // We don't consider scrolling unless the pointer is outside |
1030 // the clearly visible range already | 1047 // the central visible range already |
1031 | 1048 |
1032 int xnew = getXForFrame(m_playPointerFrame); | 1049 int xnew = getXForFrame(m_playPointerFrame); |
1033 | 1050 |
1034 #ifdef DEBUG_VIEW_WIDGET_PAINT | 1051 #ifdef DEBUG_VIEW_WIDGET_PAINT |
1035 cerr << "xnew = " << xnew << ", width = " << width() << endl; | 1052 cerr << "xnew = " << xnew << ", width = " << width() << endl; |
1036 #endif | 1053 #endif |
1037 | 1054 |
1038 if (xnew < width()/8 || xnew > (width()*7)/8) { | 1055 bool shouldScroll = (xnew > (width() * 7) / 8); |
1039 if (!somethingGoingOn) { | 1056 |
1040 long offset = getFrameForX(width()/2) - getStartFrame(); | 1057 if (!m_followPlayIsDetached && (xnew < width() / 8)) { |
1041 long newCentre = sf + offset; | 1058 shouldScroll = true; |
1042 bool changed = setCentreFrame(newCentre, false); | 1059 } |
1043 if (changed) { | 1060 |
1044 xold = getXForFrame(oldPlayPointerFrame); | 1061 if (xnew > width() / 8) { |
1045 update(xold - 4, 0, 9, height()); | 1062 m_followPlayIsDetached = false; |
1046 } | 1063 } |
1047 } | 1064 |
1048 } | 1065 if (!somethingGoingOn && shouldScroll) { |
1049 | 1066 long offset = getFrameForX(width()/2) - getStartFrame(); |
1050 update(xnew - 4, 0, 9, height()); | 1067 long newCentre = sf + offset; |
1051 | 1068 bool changed = setCentreFrame(newCentre, false); |
1052 break; | 1069 if (changed) { |
1053 } | 1070 xold = getXForFrame(oldPlayPointerFrame); |
1071 update(xold - 4, 0, 9, height()); | |
1072 } | |
1073 } | |
1074 | |
1075 update(xnew - 4, 0, 9, height()); | |
1076 } | |
1077 break; | |
1054 | 1078 |
1055 case PlaybackIgnore: | 1079 case PlaybackIgnore: |
1056 if (long(m_playPointerFrame) >= getStartFrame() && | 1080 if (long(m_playPointerFrame) >= getStartFrame() && |
1057 m_playPointerFrame < getEndFrame()) { | 1081 m_playPointerFrame < getEndFrame()) { |
1058 update(); | 1082 update(); |