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

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

Issue 2795143005: [Ash] Remove pre-MD code paths from HoverHighlightView (Closed)
Patch Set: estade comments Created 3 years, 8 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 // Convenience function for adding an icon and a label. This also sets the 45 // Convenience function for adding an icon and a label. This also sets the
46 // accessible name. Primarily used for scrollable rows in detailed views. 46 // accessible name. Primarily used for scrollable rows in detailed views.
47 void AddIconAndLabel(const gfx::ImageSkia& image, 47 void AddIconAndLabel(const gfx::ImageSkia& image, const base::string16& text);
48 const base::string16& text,
49 bool highlight);
50 48
51 // Convenience function for adding an icon, a main label, and a sub label. 49 // 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 50 // This also sets the accessible name besed on the main label. Used for
53 // scrollable rows in detailed views in material design. 51 // scrollable rows in detailed views.
54 void AddIconAndLabels(const gfx::ImageSkia& image, 52 void AddIconAndLabels(const gfx::ImageSkia& image,
55 const base::string16& text, 53 const base::string16& text,
56 const base::string16& sub_text); 54 const base::string16& sub_text);
57 55
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 56 // A convenience function for adding an icon and label for a system menu
73 // default view row. 57 // default view row.
74 void AddIconAndLabelForDefaultView(const gfx::ImageSkia& image, 58 void AddIconAndLabelForDefaultView(const gfx::ImageSkia& image,
75 const base::string16& text, 59 const base::string16& text);
76 bool highlight);
77 60
78 // Convenience function for adding a label with padding on the left for a 61 // 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 62 // blank icon. This also sets the accessible name. Returns label after
80 // parenting it. 63 // parenting it.
81 views::Label* AddLabel(const base::string16& text, 64 // TODO(tdanderson): Remove this function and use AddLabelRow() instead.
82 gfx::HorizontalAlignment alignment, 65 // See crbug.com/708190.
83 bool highlight); 66 views::Label* AddLabelDeprecated(const base::string16& text,
67 gfx::HorizontalAlignment alignment,
68 bool highlight);
84 69
85 // Adds a row containing only a text label, inset on the left by the 70 // Adds a row containing only a text label, inset on the left by the
86 // horizontal space that would normally be occupied by an icon. 71 // horizontal space that would normally be occupied by an icon.
87 void AddLabelRowMd(const base::string16& text); 72 void AddLabelRow(const base::string16& text);
88 73
89 // Add an optional right icon to an already established view (call one of 74 // Add an optional right icon to an already established view (call one of
90 // the other Add* functions first). |icon_size| is the size of the icon in DP. 75 // the other Add* functions first). |icon_size| is the size of the icon in DP.
91 void AddRightIcon(const gfx::ImageSkia& image, int icon_size); 76 void AddRightIcon(const gfx::ImageSkia& image, int icon_size);
92 77
93 // Add an optional right view to an already established view (call one of 78 // Add an optional right view to an already established view (call one of
94 // the other Add* functions first). 79 // the other Add* functions first).
95 void AddRightView(views::View* view); 80 void AddRightView(views::View* view);
96 81
97 // Hide or show the right view. 82 // Hide or show the right view.
98 void SetRightViewVisible(bool visible); 83 void SetRightViewVisible(bool visible);
99 84
100 // Allows view to expand its height. 85 // Allows view to expand its height. Size of unexapandable view is fixed and
101 // Size of unexapandable view is fixed and equals to kTrayPopupItemHeight. 86 // equals to kTrayPopupItemHeight.
102 void SetExpandable(bool expandable); 87 void SetExpandable(bool expandable);
103 88
104 // Enables or disable highlighting on the label, where a highlighted label
105 // just uses a bold font.
106 void SetHighlight(bool hightlight);
107
108 // Set a custom height for the view. A value of 0 means that no custom height 89 // Set a custom height for the view. A value of 0 means that no custom height
109 // is set. 90 // is set.
110 void set_custom_height(int custom_height) { custom_height_ = custom_height; } 91 void set_custom_height(int custom_height) { custom_height_ = custom_height; }
111 92
112 // Changes the view's current accessibility state. This will fire an 93 // Changes the view's current accessibility state. This will fire an
113 // accessibility event if needed. 94 // accessibility event if needed.
114 void SetAccessiblityState(AccessibilityState accessibility_state); 95 void SetAccessiblityState(AccessibilityState accessibility_state);
115 96
116 void set_highlight_color(SkColor color) { highlight_color_ = color; }
117 void set_default_color(SkColor color) { default_color_ = color; }
118 void set_text_highlight_color(SkColor c) { text_highlight_color_ = c; }
119 void set_text_default_color(SkColor color) { text_default_color_ = color; }
120
121 views::Label* text_label() { return text_label_; } 97 views::Label* text_label() { return text_label_; }
122 views::Label* sub_text_label() { return sub_text_label_; } 98 views::Label* sub_text_label() { return sub_text_label_; }
123 99
124 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; } 100 void set_tooltip(const base::string16& tooltip) { tooltip_ = tooltip; }
125 101
126 protected: 102 protected:
127 // Overridden from views::View. 103 // views::View:
128 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 104 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
129 105
130 // Sets the highlighted color on a text label if |hover| is set.
131 void SetHoverHighlight(bool hover);
132
133 TriView* tri_view() { return tri_view_; } 106 TriView* tri_view() { return tri_view_; }
134 107
135 private: 108 private:
136 // Actually adds the icon and label but does not set the layout manager. 109 // Adds the image and label to the row with the label being styled using
137 // Not used in material design. 110 // |font_style|.
138 void DoAddIconAndLabel(const gfx::ImageSkia& image, 111 void DoAddIconAndLabel(const gfx::ImageSkia& image,
139 int icon_size,
140 const base::string16& text, 112 const base::string16& text,
141 bool highlight); 113 TrayPopupItemStyle::FontStyle font_style);
142
143 // Adds the image and label to the row with the label being styled using
144 // |font_style|. Only used in material design.
145 void DoAddIconAndLabelMd(const gfx::ImageSkia& image,
146 const base::string16& text,
147 TrayPopupItemStyle::FontStyle font_style);
148 114
149 // Adds the image, main label and sub label to the row with the main label 115 // Adds the image, main label and sub label to the row with the main label
150 // being styled using |font_style| and the sub label being styled using 116 // being styled using |font_style| and the sub label being styled using
151 // FontStyle::CAPTION and ColorStyle::INACTIVE. Only used in material design. 117 // FontStyle::CAPTION and ColorStyle::INACTIVE.
152 void DoAddIconAndLabelsMd(const gfx::ImageSkia& image, 118 void DoAddIconAndLabels(const gfx::ImageSkia& image,
153 const base::string16& text, 119 const base::string16& text,
154 TrayPopupItemStyle::FontStyle font_style, 120 TrayPopupItemStyle::FontStyle font_style,
155 const base::string16& sub_text); 121 const base::string16& sub_text);
156 122
157 // Overridden from ActionableView: 123 // ActionableView:
158 bool PerformAction(const ui::Event& event) override; 124 bool PerformAction(const ui::Event& event) override;
159 125
160 // Overridden from views::View. 126 // views::View:
161 gfx::Size GetPreferredSize() const override; 127 gfx::Size GetPreferredSize() const override;
162 int GetHeightForWidth(int width) const override; 128 int GetHeightForWidth(int width) const override;
163 void OnMouseEntered(const ui::MouseEvent& event) override;
164 void OnMouseExited(const ui::MouseEvent& event) override;
165 void OnGestureEvent(ui::GestureEvent* event) override;
166 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
167 void OnEnabledChanged() override; 129 void OnEnabledChanged() override;
168 void OnPaintBackground(gfx::Canvas* canvas) override;
169 void OnFocus() override; 130 void OnFocus() override;
170 131
171 ViewClickListener* listener_ = nullptr; 132 ViewClickListener* listener_ = nullptr;
172 views::Label* text_label_ = nullptr; 133 views::Label* text_label_ = nullptr;
173 views::Label* sub_text_label_ = nullptr; 134 views::Label* sub_text_label_ = nullptr;
174 views::BoxLayout* box_layout_ = nullptr; // Not used in material design. 135 views::BoxLayout* box_layout_ = nullptr;
175 views::ImageView* left_icon_ = nullptr; 136 views::ImageView* left_icon_ = nullptr;
176 views::View* right_view_ = nullptr; 137 views::View* right_view_ = nullptr;
177 TriView* tri_view_ = nullptr; // Only used in material design. 138 TriView* tri_view_ = nullptr;
178 SkColor highlight_color_ = 0; // Not used in material design. 139 SkColor text_default_color_ = 0;
179 SkColor default_color_ = 0;
180 SkColor text_highlight_color_ = 0; // Not used in material design.
181 SkColor text_default_color_ = 0; // Not used in material design.
182 bool hover_ = false; // Not used in material design.
183 bool expandable_ = false; 140 bool expandable_ = false;
184 int custom_height_ = 0; // Not used in material design. 141 int custom_height_ = 0;
185 AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT; 142 AccessibilityState accessibility_state_ = AccessibilityState::DEFAULT;
186 base::string16 tooltip_; 143 base::string16 tooltip_;
187 144
188 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView); 145 DISALLOW_COPY_AND_ASSIGN(HoverHighlightView);
189 }; 146 };
190 147
191 } // namespace ash 148 } // namespace ash
192 149
193 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_ 150 #endif // ASH_COMMON_SYSTEM_TRAY_HOVER_HIGHLIGHT_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698