| Index: ui/views/controls/button/label_button_label.cc
|
| diff --git a/ui/views/controls/button/label_button_label.cc b/ui/views/controls/button/label_button_label.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fb0e182a58fdd5dc64f1ec0e3c67ca47b31b88f5
|
| --- /dev/null
|
| +++ b/ui/views/controls/button/label_button_label.cc
|
| @@ -0,0 +1,59 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "ui/views/controls/button/label_button_label.h"
|
| +
|
| +namespace views {
|
| +
|
| +LabelButtonLabel::LabelButtonLabel(const base::string16& text, int text_context)
|
| + : Label(text, text_context, style::STYLE_PRIMARY) {
|
| + SetDisabledColorInternal(
|
| + style::GetColor(text_context, style::STYLE_DISABLED, GetNativeTheme()),
|
| + true);
|
| +}
|
| +
|
| +LabelButtonLabel::~LabelButtonLabel() {}
|
| +
|
| +void LabelButtonLabel::SetDisabledColor(SkColor color) {
|
| + SetDisabledColorInternal(color, false);
|
| +}
|
| +
|
| +void LabelButtonLabel::OnEnabledChanged() {
|
| + ApplyTextColors();
|
| + Label::OnEnabledChanged();
|
| +}
|
| +
|
| +void LabelButtonLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) {
|
| + SetDisabledColorInternal(
|
| + style::GetColor(text_context(), style::STYLE_DISABLED, GetNativeTheme()),
|
| + true);
|
| + Label::OnNativeThemeChanged(theme);
|
| +}
|
| +
|
| +SkColor LabelButtonLabel::GetForegroundColor() const {
|
| + return enabled() ? enabled_color() : actual_disabled_color_;
|
| +}
|
| +
|
| +void LabelButtonLabel::OnBackgroundColorChanged() {
|
| + actual_disabled_color_ = EnsureTextColorReadable(requested_disabled_color_);
|
| +}
|
| +
|
| +void LabelButtonLabel::SetDisabledColorInternal(SkColor color,
|
| + bool from_theme) {
|
| + if (from_theme && disabled_color_set_)
|
| + return;
|
| +
|
| + disabled_color_set_ = !from_theme;
|
| + if (color == requested_disabled_color_)
|
| + return;
|
| +
|
| + requested_disabled_color_ = color;
|
| + actual_disabled_color_ = EnsureTextColorReadable(requested_disabled_color_);
|
| + if (!enabled()) {
|
| + ApplyTextColors();
|
| + SchedulePaint();
|
| + }
|
| +}
|
| +
|
| +} // namespace views
|
|
|