OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 5 #ifndef ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
6 #define ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 6 #define ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
7 | 7 |
8 #include "ash/system/tray/actionable_view.h" | 8 #include "ash/system/tray/actionable_view.h" |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "ui/gfx/font.h" | 11 #include "ui/gfx/font.h" |
12 #include "ui/gfx/text_constants.h" | 12 #include "ui/gfx/text_constants.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 class Label; | 15 class Label; |
16 } | 16 } |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 class ViewClickListener; | 19 class ViewClickListener; |
20 | 20 |
21 // A view that changes background color on hover, and triggers a callback in the | 21 // A view that changes background color on hover, and triggers a callback in the |
22 // associated ViewClickListener on click. The view can also be forced to | 22 // associated ViewClickListener on click. The view can also be forced to |
23 // maintain a fixed height. | 23 // maintain a fixed height. |
24 class HoverHighlightView : public ActionableView { | 24 class HoverHighlightView : public ActionableView { |
25 public: | 25 public: |
26 explicit HoverHighlightView(ViewClickListener* listener); | 26 explicit HoverHighlightView(ViewClickListener* listener); |
27 ~HoverHighlightView() override; | 27 ~HoverHighlightView() override; |
28 | 28 |
29 // views::View | |
30 bool GetTooltipText(const gfx::Point& p, | |
31 base::string16* tooltip) const override; | |
32 | |
29 // Convenience function for adding an icon and a label. This also sets the | 33 // Convenience function for adding an icon and a label. This also sets the |
30 // accessible name. | 34 // accessible name. |
31 void AddIconAndLabel(const gfx::ImageSkia& image, | 35 void AddIconAndLabel(const gfx::ImageSkia& image, |
32 const base::string16& text, | 36 const base::string16& text, |
33 bool highlight); | 37 bool highlight); |
34 | 38 |
35 // Convenience function for adding an icon and a label. This also sets the | 39 // Convenience function for adding an icon and a label. This also sets the |
36 // accessible name. The icon has an indent equal to | 40 // accessible name. The icon has an indent equal to |
37 // kTrayPopupPaddingHorizontal. | 41 // kTrayPopupPaddingHorizontal. |
38 void AddIndentedIconAndLabel(const gfx::ImageSkia& image, | 42 void AddIndentedIconAndLabel(const gfx::ImageSkia& image, |
(...skipping 20 matching lines...) Expand all Loading... | |
59 | 63 |
60 void set_highlight_color(SkColor color) { highlight_color_ = color; } | 64 void set_highlight_color(SkColor color) { highlight_color_ = color; } |
61 void set_default_color(SkColor color) { default_color_ = color; } | 65 void set_default_color(SkColor color) { default_color_ = color; } |
62 void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } | 66 void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; } |
63 void set_text_default_color(SkColor color) { text_default_color_ = color; } | 67 void set_text_default_color(SkColor color) { text_default_color_ = color; } |
64 | 68 |
65 views::Label* text_label() { return text_label_; } | 69 views::Label* text_label() { return text_label_; } |
66 | 70 |
67 bool hover() const { return hover_; } | 71 bool hover() const { return hover_; } |
68 | 72 |
73 void SetTooltipText(const base::string16& tooltip) { tooltip_ = tooltip; } | |
stevenjb
2015/11/23 20:42:03
set_tooltup()
(Trivial setters use the naming con
| |
74 | |
69 protected: | 75 protected: |
70 // Overridden from views::View. | 76 // Overridden from views::View. |
71 void GetAccessibleState(ui::AXViewState* state) override; | 77 void GetAccessibleState(ui::AXViewState* state) override; |
72 | 78 |
73 // Sets the highlighted color on a text label if |hover| is set. | 79 // Sets the highlighted color on a text label if |hover| is set. |
74 void SetHoverHighlight(bool hover); | 80 void SetHoverHighlight(bool hover); |
75 | 81 |
76 private: | 82 private: |
77 // Actually adds the icon and label but does not set the layout manager | 83 // Actually adds the icon and label but does not set the layout manager |
78 void DoAddIconAndLabel(const gfx::ImageSkia& image, | 84 void DoAddIconAndLabel(const gfx::ImageSkia& image, |
(...skipping 17 matching lines...) Expand all Loading... | |
96 ViewClickListener* listener_; | 102 ViewClickListener* listener_; |
97 views::Label* text_label_; | 103 views::Label* text_label_; |
98 SkColor highlight_color_; | 104 SkColor highlight_color_; |
99 SkColor default_color_; | 105 SkColor default_color_; |
100 SkColor text_highlight_color_; | 106 SkColor text_highlight_color_; |
101 SkColor text_default_color_; | 107 SkColor text_default_color_; |
102 bool hover_; | 108 bool hover_; |
103 bool expandable_; | 109 bool expandable_; |
104 bool checkable_; | 110 bool checkable_; |
105 bool checked_; | 111 bool checked_; |
112 base::string16 tooltip_; | |
106 | 113 |
107 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); | 114 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); |
108 }; | 115 }; |
109 | 116 |
110 } // namespace ash | 117 } // namespace ash |
111 | 118 |
112 #endif // ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 119 #endif // ASH_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
OLD | NEW |