| 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 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 private: | 85 private: |
| 86 DISALLOW_COPY_AND_ASSIGN(InkDropContainerView); | 86 DISALLOW_COPY_AND_ASSIGN(InkDropContainerView); |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 } // namespace | 89 } // namespace |
| 90 | 90 |
| 91 namespace views { | 91 namespace views { |
| 92 | 92 |
| 93 // static | 93 // static |
| 94 const int LabelButton::kHoverAnimationDurationMs = 170; | 94 const int LabelButton::kHoverAnimationDurationMs = 170; |
| 95 const int LabelButton::kFocusRectInset = 3; | |
| 96 const char LabelButton::kViewClassName[] = "LabelButton"; | 95 const char LabelButton::kViewClassName[] = "LabelButton"; |
| 97 | 96 |
| 98 LabelButton::LabelButton(ButtonListener* listener, const base::string16& text) | 97 LabelButton::LabelButton(ButtonListener* listener, const base::string16& text) |
| 99 : CustomButton(listener), | 98 : CustomButton(listener), |
| 100 image_(new ImageView()), | 99 image_(new ImageView()), |
| 101 label_(new Label()), | 100 label_(new Label()), |
| 102 ink_drop_container_(new InkDropContainerView()), | 101 ink_drop_container_(new InkDropContainerView()), |
| 103 cached_normal_font_list_(GetDefaultNormalFontList()), | 102 cached_normal_font_list_(GetDefaultNormalFontList()), |
| 104 cached_bold_font_list_(GetDefaultBoldFontList()), | 103 cached_bold_font_list_(GetDefaultBoldFontList()), |
| 105 button_state_images_(), | 104 button_state_images_(), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 120 | 119 |
| 121 AddChildView(image_); | 120 AddChildView(image_); |
| 122 image_->set_interactive(false); | 121 image_->set_interactive(false); |
| 123 | 122 |
| 124 AddChildView(label_); | 123 AddChildView(label_); |
| 125 label_->SetFontList(cached_normal_font_list_); | 124 label_->SetFontList(cached_normal_font_list_); |
| 126 label_->SetAutoColorReadabilityEnabled(false); | 125 label_->SetAutoColorReadabilityEnabled(false); |
| 127 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); | 126 label_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD); |
| 128 | 127 |
| 129 // Inset the button focus rect from the actual border; roughly match Windows. | 128 // Inset the button focus rect from the actual border; roughly match Windows. |
| 130 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets( | 129 SetFocusPainter(Painter::CreateDashedFocusPainterWithInsets(gfx::Insets(3))); |
| 131 kFocusRectInset, kFocusRectInset, kFocusRectInset, kFocusRectInset))); | |
| 132 } | 130 } |
| 133 | 131 |
| 134 LabelButton::~LabelButton() {} | 132 LabelButton::~LabelButton() {} |
| 135 | 133 |
| 136 gfx::ImageSkia LabelButton::GetImage(ButtonState for_state) const { | 134 gfx::ImageSkia LabelButton::GetImage(ButtonState for_state) const { |
| 137 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) | 135 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) |
| 138 return button_state_images_[STATE_NORMAL]; | 136 return button_state_images_[STATE_NORMAL]; |
| 139 return button_state_images_[for_state]; | 137 return button_state_images_[for_state]; |
| 140 } | 138 } |
| 141 | 139 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 void LabelButton::ResetLabelEnabledColor() { | 614 void LabelButton::ResetLabelEnabledColor() { |
| 617 const SkColor color = | 615 const SkColor color = |
| 618 explicitly_set_colors_[state()] | 616 explicitly_set_colors_[state()] |
| 619 ? button_state_colors_[state()] | 617 ? button_state_colors_[state()] |
| 620 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 618 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
| 621 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 619 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 622 label_->SetEnabledColor(color); | 620 label_->SetEnabledColor(color); |
| 623 } | 621 } |
| 624 | 622 |
| 625 } // namespace views | 623 } // namespace views |
| OLD | NEW |