changeset 815:09026c875301

Create separate play scroll modes for (Tony-style, DAW-style) page mode and (SV-style) paging with playhead alignment to centre on drag
author Chris Cannam
date Wed, 02 Jul 2014 17:30:09 +0100
parents db31266cf606
children 7b6c5fce5f84 fd95308b5d3f
files view/View.cpp view/ViewManager.cpp view/ViewManager.h
diffstat 3 files changed, 53 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/view/View.cpp	Wed Jul 02 08:42:45 2014 +0100
+++ b/view/View.cpp	Wed Jul 02 17:30:09 2014 +0100
@@ -55,7 +55,7 @@
     m_zoomLevel(1024),
     m_followPan(true),
     m_followZoom(true),
-    m_followPlay(PlaybackScrollPage),
+    m_followPlay(PlaybackScrollPageWithCentre),
     m_followPlayIsDetached(false),
     m_playPointerFrame(0),
     m_showProgress(showProgress),
@@ -117,8 +117,12 @@
     if (name == "Follow Playback") {
 	if (min) *min = 0;
 	if (max) *max = 2;
-        if (deflt) *deflt = int(PlaybackScrollPage);
-	return int(m_followPlay);
+        if (deflt) *deflt = int(PlaybackScrollPageWithCentre);
+        switch (m_followPlay) {
+        case PlaybackScrollContinuous: return 0;
+        case PlaybackScrollPageWithCentre: case PlaybackScrollPage: return 1;
+        case PlaybackIgnore: return 2;
+        }
     }
     if (min) *min = 0;
     if (max) *max = 0;
@@ -152,7 +156,7 @@
 	switch (value) {
 	default:
 	case 0: setPlaybackFollow(PlaybackScrollContinuous); break;
-	case 1: setPlaybackFollow(PlaybackScrollPage); break;
+	case 1: setPlaybackFollow(PlaybackScrollPageWithCentre); break;
 	case 2: setPlaybackFollow(PlaybackIgnore); break;
 	}
     }
@@ -704,17 +708,22 @@
     connect(this, SIGNAL(zoomLevelChanged(int, bool)),
 	    m_manager, SLOT(viewZoomLevelChanged(int, bool)));
 
-//    setCentreFrame(m_manager->getViewInitialCentreFrame());
-
-    if (m_followPlay == PlaybackScrollPage) {
-//        SVDEBUG << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << endl;
+    switch (m_followPlay) {
+        
+    case PlaybackScrollPage:
+    case PlaybackScrollPageWithCentre:
         setCentreFrame(m_manager->getGlobalCentreFrame(), false);
-    } else if (m_followPlay == PlaybackScrollContinuous) {
-//        SVDEBUG << "View::setViewManager: setting centre frame to playback frame: " << m_manager->getPlaybackFrame() << endl;
+        break;
+
+    case PlaybackScrollContinuous:
         setCentreFrame(m_manager->getPlaybackFrame(), false);
-    } else if (m_followPan) {
-//        SVDEBUG << "View::setViewManager: (follow pan) setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << endl;
-        setCentreFrame(m_manager->getGlobalCentreFrame(), false);
+        break;
+
+    case PlaybackIgnore:
+        if (m_followPan) {
+            setCentreFrame(m_manager->getGlobalCentreFrame(), false);
+        }
+        break;
     }
 
     if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom());
@@ -1016,6 +1025,7 @@
 	break;
 
     case PlaybackScrollPage:
+    case PlaybackScrollPageWithCentre:
 
         if (!pointerInVisibleArea && somethingGoingOn) {
 
@@ -2459,7 +2469,9 @@
 	.arg(m_followPan)
 	.arg(m_followZoom)
 	.arg(m_followPlay == PlaybackScrollContinuous ? "scroll" :
-	     m_followPlay == PlaybackScrollPage ? "page" : "ignore")
+	     m_followPlay == PlaybackScrollPageWithCentre ? "page" :
+	     m_followPlay == PlaybackScrollPage ? "daw" :
+             "ignore")
 	.arg(extraAttributes);
 
     for (int i = 0; i < (int)m_layers.size(); ++i) {
--- a/view/ViewManager.cpp	Wed Jul 02 08:42:45 2014 +0100
+++ b/view/ViewManager.cpp	Wed Jul 02 17:30:09 2014 +0100
@@ -554,7 +554,7 @@
         if (v) emit viewCentreFrameChanged(v, f);
     }
 
-    if (!dynamic_cast<Overview *>(v) || (mode == PlaybackScrollContinuous)) {
+    if (!dynamic_cast<Overview *>(v) || (mode != PlaybackIgnore)) {
         if (m_mainModelSampleRate != 0) {
             emit activity(tr("Scroll to %1")
                           .arg(RealTime::frame2RealTime
@@ -562,11 +562,10 @@
         }
     }
 
-    if (mode != PlaybackScrollContinuous) {
-        return;
+    if (mode == PlaybackScrollPageWithCentre ||
+        mode == PlaybackScrollContinuous) {
+        seek(f);
     }
-
-    seek(f);
 }
 
 void
--- a/view/ViewManager.h	Wed Jul 02 08:42:45 2014 +0100
+++ b/view/ViewManager.h	Wed Jul 02 17:30:09 2014 +0100
@@ -31,8 +31,31 @@
 class Model;
 
 enum PlaybackFollowMode {
+
+    /**
+     * View scrolls continuously during playback, keeping the playback
+     * position at the centre.
+     */
     PlaybackScrollContinuous,
+
+    /**
+     * View follows playback page-by-page, but dragging the view
+     * relocates playback to the centre frame. This is the classic
+     * Sonic Visualiser behaviour.
+     */
+    PlaybackScrollPageWithCentre,
+
+    /**
+     * View follows playback page-by-page, and the play head is moved
+     * (by the user) separately from dragging the view. This is
+     * roughly the behaviour of a typical DAW or audio editor.
+     */
     PlaybackScrollPage,
+
+    /**
+     * View is detached from playback. It doesn't follow playback, and
+     * dragging the view does not affect the play head.
+     */
     PlaybackIgnore
 };