Mercurial > hg > svgui
comparison layer/ScrollableImageCache.h @ 1325:bc2cb82050a0 zoom
Gradual ZoomLevel updates
author | Chris Cannam |
---|---|
date | Wed, 19 Sep 2018 15:42:22 +0100 |
parents | a34a2a25907c |
children |
comparison
equal
deleted
inserted
replaced
1324:13d9b422f7fe | 1325:bc2cb82050a0 |
---|---|
38 { | 38 { |
39 public: | 39 public: |
40 ScrollableImageCache() : | 40 ScrollableImageCache() : |
41 m_validLeft(0), | 41 m_validLeft(0), |
42 m_validWidth(0), | 42 m_validWidth(0), |
43 m_startFrame(0), | 43 m_startFrame(0) |
44 m_zoomLevel(0) | |
45 {} | 44 {} |
46 | 45 |
47 void invalidate() { | 46 void invalidate() { |
48 m_validWidth = 0; | 47 m_validWidth = 0; |
49 } | 48 } |
81 | 80 |
82 QRect getValidArea() const { | 81 QRect getValidArea() const { |
83 return QRect(m_validLeft, 0, m_validWidth, m_image.height()); | 82 return QRect(m_validLeft, 0, m_validWidth, m_image.height()); |
84 } | 83 } |
85 | 84 |
86 int getZoomLevel() const { | 85 ZoomLevel getZoomLevel() const { |
87 return m_zoomLevel; | 86 return m_zoomLevel; |
88 } | 87 } |
89 | 88 |
90 /** | 89 /** |
91 * Set the zoom level. If the new zoom level differs from the | 90 * Set the zoom level. If the new zoom level differs from the |
92 * current one, the cache is invalidated. (Determining whether to | 91 * current one, the cache is invalidated. (Determining whether to |
93 * invalidate the cache here is the only thing the zoom level is | 92 * invalidate the cache here is the only thing the zoom level is |
94 * used for.) | 93 * used for.) |
95 */ | 94 */ |
96 void setZoomLevel(int zoom) { | 95 void setZoomLevel(ZoomLevel zoom) { |
96 using namespace std::rel_ops; | |
97 if (m_zoomLevel != zoom) { | 97 if (m_zoomLevel != zoom) { |
98 m_zoomLevel = zoom; | 98 m_zoomLevel = zoom; |
99 invalidate(); | 99 invalidate(); |
100 } | 100 } |
101 } | 101 } |
155 private: | 155 private: |
156 QImage m_image; | 156 QImage m_image; |
157 int m_validLeft; | 157 int m_validLeft; |
158 int m_validWidth; | 158 int m_validWidth; |
159 sv_frame_t m_startFrame; | 159 sv_frame_t m_startFrame; |
160 int m_zoomLevel; | 160 ZoomLevel m_zoomLevel; |
161 }; | 161 }; |
162 | 162 |
163 #endif | 163 #endif |