changeset 1324:13d9b422f7fe zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:31 +0100
parents 57d192e26331 (diff) 8068a0bee550 (current diff)
children bc2cb82050a0
files view/AlignmentView.cpp view/Overview.cpp view/View.cpp view/View.h
diffstat 6 files changed, 42 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/layer/LayerGeometryProvider.h	Wed Sep 12 15:58:11 2018 +0100
+++ b/layer/LayerGeometryProvider.h	Mon Sep 17 13:51:31 2018 +0100
@@ -147,9 +147,10 @@
                                  bool &log) const = 0;
 
     /**
-     * Return the zoom level, i.e. the number of frames per pixel
+     * Return the zoom level, i.e. the number of frames per pixel or
+     * pixels per frame
      */
-    virtual int getZoomLevel() const = 0;
+    virtual ZoomLevel getZoomLevel() const = 0;
 
     /**
      * To be called from a layer, to obtain the extent of the surface
--- a/view/AlignmentView.cpp	Wed Sep 12 15:58:11 2018 +0100
+++ b/view/AlignmentView.cpp	Mon Sep 17 13:51:31 2018 +0100
@@ -57,14 +57,14 @@
 }
 
 void
-AlignmentView::viewAboveZoomLevelChanged(int level, bool)
+AlignmentView::viewAboveZoomLevelChanged(ZoomLevel level, bool)
 {
     m_zoomLevel = level;
     update();
 }
 
 void
-AlignmentView::viewBelowZoomLevelChanged(int, bool)
+AlignmentView::viewBelowZoomLevelChanged(ZoomLevel, bool)
 {
     update();
 }
@@ -80,9 +80,9 @@
 
     if (m_above) {
         connect(m_above,
-                SIGNAL(zoomLevelChanged(int, bool)),
+		SIGNAL(zoomLevelChanged(ZoomLevel, bool)),
                 this, 
-                SLOT(viewAboveZoomLevelChanged(int, bool)));
+		SLOT(viewAboveZoomLevelChanged(ZoomLevel, bool)));
     }
 }
 
@@ -97,9 +97,9 @@
 
     if (m_below) {
         connect(m_below,
-                SIGNAL(zoomLevelChanged(int, bool)),
+		SIGNAL(zoomLevelChanged(ZoomLevel, bool)),
                 this, 
-                SLOT(viewBelowZoomLevelChanged(int, bool)));
+		SLOT(viewBelowZoomLevelChanged(ZoomLevel, bool)));
     }
 }
 
--- a/view/AlignmentView.h	Wed Sep 12 15:58:11 2018 +0100
+++ b/view/AlignmentView.h	Mon Sep 17 13:51:31 2018 +0100
@@ -32,8 +32,8 @@
 public slots:
     virtual void globalCentreFrameChanged(sv_frame_t);
     virtual void viewCentreFrameChanged(View *, sv_frame_t);
-    virtual void viewAboveZoomLevelChanged(int, bool);
-    virtual void viewBelowZoomLevelChanged(int, bool);
+    virtual void viewAboveZoomLevelChanged(ZoomLevel, bool);
+    virtual void viewBelowZoomLevelChanged(ZoomLevel, bool);
     virtual void viewManagerPlaybackFrameChanged(sv_frame_t);
 
 protected:
--- a/view/Overview.cpp	Wed Sep 12 15:58:11 2018 +0100
+++ b/view/Overview.cpp	Mon Sep 17 13:51:31 2018 +0100
@@ -47,10 +47,9 @@
     bool zoomChanged = false;
 
     sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame();
-    int zoomLevel = int(frameCount / width());
-    if (zoomLevel < 1) zoomLevel = 1;
-    zoomLevel = getZoomConstraintBlockSize(zoomLevel,
-                                           ZoomConstraint::RoundUp);
+    ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) };
+    if (zoomLevel.level < 1) zoomLevel.level = 1;
+    zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp);
     if (zoomLevel != m_zoomLevel) {
         zoomChanged = true;
     }
--- a/view/View.cpp	Wed Sep 12 15:58:11 2018 +0100
+++ b/view/View.cpp	Mon Sep 17 13:51:31 2018 +0100
@@ -447,7 +447,7 @@
     }
 }
 
-int
+ZoomLevel
 View::getZoomLevel() const
 {
 #ifdef DEBUG_VIEW_WIDGET_PAINT
@@ -476,7 +476,7 @@
 }
 
 void
-View::setZoomLevel(int z)
+View::setZoomLevel(ZoomLevel z)
 {
     int dpratio = effectiveDevicePixelRatio();
     if (z < dpratio) return;
@@ -724,13 +724,13 @@
         m_manager->disconnect(this, SLOT(globalCentreFrameChanged(sv_frame_t)));
         m_manager->disconnect(this, SLOT(viewCentreFrameChanged(View *, sv_frame_t)));
         m_manager->disconnect(this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t)));
-        m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, int, bool)));
+        m_manager->disconnect(this, SLOT(viewZoomLevelChanged(View *, ZoomLevel, bool)));
         m_manager->disconnect(this, SLOT(toolModeChanged()));
         m_manager->disconnect(this, SLOT(selectionChanged()));
         m_manager->disconnect(this, SLOT(overlayModeChanged()));
         m_manager->disconnect(this, SLOT(zoomWheelsEnabledChanged()));
         disconnect(m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool, PlaybackFollowMode)));
-        disconnect(m_manager, SLOT(zoomLevelChanged(int, bool)));
+        disconnect(m_manager, SLOT(zoomLevelChanged(ZoomLevel, bool)));
     }
 
     m_manager = manager;
@@ -742,8 +742,8 @@
     connect(m_manager, SIGNAL(playbackFrameChanged(sv_frame_t)),
             this, SLOT(viewManagerPlaybackFrameChanged(sv_frame_t)));
 
-    connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, int, bool)),
-            this, SLOT(viewZoomLevelChanged(View *, int, bool)));
+    connect(m_manager, SIGNAL(viewZoomLevelChanged(View *, ZoomLevel, bool)),
+            this, SLOT(viewZoomLevelChanged(View *, ZoomLevel, bool)));
 
     connect(m_manager, SIGNAL(toolModeChanged()),
             this, SLOT(toolModeChanged()));
@@ -763,8 +763,8 @@
             m_manager, SLOT(viewCentreFrameChanged(sv_frame_t, bool,
                                                    PlaybackFollowMode)));
 
-    connect(this, SIGNAL(zoomLevelChanged(int, bool)),
-            m_manager, SLOT(viewZoomLevelChanged(int, bool)));
+    connect(this, SIGNAL(zoomLevelChanged(ZoomLevel, bool)),
+            m_manager, SLOT(viewZoomLevelChanged(ZoomLevel, bool)));
 
     switch (m_followPlay) {
         
@@ -1126,7 +1126,7 @@
 }
 
 void
-View::viewZoomLevelChanged(View *p, int z, bool locked)
+View::viewZoomLevelChanged(View *p, ZoomLevel z, bool locked)
 {
 #ifdef DEBUG_VIEW_WIDGET_PAINT
     cerr  << "View[" << this << "]: viewZoomLevelChanged(" << p << ", " << z << ", " << locked << ")" << endl;
@@ -1453,14 +1453,14 @@
 void
 View::zoom(bool in)
 {
-    int newZoomLevel = m_zoomLevel;
+    ZoomLevel newZoomLevel = m_zoomLevel;
 
     if (in) {
-        newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1, 
-                                                  ZoomConstraint::RoundDown);
+        newZoomLevel = getZoomConstraintLevel(m_zoomLevel.decremented(),
+                                              ZoomConstraint::RoundDown);
     } else {
-        newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1,
-                                                  ZoomConstraint::RoundUp);
+        newZoomLevel = getZoomConstraintLevel(m_zoomLevel.incremented(),
+                                              ZoomConstraint::RoundUp);
     }
 
     if (newZoomLevel != m_zoomLevel) {
--- a/view/View.h	Wed Sep 12 15:58:11 2018 +0100
+++ b/view/View.h	Mon Sep 17 13:51:31 2018 +0100
@@ -148,16 +148,17 @@
                             bool logarithmic) const;
 
     /**
-     * Return the zoom level, i.e. the number of frames per pixel
+     * Return the zoom level, i.e. the number of frames per pixel or
+     * pixels per frame
      */
-    int getZoomLevel() const;
+    ZoomLevel getZoomLevel() const;
 
     /**
-     * Set the zoom level, i.e. the number of frames per pixel.  The
-     * centre frame will be unchanged; the start and end frames will
-     * change.
+     * Set the zoom level, i.e. the number of frames per pixel or
+     * pixels per frame.  The centre frame will be unchanged; the
+     * start and end frames will change.
      */
-    virtual void setZoomLevel(int z);
+    virtual void setZoomLevel(ZoomLevel z);
 
     /**
      * Zoom in or out.
@@ -400,7 +401,7 @@
                             bool globalScroll,
                             PlaybackFollowMode followMode);
 
-    void zoomLevelChanged(int level, bool locked);
+    void zoomLevelChanged(ZoomLevel level, bool locked);
 
     void contextHelpChanged(const QString &);
 
@@ -418,7 +419,7 @@
     virtual void globalCentreFrameChanged(sv_frame_t);
     virtual void viewCentreFrameChanged(View *, sv_frame_t);
     virtual void viewManagerPlaybackFrameChanged(sv_frame_t);
-    virtual void viewZoomLevelChanged(View *, int, bool);
+    virtual void viewZoomLevelChanged(View *, ZoomLevel, bool);
 
     virtual void propertyContainerSelected(View *, PropertyContainer *pc);
 
@@ -456,9 +457,9 @@
     bool areLayersScrollable() const;
     LayerList getScrollableBackLayers(bool testChanged, bool &changed) const;
     LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const;
-    int getZoomConstraintBlockSize(int blockSize,
-                                      ZoomConstraint::RoundingDirection dir =
-                                      ZoomConstraint::RoundNearest) const;
+    ZoomLevel getZoomConstraintLevel(ZoomLevel level,
+                                     ZoomConstraint::RoundingDirection dir =
+                                     ZoomConstraint::RoundNearest) const;
 
     // True if the top layer(s) use colours for meaningful things.  If
     // this is the case, selections will be shown using unfilled boxes
@@ -481,7 +482,7 @@
     int effectiveDevicePixelRatio() const;
 
     sv_frame_t          m_centreFrame;
-    int                 m_zoomLevel;
+    ZoomLevel           m_zoomLevel;
     bool                m_followPan;
     bool                m_followZoom;
     PlaybackFollowMode  m_followPlay;
@@ -493,7 +494,7 @@
     QPixmap            *m_cache;  // I own this
     QPixmap            *m_buffer; // I own this
     sv_frame_t          m_cacheCentreFrame;
-    int                 m_cacheZoomLevel;
+    ZoomLevel           m_cacheZoomLevel;
     bool                m_selectionCached;
 
     bool                m_deleting;