Mercurial > hg > svcore
comparison base/View.cpp @ 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 | 8460b3bf8f04 |
comparison
equal
deleted
inserted
replaced
24:bb9291d84810 | 25:7dad8a310963 |
---|---|
12 #include "base/Model.h" | 12 #include "base/Model.h" |
13 #include "base/ZoomConstraint.h" | 13 #include "base/ZoomConstraint.h" |
14 #include "base/Profiler.h" | 14 #include "base/Profiler.h" |
15 | 15 |
16 #include "layer/TimeRulerLayer.h" //!!! damn, shouldn't be including that here | 16 #include "layer/TimeRulerLayer.h" //!!! damn, shouldn't be including that here |
17 #include "model/PowerOfSqrtTwoZoomConstraint.h" //!!! likewise | |
17 | 18 |
18 #include <QPainter> | 19 #include <QPainter> |
19 #include <QPaintEvent> | 20 #include <QPaintEvent> |
20 #include <QRect> | 21 #include <QRect> |
21 #include <QApplication> | 22 #include <QApplication> |
750 const | 751 const |
751 { | 752 { |
752 size_t candidate = blockSize; | 753 size_t candidate = blockSize; |
753 bool haveCandidate = false; | 754 bool haveCandidate = false; |
754 | 755 |
756 PowerOfSqrtTwoZoomConstraint defaultZoomConstraint; | |
757 | |
755 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { | 758 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { |
756 | 759 |
757 if ((*i)->getZoomConstraint()) { | 760 const ZoomConstraint *zoomConstraint = (*i)->getZoomConstraint(); |
758 | 761 if (!zoomConstraint) zoomConstraint = &defaultZoomConstraint; |
759 size_t thisBlockSize = | 762 |
760 (*i)->getZoomConstraint()->getNearestBlockSize | 763 size_t thisBlockSize = |
761 (blockSize, dir); | 764 zoomConstraint->getNearestBlockSize(blockSize, dir); |
762 | 765 |
763 // Go for the block size that's furthest from the one | 766 // Go for the block size that's furthest from the one |
764 // passed in. Most of the time, that's what we want. | 767 // passed in. Most of the time, that's what we want. |
765 if (!haveCandidate || | 768 if (!haveCandidate || |
766 (thisBlockSize > blockSize && thisBlockSize > candidate) || | 769 (thisBlockSize > blockSize && thisBlockSize > candidate) || |
767 (thisBlockSize < blockSize && thisBlockSize < candidate)) { | 770 (thisBlockSize < blockSize && thisBlockSize < candidate)) { |
768 candidate = thisBlockSize; | 771 candidate = thisBlockSize; |
769 haveCandidate = true; | 772 haveCandidate = true; |
770 } | |
771 } | 773 } |
772 } | 774 } |
773 | 775 |
774 return candidate; | 776 return candidate; |
775 } | 777 } |