comparison view/Overview.cpp @ 1325:bc2cb82050a0 zoom

Gradual ZoomLevel updates
author Chris Cannam
date Wed, 19 Sep 2018 15:42:22 +0100
parents 13d9b422f7fe
children 97c68bffbda6
comparison
equal deleted inserted replaced
1324:13d9b422f7fe 1325:bc2cb82050a0
42 } 42 }
43 43
44 void 44 void
45 Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) 45 Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame)
46 { 46 {
47 using namespace std::rel_ops;
48
47 bool zoomChanged = false; 49 bool zoomChanged = false;
48 50
49 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); 51 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame();
50 ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) }; 52 ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) };
51 if (zoomLevel.level < 1) zoomLevel.level = 1; 53 if (zoomLevel.level < 1) zoomLevel.level = 1;
52 zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp); 54 zoomLevel = getZoomConstraintLevel(zoomLevel, ZoomConstraint::RoundUp);
53 if (zoomLevel != m_zoomLevel) { 55 if (zoomLevel != m_zoomLevel) {
54 zoomChanged = true; 56 zoomChanged = true;
55 } 57 }
56 58
57 if (!zoomChanged) { 59 if (!zoomChanged) {
168 } 170 }
169 171
170 void 172 void
171 Overview::paintEvent(QPaintEvent *e) 173 Overview::paintEvent(QPaintEvent *e)
172 { 174 {
175 using namespace std::rel_ops;
176
173 // Recalculate zoom in case the size of the widget has changed. 177 // Recalculate zoom in case the size of the widget has changed.
174 178
175 #ifdef DEBUG_OVERVIEW 179 #ifdef DEBUG_OVERVIEW
176 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; 180 cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl;
177 #endif 181 #endif
178 182
179 sv_frame_t startFrame = getModelsStartFrame(); 183 sv_frame_t startFrame = getModelsStartFrame();
180 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); 184 sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame();
181 int zoomLevel = int(frameCount / width()); 185 ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) };
182 if (zoomLevel < 1) zoomLevel = 1; 186 if (zoomLevel.level < 1) zoomLevel.level = 1;
183 zoomLevel = getZoomConstraintBlockSize(zoomLevel, 187 zoomLevel = getZoomConstraintLevel(zoomLevel, ZoomConstraint::RoundUp);
184 ZoomConstraint::RoundUp);
185 if (zoomLevel != m_zoomLevel) { 188 if (zoomLevel != m_zoomLevel) {
186 m_zoomLevel = zoomLevel; 189 m_zoomLevel = zoomLevel;
187 emit zoomLevelChanged(m_zoomLevel, m_followZoom); 190 emit zoomLevelChanged(m_zoomLevel, m_followZoom);
188 } 191 }
189 192