Mercurial > hg > svgui
diff 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 |
line wrap: on
line diff
--- a/view/Overview.cpp Mon Sep 17 13:51:31 2018 +0100 +++ b/view/Overview.cpp Wed Sep 19 15:42:22 2018 +0100 @@ -44,12 +44,14 @@ void Overview::modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame) { + using namespace std::rel_ops; + bool zoomChanged = false; sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) }; if (zoomLevel.level < 1) zoomLevel.level = 1; - zoomLevel = getZoomConstraintBlockSize(zoomLevel, ZoomConstraint::RoundUp); + zoomLevel = getZoomConstraintLevel(zoomLevel, ZoomConstraint::RoundUp); if (zoomLevel != m_zoomLevel) { zoomChanged = true; } @@ -170,6 +172,8 @@ void Overview::paintEvent(QPaintEvent *e) { + using namespace std::rel_ops; + // Recalculate zoom in case the size of the widget has changed. #ifdef DEBUG_OVERVIEW @@ -178,10 +182,9 @@ sv_frame_t startFrame = getModelsStartFrame(); sv_frame_t frameCount = getModelsEndFrame() - getModelsStartFrame(); - int zoomLevel = int(frameCount / width()); - if (zoomLevel < 1) zoomLevel = 1; - zoomLevel = getZoomConstraintBlockSize(zoomLevel, - ZoomConstraint::RoundUp); + ZoomLevel zoomLevel { ZoomLevel::FramesPerPixel, int(frameCount / width()) }; + if (zoomLevel.level < 1) zoomLevel.level = 1; + zoomLevel = getZoomConstraintLevel(zoomLevel, ZoomConstraint::RoundUp); if (zoomLevel != m_zoomLevel) { m_zoomLevel = zoomLevel; emit zoomLevelChanged(m_zoomLevel, m_followZoom);