Mercurial > hg > svgui
comparison layer/TimeRulerLayer.cpp @ 1325:bc2cb82050a0 zoom
Gradual ZoomLevel updates
author | Chris Cannam |
---|---|
date | Wed, 19 Sep 2018 15:42:22 +0100 |
parents | a34a2a25907c |
children | 97c68bffbda6 |
comparison
equal
deleted
inserted
replaced
1324:13d9b422f7fe | 1325:bc2cb82050a0 |
---|---|
228 // We always use the exact incms in our calculations for where to | 228 // We always use the exact incms in our calculations for where to |
229 // draw the actual ticks or lines. | 229 // draw the actual ticks or lines. |
230 | 230 |
231 int minPixelSpacing = 50; | 231 int minPixelSpacing = 50; |
232 sv_frame_t incFrame = lrint((incms * sampleRate) / 1000); | 232 sv_frame_t incFrame = lrint((incms * sampleRate) / 1000); |
233 int incX = int(incFrame / v->getZoomLevel()); | 233 int incX = int(round(v->getZoomLevel().framesToPixels(incFrame))); |
234 int ticks = 10; | 234 int ticks = 10; |
235 if (incX < minPixelSpacing * 2) { | 235 if (incX < minPixelSpacing * 2) { |
236 ticks = quarter ? 4 : 5; | 236 ticks = quarter ? 4 : 5; |
237 } | 237 } |
238 | 238 |
254 // a different pixel when scrolling a small amount and | 254 // a different pixel when scrolling a small amount and |
255 // re-drawing with a different start frame). | 255 // re-drawing with a different start frame). |
256 | 256 |
257 double dms = ms; | 257 double dms = ms; |
258 sv_frame_t frame = lrint((dms * sampleRate) / 1000.0); | 258 sv_frame_t frame = lrint((dms * sampleRate) / 1000.0); |
259 frame /= v->getZoomLevel(); | 259 ZoomLevel zoom = v->getZoomLevel(); |
260 frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel | 260 if (zoom.zone == ZoomLevel::FramesPerPixel) { |
261 frame /= zoom.level; | |
262 frame *= zoom.level; // so frame corresponds to an exact pixel | |
263 } | |
261 | 264 |
262 if (frame == prevframe && prevframe != 0) { | 265 if (frame == prevframe && prevframe != 0) { |
263 cerr << "ERROR: frame == prevframe (== " << frame | 266 cerr << "ERROR: frame == prevframe (== " << frame |
264 << ") in TimeRulerLayer::paint" << endl; | 267 << ") in TimeRulerLayer::paint" << endl; |
265 throw std::logic_error("frame == prevframe in TimeRulerLayer::paint"); | 268 throw std::logic_error("frame == prevframe in TimeRulerLayer::paint"); |
335 | 338 |
336 for (int i = 1; i < ticks; ++i) { | 339 for (int i = 1; i < ticks; ++i) { |
337 | 340 |
338 dms = ms + (i * double(incms)) / ticks; | 341 dms = ms + (i * double(incms)) / ticks; |
339 frame = lrint((dms * sampleRate) / 1000.0); | 342 frame = lrint((dms * sampleRate) / 1000.0); |
340 frame /= v->getZoomLevel(); | 343 if (zoom.zone == ZoomLevel::FramesPerPixel) { |
341 frame *= v->getZoomLevel(); // exact pixel as above | 344 frame /= zoom.level; |
345 frame *= zoom.level; // exact pixel as above | |
346 } | |
342 | 347 |
343 x = v->getXForFrame(frame); | 348 x = v->getXForFrame(frame); |
344 | 349 |
345 if (x < rect.x() || x >= rect.x() + rect.width()) { | 350 if (x < rect.x() || x >= rect.x() + rect.width()) { |
346 #ifdef DEBUG_TIME_RULER_LAYER | 351 #ifdef DEBUG_TIME_RULER_LAYER |