# HG changeset patch # User Chris Cannam # Date 1306252464 -3600 # Node ID 496f2042155aa75366defb615f1e600747f518be # Parent 6718bbc073b4c8a08e9ad19ea2fadd9f3455e576 Jump to position when panner is clicked on diff -r 6718bbc073b4 -r 496f2042155a src/panner.cpp --- a/src/panner.cpp Tue May 24 16:26:42 2011 +0100 +++ b/src/panner.cpp Tue May 24 16:54:24 2011 +0100 @@ -32,7 +32,8 @@ }; Panner::Panner() : - m_clicked(false) + m_clicked(false), + m_moved(false) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -209,6 +210,7 @@ return; } m_clicked = true; + m_moved = false; m_clickedRect = m_pannedRect; m_clickedPoint = e->pos(); } @@ -231,6 +233,13 @@ QPointF cp = mapToScene(m_clickedPoint); QPointF mp = mapToScene(e->pos()); QPointF delta = mp - cp; + if (!m_moved) { + if ((m_clickedPoint - e->pos()).manhattanLength() > 2) { + m_moved = true; + } else { + return; + } + } QRectF nr = m_clickedRect; nr.translate(delta); m_pannedRect = nr; @@ -247,7 +256,11 @@ } if (m_clicked) { - mouseMoveEvent(e); + if (m_moved) { + mouseMoveEvent(e); + } else { + moveTo(e->pos()); + } } m_clicked = false; @@ -276,8 +289,9 @@ { QPointF sp = mapToScene(p); QRectF nr = m_pannedRect; - double d = sp.x() - nr.center().x(); - nr.translate(d, 0); + double dx = sp.x() - nr.center().x(); + double dy = sp.y() - nr.center().y(); + nr.translate(dx, dy); slotSetPannedRect(nr); emit pannedRectChanged(m_pannedRect); viewport()->update(); diff -r 6718bbc073b4 -r 496f2042155a src/panner.h --- a/src/panner.h Tue May 24 16:26:42 2011 +0100 +++ b/src/panner.h Tue May 24 16:54:24 2011 +0100 @@ -68,6 +68,7 @@ const QStyleOptionGraphicsItem []); bool m_clicked; + bool m_moved; QRectF m_clickedRect; QPoint m_clickedPoint;