Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: ash/common/system/tray/hover_highlight_view.h

Issue 2696033003: [Ash MD] Remove some non-MD code from HoverHighlightView (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "ash/common/system/tray/tray_popup_item_style.h" 9 #include "ash/common/system/tray/tray_popup_item_style.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 20 matching lines...) Expand all
31 DEFAULT, 31 DEFAULT,
32 // This view is a checked checkbox. 32 // This view is a checked checkbox.
33 CHECKED_CHECKBOX, 33 CHECKED_CHECKBOX,
34 // This view is an unchecked checkbox. 34 // This view is an unchecked checkbox.
35 UNCHECKED_CHECKBOX 35 UNCHECKED_CHECKBOX
36 }; 36 };
37 37
38 explicit HoverHighlightView(ViewClickListener* listener); 38 explicit HoverHighlightView(ViewClickListener* listener);
39 ~HoverHighlightView() override; 39 ~HoverHighlightView() override;
40 40
41 // views::View 41 // views::View:
42 bool GetTooltipText(const gfx::Point& p, 42 bool GetTooltipText(const gfx::Point& p,
43 base::string16* tooltip) const override; 43 base::string16* tooltip) const override;
44 44
45 // TODO(tdanderson): Perform further cleanup on the Add*() methods in this
46 // class. See crbug.com/686345.
47
45 // Convenience function for adding an icon and a label. This also sets the 48 // Convenience function for adding an icon and a label. This also sets the
46 // accessible name. Primarily used for scrollable rows in detailed views. 49 // accessible name. Primarily used for scrollable rows in detailed views.
47 void AddIconAndLabel(const gfx::ImageSkia& image, 50 void AddIconAndLabel(const gfx::ImageSkia& image, const base::string16& text);
48 const base::string16& text,
49 bool highlight);
50 51
51 // Convenience function for adding an icon, a main label, and a sub label. 52 // Convenience function for adding an icon, a main label, and a sub label.
52 // This also sets the accessible name besed on the main label. Used for 53 // This also sets the accessible name besed on the main label. Used for
53 // scrollable rows in detailed views in material design. 54 // scrollable rows in detailed views in material design.
54 void AddIconAndLabels(const gfx::ImageSkia& image, 55 void AddIconAndLabels(const gfx::ImageSkia& image,
55 const base::string16& text, 56 const base::string16& text,
56 const base::string16& sub_text); 57 const base::string16& sub_text);
57 58
58 // Convenience function for adding an icon and a label. This also sets the
59 // accessible name. This method allows the indent and spacing between elements
60 // to be set by the caller. |icon_size| is the size of the icon. |indent| is
61 // the distance between the edges of the view and the icons, and
62 // |space_between_items| is the minimum distance between any two child views.
63 // All distances are in DP. Primarily used for scrollable rows in detailed
64 // views.
65 void AddIconAndLabelCustomSize(const gfx::ImageSkia& image,
66 const base::string16& text,
67 bool highlight,
68 int icon_size,
69 int indent,
70 int space_between_items);
71
72 // A convenience function for adding an icon and label for a system menu 59 // A convenience function for adding an icon and label for a system menu
73 // default view row. 60 // default view row.
74 void AddIconAndLabelForDefaultView(const gfx::ImageSkia& image, 61 void AddIconAndLabelForDefaultView(const gfx::ImageSkia& image,
75 const base::string16& text, 62 const base::string16& text);
76 bool highlight);
77 63
78 // Convenience function for adding a label with padding on the left for a 64 // Convenience function for adding a label with padding on the left for a
79 // blank icon. This also sets the accessible name. Returns label after 65 // blank icon. This also sets the accessible name. Returns label after
80 // parenting it. 66 // parenting it.
81 views::Label* AddLabel(const base::string16& text, 67 views::Label* AddLabel(const base::string16& text,
82 gfx::HorizontalAlignment alignment, 68 gfx::HorizontalAlignment alignment,
83 bool highlight); 69 bool highlight);
84 70
85 // Convenience function for adding an optional check and a label. In the
86 // absence of a check, padding is added to align with checked items.
87 // Returns label after parenting it.
88 views::Label* AddCheckableLabel(const base::string16& text,
89 bool highlight,
90 bool checked);
91
92 // Adds a row containing only a text label, inset on the left by the 71 // Adds a row containing only a text label, inset on the left by the
93 // horizontal space that would normally be occupied by an icon. 72 // horizontal space that would normally be occupied by an icon.
94 void AddLabelRowMd(const base::string16& text); 73 void AddLabelRow(const base::string16& text);
95 74
96 // Add an optional right icon to an already established view (call one of 75 // Add an optional right icon to an already established view (call one of
97 // the other Add* functions first). |icon_size| is the size of the icon in DP. 76 // the other Add* functions first). |icon_size| is the size of the icon in DP.
98 void AddRightIcon(const gfx::ImageSkia& image, int icon_size); 77 void AddRightIcon(const gfx::ImageSkia& image, int icon_size);
99 78
100 // Add an optional right view to an already established view (call one of 79 // Add an optional right view to an already established view (call one of
101 // the other Add* functions first). 80 // the other Add* functions first).
102 void AddRightView(views::View* view); 81 void AddRightView(views::View* view);
103 82
104 // Hide or show the right view. 83 // Hide or show the right view.
105 void SetRightViewVisible(bool visible); 84 void SetRightViewVisible(bool visible);
106 85
107 // Allows view to expand its height. 86 // Allows view to expand its height.
108 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. 87 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight.
109 void SetExpandable(bool expandable); 88 void SetExpandable(bool expandable);
110 89
111 // Enables or disable highlighting on the label, where a highlighted label
112 // just uses a bold font.
113 void SetHighlight(bool hightlight);
114
115 // Set a custom height for the view. A value of 0 means that no custom height 90 // Set a custom height for the view. A value of 0 means that no custom height
116 // is set. 91 // is set.
117 void set_custom_height(int custom_height) { custom_height_ = custom_height; } 92 void set_custom_height(int custom_height) { custom_height_ = custom_height; }
118 93
119 // Changes the view's current accessibility state. This will fire an 94 // Changes the view's current accessibility state. This will fire an
120 // accessibility event if needed. 95 // accessibility event if needed.
121 void SetAccessiblityState(AccessibilityState accessibility_state); 96 void SetAccessiblityState(AccessibilityState accessibility_state);
122 97
123 void set_highlight_color(SkColor color) { highlight_color_ = color; }
124 void set_default_color(SkColor color) { default_color_ = color; }
125 void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; }
126 void set_text_default_color(SkColor color) { text_default_color_ = color; }
127
128 views::Label* text_label() { return text_label_; } 98 views::Label* text_label() { return text_label_; }
129 views::Label* sub_text_label() { return sub_text_label_; } 99 views::Label* sub_text_label() { return sub_text_label_; }
130 100
131 bool hover() const { return hover_; } 101 bool hover() const { return hover_; }
132 102
133 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; } 103 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; }
134 104
135 protected: 105 protected:
136 // Overridden from views::View. 106 // views::View:
137 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 107 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
138 108
139 // Sets the highlighted color on a text label if |hover| is set.
140 void SetHoverHighlight(bool hover);
141
142 TriView* tri_view() { return tri_view_; } 109 TriView* tri_view() { return tri_view_; }
143 110
144 private: 111 private:
145 // Actually adds the icon and label but does not set the layout manager.
146 // Not used in material design.
147 void DoAddIconAndLabel(const gfx::ImageSkia& image,
148 int icon_size,
149 const base::string16& text,
150 bool highlight);
151
152 // Adds the image and label to the row with the label being styled using
153 // |font_style|. Only used in material design.
154 void DoAddIconAndLabelMd(const gfx::ImageSkia& image,
155 const base::string16& text,
156 TrayPopupItemStyle::FontStyle font_style);
157
158 // Adds the image, main label and sub label to the row with the main label 112 // Adds the image, main label and sub label to the row with the main label
159 // being styled using |font_style| and the sub label being styled using 113 // being styled using |font_style| and the sub label being styled using
160 // FontStyle::CAPTION and ColorStyle::INACTIVE. Only used in material design. 114 // FontStyle::CAPTION and ColorStyle::INACTIVE. Only used in material design.
161 void DoAddIconAndLabelsMd(const gfx::ImageSkia& image, 115 void DoAddIconAndLabelsMd(const gfx::ImageSkia& image,
162 const base::string16& text, 116 const base::string16& text,
163 TrayPopupItemStyle::FontStyle font_style, 117 TrayPopupItemStyle::FontStyle font_style,
164 const base::string16& sub_text); 118 const base::string16& sub_text);
165 119
166 // Overridden from ActionableView: 120 // ActionableView:
167 bool PerformAction(const ui::Event& event) override; 121 bool PerformAction(const ui::Event& event) override;
168 122
169 // Overridden from views::View. 123 // views::View:
170 gfx::Size GetPreferredSize() const override; 124 gfx::Size GetPreferredSize() const override;
171 int GetHeightForWidth(int width) const override; 125 int GetHeightForWidth(int width) const override;
172 void OnMouseEntered(const ui::MouseEvent& event) override;
173 void OnMouseExited(const ui::MouseEvent& event) override;
174 void OnGestureEvent(ui::GestureEvent* event) override;
175 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
176 void OnEnabledChanged() override; 126 void OnEnabledChanged() override;
177 void OnPaintBackground(gfx::Canvas* canvas) override;
178 void OnFocus() override; 127 void OnFocus() override;
179 128
180 ViewClickListener* listener_ = nullptr; 129 ViewClickListener* listener_ = nullptr;
181 views::Label* text_label_ = nullptr; 130 views::Label* text_label_ = nullptr;
182 views::Label* sub_text_label_ = nullptr; 131 views::Label* sub_text_label_ = nullptr;
183 views::BoxLayout* box_layout_ = nullptr; // Not used in material design. 132 views::BoxLayout* box_layout_ = nullptr; // Not used in material design.
184 views::ImageView* left_icon_ = nullptr; 133 views::ImageView* left_icon_ = nullptr;
185 views::View* right_view_ = nullptr; 134 views::View* right_view_ = nullptr;
186 TriView* tri_view_ = nullptr; // Only used in material design. 135 TriView* tri_view_ = nullptr;
187 SkColor highlight_color_ = 0; // Not used in material design.
188 SkColor default_color_ = 0;
189 SkColor text_highlight_color_ = 0; // Not used in material design.
190 SkColor text_default_color_ = 0; // Not used in material design.
191 bool hover_ = false; // Not used in material design. 136 bool hover_ = false; // Not used in material design.
192 bool expandable_ = false; 137 bool expandable_ = false;
193 int custom_height_ = 0; // Not used in material design. 138 int custom_height_ = 0; // Not used in material design.
194 AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT; 139 AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT;
195 base::string16 tooltip_; 140 base::string16 tooltip_;
196 141
197 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); 142 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView);
198 }; 143 };
199 144
200 } // namespace ash 145 } // namespace ash
201 146
202 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ 147 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698