# HG changeset patch # User Chris Cannam # Date 1139508112 0 # Node ID 7dad8a310963970c570a7e41552c14f81fa7354f # Parent bb9291d84810d9e57028f2dafa588542c08b7ba0 * 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 diff -r bb9291d84810 -r 7dad8a310963 base/View.cpp --- 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 #include @@ -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; } }