From: Soeren Apel Date: Wed, 1 Jan 2020 09:15:57 +0000 (+0100) Subject: Fix some DecodeTrace UI issues X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=commitdiff_plain;h=41293691c797b8f5e3133c072aa869fc9cf91253 Fix some DecodeTrace UI issues --- diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 3769f889..99118d17 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -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 Decoder::ann_classes() const return result; } +vector Decoder::ann_classes() +{ + vector 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()) diff --git a/pv/data/decode/decoder.hpp b/pv/data/decode/decoder.hpp index 4baf86a0..c0a30a7e 100644 --- a/pv/data/decode/decoder.hpp +++ b/pv/data/decode/decoder.hpp @@ -111,6 +111,7 @@ public: Row* get_row_by_id(size_t id); vector ann_classes() const; + vector ann_classes(); AnnotationClass* get_ann_class_by_id(size_t id); uint32_t get_binary_class_count() const; diff --git a/pv/data/decode/row.cpp b/pv/data/decode/row.cpp index e5972517..341c61df 100644 --- a/pv/data/decode/row.cpp +++ b/pv/data/decode/row.cpp @@ -75,11 +75,17 @@ const QString Row::description() const vector Row::ann_classes() const { + assert(decoder_); + vector 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; diff --git a/pv/views/trace/decodetrace.cpp b/pv/views/trace/decodetrace.cpp index 07f88489..3deebf69 100644 --- a/pv/views/trace/decodetrace.cpp +++ b/pv/views/trace/decodetrace.cpp @@ -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)))) {