]> sigrok.org Git - pulseview.git/commitdiff
Make restack_items() available to all TraceTreeItemOwners
authorSoeren Apel <redacted>
Fri, 14 Jul 2017 06:40:04 +0000 (08:40 +0200)
committerSoeren Apel <redacted>
Fri, 14 Jul 2017 06:40:04 +0000 (08:40 +0200)
Currently, TTIO:restack_items() is empty and only the
TraceGroup actually implements it. For this reason, decode
traces (and analog traces) are correctly pushing other traces
around when their size changes.
Top-level traces that are not part of a group however aren't
handled properly, simply overlapping when they grow.

This patch makes the code available to all TTIO-derived
classes, allowing all owners (including View itself) to
properly handle this event.

pv/views/trace/tracegroup.cpp
pv/views/trace/tracegroup.hpp
pv/views/trace/tracetreeitemowner.cpp

index 9bcc29e9bb5e40f351c3b9aa725c69b7fbf691a6..daf0c6705c9861a5cabf0f02612cac2dce7eb18d 100644 (file)
@@ -156,40 +156,6 @@ int TraceGroup::owner_visual_v_offset() const
        return owner_ ? visual_v_offset() + owner_->owner_visual_v_offset() : 0;
 }
 
-void TraceGroup::restack_items()
-{
-       vector<shared_ptr<TraceTreeItem>> items(trace_tree_child_items());
-
-       // Sort by the centre line of the extents
-       stable_sort(items.begin(), items.end(),
-               [](const shared_ptr<TraceTreeItem> &a, const shared_ptr<TraceTreeItem> &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<TraceTreeItem> r : items) {
-               const pair<int, int> 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
 {
        return owner_ ? owner_->depth() + 1 : 0;
index 6a72318abf87d79edb272ad242ad95258fcd587e..48b1bf23bcaf4424acbcffb212812253ebbff6bf 100644 (file)
@@ -111,8 +111,6 @@ public:
         */
        int owner_visual_v_offset() const;
 
-       void restack_items();
-
        /**
         * Returns the number of nested parents that this row item owner has.
         */
index a65c621737cfccfc453bbc9718b22b31212ff1e3..d2512332830a7e9784798e83364c2ff16264a862 100644 (file)
@@ -112,6 +112,36 @@ pair<int, int> TraceTreeItemOwner::v_extents() const
 
 void TraceTreeItemOwner::restack_items()
 {
+       vector<shared_ptr<TraceTreeItem>> items(trace_tree_child_items());
+
+       // Sort by the centre line of the extents
+       stable_sort(items.begin(), items.end(),
+               [](const shared_ptr<TraceTreeItem> &a, const shared_ptr<TraceTreeItem> &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<TraceTreeItem> r : items) {
+               const pair<int, int> 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;
+       }
 }
 
 } // namespace trace