X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Fruler.cpp;h=049cc4af196a8c2203d0ef3ee285e9fa33f17a84;hb=a2ae0205f2737dfd8f7647f9eae2fdcb47a0ad25;hp=9e639383942ed1149702f9e369b16452a46eba1f;hpb=64b678ba0bf16e3a3c1aceffef170f3dbcc588d3;p=pulseview.git diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 9e63938..049cc4a 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -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); @@ -59,6 +58,14 @@ Ruler::Ruler(View &parent) : this, SLOT(hover_point_changed())); } +void Ruler::clear_selection() +{ + CursorPair &cursors = _view.cursors(); + cursors.first().select(false); + cursors.second().select(false); + update(); +} + QString Ruler::format_time(double t, unsigned int prefix, unsigned int precision) { @@ -163,7 +170,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); @@ -186,14 +194,13 @@ void Ruler::mousePressEvent(QMouseEvent *e) _grabbed_marker = NULL; if (_view.cursors_shown()) { - std::pair &cursors = - _view.cursors(); - if (cursors.first.get_label_rect( + CursorPair &cursors = _view.cursors(); + if (cursors.first().get_label_rect( rect()).contains(e->pos())) - _grabbed_marker = &cursors.first; - else if (cursors.second.get_label_rect( + _grabbed_marker = &cursors.first(); + else if (cursors.second().get_label_rect( rect()).contains(e->pos())) - _grabbed_marker = &cursors.second; + _grabbed_marker = &cursors.second(); } } } @@ -203,17 +210,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(); - pair &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();