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_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 5 #ifndef ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
6 #define ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 6 #define ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
7 | 7 |
8 #include "ash/common/system/tray/actionable_view.h" | 8 #include "ash/common/system/tray/actionable_view.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 bool GetTooltipText(const gfx::Point& p, | 31 bool GetTooltipText(const gfx::Point& p, |
32 base::string16* tooltip) const override; | 32 base::string16* tooltip) const override; |
33 | 33 |
34 // Convenience function for adding an icon and a label. This also sets the | 34 // Convenience function for adding an icon and a label. This also sets the |
35 // accessible name. | 35 // accessible name. |
36 void AddIconAndLabel(const gfx::ImageSkia& image, | 36 void AddIconAndLabel(const gfx::ImageSkia& image, |
37 const base::string16& text, | 37 const base::string16& text, |
38 bool highlight); | 38 bool highlight); |
39 | 39 |
40 // Convenience function for adding an icon and a label. This also sets the | 40 // Convenience function for adding an icon and a label. This also sets the |
41 // accessible name. The icon has an indent equal to | 41 // accessible name. This method allows the indent and spacing between elements |
42 // kTrayPopupPaddingHorizontal. | 42 // to be set by the caller. |icon_size| is the size of the icon. |indent| is |
43 void AddIndentedIconAndLabel(const gfx::ImageSkia& image, | 43 // the distance between the edges of the view and the icons, and |
44 const base::string16& text, | 44 // |space_between_items| is the minimum distance between any two child views. |
45 bool highlight); | 45 // All distances are in DP. |
| 46 void AddIconAndLabelCustomSize(const gfx::ImageSkia& image, |
| 47 const base::string16& text, |
| 48 bool highlight, |
| 49 int icon_size, |
| 50 int indent, |
| 51 int space_between_items); |
46 | 52 |
47 // Convenience function for adding a label with padding on the left for a | 53 // Convenience function for adding a label with padding on the left for a |
48 // blank icon. This also sets the accessible name. Returns label after | 54 // blank icon. This also sets the accessible name. Returns label after |
49 // parenting it. | 55 // parenting it. |
50 views::Label* AddLabel(const base::string16& text, | 56 views::Label* AddLabel(const base::string16& text, |
51 gfx::HorizontalAlignment alignment, | 57 gfx::HorizontalAlignment alignment, |
52 bool highlight); | 58 bool highlight); |
53 | 59 |
54 // Convenience function for adding an optional check and a label. In the | 60 // Convenience function for adding an optional check and a label. In the |
55 // absence of a check, padding is added to align with checked items. | 61 // absence of a check, padding is added to align with checked items. |
56 // Returns label after parenting it. | 62 // Returns label after parenting it. |
57 views::Label* AddCheckableLabel(const base::string16& text, | 63 views::Label* AddCheckableLabel(const base::string16& text, |
58 bool highlight, | 64 bool highlight, |
59 bool checked); | 65 bool checked); |
60 | 66 |
61 // Add an optional right icon to an already established view (call one of | 67 // Add an optional right icon to an already established view (call one of |
62 // the other Add* functions first). | 68 // the other Add* functions first). |icon_size| is the size of the icon in DP. |
63 void AddRightIcon(const gfx::ImageSkia& image); | 69 void AddRightIcon(const gfx::ImageSkia& image, int icon_size); |
64 | 70 |
65 // Hide or show the right icon. | 71 // Hide or show the right icon. |
66 void SetRightIconVisible(bool visible); | 72 void SetRightIconVisible(bool visible); |
67 | 73 |
68 // Allows view to expand its height. | 74 // Allows view to expand its height. |
69 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. | 75 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. |
70 void SetExpandable(bool expandable); | 76 void SetExpandable(bool expandable); |
71 | 77 |
72 // Enables or disable highlighting on the label, where a highlighted label | 78 // Enables or disable highlighting on the label, where a highlighted label |
73 // just uses a bold font. | 79 // just uses a bold font. |
(...skipping 13 matching lines...) Expand all Loading... |
87 protected: | 93 protected: |
88 // Overridden from views::View. | 94 // Overridden from views::View. |
89 void GetAccessibleState(ui::AXViewState* state) override; | 95 void GetAccessibleState(ui::AXViewState* state) override; |
90 | 96 |
91 // Sets the highlighted color on a text label if |hover| is set. | 97 // Sets the highlighted color on a text label if |hover| is set. |
92 void SetHoverHighlight(bool hover); | 98 void SetHoverHighlight(bool hover); |
93 | 99 |
94 private: | 100 private: |
95 // Actually adds the icon and label but does not set the layout manager | 101 // Actually adds the icon and label but does not set the layout manager |
96 void DoAddIconAndLabel(const gfx::ImageSkia& image, | 102 void DoAddIconAndLabel(const gfx::ImageSkia& image, |
| 103 int icon_size, |
97 const base::string16& text, | 104 const base::string16& text, |
98 bool highlight); | 105 bool highlight); |
99 | 106 |
100 // Overridden from ActionableView: | 107 // Overridden from ActionableView: |
101 bool PerformAction(const ui::Event& event) override; | 108 bool PerformAction(const ui::Event& event) override; |
102 | 109 |
103 // Overridden from views::View. | 110 // Overridden from views::View. |
104 gfx::Size GetPreferredSize() const override; | 111 gfx::Size GetPreferredSize() const override; |
105 int GetHeightForWidth(int width) const override; | 112 int GetHeightForWidth(int width) const override; |
106 void OnMouseEntered(const ui::MouseEvent& event) override; | 113 void OnMouseEntered(const ui::MouseEvent& event) override; |
(...skipping 17 matching lines...) Expand all Loading... |
124 bool checkable_ = false; | 131 bool checkable_ = false; |
125 bool checked_ = false; | 132 bool checked_ = false; |
126 base::string16 tooltip_; | 133 base::string16 tooltip_; |
127 | 134 |
128 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); | 135 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); |
129 }; | 136 }; |
130 | 137 |
131 } // namespace ash | 138 } // namespace ash |
132 | 139 |
133 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ | 140 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ |
OLD | NEW |