Mercurial > hg > svgui
comparison view/View.cpp @ 1363:bbeffb29bf09
Fix inconsistency between centre frame actually set and centre frame notified as set, which caused the start frame location to creep out of place gradually as you page through
author | Chris Cannam |
---|---|
date | Tue, 30 Oct 2018 14:00:20 +0000 |
parents | 93eaff6f206d |
children | 694004228ab7 |
comparison
equal
deleted
inserted
replaced
1362:d79e21855aef | 1363:bbeffb29bf09 |
---|---|
338 sv_frame_t formerCentre = m_centreFrame; | 338 sv_frame_t formerCentre = m_centreFrame; |
339 m_centreFrame = f; | 339 m_centreFrame = f; |
340 | 340 |
341 if (m_zoomLevel.zone == ZoomLevel::PixelsPerFrame) { | 341 if (m_zoomLevel.zone == ZoomLevel::PixelsPerFrame) { |
342 | 342 |
343 #ifdef DEBUG_VIEW_WIDGET_PAINT | 343 #ifdef DEBUG_VIEW |
344 SVCERR << "View(" << this << ")::setCentreFrame: in PixelsPerFrame zone, so change must be visible" << endl; | 344 SVCERR << "View(" << this << ")::setCentreFrame: in PixelsPerFrame zone, so change must be visible" << endl; |
345 #endif | 345 #endif |
346 update(); | 346 update(); |
347 changeVisible = true; | 347 changeVisible = true; |
348 | 348 |
351 int formerPixel = int(formerCentre / m_zoomLevel.level); | 351 int formerPixel = int(formerCentre / m_zoomLevel.level); |
352 int newPixel = int(m_centreFrame / m_zoomLevel.level); | 352 int newPixel = int(m_centreFrame / m_zoomLevel.level); |
353 | 353 |
354 if (newPixel != formerPixel) { | 354 if (newPixel != formerPixel) { |
355 | 355 |
356 #ifdef DEBUG_VIEW_WIDGET_PAINT | 356 #ifdef DEBUG_VIEW |
357 SVCERR << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; | 357 SVCERR << "View(" << this << ")::setCentreFrame: newPixel " << newPixel << ", formerPixel " << formerPixel << endl; |
358 #endif | 358 #endif |
359 // ensure the centre frame is a multiple of the zoom level | 359 // ensure the centre frame is a multiple of the zoom level |
360 m_centreFrame = sv_frame_t(newPixel) * m_zoomLevel.level; | 360 m_centreFrame = sv_frame_t(newPixel) * m_zoomLevel.level; |
361 | |
362 #ifdef DEBUG_VIEW | |
363 SVCERR << "View(" << this | |
364 << ")::setCentreFrame: centre frame rounded to " | |
365 << m_centreFrame << " (zoom level is " | |
366 << m_zoomLevel.level << ")" << endl; | |
367 #endif | |
361 | 368 |
362 update(); | 369 update(); |
363 changeVisible = true; | 370 changeVisible = true; |
364 } | 371 } |
365 } | 372 } |
366 | 373 |
367 if (e) { | 374 if (e) { |
368 sv_frame_t rf = alignToReference(f); | 375 sv_frame_t rf = alignToReference(m_centreFrame); |
369 #ifdef DEBUG_VIEW | 376 #ifdef DEBUG_VIEW |
370 cerr << "View[" << this << "]::setCentreFrame(" << f | 377 cerr << "View[" << this << "]::setCentreFrame(" << f |
371 << "): emitting centreFrameChanged(" | 378 << "): m_centreFrame = " << m_centreFrame |
372 << rf << ")" << endl; | 379 << ", emitting centreFrameChanged with aligned frame " |
380 << rf << endl; | |
373 #endif | 381 #endif |
374 emit centreFrameChanged(rf, m_followPan, m_followPlay); | 382 emit centreFrameChanged(rf, m_followPan, m_followPlay); |
375 } | 383 } |
376 } | 384 } |
377 | 385 |
425 --fdiff; // round to the left | 433 --fdiff; // round to the left |
426 } | 434 } |
427 result = fdiff + m_centreFrame; | 435 result = fdiff + m_centreFrame; |
428 } | 436 } |
429 | 437 |
430 #ifdef DEBUG_VIEW | 438 #ifdef DEBUG_VIEW_WIDGET_PAINT |
431 if (x == 0) { | 439 if (x == 0) { |
432 SVCERR << "getFrameForX(" << x << "): diff = " << diff << ", fdiff = " | 440 SVCERR << "getFrameForX(" << x << "): diff = " << diff << ", fdiff = " |
433 << fdiff << ", m_centreFrame = " << m_centreFrame | 441 << fdiff << ", m_centreFrame = " << m_centreFrame |
434 << ", level = " << m_zoomLevel.level | 442 << ", level = " << m_zoomLevel.level |
435 << ", diff % level = " << (diff % m_zoomLevel.level) | 443 << ", diff % level = " << (diff % m_zoomLevel.level) |
1602 } else { | 1610 } else { |
1603 delta = (getEndFrame() - getStartFrame()) / 20; | 1611 delta = (getEndFrame() - getStartFrame()) / 20; |
1604 } | 1612 } |
1605 if (right) delta = -delta; | 1613 if (right) delta = -delta; |
1606 | 1614 |
1615 #ifdef DEBUG_VIEW | |
1616 SVCERR << "View::scroll(" << right << ", " << lots << ", " << e << "): " | |
1617 << "delta = " << delta << ", m_centreFrame = " << m_centreFrame | |
1618 << endl; | |
1619 #endif | |
1620 | |
1607 if (m_centreFrame < delta) { | 1621 if (m_centreFrame < delta) { |
1608 setCentreFrame(0, e); | 1622 setCentreFrame(0, e); |
1609 } else if (m_centreFrame - delta >= getModelsEndFrame()) { | 1623 } else if (m_centreFrame - delta >= getModelsEndFrame()) { |
1610 setCentreFrame(getModelsEndFrame(), e); | 1624 setCentreFrame(getModelsEndFrame(), e); |
1611 } else { | 1625 } else { |