changeset 25:7dad8a310963

* Add basics of MIDI file import. Doesn't actually create the model yet. * Add rewind to start / ffwd to end. * Make zoom constraint default to sqrt(2) type if no constraint set
author Chris Cannam
date Thu, 09 Feb 2006 18:01:52 +0000
parents bb9291d84810
children 090c22aa726a
files base/View.cpp
diffstat 1 files changed, 14 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/base/View.cpp	Wed Feb 08 17:59:16 2006 +0000
+++ b/base/View.cpp	Thu Feb 09 18:01:52 2006 +0000
@@ -14,6 +14,7 @@
 #include "base/Profiler.h"
 
 #include "layer/TimeRulerLayer.h" //!!! damn, shouldn't be including that here
+#include "model/PowerOfSqrtTwoZoomConstraint.h" //!!! likewise
 
 #include <QPainter>
 #include <QPaintEvent>
@@ -752,22 +753,23 @@
     size_t candidate = blockSize;
     bool haveCandidate = false;
 
+    PowerOfSqrtTwoZoomConstraint defaultZoomConstraint;
+
     for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
 
-	if ((*i)->getZoomConstraint()) {
+	const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint();
+	if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint;
 
-	    size_t thisBlockSize = 
-		(*i)->getZoomConstraint()->getNearestBlockSize
-		(blockSize, dir);
+	size_t thisBlockSize =
+	    zoomConstraint->getNearestBlockSize(blockSize, dir);
 
-	    // Go for the block size that's furthest from the one
-	    // passed in.  Most of the time, that's what we want.
-	    if (!haveCandidate ||
-		(thisBlockSize > blockSize && thisBlockSize > candidate) ||
-		(thisBlockSize < blockSize && thisBlockSize < candidate)) {
-		candidate = thisBlockSize;
-		haveCandidate = true;
-	    }
+	// Go for the block size that's furthest from the one
+	// passed in.  Most of the time, that's what we want.
+	if (!haveCandidate ||
+	    (thisBlockSize > blockSize && thisBlockSize > candidate) ||
+	    (thisBlockSize < blockSize && thisBlockSize < candidate)) {
+	    candidate = thisBlockSize;
+	    haveCandidate = true;
 	}
     }