| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/gfx/animation/throb_animation.h" | 10 #include "ui/gfx/animation/throb_animation.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 namespace views { | 32 namespace views { |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 const int LabelButton::kHoverAnimationDurationMs = 170; | 35 const int LabelButton::kHoverAnimationDurationMs = 170; |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 const char LabelButton::kViewClassName[] = "LabelButton"; | 38 const char LabelButton::kViewClassName[] = "LabelButton"; |
| 39 | 39 |
| 40 LabelButton::LabelButton(ButtonListener* listener, const string16& text) | 40 LabelButton::LabelButton(ButtonListener* listener, const base::string16& text) |
| 41 : CustomButton(listener), | 41 : CustomButton(listener), |
| 42 image_(new ImageView()), | 42 image_(new ImageView()), |
| 43 label_(new Label()), | 43 label_(new Label()), |
| 44 button_state_images_(), | 44 button_state_images_(), |
| 45 button_state_colors_(), | 45 button_state_colors_(), |
| 46 explicitly_set_colors_(), | 46 explicitly_set_colors_(), |
| 47 is_default_(false), | 47 is_default_(false), |
| 48 style_(STYLE_TEXTBUTTON) { | 48 style_(STYLE_TEXTBUTTON) { |
| 49 SetAnimationDuration(kHoverAnimationDurationMs); | 49 SetAnimationDuration(kHoverAnimationDurationMs); |
| 50 SetText(text); | 50 SetText(text); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 68 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) | 68 if (for_state != STATE_NORMAL && button_state_images_[for_state].isNull()) |
| 69 return button_state_images_[STATE_NORMAL]; | 69 return button_state_images_[STATE_NORMAL]; |
| 70 return button_state_images_[for_state]; | 70 return button_state_images_[for_state]; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void LabelButton::SetImage(ButtonState for_state, const gfx::ImageSkia& image) { | 73 void LabelButton::SetImage(ButtonState for_state, const gfx::ImageSkia& image) { |
| 74 button_state_images_[for_state] = image; | 74 button_state_images_[for_state] = image; |
| 75 UpdateImage(); | 75 UpdateImage(); |
| 76 } | 76 } |
| 77 | 77 |
| 78 const string16& LabelButton::GetText() const { | 78 const base::string16& LabelButton::GetText() const { |
| 79 return label_->text(); | 79 return label_->text(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void LabelButton::SetText(const string16& text) { | 82 void LabelButton::SetText(const base::string16& text) { |
| 83 SetAccessibleName(text); | 83 SetAccessibleName(text); |
| 84 label_->SetText(text); | 84 label_->SetText(text); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void LabelButton::SetTextColor(ButtonState for_state, SkColor color) { | 87 void LabelButton::SetTextColor(ButtonState for_state, SkColor color) { |
| 88 button_state_colors_[for_state] = color; | 88 button_state_colors_[for_state] = color; |
| 89 if (for_state == STATE_DISABLED) | 89 if (for_state == STATE_DISABLED) |
| 90 label_->SetDisabledColor(color); | 90 label_->SetDisabledColor(color); |
| 91 else if (for_state == state()) | 91 else if (for_state == state()) |
| 92 label_->SetEnabledColor(color); | 92 label_->SetEnabledColor(color); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 return ui::NativeTheme::kNormal; | 394 return ui::NativeTheme::kNormal; |
| 395 } | 395 } |
| 396 | 396 |
| 397 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 397 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
| 398 ui::NativeTheme::ExtraParams* params) const { | 398 ui::NativeTheme::ExtraParams* params) const { |
| 399 GetExtraParams(params); | 399 GetExtraParams(params); |
| 400 return ui::NativeTheme::kHovered; | 400 return ui::NativeTheme::kHovered; |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace views | 403 } // namespace views |
| OLD | NEW |