X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fview%2Ftracegroup.cpp;h=765f0973229739e4cf7114333c2d58da70f3d1aa;hb=14ca8a8deb6fe6d96567aa11a669dce68af67885;hp=3058cec5158ba90e1979a82ba3dd9d790b43ef56;hpb=3e769a374963f37f7d52b65ef6c56bcdf1ef11fe;p=pulseview.git diff --git a/pv/view/tracegroup.cpp b/pv/view/tracegroup.cpp index 3058cec5..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,9 +150,44 @@ 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::restack_items() +{ + 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; + } } unsigned int TraceGroup::depth() const @@ -160,7 +195,7 @@ unsigned int TraceGroup::depth() const return _owner ? _owner->depth() + 1 : 0; } -void TraceGroup::on_ungroup() +void TraceGroup::ungroup() { const vector< shared_ptr > items( child_items().begin(), child_items().end()); @@ -172,6 +207,11 @@ void TraceGroup::on_ungroup() _owner->remove_child_item(shared_from_this()); } +void TraceGroup::on_ungroup() +{ + ungroup(); +} + void TraceGroup::appearance_changed(bool label, bool content) { if (_owner)