From: Soeren Apel Date: Sun, 3 Apr 2016 18:34:50 +0000 (+0200) Subject: TraceTreeItemOwner: Change behavior for empty containers X-Git-Tag: pulseview-0.4.0~324 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d9177e6cfafcbb3bdca8f8529e7c74f6a56d0a1a;p=pulseview.git TraceTreeItemOwner: Change behavior for empty containers 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. --- diff --git a/pv/view/tracetreeitemowner.cpp b/pv/view/tracetreeitemowner.cpp index 24174794..1449d813 100644 --- a/pv/view/tracetreeitemowner.cpp +++ b/pv/view/tracetreeitemowner.cpp @@ -87,13 +87,16 @@ void TraceTreeItemOwner::remove_child_item(std::shared_ptr item) pair TraceTreeItemOwner::v_extents() const { - pair extents(INT_MAX, INT_MIN); + bool has_children = false; + pair extents(INT_MAX, INT_MIN); for (const shared_ptr t : trace_tree_child_items()) { assert(t); if (!t->enabled()) continue; + has_children = true; + const int child_offset = t->layout_v_offset(); const pair child_extents = t->v_extents(); extents.first = min(child_extents.first + child_offset, @@ -102,6 +105,9 @@ pair TraceTreeItemOwner::v_extents() const extents.second); } + if (!has_children) + extents = make_pair(0, 0); + return extents; }