]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/timemarker.cpp
Trace View: Move ruler time conversion from View to Ruler
[pulseview.git] / pv / views / trace / timemarker.cpp
index 65b9481d12ff8261d321143d01b2add95c38ae5a..ec4c97d78937fb8d76ec42e8e69fa670897ce3f7 100644 (file)
@@ -25,6 +25,7 @@
 #include "timemarker.hpp"
 
 #include "pv/widgets/timestampspinbox.hpp"
+#include "ruler.hpp"
 #include "view.hpp"
 
 #include <QApplication>
@@ -65,7 +66,7 @@ void TimeMarker::set_time(const pv::util::Timestamp& time)
 
        if (value_widget_) {
                updating_value_widget_ = true;
-               value_widget_->setValue(time);
+               value_widget_->setValue(view_.ruler()->get_ruler_time_from_absolute_time(time));
                updating_value_widget_ = false;
        }
 
@@ -80,7 +81,9 @@ float TimeMarker::get_x() const
 
 QPoint TimeMarker::drag_point(const QRect &rect) const
 {
-       return QPoint(get_x(), rect.bottom());
+       (void)rect;
+
+       return QPoint(get_x(), view_.mapFromGlobal(QCursor::pos()).y());
 }
 
 QRectF TimeMarker::label_rect(const QRectF &rect) const
@@ -177,7 +180,7 @@ pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent)
        popup->setLayout(form);
 
        value_widget_ = new pv::widgets::TimestampSpinBox(parent);
-       value_widget_->setValue(time_);
+       value_widget_->setValue(view_.ruler()->get_ruler_time_from_absolute_time(time_));
 
        connect(value_widget_, SIGNAL(valueChanged(const pv::util::Timestamp&)),
                this, SLOT(on_value_changed(const pv::util::Timestamp&)));
@@ -190,7 +193,7 @@ pv::widgets::Popup* TimeMarker::create_popup(QWidget *parent)
 void TimeMarker::on_value_changed(const pv::util::Timestamp& value)
 {
        if (!updating_value_widget_)
-               set_time(value);
+               set_time(view_.ruler()->get_absolute_time_from_ruler_time(value));
 }
 
 } // namespace trace