X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Ftracetreeitemowner.cpp;h=1449d813dac5e808bef25ac18253cf08500b760f;hp=56433752889987d01becd4b92eb5c27cd86917cb;hb=3b353d67bba8fc2076d03e93fed6483572600fa9;hpb=a8743cd962b2d18082c6ddaeb554d56013919d95 diff --git a/pv/view/tracetreeitemowner.cpp b/pv/view/tracetreeitemowner.cpp index 56433752..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,9 +105,29 @@ pair TraceTreeItemOwner::v_extents() const extents.second); } + if (!has_children) + extents = make_pair(0, 0); + return extents; } +bool TraceTreeItemOwner::reassign_bgcolour_states(bool next_bgcolour_state) +{ + vector< shared_ptr > items = trace_tree_child_items(); + + // Sort items according to vertical position + sort(items.begin(), items.end(), + [](const shared_ptr a, const shared_ptr b) { + return a->layout_v_offset() > b->layout_v_offset(); }); + + for (const shared_ptr item : items) { + item->set_bgcolour_state(next_bgcolour_state); + next_bgcolour_state = !next_bgcolour_state; + } + + return next_bgcolour_state; +} + void TraceTreeItemOwner::restack_items() { }