comparison view/Overview.cpp @ 643:77fa3fdbfc7e sv_v2.1

Fix bug that caused overview to jump back to its original position after moving on double-click
author Chris Cannam
date Thu, 16 May 2013 13:11:13 +0100
parents 2c35737cd3f8
children 1a0dfcbffaf1
comparison
equal deleted inserted replaced
642:2c35737cd3f8 643:77fa3fdbfc7e
20 20
21 #include <QPaintEvent> 21 #include <QPaintEvent>
22 #include <QPainter> 22 #include <QPainter>
23 #include <iostream> 23 #include <iostream>
24 24
25 #define DEBUG_OVERVIEW 1 25 //#define DEBUG_OVERVIEW 1
26 26
27 using std::cerr; 27 using std::cerr;
28 using std::endl; 28 using std::endl;
29 29
30 Overview::Overview(QWidget *w) : 30 Overview::Overview(QWidget *w) :
275 } 275 }
276 276
277 if (std::max(m_centreFrame, newCentreFrame) - 277 if (std::max(m_centreFrame, newCentreFrame) -
278 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) { 278 std::min(m_centreFrame, newCentreFrame) > size_t(m_zoomLevel)) {
279 size_t rf = alignToReference(newCentreFrame); 279 size_t rf = alignToReference(newCentreFrame);
280 #ifdef DEBUG_OVERVIEW
281 std::cerr << "Overview::mouseMoveEvent: x " << e->x() << " and click x " << m_clickPos.x() << " -> frame " << newCentreFrame << " -> rf " << rf << std::endl;
282 #endif
280 emit centreFrameChanged(rf, true, PlaybackScrollContinuous); 283 emit centreFrameChanged(rf, true, PlaybackScrollContinuous);
281 } 284 }
282 } 285 }
283 286
284 void 287 void
285 Overview::mouseDoubleClickEvent(QMouseEvent *e) 288 Overview::mouseDoubleClickEvent(QMouseEvent *e)
286 { 289 {
287 long frame = getFrameForX(e->x()); 290 long frame = getFrameForX(e->x());
288 size_t rf = 0; 291 size_t rf = 0;
289 if (frame > 0) rf = alignToReference(frame); 292 if (frame > 0) rf = alignToReference(frame);
293 #ifdef DEBUG_OVERVIEW
294 std::cerr << "Overview::mouseDoubleClickEvent: frame " << frame << " -> rf " << rf << std::endl;
295 #endif
296 m_clickedInRange = false; // we're not starting a drag with the second click
290 emit centreFrameChanged(rf, true, PlaybackScrollContinuous); 297 emit centreFrameChanged(rf, true, PlaybackScrollContinuous);
291 } 298 }
292 299
293 void 300 void
294 Overview::enterEvent(QEvent *) 301 Overview::enterEvent(QEvent *)