]> sigrok.org Git - pulseview.git/blobdiff - pv/views/trace/decodetrace.cpp
Rename Decoder::shown() and such
[pulseview.git] / pv / views / trace / decodetrace.cpp
index d4df80418b64d383fe1e5f0b74c2a0334ad4d5b8..fc7ae6b0042ec375fa1863bed85ce0934eb2e81a 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;
 
@@ -230,7 +231,7 @@ void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
                // If the row is hidden, we don't want to fetch annotations
                assert(r.decode_row);
                assert(r.decode_row->decoder());
-               if ((!r.decode_row->decoder()->shown()) || (!r.decode_row->visible())) {
+               if ((!r.decode_row->decoder()->visible()) || (!r.decode_row->visible())) {
                        r.currently_visible = false;
                        continue;
                }
@@ -239,12 +240,14 @@ void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp)
                decode_signal_->get_annotation_subset(annotations, r.decode_row,
                        current_segment_, sample_range.first, sample_range.second);
 
-               // Show row if there are visible annotations or when user wants to see
+               // Show row if there are visible annotations, when user wants to see
                // all rows that have annotations somewhere and this one is one of them
+               // or when the row has at least one hidden annotation class
                r.currently_visible = !annotations.empty();
                if (!r.currently_visible) {
                        size_t ann_count = decode_signal_->get_annotation_count(r.decode_row, current_segment_);
-                       r.currently_visible = always_show_all_rows_ && (ann_count > 0);
+                       r.currently_visible = (always_show_all_rows_ || r.has_hidden_classes) &&
+                               (ann_count > 0);
                }
 
                if (r.currently_visible) {
@@ -274,6 +277,8 @@ void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp)
 {
        unsigned int y = get_visual_y();
 
+       update_expanded_rows();
+
        for (const DecodeTraceRow& r : rows_) {
                if (!r.currently_visible)
                        continue;
@@ -282,6 +287,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));
 
@@ -530,7 +537,7 @@ void DecodeTrace::hover_point_changed(const QPoint &hp)
 
        if (hover_row) {
                int row_y = get_row_y(hover_row);
-               if ((hp.x() > 0) && (hp.x() < 2 * ArrowSize) &&
+               if ((hp.x() > 0) && (hp.x() < (int)(ArrowSize + 3 + hover_row->title_width)) &&
                        (hp.y() > (int)(row_y - ArrowSize)) && (hp.y() < (int)(row_y + ArrowSize)))
                        hover_row->expand_marker_highlighted = true;
        }
@@ -576,7 +583,7 @@ void DecodeTrace::mouse_left_press_event(const QMouseEvent* event)
                        continue;
 
                unsigned int y = get_row_y(&r);
-               if ((event->x() > 0) && (event->x() <= (int)(ArrowSize + 3)) &&
+               if ((event->x() > 0) && (event->x() <= (int)(ArrowSize + 3 + r.title_width)) &&
                        (event->y() > (int)(y - (default_row_height_ / 2))) &&
                        (event->y() <= (int)(y + (default_row_height_ / 2)))) {
 
@@ -1027,7 +1034,7 @@ void DecodeTrace::create_decoder_form(int index,
                        tr("%1:\n%2").arg(QString::fromUtf8(decoder->longname),
                                QString::fromUtf8(decoder->desc)),
                        nullptr, decoder_deletable);
-       group->set_decoder_visible(dec->shown());
+       group->set_decoder_visible(dec->visible());
 
        if (decoder_deletable) {
                delete_mapper_.setMapping(group, index);
@@ -1257,6 +1264,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 +1293,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;
@@ -1358,9 +1368,11 @@ void DecodeTrace::set_row_collapsed(DecodeTraceRow* r)
 void DecodeTrace::update_expanded_rows()
 {
        for (DecodeTraceRow& r : rows_) {
-
                r.container->move(2 * ArrowSize,
                        get_row_y(&r) + default_row_height_);
+
+               r.container->resize(owner_->view()->viewport()->width() - r.container->pos().x(),
+                       r.height - 2 * default_row_height_);
        }
 }
 
@@ -1501,10 +1513,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);
 }