X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fview%2Ftracetreeitemowner.cpp;h=b570c0386c3ef556e4e9cd41927749e212fcb5b6;hb=87a97d8aa169936ec2dcd229df88b8c5b4a1411c;hp=56433752889987d01becd4b92eb5c27cd86917cb;hpb=a8743cd962b2d18082c6ddaeb554d56013919d95;p=pulseview.git
diff --git a/pv/view/tracetreeitemowner.cpp b/pv/view/tracetreeitemowner.cpp
index 5643375..b570c03 100644
--- a/pv/view/tracetreeitemowner.cpp
+++ b/pv/view/tracetreeitemowner.cpp
@@ -14,8 +14,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ * along with this program; if not, see .
*/
#include
@@ -35,7 +34,8 @@ using std::static_pointer_cast;
using std::vector;
namespace pv {
-namespace view {
+namespace views {
+namespace TraceView {
const ViewItemOwner::item_list& TraceTreeItemOwner::child_items() const
{
@@ -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,12 +105,33 @@ 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()
{
}
-} // view
-} // pv
+} // namespace TraceView
+} // namespace views
+} // namespace pv