| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "ui/base/material_design/material_design_controller.h" |
| 15 #include "ui/gfx/animation/throb_animation.h" | 16 #include "ui/gfx/animation/throb_animation.h" |
| 16 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/color_utils.h" | 18 #include "ui/gfx/color_utils.h" |
| 18 #include "ui/gfx/font_list.h" | 19 #include "ui/gfx/font_list.h" |
| 19 #include "ui/gfx/geometry/vector2d.h" | 20 #include "ui/gfx/geometry/vector2d.h" |
| 20 #include "ui/native_theme/native_theme.h" | 21 #include "ui/native_theme/native_theme.h" |
| 21 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 22 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 22 #include "ui/views/animation/ink_drop_hover.h" | 23 #include "ui/views/animation/ink_drop_hover.h" |
| 23 #include "ui/views/background.h" | 24 #include "ui/views/background.h" |
| 24 #include "ui/views/controls/button/label_button_border.h" | 25 #include "ui/views/controls/button/label_button_border.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 101 |
| 101 AddChildView(image_); | 102 AddChildView(image_); |
| 102 image_->set_interactive(false); | 103 image_->set_interactive(false); |
| 103 | 104 |
| 104 AddChildView(label_); | 105 AddChildView(label_); |
| 105 label_->SetFontList(cached_normal_font_list_); | 106 label_->SetFontList(cached_normal_font_list_); |
| 106 label_->SetAutoColorReadabilityEnabled(false); | 107 label_->SetAutoColorReadabilityEnabled(false); |
| 107 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); | 108 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); |
| 108 | 109 |
| 109 // Inset the button focus rect from the actual border; roughly match Windows. | 110 // Inset the button focus rect from the actual border; roughly match Windows. |
| 110 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets( | 111 if (!ui::MaterialDesignController::IsModeMaterial()) { |
| 111 kFocusRectInset, kFocusRectInset, kFocusRectInset, kFocusRectInset))); | 112 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets( |
| 113 kFocusRectInset, kFocusRectInset, kFocusRectInset, kFocusRectInset))); |
| 114 } |
| 112 } | 115 } |
| 113 | 116 |
| 114 LabelButton::~LabelButton() {} | 117 LabelButton::~LabelButton() {} |
| 115 | 118 |
| 116 const gfx::ImageSkia& LabelButton::GetImage(ButtonState for_state) { | 119 const gfx::ImageSkia& LabelButton::GetImage(ButtonState for_state) { |
| 117 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) | 120 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) |
| 118 return button_state_images_[STATE_NORMAL]; | 121 return button_state_images_[STATE_NORMAL]; |
| 119 return button_state_images_[for_state]; | 122 return button_state_images_[for_state]; |
| 120 } | 123 } |
| 121 | 124 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 void LabelButton::ResetLabelEnabledColor() { | 571 void LabelButton::ResetLabelEnabledColor() { |
| 569 const SkColor color = | 572 const SkColor color = |
| 570 explicitly_set_colors_[state()] | 573 explicitly_set_colors_[state()] |
| 571 ? button_state_colors_[state()] | 574 ? button_state_colors_[state()] |
| 572 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 575 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
| 573 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 576 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 574 label_->SetEnabledColor(color); | 577 label_->SetEnabledColor(color); |
| 575 } | 578 } |
| 576 | 579 |
| 577 } // namespace views | 580 } // namespace views |
| OLD | NEW |