comparison view/Overview.cpp @ 1326:97c68bffbda6 zoom

More ZoomLevel updates
author Chris Cannam
date Thu, 20 Sep 2018 10:45:24 +0100
parents bc2cb82050a0
children b39cd8fb309f
comparison
equal deleted inserted replaced
1325:bc2cb82050a0 1326:97c68bffbda6
122 update(); 122 update();
123 } 123 }
124 } 124 }
125 125
126 void 126 void
127 Overview::viewZoomLevelChanged(View *v, int, bool) 127 Overview::viewZoomLevelChanged(View *v, ZoomLevel, bool)
128 { 128 {
129 if (v == this) return; 129 if (v == this) return;
130 if (m_views.find(v) != m_views.end()) { 130 if (m_views.find(v) != m_views.end()) {
131 update(); 131 update();
132 } 132 }
188 if (zoomLevel != m_zoomLevel) { 188 if (zoomLevel != m_zoomLevel) {
189 m_zoomLevel = zoomLevel; 189 m_zoomLevel = zoomLevel;
190 emit zoomLevelChanged(m_zoomLevel, m_followZoom); 190 emit zoomLevelChanged(m_zoomLevel, m_followZoom);
191 } 191 }
192 192
193 sv_frame_t centreFrame = startFrame + m_zoomLevel * (width() / 2); 193 sv_frame_t centreFrame = startFrame +
194 sv_frame_t(round(m_zoomLevel.pixelsToFrames(width()/2)));
195
194 if (centreFrame > (startFrame + getModelsEndFrame())/2) { 196 if (centreFrame > (startFrame + getModelsEndFrame())/2) {
195 centreFrame = (startFrame + getModelsEndFrame())/2; 197 centreFrame = (startFrame + getModelsEndFrame())/2;
196 } 198 }
197 if (centreFrame != m_centreFrame) { 199 if (centreFrame != m_centreFrame) {
198 #ifdef DEBUG_OVERVIEW 200 #ifdef DEBUG_OVERVIEW
309 Overview::mouseMoveEvent(QMouseEvent *e) 311 Overview::mouseMoveEvent(QMouseEvent *e)
310 { 312 {
311 if (!m_clickedInRange) return; 313 if (!m_clickedInRange) return;
312 314
313 int xoff = int(e->x()) - int(m_clickPos.x()); 315 int xoff = int(e->x()) - int(m_clickPos.x());
314 sv_frame_t frameOff = xoff * m_zoomLevel; 316 sv_frame_t frameOff = sv_frame_t(round(m_zoomLevel.pixelsToFrames(xoff)));
315 317
316 sv_frame_t newCentreFrame = m_dragCentreFrame; 318 sv_frame_t newCentreFrame = m_dragCentreFrame;
317 if (frameOff > 0) { 319 if (frameOff > 0) {
318 newCentreFrame += frameOff; 320 newCentreFrame += frameOff;
319 } else if (newCentreFrame >= -frameOff) { 321 } else if (newCentreFrame >= -frameOff) {
326 newCentreFrame = getModelsEndFrame(); 328 newCentreFrame = getModelsEndFrame();
327 if (newCentreFrame > 0) --newCentreFrame; 329 if (newCentreFrame > 0) --newCentreFrame;
328 } 330 }
329 331
330 if (std::max(m_centreFrame, newCentreFrame) - 332 if (std::max(m_centreFrame, newCentreFrame) -
331 std::min(m_centreFrame, newCentreFrame) > m_zoomLevel) { 333 std::min(m_centreFrame, newCentreFrame) >
334 m_zoomLevel.pixelsToFrames(1)) {
332 sv_frame_t rf = alignToReference(newCentreFrame); 335 sv_frame_t rf = alignToReference(newCentreFrame);
333 #ifdef DEBUG_OVERVIEW 336 #ifdef DEBUG_OVERVIEW
334 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl; 337 cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << endl;
335 #endif 338 #endif
336 if (m_followPlay == PlaybackScrollContinuous || 339 if (m_followPlay == PlaybackScrollContinuous ||