Mercurial > hg > svgui
comparison layer/ScrollableMagRangeCache.h @ 1353:86429ff00f05
Merge from branch zoom
author | Chris Cannam |
---|---|
date | Wed, 10 Oct 2018 08:44:27 +0100 |
parents | bc2cb82050a0 |
children |
comparison
equal
deleted
inserted
replaced
1351:9fb7133dd818 | 1353:86429ff00f05 |
---|---|
34 */ | 34 */ |
35 class ScrollableMagRangeCache | 35 class ScrollableMagRangeCache |
36 { | 36 { |
37 public: | 37 public: |
38 ScrollableMagRangeCache() : | 38 ScrollableMagRangeCache() : |
39 m_startFrame(0), | 39 m_startFrame(0) |
40 m_zoomLevel(0) | |
41 {} | 40 {} |
42 | 41 |
43 void invalidate() { | 42 void invalidate() { |
44 m_ranges = std::vector<MagnitudeRange>(m_ranges.size()); | 43 m_ranges = std::vector<MagnitudeRange>(m_ranges.size()); |
45 } | 44 } |
56 if (getWidth() != newWidth) { | 55 if (getWidth() != newWidth) { |
57 m_ranges = std::vector<MagnitudeRange>(newWidth); | 56 m_ranges = std::vector<MagnitudeRange>(newWidth); |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 int getZoomLevel() const { | 60 ZoomLevel getZoomLevel() const { |
62 return m_zoomLevel; | 61 return m_zoomLevel; |
63 } | 62 } |
64 | 63 |
65 /** | 64 /** |
66 * Set the zoom level. If the new zoom level differs from the | 65 * Set the zoom level. If the new zoom level differs from the |
67 * current one, the cache is invalidated. (Determining whether to | 66 * current one, the cache is invalidated. (Determining whether to |
68 * invalidate the cache here is the only thing the zoom level is | 67 * invalidate the cache here is the only thing the zoom level is |
69 * used for.) | 68 * used for.) |
70 */ | 69 */ |
71 void setZoomLevel(int zoom) { | 70 void setZoomLevel(ZoomLevel zoom) { |
71 using namespace std::rel_ops; | |
72 if (m_zoomLevel != zoom) { | 72 if (m_zoomLevel != zoom) { |
73 m_zoomLevel = zoom; | 73 m_zoomLevel = zoom; |
74 invalidate(); | 74 invalidate(); |
75 } | 75 } |
76 } | 76 } |
131 void sampleColumn(int column, const MagnitudeRange &r); | 131 void sampleColumn(int column, const MagnitudeRange &r); |
132 | 132 |
133 private: | 133 private: |
134 std::vector<MagnitudeRange> m_ranges; | 134 std::vector<MagnitudeRange> m_ranges; |
135 sv_frame_t m_startFrame; | 135 sv_frame_t m_startFrame; |
136 int m_zoomLevel; | 136 ZoomLevel m_zoomLevel; |
137 }; | 137 }; |
138 | 138 |
139 #endif | 139 #endif |