comparison layer/ScrollableMagRangeCache.h @ 1266:a34a2a25907c

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents c53ed1a6fcbd
children bc2cb82050a0
comparison
equal deleted inserted replaced
1265:6e724c81f18f 1266:a34a2a25907c
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) 40 m_zoomLevel(0)
41 {} 41 {}
42 42
43 void invalidate() { 43 void invalidate() {
44 m_ranges = std::vector<MagnitudeRange>(m_ranges.size()); 44 m_ranges = std::vector<MagnitudeRange>(m_ranges.size());
45 } 45 }
46 46
47 int getWidth() const { 47 int getWidth() const {
48 return int(m_ranges.size()); 48 return int(m_ranges.size());
49 } 49 }
50 50
51 /** 51 /**
52 * Set the width of the cache in columns. If the new size differs 52 * Set the width of the cache in columns. If the new size differs
53 * from the current size, the cache is invalidated. 53 * from the current size, the cache is invalidated.
54 */ 54 */
55 void resize(int newWidth) { 55 void resize(int newWidth) {
56 if (getWidth() != newWidth) { 56 if (getWidth() != newWidth) {
57 m_ranges = std::vector<MagnitudeRange>(newWidth); 57 m_ranges = std::vector<MagnitudeRange>(newWidth);
58 } 58 }
59 } 59 }
60 60
61 int getZoomLevel() const { 61 int getZoomLevel() const {
62 return m_zoomLevel; 62 return m_zoomLevel;
63 } 63 }
64 64
65 /** 65 /**
66 * Set the zoom level. If the new zoom level differs from the 66 * Set the zoom level. If the new zoom level differs from the
67 * current one, the cache is invalidated. (Determining whether to 67 * current one, the cache is invalidated. (Determining whether to
74 invalidate(); 74 invalidate();
75 } 75 }
76 } 76 }
77 77
78 sv_frame_t getStartFrame() const { 78 sv_frame_t getStartFrame() const {
79 return m_startFrame; 79 return m_startFrame;
80 } 80 }
81 81
82 /** 82 /**
83 * Set the start frame. If the new start frame differs from the 83 * Set the start frame. If the new start frame differs from the
84 * current one, the cache is invalidated. To scroll, i.e. to set 84 * current one, the cache is invalidated. To scroll, i.e. to set
91 invalidate(); 91 invalidate();
92 } 92 }
93 } 93 }
94 94
95 bool isColumnSet(int column) const { 95 bool isColumnSet(int column) const {
96 return in_range_for(m_ranges, column) && m_ranges.at(column).isSet(); 96 return in_range_for(m_ranges, column) && m_ranges.at(column).isSet();
97 } 97 }
98 98
99 bool areColumnsSet(int x, int count) const { 99 bool areColumnsSet(int x, int count) const {
100 for (int i = 0; i < count; ++i) { 100 for (int i = 0; i < count; ++i) {
101 if (!isColumnSet(x + i)) return false; 101 if (!isColumnSet(x + i)) return false;
102 } 102 }
103 return true; 103 return true;
104 } 104 }
105 105
106 /** 106 /**
107 * Get the magnitude range for a single column. 107 * Get the magnitude range for a single column.
108 */ 108 */
109 MagnitudeRange getRange(int column) const { 109 MagnitudeRange getRange(int column) const {
110 return m_ranges.at(column); 110 return m_ranges.at(column);
111 } 111 }
112 112
113 /** 113 /**
114 * Get the magnitude range for a range of columns. 114 * Get the magnitude range for a range of columns.
115 */ 115 */