X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fcursorpair.cpp;h=c3753e6560707cbeacd132e4b94140a7a9455c28;hp=2ad8eef6b50f818478dfdec875be9031676c7145;hb=ec39632d1267a42cb858ac6ad7c98486886a46a0;hpb=e9f909b8ab36f5d147dc9d6dd429df7c1a7fb650 diff --git a/pv/view/cursorpair.cpp b/pv/view/cursorpair.cpp index 2ad8eef6..c3753e65 100644 --- a/pv/view/cursorpair.cpp +++ b/pv/view/cursorpair.cpp @@ -36,6 +36,7 @@ namespace pv { namespace view { const int CursorPair::DeltaPadding = 8; +const QColor CursorPair::ViewportFillColour(220, 231, 243); CursorPair::CursorPair(View &view) : TimeItem(view), @@ -84,8 +85,8 @@ pv::widgets::Popup* CursorPair::create_popup(QWidget *parent) QRectF CursorPair::label_rect(const QRectF &rect) const { const QSizeF label_size( - text_size_.width() + View::LabelPadding.width() * 2, - text_size_.height() + View::LabelPadding.height() * 2); + text_size_.width() + LabelPadding.width() * 2, + text_size_.height() + LabelPadding.height() * 2); const pair offsets(get_cursor_offsets()); const pair normal_offsets( (offsets.first < offsets.second) ? offsets : @@ -97,17 +98,23 @@ QRectF CursorPair::label_rect(const QRectF &rect) const (float)rect.width() + height); return QRectF(left, rect.height() - label_size.height() - - TimeMarker::ArrowSize - TimeMarker::Offset - 0.5f, + TimeMarker::ArrowSize - 0.5f, right - left, height); } -void CursorPair::draw_markers(QPainter &p, const QRect &rect) +void CursorPair::paint_label(QPainter &p, const QRect &rect, bool hover) { 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)); @@ -124,7 +131,8 @@ void CursorPair::draw_markers(QPainter &p, const QRect &rect) p.drawRoundedRect(delta_rect, radius, radius); } - p.setBrush(Cursor::FillColour); + p.setBrush(hover ? Cursor::FillColour.lighter() : + Cursor::FillColour); p.setPen(Cursor::FillColour.darker()); p.drawRoundedRect(delta_rect, radius, radius); @@ -132,40 +140,26 @@ void CursorPair::draw_markers(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)); + p.setBrush(QBrush(ViewportFillColour)); const pair offsets(get_cursor_offsets()); 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)