blob: 4d0fdeada8d3fd777b479774da582ba202ca7683 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2012 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/base/ui/color_scheme.html">
<link rel="import" href="/model/selection_state.html">
<script>
'use strict';
/**
* @fileoverview Provides color scheme related functions.
*/
tr.exportTo('tr.c', function() {
var paletteRaw = tr.b.ui.getRawColorPalette();
var palette = tr.b.ui.getColorPalette();
var SelectionState = tr.model.SelectionState;
/**
* Provides methods to get view values for events.
*/
var EventPresenter = {
getSelectableItemColor: function(item) {
var colorId = item.colorId + this.getColorIdOffset_(item);
return palette[colorId];
},
getColorIdOffset_: function(event) {
if (event.selectionState === SelectionState.SELECTED)
return tr.b.ui.paletteProperties.highlightIdBoost;
else if (event.selectionState === SelectionState.DIMMED)
return tr.b.ui.paletteProperties.desaturateIdBoost;
return 0;
},
getTextColor: function(event) {
if (event.selectionState === SelectionState.DIMMED)
return 'rgb(60,60,60)';
return 'rgb(0,0,0)';
},
getSliceColorId: function(slice) {
return slice.colorId + this.getColorIdOffset_(slice);
},
getSliceAlpha: function(slice, async) {
var alpha = 1;
if (async)
alpha *= 0.3;
return alpha;
},
getInstantSliceColor: function(instant) {
var colorId = instant.colorId + this.getColorIdOffset_(instant);
return tr.b.ui.colorToRGBAString(paletteRaw[colorId], 1.0);
},
getObjectInstanceColor: function(instance) {
var colorId = instance.colorId + this.getColorIdOffset_(instance);
return tr.b.ui.colorToRGBAString(paletteRaw[colorId], 0.25);
},
getObjectSnapshotColor: function(snapshot) {
var colorId =
snapshot.objectInstance.colorId + this.getColorIdOffset_(snapshot);
return palette[colorId];
},
getCounterSeriesColor: function(colorId, selectionState,
opt_alphaMultiplier) {
var event = {selectionState: selectionState};
return tr.b.ui.colorToRGBAString(
paletteRaw[colorId + this.getColorIdOffset_(event)],
(opt_alphaMultiplier !== undefined ? opt_alphaMultiplier : 1.0));
},
getBarSnapshotColor: function(snapshot, offset) {
var colorId =
(snapshot.objectInstance.colorId + offset) %
tr.b.ui.paletteProperties.numGeneralPurposeColorIds;
colorId += this.getColorIdOffset_(snapshot);
return tr.b.ui.colorToRGBAString(paletteRaw[colorId], 1.0);
}
};
return {
EventPresenter: EventPresenter
};
});
</script>