From bcb94a6f4ac2e679997ee399f6868f00ecd1a5bd Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 14 Jan 2014 00:54:52 +0100 Subject: [PATCH] improved constrained crop feature --- src/mtsgui/glwidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mtsgui/glwidget.cpp b/src/mtsgui/glwidget.cpp index a620c84a..910e072f 100644 --- a/src/mtsgui/glwidget.cpp +++ b/src/mtsgui/glwidget.cpp @@ -608,9 +608,9 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) { int dx = m_cropEnd.x-m_cropStart.x, dy = m_cropEnd.y-m_cropStart.y; if (std::abs(dx) > std::abs(dy)) - m_cropEnd.y = std::min(std::max(0, m_cropStart.y + dx), maxCrop.y-1); + m_cropEnd.y = std::min(std::max(0, m_cropStart.y + std::abs(dx)*(dy<0 ? -1 : 1)), maxCrop.y-1); else - m_cropEnd.x = std::min(std::max(0, m_cropStart.x + dy), maxCrop.x-1); + m_cropEnd.x = std::min(std::max(0, m_cropStart.x + std::abs(dy)*(dx<0 ? -1 : 1)), maxCrop.x-1); } m_statusMessage =