1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
ash / hud_display / legend.h [blame]
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_HUD_DISPLAY_LEGEND_H_
#define ASH_HUD_DISPLAY_LEGEND_H_
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/raw_ref.h"
#include "ui/views/view.h"
namespace ash {
namespace hud_display {
class Graph;
// Draws legend view.
class Legend : public views::View {
METADATA_HEADER(Legend, views::View)
public:
using Formatter = base::RepeatingCallback<std::u16string(float)>;
struct Entry {
Entry(const Graph& graph,
std::u16string label,
std::u16string tooltip,
Formatter formatter);
Entry(const Entry&);
~Entry();
const raw_ref<const Graph> graph;
std::u16string label;
std::u16string tooltip;
Formatter formatter; // formatting function
};
explicit Legend(const std::vector<Entry>& contents);
Legend(const Legend&) = delete;
Legend& operator=(const Legend&) = delete;
~Legend() override;
// views::View:
void Layout(PassKey) override;
// Display values for the given index. |index| is always interpreted as
// "negative", i.e. "0" - current data, "1" - previous graph data, 2 - two
// steps ago. I.e. it's number of graph points from the right graph edge.
void SetValuesIndex(size_t index);
// Update displayed values after data was updated.
void RefreshValues();
};
} // namespace hud_display
} // namespace ash
#endif // ASH_HUD_DISPLAY_LEGEND_H_