X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;ds=sidebyside;f=pv%2Fview%2Ftrace.cpp;h=6c43c4c2238044c572fbe0edc4e7343449c06ba7;hb=01fd32630269c1cfb99eb2b0d6060d7d19a42475;hp=4de3f141cc87438bcf6f3d9b2ea1ef1b43822888;hpb=640d69ce065e5c5a30e83395b259a63f7e03c779;p=pulseview.git diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index 4de3f14..6c43c4c 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -68,8 +68,17 @@ void Trace::set_v_offset(int v_offset) _v_offset = v_offset; } -void Trace::paint_label(QPainter &p, int y, int right, bool hover) +void Trace::set_view(pv::view::View *view) { + assert(view); + _view = view; +} + +void Trace::paint_label(QPainter &p, int right, bool hover) +{ + assert(_view); + const int y = _v_offset - _view->v_offset(); + p.setBrush(_colour); if (!enabled()) @@ -78,7 +87,7 @@ void Trace::paint_label(QPainter &p, int y, int right, bool hover) const QColor colour = get_colour(); compute_text_size(p); - const QRectF label_rect = get_label_rect(y, right); + const QRectF label_rect = get_label_rect(right); // Paint the label const QPointF points[] = { @@ -120,12 +129,11 @@ void Trace::paint_label(QPainter &p, int y, int right, bool hover) p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name); } -bool Trace::pt_in_label_rect(int y, int left, int right, - const QPoint &point) +bool Trace::pt_in_label_rect(int left, int right, const QPoint &point) { (void)left; - const QRectF label = get_label_rect(y, right); + const QRectF label = get_label_rect(right); return QRectF( QPointF(label.left() - LabelHitPadding, label.top() - LabelHitPadding), @@ -140,10 +148,13 @@ void Trace::compute_text_size(QPainter &p) p.boundingRect(QRectF(), 0, "Tg").height()); } -QRectF Trace::get_label_rect(int y, int right) +QRectF Trace::get_label_rect(int right) { using pv::view::View; + assert(_view); + const int y = _v_offset - _view->v_offset(); + const QSizeF label_size( _text_size.width() + View::LabelPadding.width() * 2, ceilf((_text_size.height() + View::LabelPadding.height() * 2) / 2) * 2);