From: Soeren Apel Date: Mon, 1 Oct 2018 07:21:59 +0000 (+0200) Subject: View: Make TimeItem derivatives snap to edges when ruler-dragged X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=fc1df2df99c8ac41269ffba5966fcbb9a2e28479;p=pulseview.git View: Make TimeItem derivatives snap to edges when ruler-dragged Without this change, the snap-to-edge feature doesn't work when TimeItem derivatives are dragged in the ruler. --- diff --git a/pv/views/trace/view.cpp b/pv/views/trace/view.cpp index 29c0675d..b8bbe357 100644 --- a/pv/views/trace/view.cpp +++ b/pv/views/trace/view.cpp @@ -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