1<!DOCTYPE html>
2<!--
3Copyright (c) 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/base/base.html">
9<link rel="import" href="/tracing/base/color_scheme.html">
10
11<script>
12'use strict';
13
14/**
15 * @fileoverview Provides the SelectionState class.
16 */
17tr.exportTo('tr.model', function() {
18  var ColorScheme = tr.b.ColorScheme;
19
20  /**
21   * Describes the level of visual highlighting to apply to an event when shown.
22   *
23   * color_scheme.html defines N variations off of a base color palette,
24   * one for each selection state, all concatenated into one flat array. To
25   * pick the final colorId for a given variations, the SelectionState is
26   * multiplied by the number of base colors.
27   *
28   * Thus, the values here must be kept in sync with color_scheme's palette
29   * layout.
30   */
31  var SelectionState = {
32    NONE: 0,
33
34    // Legacy names.
35    SELECTED: ColorScheme.properties.brightenedOffsets[0],
36    HIGHLIGHTED: ColorScheme.properties.brightenedOffsets[1],
37    DIMMED: ColorScheme.properties.dimmedOffsets[0],
38
39    // Modern names.
40    BRIGHTENED0: ColorScheme.properties.brightenedOffsets[0],
41    BRIGHTENED1: ColorScheme.properties.brightenedOffsets[1],
42    BRIGHTENED2: ColorScheme.properties.brightenedOffsets[2],
43
44    DIMMED0: ColorScheme.properties.dimmedOffsets[0],
45    DIMMED1: ColorScheme.properties.dimmedOffsets[1],
46    DIMMED2: ColorScheme.properties.dimmedOffsets[2]
47  };
48
49  var brighteningLevels = [
50    SelectionState.NONE,
51    SelectionState.BRIGHTENED0,
52    SelectionState.BRIGHTENED1,
53    SelectionState.BRIGHTENED2
54  ];
55  SelectionState.getFromBrighteningLevel = function(level) {
56    return brighteningLevels[level];
57  }
58
59  var dimmingLevels = [
60    SelectionState.DIMMED0,
61    SelectionState.DIMMED1,
62    SelectionState.DIMMED2
63  ];
64  SelectionState.getFromDimmingLevel = function(level) {
65    return dimmingLevels[level];
66  }
67
68  return {
69    SelectionState: SelectionState
70  };
71});
72</script>
73