summaryrefslogtreecommitdiffhomepage
path: root/spline/spline-widget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'spline/spline-widget.cpp')
-rw-r--r--spline/spline-widget.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 2429ffc3..46e2095c 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -1,17 +1,22 @@
#include "spline-widget.hpp"
#include "compat/math.hpp"
-#include "compat/macros.hpp"
#include <algorithm>
#include <QPainter>
+#include <QPainterPath>
#include <QPixmap>
#include <QString>
#include <QToolTip>
#include <QtEvents>
+#include <QPainterPath>
#include <QDebug>
+#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
+# define OTR_OBSOLETE_QT_WORKAROUND
+#endif
+
namespace spline_detail {
spline_widget::spline_widget(QWidget *parent) : QWidget(parent)
@@ -43,7 +48,7 @@ void spline_widget::set_config(base_spline* spl)
if (spl)
{
std::shared_ptr<base_settings> s = spl->get_settings();
- connection = connect(s.get(), &base_settings::recomputed,
+ connection = connect(&*s, &base_settings::recomputed,
this, [this] { reload_spline(); },
Qt::QueuedConnection);
}
@@ -78,10 +83,6 @@ bool spline_widget::is_preview_only() const
return preview_only;
}
-#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
-# define OTR_OBSOLETE_QT_WORKAROUND
-#endif
-
void spline_widget::drawBackground()
{
QPainter painter(&background_img);
@@ -111,12 +112,12 @@ void spline_widget::drawBackground()
const int ystep = (int)std::ceil(y_step_), xstep = (int)std::ceil(x_step_);
const double maxx = config->max_input();
const double maxy = config->max_output();
-
#ifndef OTR_OBSOLETE_QT_WORKAROUND
double space_width = metrics.horizontalAdvance(' ');
#else
- double space_width = metrics.averageCharWidth();
+ double space_width = metrics.boundingRect(' ').right();
#endif
+ painter.setPen(palette().text().color());
// vertical grid
for (int i = 0; i <= maxy; i += ystep)
@@ -152,11 +153,10 @@ void spline_widget::drawBackground()
#ifndef OTR_OBSOLETE_QT_WORKAROUND
double advance = metrics.horizontalAdvance(text);
#else
- double advance = rect.right();
+ double advance = metrics.boundingRect(text).right();
#endif
-
painter.drawText(QPointF(x - advance/2 - rect.left(),
- pixel_bounds.height() - rect.top() + rect.height()),
+ pixel_bounds.bottom() + metrics.lineSpacing()),
text);
}
}
@@ -631,8 +631,8 @@ QPointF spline_widget::pixel_to_point(const QPointF& point)
if (snap_y > 0)
y = snap(y, snap_y);
- x = clamp(x, 0, config->max_input());
- y = clamp(y, 0, config->max_output());
+ x = std::clamp(x, 0., config->max_input());
+ y = std::clamp(y, 0., config->max_output());
return { x, y };
}