X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecodetrace.cpp;h=eb1f7f83d01324d1527e81ffdb890e17a2194dcd;hp=e7ffbbb6acd361e9f44749cad1ea80d413049c5c;hb=7352be721b90b630efd742b53e1a0ea16bb834b8;hpb=bdc2a99bcaa5aba7c6de2543bab6534299b8a5ee;ds=sidebyside diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index e7ffbbb6..eb1f7f83 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -425,7 +425,7 @@ void DecodeTrace::draw_annotation(const pv::data::decode::Annotation &a, if (a.start_sample() == a.end_sample()) draw_instant(a, p, fill, outline, h, start, y); else - draw_range(a, p, fill, outline, h, start, end, y); + draw_range(a, p, fill, outline, h, start, end, y, pp); } void DecodeTrace::draw_annotation_block( @@ -485,7 +485,7 @@ void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter & void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, QColor fill, QColor outline, int h, double start, - double end, int y) const + double end, int y, const ViewItemPaintParams &pp) const { const double top = y + .5 - h / 2; const double bottom = y + .5 + h / 2; @@ -516,8 +516,15 @@ void DecodeTrace::draw_range(const pv::data::decode::Annotation &a, QPainter &p, if (annotations.empty()) return; - QRectF rect(start + cap_width, y - h / 2, - end - start - cap_width * 2, h); + const int ann_start = start + cap_width; + const int ann_end = end - cap_width; + + const int real_start = std::max(ann_start, pp.left()); + const int real_end = std::min(ann_end, pp.right()); + + const int real_width = real_end - real_start; + + QRectF rect(real_start, y - h / 2, real_width, h); if (rect.width() <= 4) return;