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

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: missed-some 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 SetDisabledColorInternal(
12 style::GetColor(text_context, style::STYLE_DISABLED, GetNativeTheme()),
13 true);
14 }
15
16 LabelButtonLabel::~LabelButtonLabel() {}
17
18 void LabelButtonLabel::SetDisabledColor(SkColor color) {
19 SetDisabledColorInternal(color, false);
20 }
21
22 void LabelButtonLabel::OnEnabledChanged() {
23 ApplyTextColors();
24 Label::OnEnabledChanged();
25 }
26
27 void LabelButtonLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) {
28 SetDisabledColorInternal(
29 style::GetColor(text_context(), style::STYLE_DISABLED, GetNativeTheme()),
30 true);
31 Label::OnNativeThemeChanged(theme);
32 }
33
34 SkColor LabelButtonLabel::GetForegroundColor() const {
35 return enabled() ? enabled_color() : actual_disabled_color_;
36 }
37
38 void LabelButtonLabel::OnBackgroundColorChanged() {
39 actual_disabled_color_ = EnsureTextColorReadable(requested_disabled_color_);
40 }
41
42 void LabelButtonLabel::SetDisabledColorInternal(SkColor color,
43 bool from_theme) {
44 if (from_theme && disabled_color_set_)
45 return;
46
47 disabled_color_set_ = !from_theme;
48 if (color == requested_disabled_color_)
49 return;
50
51 requested_disabled_color_ = color;
52 actual_disabled_color_ = EnsureTextColorReadable(requested_disabled_color_);
53 if (!enabled()) {
54 ApplyTextColors();
55 SchedulePaint();
56 }
57 }
58
59 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698