]> sigrok.org Git - pulseview.git/blobdiff - pv/view/ruler.cpp
Added pv::view::MarginWidget as a common base class of Header and Ruler
[pulseview.git] / pv / view / ruler.cpp
index 0322af8a611e1ad9520b854e2cbae0b7ec39ad81..654e6f45caea7652ae3ff5246492606833d42e82 100644 (file)
@@ -49,8 +49,7 @@ const int Ruler::FirstSIPrefixPower = -15;
 const int Ruler::HoverArrowSize = 5;
 
 Ruler::Ruler(View &parent) :
-       QWidget(&parent),
-       _view(parent),
+       MarginWidget(parent),
        _grabbed_marker(NULL)
 {
        setMouseTracking(true);
@@ -163,7 +162,8 @@ void Ruler::paintEvent(QPaintEvent*)
        } while (x < width());
 
        // Draw the cursors
-       draw_cursors(p, prefix);
+       if (_view.cursors_shown())
+               _view.cursors().draw_markers(p, rect(), prefix);
 
        // Draw the hover mark
        draw_hover_mark(p);
@@ -202,17 +202,6 @@ void Ruler::mouseReleaseEvent(QMouseEvent *)
        _grabbed_marker = NULL;
 }
 
-void Ruler::draw_cursors(QPainter &p, unsigned int prefix)
-{
-       if (!_view.cursors_shown())
-               return;
-
-       const QRect r = rect();
-       CursorPair &cursors = _view.cursors();
-       cursors.first().paint_label(p, r, prefix);
-       cursors.second().paint_label(p, r, prefix);
-}
-
 void Ruler::draw_hover_mark(QPainter &p)
 {
        const int x = _view.hover_point().x();