]> git.sesse.net Git - kdenlive/commitdiff
bezier color curves: fix point selection with non-standard zoom
authorTill Theato <root@ttill.de>
Sat, 5 Mar 2011 21:56:41 +0000 (21:56 +0000)
committerTill Theato <root@ttill.de>
Sat, 5 Mar 2011 21:56:41 +0000 (21:56 +0000)
svn path=/trunk/kdenlive/; revision=5478

src/beziercurve/beziersplineeditor.cpp

index fc5278b24d69c47d1c63877ff1b5d32190cc9465..f830bd0906dc4641ab0293bed848eb9f5d47b28f 100644 (file)
@@ -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