From 07b27beab17b85111e5d4879cf4b08f081e4cdf9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 27 Aug 2018 17:16:09 +0200 Subject: spline/widget: fix min point distance logic - rename the function - return min distance value in position of `x', not pixels - add some DPI scaling for point size and line length - use snap logic where it was ignored --- spline/spline-widget.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'spline/spline-widget.hpp') diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp index 2fa2a365..70071c28 100644 --- a/spline/spline-widget.hpp +++ b/spline/spline-widget.hpp @@ -15,6 +15,8 @@ #include "export.hpp" +#include + #include #include @@ -40,7 +42,7 @@ public: void setConfig(base_spline* spl); QColor colorBezier() const; - void setColorBezier(QColor color); + void setColorBezier(QColor const& color); void force_redraw(); void set_preview_only(bool val); @@ -61,7 +63,7 @@ protected slots: void mouseMoveEvent(QMouseEvent *e) override; void mouseReleaseEvent(QMouseEvent *e) override; private: - double get_closeness_limit(); + double min_pt_distance() const; void show_tooltip(const QPoint& pos, const QPointF& value = QPointF(0, 0)); bool is_in_bounds(const QPointF& pos) const; @@ -80,6 +82,8 @@ private: QPointF pixel_to_point(const QPointF& point); QPointF point_to_pixel(const QPointF& point); + static double snap(double x, double snap_value); + QPointF c; base_spline* _config = nullptr; @@ -98,7 +102,10 @@ private: int moving_control_point_idx = -1; bool _draw_function = true, _preview_only = false; - static constexpr inline int point_size = 4; + // point's circle radius on the widget + static constexpr inline int point_size_in_pixels_ = 4; + + const double point_size_in_pixels = point_size_in_pixels_ * std::fmax(1, devicePixelRatioF() * .66); }; } // ns spline_detail -- cgit v1.2.3