diff view/ViewManager.cpp @ 211:e2baee498ec8

* Rejig handling of scrolling views. Ensures, among other things, that playing when there is a scroll mode view present (e.g. a spectrum) does not drag any page mode views into scroll mode with it.
author Chris Cannam
date Thu, 01 Mar 2007 11:55:46 +0000
parents 5b7472db612b
children cd81066ac7ad
line wrap: on
line diff
--- a/view/ViewManager.cpp	Wed Feb 28 11:20:14 2007 +0000
+++ b/view/ViewManager.cpp	Thu Mar 01 11:55:46 2007 +0000
@@ -17,6 +17,7 @@
 #include "base/AudioPlaySource.h"
 #include "data/model/Model.h"
 #include "base/CommandHistory.h"
+#include "View.h"
 
 #include <QSettings>
 
@@ -48,10 +49,6 @@
     settings.endGroup();
 
     connect(this, 
-	    SIGNAL(centreFrameChanged(void *, unsigned long, bool)),
-	    SLOT(considerSeek(void *, unsigned long, bool)));
-
-    connect(this, 
 	    SIGNAL(zoomLevelChanged(void *, unsigned long, bool)),
 	    SLOT(considerZoomChange(void *, unsigned long, bool)));
 }
@@ -76,6 +73,7 @@
     std::cout << "ViewManager::setGlobalCentreFrame to " << f << std::endl;
 #endif
     m_globalCentreFrame = f;
+    emit globalCentreFrameChanged(f);
 }
 
 unsigned long
@@ -335,18 +333,32 @@
 }
 
 void
-ViewManager::considerSeek(void *p, unsigned long f, bool locked)
+ViewManager::viewCentreFrameChanged(unsigned long f, bool locked,
+                                    PlaybackFollowMode mode)
 {
+    View *v = dynamic_cast<View *>(sender());
+
     if (locked) {
-	m_globalCentreFrame = f;
+        m_globalCentreFrame = f;
+        emit globalCentreFrameChanged(f);
+    } else {
+        if (v) emit viewCentreFrameChanged(v, f);
     }
 
+    if (mode == PlaybackIgnore) {
+        return;
+    }
+
+    seek(f);
+}
+
+void
+ViewManager::seek(unsigned long f)
+{
 #ifdef DEBUG_VIEW_MANAGER 
-    std::cout << "ViewManager::considerSeek(" << p << ", " << f << ", " << locked << ")" << std::endl;
+    std::cout << "ViewManager::seek(" << f << ")" << std::endl;
 #endif
 
-    if (p == this || !locked) return;
-
     if (m_playSource && m_playSource->isPlaying()) {
 	unsigned long playFrame = m_playSource->getCurrentPlayingFrame();
 	unsigned long diff = std::max(f, playFrame) - std::min(f, playFrame);
@@ -356,9 +368,13 @@
 #ifdef DEBUG_VIEW_MANAGER 
 	    std::cout << "ViewManager::considerSeek: reseeking from " << playFrame << " to " << f << std::endl;
 #endif
+            emit playbackFrameChanged(f);
 	}
     } else {
-	m_playbackFrame = f; //!!! only if that view is in scroll mode?
+        if (m_playbackFrame != f) {
+            m_playbackFrame = f;
+            emit playbackFrameChanged(f);
+        }
     }
 }