Mercurial > hg > easyhg
changeset 389:496f2042155a item_appearance_adjustments
Jump to position when panner is clicked on
author | Chris Cannam |
---|---|
date | Tue, 24 May 2011 16:54:24 +0100 |
parents | 6718bbc073b4 |
children | ef31a55c86b6 |
files | src/panner.cpp src/panner.h |
diffstat | 2 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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();