From d66a83c2977ef9650c51ad4df49cc624092c32b9 Mon Sep 17 00:00:00 2001 From: Till Theato Date: Sat, 5 Mar 2011 21:56:41 +0000 Subject: [PATCH] bezier color curves: fix point selection with non-standard zoom svn path=/trunk/kdenlive/; revision=5478 --- src/beziercurve/beziersplineeditor.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/beziercurve/beziersplineeditor.cpp b/src/beziercurve/beziersplineeditor.cpp index fc5278b2..f830bd09 100644 --- a/src/beziercurve/beziersplineeditor.cpp +++ b/src/beziercurve/beziersplineeditor.cpp @@ -265,12 +265,13 @@ void BezierSplineEditor::mousePressEvent(QMouseEvent* event) { int wWidth = width() - 1; int wHeight = height() - 1; - int offset = 1/8. * m_zoomLevel * (wWidth > wHeight ? wWidth : wHeight); - wWidth -= 2 * offset; - wHeight -= 2 * offset; + int offsetX = 1/8. * m_zoomLevel * wWidth; + int offsetY = 1/8. * m_zoomLevel * wHeight; + wWidth -= 2 * offsetX; + wHeight -= 2 * offsetY; - double x = (event->pos().x() - offset) / (double)(wWidth); - double y = 1.0 - (event->pos().y() - offset) / (double)(wHeight); + double x = (event->pos().x() - offsetX) / (double)(wWidth); + double y = 1.0 - (event->pos().y() - offsetY) / (double)(wHeight); point_types selectedPoint; int closestPointIndex = nearestPointInRange(QPointF(x, y), wWidth, wHeight, &selectedPoint); @@ -337,12 +338,13 @@ void BezierSplineEditor::mouseMoveEvent(QMouseEvent* event) { int wWidth = width() - 1; int wHeight = height() - 1; - int offset = 1/8. * m_zoomLevel * (wWidth > wHeight ? wWidth : wHeight); - wWidth -= 2 * offset; - wHeight -= 2 * offset; + int offsetX = 1/8. * m_zoomLevel * wWidth; + int offsetY = 1/8. * m_zoomLevel * wHeight; + wWidth -= 2 * offsetX; + wHeight -= 2 * offsetY; - double x = (event->pos().x() - offset) / (double)(wWidth); - double y = 1.0 - (event->pos().y() - offset) / (double)(wHeight); + double x = (event->pos().x() - offsetX) / (double)(wWidth); + double y = 1.0 - (event->pos().y() - offsetY) / (double)(wHeight); if (m_mode == ModeNormal) { // If no point is selected set the the cursor shape if on top -- 2.39.2