]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/cursorpair.cpp
Show relative time of flags on hover
[pulseview.git] / pv / views / trace / cursorpair.cpp
index b940090ac8b68861d95ab5e16dec80f630b8cebc..f58db8fafd4ebf97b0221d1ea87d2911188e3508 100644 (file)
@@ -84,11 +84,24 @@ void CursorPair::set_time(const pv::util::Timestamp& time)
        second_->set_time(time + delta);
 }
 
+const pv::util::Timestamp CursorPair::time() const
+{
+       return (first_->time() + second_->time()) / 2.0f;
+}
+
 float CursorPair::get_x() const
 {
        return (first_->get_x() + second_->get_x()) / 2.0f;
 }
 
+const pv::util::Timestamp CursorPair::delta(const pv::util::Timestamp& other) const
+{
+       if (other < second_->time())
+               return other - first_->time();
+       else
+               return other - second_->time();
+}
+
 QPoint CursorPair::drag_point(const QRect &rect) const
 {
        return first_->drag_point(rect);