summaryrefslogtreecommitdiffhomepage
path: root/spline-widget/spline-widget.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-12-08 05:38:00 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-12-08 05:38:00 +0100
commitb48a48c143d64caac7d456f9f2a7db180f845a9a (patch)
tree1c44500607674f8b5234a97ee1341c582b14633d /spline-widget/spline-widget.cpp
parentec4c9bb2b53d351dd20f3db342a79a9a75fbc5b9 (diff)
spline-widget: improve preview mode for tobii
Diffstat (limited to 'spline-widget/spline-widget.cpp')
-rw-r--r--spline-widget/spline-widget.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/spline-widget/spline-widget.cpp b/spline-widget/spline-widget.cpp
index 45a90c6a..f10995d4 100644
--- a/spline-widget/spline-widget.cpp
+++ b/spline-widget/spline-widget.cpp
@@ -101,7 +101,8 @@ void spline_widget::drawBackground()
_background = QPixmap(width(), height());
QPainter painter(&_background);
- painter.fillRect(rect(), QColor::fromRgb(204, 204, 204));
+
+ painter.fillRect(rect(), QWidget::palette().color(QWidget::backgroundRole()));
QColor bg_color(112, 154, 209);
if (!isEnabled() && !_preview_only)
@@ -308,11 +309,11 @@ void spline_widget::drawLine(QPainter& painter, const QPoint& start, const QPoin
void spline_widget::mousePressEvent(QMouseEvent *e)
{
- if (!_config || !isEnabled())
- return;
-
- if (!is_in_bounds(e->pos()))
+ if (!_config || !isEnabled() || !is_in_bounds(e->pos()))
+ {
+ clearFocus();
return;
+ }
const int point_pixel_closeness_limit = get_closeness_limit();
@@ -384,6 +385,13 @@ void spline_widget::mousePressEvent(QMouseEvent *e)
void spline_widget::mouseMoveEvent(QMouseEvent *e)
{
+ if (_preview_only && _config)
+ {
+ show_tooltip(e->pos());
+ clearFocus();
+ return;
+ }
+
if (!_config || !isEnabled() || !isActiveWindow() || (moving_control_point_idx != -1 && !hasFocus()))
{
clearFocus();
@@ -488,11 +496,15 @@ int spline_widget::get_closeness_limit()
return std::max(iround(snap_x * c.x()), 1);
}
-void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_, const QString& prefix)
+void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
{
const QPointF value = QPoint(0, 0) == value_ ? pixel_coord_to_point(pos) : value_;
double x = value.x(), y = value.y();
+
+ if (_preview_only)
+ y = _config->get_value_no_save(x);
+
const int x_ = iround(x), y_ = iround(y);
using std::fabs;
@@ -508,7 +520,7 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_, const
const QPoint pix(int(pos.x()) + add_x, int(pos.y()) + add_y);
QToolTip::showText(mapToGlobal(pix),
- QStringLiteral("value: %1%2x%3").arg(prefix).arg(x).arg(y),
+ QStringLiteral("value: %1x%2").arg(x).arg(y),
this,
rect(),
0);