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

Side by Side Diff: ui/views/controls/button/label_button.h

Issue 2620453005: Material Design: Fix MdLabelButton not updating text colors on theme changes (Closed)
Patch Set: Add [set_]explicitly_set_text_colors() Created 3 years, 11 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
« no previous file with comments | « no previous file | ui/views/controls/button/md_text_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 5 #ifndef UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 6 #define UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
7 7
8 #include <array>
8 #include <memory> 9 #include <memory>
9 10
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
14 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
15 #include "ui/views/controls/button/custom_button.h" 16 #include "ui/views/controls/button/custom_button.h"
16 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
17 #include "ui/views/controls/label.h" 18 #include "ui/views/controls/label.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Updates the image view to contain the appropriate button state image. 144 // Updates the image view to contain the appropriate button state image.
144 void UpdateImage(); 145 void UpdateImage();
145 146
146 // Updates the border as per the NativeTheme, unless a different border was 147 // Updates the border as per the NativeTheme, unless a different border was
147 // set with SetBorder. 148 // set with SetBorder.
148 void UpdateThemedBorder(); 149 void UpdateThemedBorder();
149 150
150 // NativeThemeDelegate: 151 // NativeThemeDelegate:
151 gfx::Rect GetThemePaintRect() const override; 152 gfx::Rect GetThemePaintRect() const override;
152 153
154 std::array<bool, STATE_COUNT> explicitly_set_colors() const {
Evan Stade 2017/01/09 20:02:30 should this return a const ref
Tom (Use chromium acct) 2017/01/09 20:31:50 Done.
155 return explicitly_set_colors_;
156 }
157 void set_explicitly_set_colors(std::array<bool, STATE_COUNT> colors) {
Evan Stade 2017/01/09 20:02:30 const ref
Tom (Use chromium acct) 2017/01/09 20:31:50 Done.
158 explicitly_set_colors_ = colors;
159 }
160
153 private: 161 private:
154 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init); 162 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Init);
155 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label); 163 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Label);
156 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image); 164 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, Image);
157 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage); 165 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, LabelAndImage);
158 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, FontList); 166 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, FontList);
159 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, ResetColorsFromNativeTheme); 167 FRIEND_TEST_ALL_PREFIXES(LabelButtonTest, ResetColorsFromNativeTheme);
160 168
161 void SetTextInternal(const base::string16& text); 169 void SetTextInternal(const base::string16& text);
162 170
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 205
198 // The cached font lists in the normal and bold style. 206 // The cached font lists in the normal and bold style.
199 gfx::FontList cached_normal_font_list_; 207 gfx::FontList cached_normal_font_list_;
200 gfx::FontList cached_bold_font_list_; 208 gfx::FontList cached_bold_font_list_;
201 209
202 // The images and colors for each button state. 210 // The images and colors for each button state.
203 gfx::ImageSkia button_state_images_[STATE_COUNT]; 211 gfx::ImageSkia button_state_images_[STATE_COUNT];
204 SkColor button_state_colors_[STATE_COUNT]; 212 SkColor button_state_colors_[STATE_COUNT];
205 213
206 // Used to track whether SetTextColor() has been invoked. 214 // Used to track whether SetTextColor() has been invoked.
207 bool explicitly_set_colors_[STATE_COUNT]; 215 std::array<bool, STATE_COUNT> explicitly_set_colors_;
208 216
209 // |min_size_| increases monotonically with the preferred size. 217 // |min_size_| increases monotonically with the preferred size.
210 mutable gfx::Size min_size_; 218 mutable gfx::Size min_size_;
211 // |max_size_| may be set to clamp the preferred size. 219 // |max_size_| may be set to clamp the preferred size.
212 gfx::Size max_size_; 220 gfx::Size max_size_;
213 221
214 // Cache the last computed preferred size. 222 // Cache the last computed preferred size.
215 mutable gfx::Size cached_preferred_size_; 223 mutable gfx::Size cached_preferred_size_;
216 mutable bool cached_preferred_size_valid_; 224 mutable bool cached_preferred_size_valid_;
217 225
(...skipping 18 matching lines...) Expand all
236 gfx::HorizontalAlignment horizontal_alignment_; 244 gfx::HorizontalAlignment horizontal_alignment_;
237 245
238 std::unique_ptr<Painter> focus_painter_; 246 std::unique_ptr<Painter> focus_painter_;
239 247
240 DISALLOW_COPY_AND_ASSIGN(LabelButton); 248 DISALLOW_COPY_AND_ASSIGN(LabelButton);
241 }; 249 };
242 250
243 } // namespace views 251 } // namespace views
244 252
245 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_ 253 #endif // UI_VIEWS_CONTROLS_BUTTON_LABEL_BUTTON_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/button/md_text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698