]> sigrok.org Git - pulseview.git/commitdiff
View: Make TimeItem derivatives snap to edges when ruler-dragged
authorSoeren Apel <redacted>
Mon, 1 Oct 2018 07:21:59 +0000 (09:21 +0200)
committerSoeren Apel <redacted>
Wed, 3 Oct 2018 20:02:31 +0000 (22:02 +0200)
Without this change, the snap-to-edge feature doesn't work
when TimeItem derivatives are dragged in the ruler.

pv/views/trace/view.cpp

index 29c0675d63b5ca1f2db20da4008e88083c8ac110..b8bbe35798825b1c1ff129fd5bae798f55219ddc 100644 (file)
@@ -1266,7 +1266,10 @@ bool View::eventFilter(QObject *object, QEvent *event)
                if (object == viewport_)
                        hover_point_ = mouse_event->pos();
                else if (object == ruler_)
-                       hover_point_ = QPoint(mouse_event->x(), 0);
+                       // Adjust the hover point's y coordinate so that it's relative to
+                       // the top of the viewport. The result may be negative.
+                       hover_point_ = QPoint(mouse_event->pos().x(),
+                               mouse_event->pos().y() - ruler_->sizeHint().height());
                else if (object == header_)
                        hover_point_ = QPoint(0, mouse_event->y());
                else