blob: 104b9a63eba7b6b3616c32e154ab31de3c7bcc61 [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="/core/trace_model/event.html">
<link rel="import" href="/base/ui/color_scheme.html">
<script>
'use strict';
/**
* @fileoverview Provides color scheme related functions.
*/
tv.exportTo('tv.c', function() {
var paletteRaw = tv.b.ui.getRawColorPalette();
var palette = tv.b.ui.getColorPalette();
var SelectionState = tv.c.trace_model.SelectionState;
/**
* Provides methods to get view values for events.
*/
var EventPresenter = {
getAlpha_: function(event) {
if (event.selectionState === SelectionState.DIMMED)
return 0.3;
return 1.0;
},
getColorIdOffset_: function(event) {
if (event.selectionState === SelectionState.SELECTED)
return tv.b.ui.paletteProperties.highlightIdBoost;
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 = this.getAlpha_(slice);
if (async)
alpha *= 0.3;
return alpha;
},
getInstantSliceColor: function(instant) {
var colorId = instant.colorId + this.getColorIdOffset_(instant);
return tv.b.ui.colorToRGBAString(paletteRaw[colorId],
this.getAlpha_(instant));
},
getObjectInstanceColor: function(instance) {
var colorId = instance.colorId + this.getColorIdOffset_(instance);
return tv.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 tv.b.ui.colorToRGBAString(
paletteRaw[colorId + this.getColorIdOffset_(event)],
this.getAlpha_(event) *
(opt_alphaMultiplier !== undefined ? opt_alphaMultiplier : 1.0));
},
getBarSnapshotColor: function(snapshot, offset) {
var colorId =
(snapshot.objectInstance.colorId + offset) %
tv.b.ui.paletteProperties.numGeneralPurposeColorIds;
colorId += this.getColorIdOffset_(snapshot);
return tv.b.ui.colorToRGBAString(paletteRaw[colorId],
this.getAlpha_(snapshot));
}
};
return {
EventPresenter: EventPresenter
};
});
</script>