changeset 624:15a566f26114 zoom

ZoomLevel fixes
author Chris Cannam
date Thu, 20 Sep 2018 11:45:37 +0100
parents 9e15607531b2
children 5bc9f9144505
files framework/MainWindowBase.cpp framework/MainWindowBase.h framework/SVFileReader.cpp
diffstat 3 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Wed Sep 12 15:58:35 2018 +0100
+++ b/framework/MainWindowBase.cpp	Thu Sep 20 11:45:37 2018 +0100
@@ -2789,9 +2789,7 @@
     else pixels = 1;
     if (pixels > 4) pixels -= 4;
 
-    int zoomLevel = int((end - start) / pixels);
-    if (zoomLevel < 1) zoomLevel = 1;
-
+    ZoomLevel zoomLevel = ZoomLevel::fromRatio(pixels, end - start);
     currentPane->setZoomLevel(zoomLevel);
     currentPane->setCentreFrame((start + end) / 2);
 }
@@ -2804,7 +2802,9 @@
     settings.beginGroup("MainWindow");
     int zoom = settings.value("zoom-default", 1024).toInt();
     settings.endGroup();
-    if (currentPane) currentPane->setZoomLevel(zoom);
+    if (currentPane) {
+        currentPane->setZoomLevel(ZoomLevel(ZoomLevel::FramesPerPixel, zoom));
+    }
 }
 
 void
@@ -3824,7 +3824,7 @@
 }
 
 void
-MainWindowBase::viewZoomLevelChanged(View *v, int , bool )
+MainWindowBase::viewZoomLevelChanged(View *v, ZoomLevel, bool )
 {
     if ((m_playSource && m_playSource->isPlaying()) || !getMainModel()) return;
     Pane *p = 0;
--- a/framework/MainWindowBase.h	Wed Sep 12 15:58:35 2018 +0100
+++ b/framework/MainWindowBase.h	Thu Sep 20 11:45:37 2018 +0100
@@ -257,7 +257,7 @@
     virtual void playbackFrameChanged(sv_frame_t);
     virtual void globalCentreFrameChanged(sv_frame_t);
     virtual void viewCentreFrameChanged(View *, sv_frame_t);
-    virtual void viewZoomLevelChanged(View *, int, bool);
+    virtual void viewZoomLevelChanged(View *, ZoomLevel, bool);
     virtual void monitoringLevelsChanged(float, float) = 0;
     virtual void recordDurationChanged(sv_frame_t, sv_samplerate_t);
 
--- a/framework/SVFileReader.cpp	Wed Sep 12 15:58:35 2018 +0100
+++ b/framework/SVFileReader.cpp	Thu Sep 20 11:45:37 2018 +0100
@@ -769,6 +769,14 @@
     READ_MANDATORY(int, followZoom, toInt);
     QString tracking = attributes.value("tracking");
 
+    ZoomLevel zoomLevel;
+    int deepZoom = attributes.value("deepZoom").trimmed().toInt(&ok);
+    if (ok && zoom == 1 && deepZoom > 1) {
+        zoomLevel = { ZoomLevel::PixelsPerFrame, deepZoom };
+    } else {
+        zoomLevel = { ZoomLevel::FramesPerPixel, zoom };
+    }
+
     // Specify the follow modes before we set the actual values
     view->setFollowGlobalPan(followPan);
     view->setFollowGlobalZoom(followZoom);
@@ -779,7 +787,7 @@
 
     // Then set these values
     view->setCentreFrame(centre);
-    view->setZoomLevel(zoom);
+    view->setZoomLevel(zoomLevel);
 
     // And pane properties
     READ_MANDATORY(int, centreLineVisible, toInt);