summaryrefslogtreecommitdiffhomepage
path: root/spline
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-06-25 21:04:15 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-06-25 21:04:29 +0200
commit0b7de47259713acef2682755cc79263883741bf1 (patch)
tree46106e6304db240f8b2ab35524fdc78d812d0293 /spline
parent6f4388a445c6701b592e90d87f08361d773a09b1 (diff)
spline: set minimum size hint
Diffstat (limited to 'spline')
-rw-r--r--spline/spline-widget.cpp15
-rw-r--r--spline/spline-widget.hpp6
2 files changed, 20 insertions, 1 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index d329d8e2..363720c8 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -260,6 +260,21 @@ void spline_widget::drawFunction()
}
}
+double spline_widget::screen_dpi() const
+{
+#ifdef _WIN32
+ return std::max(devicePixelRatioF, 1.);
+#else
+ return std::max(std::max(logicalDpiX()/(double)physicalDpiX(), devicePixelRatioF()), 1.);
+#endif
+}
+
+QSize spline_widget::minimumSizeHint() const
+{
+ const double dpi = screen_dpi();
+ return { iround(800 * dpi), iround(250 * dpi) };
+}
+
void spline_widget::paintEvent(QPaintEvent *e)
{
if (!config)
diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp
index 178e5b23..ab0060f2 100644
--- a/spline/spline-widget.hpp
+++ b/spline/spline-widget.hpp
@@ -54,6 +54,8 @@ public:
void set_snap(double x, double y) { snap_x = x; snap_y = y; }
void get_snap(double& x, double& y) const { x = snap_x; y = snap_y; }
+
+ QSize minimumSizeHint() const override;
public slots:
void reload_spline();
protected slots:
@@ -79,6 +81,8 @@ private:
void update_range();
void changeEvent(QEvent* e) override;
+ double screen_dpi() const;
+
QPointF pixel_to_point(const QPointF& point);
QPointF point_to_pixel(const QPointF& point);
@@ -105,7 +109,7 @@ private:
// point's circle radius on the widget
static constexpr int point_size_in_pixels_ = 4;
- const double point_size_in_pixels = point_size_in_pixels_ * std::fmax(1, devicePixelRatioF() * .66);
+ const double point_size_in_pixels = point_size_in_pixels_ * screen_dpi();
};
} // ns spline_detail