3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/tracing/tracks/container_track.html">
9 <link rel="import" href="/tvcm/sorted_array_utils.html">
10 <link rel="import" href="/tvcm/ui.html">
15 tvcm.exportTo('tracing.tracks', function() {
17 * A track that displays a group of objects in multiple rows.
19 * @extends {ContainerTrack}
21 var MultiRowTrack = tvcm.ui.define(
22 'multi-row-track', tracing.tracks.ContainerTrack);
24 MultiRowTrack.prototype = {
26 __proto__: tracing.tracks.ContainerTrack.prototype,
28 decorate: function(viewport) {
29 tracing.tracks.ContainerTrack.prototype.decorate.call(this, viewport);
32 this.itemsGroupedOnLastUpdateContents_ = undefined;
33 this.itemsToGroup_ = undefined;
34 this.currentSubRows_ = [];
38 return this.itemsToGroup_;
41 set itemsToGroup(itemsToGroup) {
42 this.itemsToGroup_ = itemsToGroup;
43 this.updateContents_();
52 this.updateContents_();
61 this.updateContents_();
65 return this.currentSubRows_;
68 get hasVisibleContent() {
69 return this.children.length > 0;
72 updateContents_: function() {
73 if (!this.itemsToGroup_) {
74 this.updateHeadingAndTooltip_();
75 this.currentSubRows_ = [];
79 if (this.areArrayContentsSame_(this.itemsGroupedOnLastUpdateContents_,
80 this.itemsToGroup_)) {
81 this.updateHeadingAndTooltip_();
85 this.itemsGroupedOnLastUpdateContents_ = this.itemsToGroup_;
88 if (!this.itemsToGroup_.length) {
89 this.currentSubRows_ = [];
92 var subRows = this.buildSubRows_(this.itemsToGroup_);
93 this.currentSubRows_ = subRows;
94 for (var srI = 0; srI < subRows.length; srI++) {
95 var subRow = subRows[srI];
98 this.addSubTrack_(subRow);
100 this.updateHeadingAndTooltip_();
103 updateHeadingAndTooltip_: function() {
104 if (!this.firstChild)
106 this.firstChild.heading = this.heading_;
107 this.firstChild.tooltip = this.tooltip_;
111 * Breaks up the list of slices into N rows, each of which is a list of
112 * slices that are non overlapping.
114 buildSubRows_: function(itemsToGroup) {
115 throw new Error('Not implemented');
118 addSubTrack_: function(subRowItems) {
119 throw new Error('Not implemented');
122 areArrayContentsSame_: function(a, b) {
125 if (!a.length || !b.length)
127 if (a.length != b.length)
129 for (var i = 0; i < a.length; ++i) {
138 MultiRowTrack: MultiRowTrack