| <!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/selection_state.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 = { |
| getSelectableItemColor: function(item) { |
| var colorId = item.colorId + this.getColorIdOffset_(item); |
| return palette[colorId]; |
| }, |
| |
| getColorIdOffset_: function(event) { |
| if (event.selectionState === SelectionState.SELECTED) |
| return tv.b.ui.paletteProperties.highlightIdBoost; |
| else if (event.selectionState === SelectionState.DIMMED) |
| return tv.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 tv.b.ui.colorToRGBAString(paletteRaw[colorId], 1.0); |
| }, |
| |
| 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)], |
| (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], 1.0); |
| } |
| }; |
| |
| return { |
| EventPresenter: EventPresenter |
| }; |
| }); |
| </script> |