changeset 516:e4e0ae491a48

* Attempt to pick more sensible default centre frame for newly created view
author Chris Cannam
date Tue, 03 Mar 2009 16:46:27 +0000
parents ff1dc4f302bd
children 1c6439ef99d6
files view/PaneStack.cpp view/View.cpp view/View.h
diffstat 3 files changed, 26 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/view/PaneStack.cpp	Fri Feb 27 14:24:54 2009 +0000
+++ b/view/PaneStack.cpp	Tue Mar 03 16:46:27 2009 +0000
@@ -82,8 +82,19 @@
     currentIndicator->setMinimumWidth(8);
     currentIndicator->setScaledContents(true);
 
+    long initialCentreFrame = -1;
+    for (int i = 0; i < m_panes.size(); ++i) {
+        long f = m_panes[i].pane->getCentreFrame();
+        initialCentreFrame = f;
+        break;
+    }
+
     Pane *pane = new Pane(frame);
-    pane->setViewManager(m_viewManager);
+    if (initialCentreFrame >= 0) {
+        pane->setViewManager(m_viewManager, initialCentreFrame);
+    } else {
+        pane->setViewManager(m_viewManager);
+    }
     layout->addWidget(pane, 0, 1, 2, 1);
     layout->setColumnStretch(1, 20);
 
--- a/view/View.cpp	Fri Feb 27 14:24:54 2009 +0000
+++ b/view/View.cpp	Tue Mar 03 16:46:27 2009 +0000
@@ -676,16 +676,19 @@
     connect(this, SIGNAL(zoomLevelChanged(unsigned long, bool)),
 	    m_manager, SLOT(viewZoomLevelChanged(unsigned long, bool)));
 
+//    setCentreFrame(m_manager->getViewInitialCentreFrame());
+
     if (m_followPlay == PlaybackScrollPage) {
-        std::cerr << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl;
+//        std::cerr << "View::setViewManager: setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl;
         setCentreFrame(m_manager->getGlobalCentreFrame(), false);
     } else if (m_followPlay == PlaybackScrollContinuous) {
-        std::cerr << "View::setViewManager: setting centre frame to playback frame: " << m_manager->getPlaybackFrame() << std::endl;
+//        std::cerr << "View::setViewManager: setting centre frame to playback frame: " << m_manager->getPlaybackFrame() << std::endl;
         setCentreFrame(m_manager->getPlaybackFrame(), false);
     } else if (m_followPan) {
-        std::cerr << "View::setViewManager: (follow pan) setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl;
+//        std::cerr << "View::setViewManager: (follow pan) setting centre frame to global centre frame: " << m_manager->getGlobalCentreFrame() << std::endl;
         setCentreFrame(m_manager->getGlobalCentreFrame(), false);
     }
+
     if (m_followZoom) setZoomLevel(m_manager->getGlobalZoom());
 
     movePlayPointer(getAlignedPlaybackFrame());
@@ -694,6 +697,13 @@
 }
 
 void
+View::setViewManager(ViewManager *vm, long initialCentreFrame)
+{
+    setViewManager(vm);
+    setCentreFrame(initialCentreFrame, false);
+}
+
+void
 View::setFollowGlobalPan(bool f)
 {
     m_followPan = f;
--- a/view/View.h	Fri Feb 27 14:24:54 2009 +0000
+++ b/view/View.h	Tue Mar 03 16:46:27 2009 +0000
@@ -175,6 +175,7 @@
     virtual const Layer *getSelectedLayer() const;
 
     virtual void setViewManager(ViewManager *m);
+    virtual void setViewManager(ViewManager *m, long initialFrame);
     virtual ViewManager *getViewManager() const { return m_manager; }
 
     virtual void setFollowGlobalPan(bool f);