diff options
-rw-r--r-- | spline-widget/spline-widget.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp index 5fa0644c..c7dd5e5a 100644 --- a/spline-widget/spline-widget.cpp +++ b/spline-widget/spline-widget.cpp @@ -324,38 +324,35 @@ void spline_widget::mousePressEvent(QMouseEvent *e) { bool bTouchingPoint = false; moving_control_point_idx = -1; - if (_config) + for (int i = 0; i < points.size(); i++) + { + if (point_within_pixel(points[i], e->pos())) + { + bTouchingPoint = true; + moving_control_point_idx = int(i); + break; + } + } + if (!bTouchingPoint) { + bool too_close = false; + const QPoint pos = e->pos(); + for (int i = 0; i < points.size(); i++) { - if (point_within_pixel(points[i], e->pos())) + const QPointF pt = point_to_pixel(points[i]); + const qreal x = std::fabs(pt.x() - pos.x()); + if (point_pixel_closeness_limit >= x) { - bTouchingPoint = true; - moving_control_point_idx = int(i); + too_close = true; break; } } - if (!bTouchingPoint) - { - bool too_close = false; - const QPoint pos = e->pos(); - - for (int i = 0; i < points.size(); i++) - { - const QPointF pt = point_to_pixel(points[i]); - const qreal x = std::fabs(pt.x() - pos.x()); - if (point_pixel_closeness_limit >= x) - { - too_close = true; - break; - } - } - if (!too_close) - { - _config->add_point(pixel_coord_to_point(e->pos())); - show_tooltip(e->pos()); - } + if (!too_close) + { + _config->add_point(pixel_coord_to_point(e->pos())); + show_tooltip(e->pos()); } } } |