comparison view/View.cpp @ 511:455810e65543

* Do a _slightly_ better job of ensuring new panes come up showing the right region of the track (but not quite better enough)
author Chris Cannam
date Thu, 26 Feb 2009 11:02:05 +0000
parents 683c46d7500b
children 1341e95eeae9
comparison
equal deleted inserted replaced
510:683c46d7500b 511:455810e65543
675 675
676 connect(this, SIGNAL(zoomLevelChanged(unsigned long, bool)), 676 connect(this, SIGNAL(zoomLevelChanged(unsigned long, bool)),
677 m_manager, SLOT(viewZoomLevelChanged(unsigned long, bool))); 677 m_manager, SLOT(viewZoomLevelChanged(unsigned long, bool)));
678 678
679 if (m_followPlay == PlaybackScrollPage) { 679 if (m_followPlay == PlaybackScrollPage) {
680 // std::cerr << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl; 680 std::cerr << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl;
681 setCentreFrame(m_manager->getGlobalCentreFrame(), false); 681 setCentreFrame(m_manager->getGlobalCentreFrame(), false);
682 } else if (m_followPlay == PlaybackScrollContinuous) { 682 } else if (m_followPlay == PlaybackScrollContinuous) {
683 // std::cerr << "View::setViewManager: setting centre frame to playback frame: " << m_manager->getPlaybackFrame() << std::endl; 683 std::cerr << "View::setViewManager: setting centre frame to playback frame: " << m_manager->getPlaybackFrame() << std::endl;
684 setCentreFrame(m_manager->getPlaybackFrame(), false); 684 setCentreFrame(m_manager->getPlaybackFrame(), false);
685 } else if (m_followPan) { 685 } else if (m_followPan) {
686 // std::cerr << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl; 686 std::cerr << "View::setViewManager: (follow pan) setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl;
687 setCentreFrame(m_manager->getGlobalCentreFrame(), false); 687 setCentreFrame(m_manager->getGlobalCentreFrame(), false);
688 } 688 }
689 if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom()); 689 if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom());
690
691 movePlayPointer(getAlignedPlaybackFrame());
690 692
691 toolModeChanged(); 693 toolModeChanged();
692 } 694 }
693 695
694 void 696 void
925 if (sender() != m_manager) return; 927 if (sender() != m_manager) return;
926 } 928 }
927 929
928 f = getAlignedPlaybackFrame(); 930 f = getAlignedPlaybackFrame();
929 931
930 if (m_playPointerFrame == f) return; 932 movePlayPointer(f);
931 bool visible = (getXForFrame(m_playPointerFrame) != getXForFrame(f)); 933 }
934
935 void
936 View::movePlayPointer(unsigned long newFrame)
937 {
938 if (m_playPointerFrame == newFrame) return;
939 bool visibleChange =
940 (getXForFrame(m_playPointerFrame) != getXForFrame(newFrame));
932 size_t oldPlayPointerFrame = m_playPointerFrame; 941 size_t oldPlayPointerFrame = m_playPointerFrame;
933 m_playPointerFrame = f; 942 m_playPointerFrame = newFrame;
934 if (!visible) return; 943 if (!visibleChange) return;
935 944
936 switch (m_followPlay) { 945 switch (m_followPlay) {
937 946
938 case PlaybackScrollContinuous: 947 case PlaybackScrollContinuous:
939 if (QApplication::mouseButtons() == Qt::NoButton) { 948 if (QApplication::mouseButtons() == Qt::NoButton) {
940 setCentreFrame(f, false); 949 setCentreFrame(m_playPointerFrame, false);
941 } 950 }
942 break; 951 break;
943 952
944 case PlaybackScrollPage: 953 case PlaybackScrollPage:
945 { 954 {
946 int xold = getXForFrame(oldPlayPointerFrame); 955 int xold = getXForFrame(oldPlayPointerFrame);
947 update(xold - 1, 0, 3, height()); 956 update(xold - 1, 0, 3, height());
948 957
949 long w = getEndFrame() - getStartFrame(); 958 long w = getEndFrame() - getStartFrame();
950 w -= w/5; 959 w -= w/5;
951 long sf = (f / w) * w - w/8; 960 long sf = (m_playPointerFrame / w) * w - w/8;
952 961
953 if (m_manager && 962 if (m_manager &&
954 m_manager->isPlaying() && 963 m_manager->isPlaying() &&
955 m_manager->getPlaySelectionMode()) { 964 m_manager->getPlaySelectionMode()) {
956 MultiSelection::SelectionList selections = m_manager->getSelections(); 965 MultiSelection::SelectionList selections = m_manager->getSelections();
961 } 970 }
962 } 971 }
963 } 972 }
964 973
965 #ifdef DEBUG_VIEW_WIDGET_PAINT 974 #ifdef DEBUG_VIEW_WIDGET_PAINT
966 std::cerr << "PlaybackScrollPage: f = " << f << ", sf = " << sf << ", start frame " 975 std::cerr << "PlaybackScrollPage: f = " << m_playPointerFrame << ", sf = " << sf << ", start frame "
967 << getStartFrame() << std::endl; 976 << getStartFrame() << std::endl;
968 #endif 977 #endif
969 978
970 // We don't consider scrolling unless the pointer is outside 979 // We don't consider scrolling unless the pointer is outside
971 // the clearly visible range already 980 // the clearly visible range already
992 1001
993 break; 1002 break;
994 } 1003 }
995 1004
996 case PlaybackIgnore: 1005 case PlaybackIgnore:
997 if (long(f) >= getStartFrame() && f < getEndFrame()) { 1006 if (long(m_playPointerFrame) >= getStartFrame() &&
1007 m_playPointerFrame < getEndFrame()) {
998 update(); 1008 update();
999 } 1009 }
1000 break; 1010 break;
1001 } 1011 }
1002 } 1012 }