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

Unified 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 side-by-side diff with in-line comments
Download patch
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..3f39a971c8bb64a3a412c9c635971e5328a2eb6f
--- /dev/null
+++ b/ui/views/controls/button/label_button_label.cc
@@ -0,0 +1,49 @@
+// 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) {}
+
+LabelButtonLabel::~LabelButtonLabel() {}
+
+void LabelButtonLabel::SetDisabledColor(SkColor color) {
+ requested_disabled_color_ = color;
+ disabled_color_set_ = true;
+ if (!enabled())
+ Label::SetEnabledColor(color);
+}
+
+void LabelButtonLabel::SetEnabledColor(SkColor color) {
+ requested_enabled_color_ = color;
+ enabled_color_set_ = true;
+ if (enabled())
+ Label::SetEnabledColor(color);
+}
+
+void LabelButtonLabel::OnEnabledChanged() {
+ SetColorForEnableState();
+ Label::OnEnabledChanged();
+}
+
+void LabelButtonLabel::OnNativeThemeChanged(const ui::NativeTheme* theme) {
+ SetColorForEnableState();
+ Label::OnNativeThemeChanged(theme);
+}
+
+void LabelButtonLabel::SetColorForEnableState() {
+ if (enabled() ? enabled_color_set_ : disabled_color_set_) {
+ Label::SetEnabledColor(enabled() ? requested_enabled_color_
+ : requested_disabled_color_);
+ } else {
+ int style = enabled() ? style::STYLE_PRIMARY : style::STYLE_DISABLED;
+ Label::SetEnabledColor(
+ style::GetColor(text_context(), style, GetNativeTheme()));
+ }
+}
+
+} // namespace views

Powered by Google App Engine
This is Rietveld 408576698