]> sigrok.org Git - pulseview.git/commitdiff
DecodeTrace: Add widget container
authorSoeren Apel <redacted>
Mon, 23 Dec 2019 13:21:17 +0000 (14:21 +0100)
committerSoeren Apel <redacted>
Wed, 1 Jan 2020 12:15:21 +0000 (13:15 +0100)
pv/views/trace/decodetrace.cpp
pv/views/trace/decodetrace.hpp

index 61163bc2bdca727068f7384d0c455877ef5756fe..3555d57635ec28588abbaa6d5a83781320baffcf 100644 (file)
@@ -158,6 +158,9 @@ DecodeTrace::DecodeTrace(pv::Session &session,
 DecodeTrace::~DecodeTrace()
 {
        GlobalSettings::remove_change_handler(this);
+
+       for (RowData& r : rows_)
+               delete r.container;
 }
 
 bool DecodeTrace::enabled() const
@@ -566,10 +569,15 @@ void DecodeTrace::mouse_left_press_event(const QMouseEvent* event)
                        } else {
                                r.expanding = true;
                                r.anim_shape = 0;
+                               r.container->setVisible(true);
                        }
 
                        r.animation_step = 0;
                        r.anim_height = r.height;
+
+                       r.container->move(2 * ArrowSize,
+                               get_row_y(&r) + default_row_height_);
+
                        animation_timer_.start();
                }
        }
@@ -1188,6 +1196,7 @@ void DecodeTrace::update_rows()
                        nr.expanded = false;
                        nr.collapsing = false;
                        nr.expand_marker_shape = default_marker_shape_;
+                       nr.container = new QWidget(owner_->view()->viewport());
 
                        rows_.push_back(nr);
                        r = &rows_.back();
@@ -1198,6 +1207,10 @@ void DecodeTrace::update_rows()
 
                const int w = m.boundingRect(r->decode_row.title()).width() + RowTitleMargin;
                r->title_width = w;
+
+               r->container->resize(owner_->view()->viewport()->width() - r->container->pos().x(),
+                       r->expanded_height - 2 * default_row_height_);
+               r->container->setVisible(false);
        }
 
        // Remove any rows that no longer exist, obeying that iterators are invalidated
@@ -1207,6 +1220,7 @@ void DecodeTrace::update_rows()
 
                for (unsigned int i = 0; i < rows_.size(); i++)
                        if (!rows_[i].exists) {
+                               delete rows_[i].container;
                                rows_.erase(rows_.begin() + i);
                                any_exists = true;
                                break;
@@ -1490,6 +1504,7 @@ void DecodeTrace::on_animation_timer()
                                r.collapsing = false;
                                r.expanded = false;
                                r.expand_marker_shape = default_marker_shape_;
+                               r.container->setVisible(false);
                        }
                }
 
@@ -1500,6 +1515,9 @@ void DecodeTrace::on_animation_timer()
                r.expand_marker_shape.setPoint(0, 0, -ArrowSize + r.anim_shape);
                r.expand_marker_shape.setPoint(1, ArrowSize, r.anim_shape);
                r.expand_marker_shape.setPoint(2, 2*r.anim_shape, ArrowSize - r.anim_shape);
+
+               r.container->resize(owner_->view()->viewport()->width() - r.container->pos().x(),
+                       r.height - 2 * default_row_height_);
        }
 
        if (animation_finished)
index 79f7a27d23b948bebf3c231de8df04c5042bfdd0..662562c371984ade791a71aecbf6dfc8b46b6e72 100644 (file)
@@ -81,6 +81,8 @@ struct RowData {
        bool expand_marker_highlighted, expanding, expanded, collapsing;
        QPolygon expand_marker_shape;
        float anim_height, anim_shape;
+
+       QWidget* container;
 };
 
 class DecodeTrace : public Trace