]> sigrok.org Git - pulseview.git/commitdiff
DecodeTrace: Highlight row expand markers when a class is hidden
authorSoeren Apel <redacted>
Mon, 30 Dec 2019 18:15:31 +0000 (19:15 +0100)
committerSoeren Apel <redacted>
Wed, 1 Jan 2020 14:05:05 +0000 (15:05 +0100)
pv/data/decode/row.cpp
pv/data/decode/row.hpp
pv/data/decode/rowdata.cpp
pv/views/trace/decodetrace.cpp
pv/views/trace/decodetrace.hpp

index 72a6869f94250abcbe731a75d5ebcaffc3b028a2..e5972517a446bc7a47b0ba3a6238e257b91b8114 100644 (file)
@@ -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_) ||
index 21f46d22057fccaf71f32f4b419acc24980fb20f..b877b58b85b4ca25300dad8d45e12042ad30a7a8 100644 (file)
@@ -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;
 
index c1efdde4f16f07bb7a6f55ddb751b8a8e44cbaa5..83a8021ef5a11136f747b02ac2724644ac7eb280 100644 (file)
@@ -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);
                }
        }
index d4df80418b64d383fe1e5f0b74c2a0334ad4d5b8..0f625b1a3b4bd62ba37f6b309056d81fa9457773 100644 (file)
@@ -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<void*>();
        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<void*>();
+       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);
 }
 
index e262498848bf2c2c513498c69a499d6d2bc96bad..d7fddbc28ed90d35b1f389e32a7ab07c2e4b0365 100644 (file)
@@ -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;