]> git.sesse.net Git - kdenlive/blobdiff - src/beziercurve/beziersplineeditor.cpp
Bezier Spline: Add checkable button show all handles: Whether to show handles for...
[kdenlive] / src / beziercurve / beziersplineeditor.cpp
index 0b39b11e083409a215b9da93c920e245567efa69..eeaae3b0ae9edbbca9c0fd290e5b1cd59505716f 100644 (file)
@@ -27,6 +27,7 @@ BezierSplineEditor::BezierSplineEditor(QWidget* parent) :
         m_mode(ModeNormal),
         m_zoomLevel(0),
         m_gridLines(3),
+        m_showAllHandles(true),
         m_pixmapCache(NULL),
         m_pixmapIsDirty(true),
         m_currentPointIndex(-1)
@@ -101,6 +102,12 @@ void BezierSplineEditor::slotZoomOut()
     update();
 }
 
+void BezierSplineEditor::setShowAllHandles(bool show)
+{
+    m_showAllHandles = show;
+    update();
+}
+
 int BezierSplineEditor::gridLines()
 {
     return m_gridLines;
@@ -228,7 +235,7 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
 
         p.drawEllipse(QRectF(point.p.x() * wWidth - 3,
                              wHeight - 3 - point.p.y() * wHeight, 6, 6));
-        if (i != 0) {
+        if (i != 0 && (i == m_currentPointIndex || m_showAllHandles)) {
 #if QT_VERSION >= 0x040600
             p.drawConvexPolygon(handle.translated(point.h1.x() * wWidth, wHeight - point.h1.y() * wHeight));
 #else
@@ -237,7 +244,7 @@ void BezierSplineEditor::paintEvent(QPaintEvent* event)
             p.drawConvexPolygon(tmp);
 #endif
         }
-        if (i != max) {
+        if (i != max && (i == m_currentPointIndex || m_showAllHandles)) {
 #if QT_VERSION >= 0x040600
             p.drawConvexPolygon(handle.translated(point.h2.x() * wWidth, wHeight - point.h2.y() * wHeight));
 #else
@@ -462,7 +469,8 @@ int BezierSplineEditor::nearestPointInRange(QPointF p, int wWidth, int wHeight,
         ++i;
     }
 
-    if (nearestIndex >= 0) {
+    if (nearestIndex >= 0 && (nearestIndex == m_currentPointIndex || selectedPoint == PTypeP || m_showAllHandles)) {
+        // a point was found and it is not a hidden handle
         BPoint point = m_spline.points()[nearestIndex];
         if (qAbs(p.x() - point[(int)selectedPoint].x()) * wWidth < 5 && qAbs(p.y() - point[(int)selectedPoint].y()) * wHeight < 5) {
             *sel = selectedPoint;