OLD | NEW |
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 #include "ui/views/controls/button/label_button.h" | 5 #include "ui/views/controls/button/label_button.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "ui/gfx/animation/throb_animation.h" | 9 #include "ui/gfx/animation/throb_animation.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/color_utils.h" |
11 #include "ui/gfx/font_list.h" | 12 #include "ui/gfx/font_list.h" |
12 #include "ui/gfx/geometry/vector2d.h" | 13 #include "ui/gfx/geometry/vector2d.h" |
13 #include "ui/gfx/sys_color_change_listener.h" | |
14 #include "ui/native_theme/native_theme.h" | 14 #include "ui/native_theme/native_theme.h" |
15 #include "ui/views/background.h" | 15 #include "ui/views/background.h" |
16 #include "ui/views/controls/button/label_button_border.h" | 16 #include "ui/views/controls/button/label_button_border.h" |
17 #include "ui/views/painter.h" | 17 #include "ui/views/painter.h" |
18 #include "ui/views/window/dialog_delegate.h" | 18 #include "ui/views/window/dialog_delegate.h" |
19 | 19 |
20 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 20 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
21 #include "ui/views/linux_ui/linux_ui.h" | 21 #include "ui/views/linux_ui/linux_ui.h" |
22 #endif | 22 #endif |
23 | 23 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 SkColor colors[STATE_COUNT] = { | 387 SkColor colors[STATE_COUNT] = { |
388 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), | 388 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor), |
389 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), | 389 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), |
390 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), | 390 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonHoverColor), |
391 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), | 391 theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonDisabledColor), |
392 }; | 392 }; |
393 | 393 |
394 // Certain styles do not change text color when hovered or pressed. | 394 // Certain styles do not change text color when hovered or pressed. |
395 bool constant_text_color = false; | 395 bool constant_text_color = false; |
396 // Use hardcoded colors for inverted color scheme support and STYLE_BUTTON. | 396 // Use hardcoded colors for inverted color scheme support and STYLE_BUTTON. |
397 if (gfx::IsInvertedColorScheme()) { | 397 if (color_utils::IsInvertedColorScheme()) { |
398 constant_text_color = true; | 398 constant_text_color = true; |
399 colors[STATE_NORMAL] = SK_ColorWHITE; | 399 colors[STATE_NORMAL] = SK_ColorWHITE; |
400 label_->SetBackgroundColor(SK_ColorBLACK); | 400 label_->SetBackgroundColor(SK_ColorBLACK); |
401 label_->set_background(Background::CreateSolidBackground(SK_ColorBLACK)); | 401 label_->set_background(Background::CreateSolidBackground(SK_ColorBLACK)); |
402 label_->SetAutoColorReadabilityEnabled(true); | 402 label_->SetAutoColorReadabilityEnabled(true); |
403 label_->SetShadows(gfx::ShadowValues()); | 403 label_->SetShadows(gfx::ShadowValues()); |
404 } else if (style() == STYLE_BUTTON) { | 404 } else if (style() == STYLE_BUTTON) { |
405 // TODO(erg): This is disabled on desktop linux because of the binary asset | 405 // TODO(erg): This is disabled on desktop linux because of the binary asset |
406 // confusion. These details should either be pushed into ui::NativeThemeWin | 406 // confusion. These details should either be pushed into ui::NativeThemeWin |
407 // or should be obsoleted by rendering buttons with paint calls instead of | 407 // or should be obsoleted by rendering buttons with paint calls instead of |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 GetExtraParams(params); | 516 GetExtraParams(params); |
517 return ui::NativeTheme::kHovered; | 517 return ui::NativeTheme::kHovered; |
518 } | 518 } |
519 | 519 |
520 void LabelButton::ResetCachedPreferredSize() { | 520 void LabelButton::ResetCachedPreferredSize() { |
521 cached_preferred_size_valid_ = false; | 521 cached_preferred_size_valid_ = false; |
522 cached_preferred_size_ = gfx::Size(); | 522 cached_preferred_size_ = gfx::Size(); |
523 } | 523 } |
524 | 524 |
525 } // namespace views | 525 } // namespace views |
OLD | NEW |