]> sigrok.org Git - pulseview.git/commitdiff
Fix some DecodeTrace UI issues
authorSoeren Apel <redacted>
Wed, 1 Jan 2020 09:15:57 +0000 (10:15 +0100)
committerSoeren Apel <redacted>
Wed, 1 Jan 2020 14:05:05 +0000 (15:05 +0100)
pv/data/decode/decoder.cpp
pv/data/decode/decoder.hpp
pv/data/decode/row.cpp
pv/views/trace/decodetrace.cpp

index 3769f8898f18fc7736691c4288fde9b175f5c206..99118d1707e5361e9f9449fbb6b24e18b1cd61f1 100644 (file)
@@ -76,9 +76,13 @@ Decoder::Decoder(const srd_decoder *const dec) :
                        ann_classes_.at((size_t)cl->data).row = &(rows_.back());
        }
 
-       if (rows_.empty())
+       if (rows_.empty()) {
                // Make sure there is a row for PDs without row declarations
-               rows_.emplace_back(0, this);
+               rows_.push_back({0, this});
+
+               for (AnnotationClass& c : ann_classes_)
+                       c.row = &(rows_.back());
+       }
 }
 
 Decoder::~Decoder()
@@ -242,6 +246,16 @@ vector<const AnnotationClass*> Decoder::ann_classes() const
        return result;
 }
 
+vector<AnnotationClass*> Decoder::ann_classes()
+{
+       vector<AnnotationClass*> result;
+
+       for (AnnotationClass& c : ann_classes_)
+               result.push_back(&c);
+
+       return result;
+}
+
 AnnotationClass* Decoder::get_ann_class_by_id(size_t id)
 {
        if (id >= ann_classes_.size())
index 4baf86a026aeb4b62bf140f6af273ebae8d4156c..c0a30a7e2f50a9e89c574dba739c0d8f7e1a0ece 100644 (file)
@@ -111,6 +111,7 @@ public:
        Row* get_row_by_id(size_t id);
 
        vector<const AnnotationClass*> ann_classes() const;
+       vector<AnnotationClass*> ann_classes();
        AnnotationClass* get_ann_class_by_id(size_t id);
 
        uint32_t get_binary_class_count() const;
index e5972517a446bc7a47b0ba3a6238e257b91b8114..341c61dfd1fea3547bc3dab46fd1d965970e425b 100644 (file)
@@ -75,11 +75,17 @@ const QString Row::description() const
 
 vector<AnnotationClass*> Row::ann_classes() const
 {
+       assert(decoder_);
+
        vector<AnnotationClass*> result;
 
-       if (!srd_row_)
+       if (!srd_row_) {
+               if (index_ == 0) {
+                       // When operating as the fallback row, all annotation classes belong to it
+                       return decoder_->ann_classes();
+               }
                return result;
-       assert(decoder_);
+       }
 
        for (GSList *l = srd_row_->ann_classes; l; l = l->next) {
                size_t class_id = (size_t)l->data;
index 07f88489fd18a9adeb9045bbaca72055faad881d..3deebf6951ae769814a174a37f916d0ace393b91 100644 (file)
@@ -240,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) {
@@ -535,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;
        }
@@ -581,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)))) {