From 23f5a317d0bb16a339e063ad11619f2d77db4517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 18 Nov 2016 18:02:40 +0100 Subject: [PATCH] Fixed graph bounds issue --- src/graphitem.cpp | 4 ++-- src/graphview.cpp | 2 ++ src/pathitem.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/graphitem.cpp b/src/graphitem.cpp index e8ed7b90..224987c7 100644 --- a/src/graphitem.cpp +++ b/src/graphitem.cpp @@ -120,9 +120,9 @@ void GraphItem::emitSliderPositionChanged(qreal pos) if (pos >= _graph.first().t() && pos <= _graph.last().t()) emit sliderPositionChanged(distanceAtTime(pos)); else - emit sliderPositionChanged(_graph.last().s() + 1); + emit sliderPositionChanged(NAN); } else - emit sliderPositionChanged(_graph.last().s() + 1); + emit sliderPositionChanged(NAN); } else emit sliderPositionChanged(pos); } diff --git a/src/graphview.cpp b/src/graphview.cpp index 9dd61426..1637fd74 100644 --- a/src/graphview.cpp +++ b/src/graphview.cpp @@ -400,6 +400,8 @@ void GraphView::emitSliderPositionChanged(const QPointF &pos) return; _sliderPos = (pos.x() / _slider->area().width()) * bounds().width(); + _sliderPos = qMax(_sliderPos, bounds().left()); + _sliderPos = qMin(_sliderPos, bounds().right()); updateSliderPosition(); emit sliderPositionChanged(_sliderPos); diff --git a/src/pathitem.cpp b/src/pathitem.cpp index 4e3e9bda..1520e236 100644 --- a/src/pathitem.cpp +++ b/src/pathitem.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -108,12 +109,11 @@ QPointF PathItem::position(qreal x) const void PathItem::moveMarker(qreal distance) { - if (distance > _distance.last()) - _marker->setVisible(false); - else { + if (distance >= _distance.first() && distance <= _distance.last()) { _marker->setVisible(true); _marker->setPos(position(distance)); - } + } else + _marker->setVisible(false); } void PathItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)