]> git.sesse.net Git - kdenlive/blobdiff - src/beziercurve/bpoint.cpp
Bezier spline widget: use DragValue instead of SpinBoxes, range 0-1 with 3 decimals...
[kdenlive] / src / beziercurve / bpoint.cpp
index c335b4cd69d24560847167ba748cee1395a4403b..e879e721f73f962ee2edf76b6441769ef26c0b25 100644 (file)
@@ -35,6 +35,16 @@ BPoint::BPoint(QPointF handle1, QPointF point, QPointF handle2) :
     autoSetLinked();
 }
 
+QPointF &BPoint::operator[](int i)
+{
+    return i == 0 ? h1 : (i == 1 ? p : h2);
+}
+
+const QPointF &BPoint::operator[](int i) const
+{
+    return i == 0 ? h1 : (i == 1 ? p : h2);
+}
+
 bool BPoint::operator==(const BPoint& point) const
 {
     return      point.h1 == h1 &&
@@ -76,9 +86,14 @@ void BPoint::setH2(QPointF handle2)
 
 void BPoint::keepInRange(qreal xMin, qreal xMax)
 {
+    Q_UNUSED(xMin);
+    Q_UNUSED(xMax);
 }
 
 void BPoint::autoSetLinked()
 {
-    handlesLinked = !QLineF(h1, p).angleTo(QLineF(p, h2));
+    // sometimes the angle is returned as 360°
+    // due to rounding problems the angle is sometimes not quite 0
+    qreal angle = QLineF(h1, p).angleTo(QLineF(p, h2));
+    handlesLinked = angle < 1e-3 || qRound(angle) == 360;
 }