X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Fcursorpair.cpp;h=c5a1bc9923beafb00c805eff8f331735a764bbdf;hb=819e2e95555b2b3c2190f24a3cfa82250d1f34e5;hp=2ff32c53ef9fbbe4d46b2d1d8fb22425ee03626f;hpb=2fae5107535c39adde322393d2f6d18098c0154e;p=pulseview.git diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 2ff32c53..c5a1bc99 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -106,8 +106,14 @@ void CursorPair::paint_label(QPainter &p, const QRect &rect) assert(first_); assert(second_); + if (!enabled()) + return; + const unsigned int prefix = view_.tick_prefix(); + const QColor text_colour = + ViewItem::select_text_colour(Cursor::FillColour); + p.setPen(text_colour); compute_text_size(p, prefix); QRectF delta_rect(label_rect(rect)); @@ -132,20 +138,16 @@ void CursorPair::paint_label(QPainter &p, const QRect &rect) p.setPen(Cursor::FillColour.lighter()); p.drawRoundedRect(delta_rect, highlight_radius, highlight_radius); - p.setPen(SelectableItem::select_text_colour( - Cursor::FillColour)); + p.setPen(text_colour); p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter, pv::util::format_time(second_->time() - first_->time(), prefix, 2)); } - - // Paint the cursor markers - first_->paint_label(p, rect); - second_->paint_label(p, rect); } -void CursorPair::draw_viewport_background(QPainter &p, - const QRect &rect) -{ +void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp) { + if (!enabled()) + return; + p.setPen(Qt::NoPen); p.setBrush(QBrush(View::CursorAreaColour)); @@ -153,19 +155,9 @@ void CursorPair::draw_viewport_background(QPainter &p, const int l = (int)max(min( offsets.first, offsets.second), 0.0f); const int r = (int)min(max( - offsets.first, offsets.second), (float)rect.width()); - - p.drawRect(l, 0, r - l, rect.height()); -} - -void CursorPair::draw_viewport_foreground(QPainter &p, - const QRect &rect) -{ - assert(first_); - assert(second_); + offsets.first, offsets.second), (float)pp.width()); - first_->paint(p, rect); - second_->paint(p, rect); + p.drawRect(l, pp.top(), r - l, pp.height()); } void CursorPair::compute_text_size(QPainter &p, unsigned int prefix)