X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Ftracegroup.cpp;h=765f0973229739e4cf7114333c2d58da70f3d1aa;hb=14ca8a8deb6fe6d96567aa11a669dce68af67885;hp=4404b1cd866fe9e160e05a676b9fd3423c3fddd4;hpb=be9e7b4bb29b6594ec2b64442748ab135b684bf8;p=pulseview.git diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index 4404b1cd..765f0973 100644 --- a/pv/view/tracegroup.cpp +++ b/pv/view/tracegroup.cpp @@ -116,7 +116,7 @@ QRectF TraceGroup::label_rect(int right) const { QRectF rect; for (const shared_ptr r : child_items()) - if (r) + if (r && r->enabled()) rect = rect.united(r->label_rect(right)); return QRectF(rect.x() - Width - Padding, rect.y(), @@ -150,18 +150,52 @@ pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent) return NULL; } -int TraceGroup::owner_v_offset() const +int TraceGroup::owner_visual_v_offset() const { - return _owner ? layout_v_offset() + _owner->owner_v_offset() : 0; + return _owner ? visual_v_offset() + _owner->owner_visual_v_offset() : 0; } -void TraceGroup::update_viewport() +void TraceGroup::restack_items() { - if (_owner) - _owner->update_viewport(); + vector< shared_ptr > items( + child_items().begin(), child_items().end()); + + // Sort by the centre line of the extents + stable_sort(items.begin(), items.end(), + [](const shared_ptr &a, const shared_ptr &b) { + const auto aext = a->v_extents(); + const auto bext = b->v_extents(); + return a->layout_v_offset() + + (aext.first + aext.second) / 2 < + b->layout_v_offset() + + (bext.first + bext.second) / 2; + }); + + int total_offset = 0; + for (shared_ptr r : items) { + const pair extents = r->v_extents(); + if (extents.first == 0 && extents.second == 0) + continue; + + // We position disabled traces, so that they are close to the + // animation target positon should they be re-enabled + if (r->enabled()) + total_offset += -extents.first; + + if (!r->dragging()) + r->set_layout_v_offset(total_offset); + + if (r->enabled()) + total_offset += extents.second; + } } -void TraceGroup::on_ungroup() +unsigned int TraceGroup::depth() const +{ + return _owner ? _owner->depth() + 1 : 0; +} + +void TraceGroup::ungroup() { const vector< shared_ptr > items( child_items().begin(), child_items().end()); @@ -171,7 +205,23 @@ void TraceGroup::on_ungroup() _owner->add_child_item(r); _owner->remove_child_item(shared_from_this()); - appearance_changed(); +} + +void TraceGroup::on_ungroup() +{ + ungroup(); +} + +void TraceGroup::appearance_changed(bool label, bool content) +{ + if (_owner) + _owner->appearance_changed(label, content); +} + +void TraceGroup::extents_changed(bool horz, bool vert) +{ + if (_owner) + _owner->extents_changed(horz, vert); } } // namespace view