1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
8 base.require('color_mappings');
9 base.require('quad_view');
11 base.exportTo('ccfv', function() {
16 function TreeQuadViewSelection(view, tiles) {
21 TreeQuadViewSelection.prototype = {
22 activate: function() {
23 this.tiles.forEach(function(tile) {
26 this.view.updateQuads_();
29 deactivate: function() {
30 this.tiles.forEach(function(tile) {
31 tile.selected = false;
33 this.view.updateQuads_();
40 var TreeQuadView = ui.define(ccfv.QuadView);
42 TreeQuadView.prototype = {
43 __proto__: ccfv.QuadView.prototype,
45 decorate: function() {
46 this.which_tree_ = undefined;
47 this.tiles_ = undefined;
48 this.colorMap_ = ccfv.ALL_TILE_COLOR_MAPS[0];
61 return this.which_tree_;
64 set which_tree(which_tree) {
65 this.which_tree_ = which_tree;
70 return this.colorMap_;
78 updateQuads_: function() {
79 if (this.which_tree_ === undefined ||
81 this.quads = undefined;
85 var tiles = this.tiles_;
86 var which_tree = this.which_tree_;
89 for (var i = 0; i < tiles.length; i++) {
91 var priority = tile.priority[which_tree];
92 if (!priority.is_live)
95 var value = this.colorMap_.getValueForTile(tile, priority);
96 var backgroundColor = value !== undefined ?
97 this.colorMap_.getBackgroundColorForValue(value) : undefined;
99 var quad = priority.current_screen_quad;
101 backgroundColor: backgroundColor,
102 selected: tile.selected,
112 createSelection_: function(quadIndices) {
114 for (var i = 0; i < quadIndices.length; i++)
115 tiles.push(this.tiles_[quadIndices[i]]);
116 return new TreeQuadViewSelection(this, tiles);
121 TreeQuadView: TreeQuadView,
122 TreeQuadViewSelection: TreeQuadViewSelection,