From: Soeren Apel Date: Mon, 30 Dec 2019 18:15:31 +0000 (+0100) Subject: DecodeTrace: Highlight row expand markers when a class is hidden X-Git-Url: http://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=81dc02212c05c99554194a15f9b584e6b500cda9 DecodeTrace: Highlight row expand markers when a class is hidden --- diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index 72a6869f..e5972517 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -104,6 +104,15 @@ void Row::set_visible(bool visible) visible_ = visible; } +bool Row::has_hidden_classes() const +{ + for (const AnnotationClass* c : ann_classes()) + if (!c->visible) + return true; + + return false; +} + bool Row::operator<(const Row& other) const { return (decoder_ < other.decoder_) || diff --git a/pv/data/decode/row.hpp b/pv/data/decode/row.hpp index 21f46d22..b877b58b 100644 --- a/pv/data/decode/row.hpp +++ b/pv/data/decode/row.hpp @@ -54,6 +54,8 @@ public: bool visible() const; void set_visible(bool visible); + bool has_hidden_classes() const; + bool operator<(const Row& other) const; bool operator==(const Row& other) const; diff --git a/pv/data/decode/rowdata.cpp b/pv/data/decode/rowdata.cpp index c1efdde4..83a8021e 100644 --- a/pv/data/decode/rowdata.cpp +++ b/pv/data/decode/rowdata.cpp @@ -79,9 +79,9 @@ void RowData::get_annotation_subset( class_visible[c->id] = 1; for (const auto& annotation : annotations_) - if ((annotation.end_sample() > start_sample) && - (annotation.start_sample() <= end_sample) && - (class_visible[annotation.ann_class()])) + if ((class_visible[annotation.ann_class()]) && + (annotation.end_sample() > start_sample) && + (annotation.start_sample() <= end_sample)) dest.push_back(annotation); } } diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index d4df8041..0f625b1a 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -87,6 +87,7 @@ namespace trace { const QColor DecodeTrace::ErrorBgColor = QColor(0xEF, 0x29, 0x29); const QColor DecodeTrace::NoDecodeColor = QColor(0x88, 0x8A, 0x85); +const QColor DecodeTrace::ExpandMarkerWarnColor = QColor(0xFF, 0xA5, 0x00); // QColorConstants::Svg::orange const uint8_t DecodeTrace::ExpansionAreaHeaderAlpha = 10 * 255 / 100; const uint8_t DecodeTrace::ExpansionAreaAlpha = 5 * 255 / 100; @@ -282,6 +283,8 @@ void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp) if (r.expand_marker_highlighted) p.setBrush(QApplication::palette().brush(QPalette::Highlight)); + else if (r.has_hidden_classes) + p.setBrush(ExpandMarkerWarnColor); else p.setBrush(QApplication::palette().brush(QPalette::WindowText)); @@ -1257,6 +1260,8 @@ void DecodeTrace::initialize_row_widgets(DecodeTraceRow* r, unsigned int row_id) r->selector_container->layout()->addWidget(cb); cb->setProperty("ann_class_ptr", QVariant::fromValue((void*)ann_class)); + cb->setProperty("decode_trace_row_ptr", QVariant::fromValue((void*)r)); + class_show_hide_mapper_.setMapping(cb, cb); connect(cb, SIGNAL(stateChanged(int)), &class_show_hide_mapper_, SLOT(map())); @@ -1284,6 +1289,7 @@ void DecodeTrace::update_rows() nr.height = default_row_height_; nr.expanded_height = default_row_height_; nr.currently_visible = false; + nr.has_hidden_classes = decode_row->has_hidden_classes(); nr.expand_marker_highlighted = false; nr.expanding = false; nr.expanded = false; @@ -1501,10 +1507,16 @@ void DecodeTrace::on_show_hide_class(QWidget* sender) { void* ann_class_ptr = sender->property("ann_class_ptr").value(); assert(ann_class_ptr); - AnnotationClass* ann_class = (AnnotationClass*)ann_class_ptr; + ann_class->visible = !ann_class->visible; + void* row_ptr = sender->property("decode_trace_row_ptr").value(); + assert(row_ptr); + DecodeTraceRow* row = (DecodeTraceRow*)row_ptr; + + row->has_hidden_classes = row->decode_row->has_hidden_classes(); + owner_->row_item_appearance_changed(false, true); } diff --git a/pv/views/trace/decodetrace.hpp b/pv/views/trace/decodetrace.hpp index e2624988..d7fddbc2 100644 --- a/pv/views/trace/decodetrace.hpp +++ b/pv/views/trace/decodetrace.hpp @@ -80,7 +80,7 @@ struct DecodeTraceRow { Row* decode_row; unsigned int height, expanded_height, title_width, animation_step; - bool exists, currently_visible; + bool exists, currently_visible, has_hidden_classes; bool expand_marker_highlighted, expanding, expanded, collapsing; QPolygon expand_marker_shape; float anim_height, anim_shape; @@ -98,6 +98,7 @@ class DecodeTrace : public Trace private: static const QColor ErrorBgColor; static const QColor NoDecodeColor; + static const QColor ExpandMarkerWarnColor; static const uint8_t ExpansionAreaHeaderAlpha; static const uint8_t ExpansionAreaAlpha;