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

Side by Side Diff: ui/views/controls/button/label_button_label.cc

Issue 2913933002: Move views::Label DisabledColor logic into views::LabelButtonLabel (Closed)
Patch Set: Back to PatchSet 11 Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/views/controls/button/label_button_label.h"
6
7 namespace views {
8
9 LabelButtonLabel::LabelButtonLabel(const base::string16& text, int text_context)
10 : Label(text, text_context, style::STYLE_PRIMARY) {}
11
12 LabelButtonLabel::~LabelButtonLabel() {}
13
14 void LabelButtonLabel::SetDisabledColor(SkColor color) {
15 requested_disabled_color_ = color;
16 disabled_color_set_ = true;
17 if (!enabled())
18 Label::SetEnabledColor(color);
19 }
20
21 void LabelButtonLabel::SetEnabledColor(SkColor color) {
22 requested_enabled_color_ = color;
23 enabled_color_set_ = true;
24 if (enabled())
25 Label::SetEnabledColor(color);
26 }
27
28 void LabelButtonLabel::OnEnabledChanged() {
29 SetColorForEnableState();
30 Label::OnEnabledChanged();
31 }
32
33 void LabelButtonLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) {
34 SetColorForEnableState();
35 Label::OnNativeThemeChanged(theme);
36 }
37
38 void LabelButtonLabel::SetColorForEnableState() {
39 if (enabled() ? enabled_color_set_ : disabled_color_set_) {
40 Label::SetEnabledColor(enabled() ? requested_enabled_color_
41 : requested_disabled_color_);
42 } else {
43 int style = enabled() ? style::STYLE_PRIMARY : style::STYLE_DISABLED;
44 Label::SetEnabledColor(
45 style::GetColor(text_context(), style, GetNativeTheme()));
46 }
47 }
48
49 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698