From: Soeren Apel Date: Wed, 30 Dec 2015 17:34:47 +0000 (+0100) Subject: DecodeTrace: Prevent trace height from jumping X-Git-Tag: pulseview-0.3.0~12 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=eee89ff865c28854eebdcecbe344f225b9ee366f;p=pulseview.git DecodeTrace: Prevent trace height from jumping In 506317984393a41000650ccca868f3dd66872a4f, the decode trace height was made dependent on the number of currently visible annotation rows. This however has issues: when zooming in on an area where there are no annotations, the height of the decode trace collapses. With this patch, this can't happen anymore as a new variable keeps track of the maximum number of annotation rows ever encountered, keeping the decoder trace height stable. --- diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 2e16ff96..f2aadd1b 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -133,6 +133,7 @@ DecodeTrace::DecodeTrace(pv::Session &session, session_(session), decoder_stack_(decoder_stack), row_height_(0), + max_visible_rows_(0), delete_mapper_(this), show_hide_mapper_(this) { @@ -161,9 +162,8 @@ const std::shared_ptr& DecodeTrace::decoder() const pair DecodeTrace::v_extents() const { const int row_height = (ViewItemPaintParams::text_height() * 6) / 4; - const int rows = visible_rows_.size(); - return make_pair(-row_height, row_height * rows); + return make_pair(-row_height, row_height * max_visible_rows_); } void DecodeTrace::paint_back(QPainter &p, const ViewItemPaintParams &pp) @@ -222,6 +222,9 @@ void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) // Draw the hatching draw_unresolved_period(p, annotation_height, pp.left(), pp.right()); + + // Update the maximum row count if needed + max_visible_rows_ = std::max(max_visible_rows_, (int)visible_rows_.size()); } void DecodeTrace::paint_fore(QPainter &p, const ViewItemPaintParams &pp) diff --git a/pv/view/decodetrace.hpp b/pv/view/decodetrace.hpp index 92544ae2..4964a95d 100644 --- a/pv/view/decodetrace.hpp +++ b/pv/view/decodetrace.hpp @@ -206,7 +206,7 @@ private: std::vector decoder_forms_; std::vector visible_rows_; - int row_height_; + int row_height_, max_visible_rows_; QSignalMapper delete_mapper_, show_hide_mapper_; };