]> sigrok.org Git - pulseview.git/commitdiff
TraceTreeItemOwner: Change behavior for empty containers
authorSoeren Apel <redacted>
Sun, 3 Apr 2016 18:34:50 +0000 (20:34 +0200)
committerSoeren Apel <redacted>
Sun, 3 Apr 2016 18:34:50 +0000 (20:34 +0200)
An empty TraceTreeItemOwner's v_extents are no longer
[INT_MAX, INT_MIN] but [0, 0] instead. As new items were added
relative to the view's own v_extents, items were added at
positions close to the over-/underflow margin. This messed up
the scrollbar among other things. Returning [0, 0] instead
allows for better handling of such cases.

pv/view/tracetreeitemowner.cpp

index 24174794456d01ffb2fd05cbf27601cdc1e16334..1449d813dac5e808bef25ac18253cf08500b760f 100644 (file)
@@ -87,13 +87,16 @@ void TraceTreeItemOwner::remove_child_item(std::shared_ptr<TraceTreeItem> item)
 
 pair<int, int> TraceTreeItemOwner::v_extents() const
 {
-       pair<int, int> extents(INT_MAX, INT_MIN);
+       bool has_children = false;
 
+       pair<int, int> extents(INT_MAX, INT_MIN);
        for (const shared_ptr<TraceTreeItem> t : trace_tree_child_items()) {
                assert(t);
                if (!t->enabled())
                        continue;
 
+               has_children = true;
+
                const int child_offset = t->layout_v_offset();
                const pair<int, int> child_extents = t->v_extents();
                extents.first = min(child_extents.first + child_offset,
@@ -102,6 +105,9 @@ pair<int, int> TraceTreeItemOwner::v_extents() const
                        extents.second);
        }
 
+       if (!has_children)
+               extents = make_pair(0, 0);
+
        return extents;
 }