Mercurial > hg > svgui
comparison layer/Layer.cpp @ 1434:ec6605563544
Fix tendency of start position of measure rect to wander as you drag out the rec
t (at certain zoom resolutions)
author | Chris Cannam |
---|---|
date | Thu, 21 Mar 2019 15:22:20 +0000 |
parents | c8a6fd3f9dff |
children | 5554d5187494 |
comparison
equal
deleted
inserted
replaced
1421:70e93f996da6 | 1434:ec6605563544 |
---|---|
371 } | 371 } |
372 | 372 |
373 void | 373 void |
374 Layer::measureStart(LayerGeometryProvider *v, QMouseEvent *e) | 374 Layer::measureStart(LayerGeometryProvider *v, QMouseEvent *e) |
375 { | 375 { |
376 setMeasureRectFromPixrect(v, m_draggingRect, | 376 m_draggingRect.haveFrames = hasTimeXAxis(); |
377 QRect(e->x(), e->y(), 0, 0)); | 377 |
378 // NB if haveFrames, then pixrect x and width will be rewritten on | |
379 // every paint according to the current locations of the | |
380 // definitive frame values. So we should set the start frame value | |
381 // once on measureStart, and then not modify it on drag (to avoid | |
382 // drift from repeated conversion back and forth). | |
383 | |
384 m_draggingRect.pixrect = QRect(e->x(), e->y(), 0, 0); | |
385 | |
386 if (m_draggingRect.haveFrames) { | |
387 m_draggingRect.startFrame = v->getFrameForX(e->x()); | |
388 m_draggingRect.endFrame = v->getFrameForX(e->x()); | |
389 } | |
390 | |
391 setMeasureRectYCoord(v, m_draggingRect, true, e->y()); | |
392 setMeasureRectYCoord(v, m_draggingRect, false, e->y()); | |
393 | |
378 m_haveDraggingRect = true; | 394 m_haveDraggingRect = true; |
379 } | 395 } |
380 | 396 |
381 void | 397 void |
382 Layer::measureDrag(LayerGeometryProvider *v, QMouseEvent *e) | 398 Layer::measureDrag(LayerGeometryProvider *v, QMouseEvent *e) |
383 { | 399 { |
384 if (!m_haveDraggingRect) return; | 400 if (!m_haveDraggingRect) return; |
385 | 401 |
386 setMeasureRectFromPixrect(v, m_draggingRect, | 402 m_draggingRect.pixrect.setHeight(e->y() - m_draggingRect.pixrect.y()); |
387 QRect(m_draggingRect.pixrect.x(), | 403 |
388 m_draggingRect.pixrect.y(), | 404 if (m_draggingRect.haveFrames) { |
389 e->x() - m_draggingRect.pixrect.x(), | 405 m_draggingRect.endFrame = v->getFrameForX(e->x()); |
390 e->y() - m_draggingRect.pixrect.y())); | 406 } else { |
407 m_draggingRect.pixrect.setWidth(e->x() - m_draggingRect.pixrect.x()); | |
408 } | |
409 | |
410 setMeasureRectYCoord(v, m_draggingRect, false, e->y()); | |
391 } | 411 } |
392 | 412 |
393 void | 413 void |
394 Layer::measureEnd(LayerGeometryProvider *v, QMouseEvent *e) | 414 Layer::measureEnd(LayerGeometryProvider *v, QMouseEvent *e) |
395 { | 415 { |