| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 if (style == STYLE_BUTTON) { | 153 if (style == STYLE_BUTTON) { |
| 154 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 154 label_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 155 SetFocusable(true); | 155 SetFocusable(true); |
| 156 } | 156 } |
| 157 if (style == STYLE_BUTTON) | 157 if (style == STYLE_BUTTON) |
| 158 set_min_size(gfx::Size(70, 33)); | 158 set_min_size(gfx::Size(70, 33)); |
| 159 | 159 |
| 160 ResetColorsFromNativeTheme(); | 160 ResetColorsFromNativeTheme(); |
| 161 | 161 |
| 162 UpdateThemedBorder(new LabelButtonBorder(style_)); | 162 UpdateThemedBorder(scoped_ptr<Border>(new LabelButtonBorder(style_))); |
| 163 | 163 |
| 164 // Invalidate the layout to pickup the new insets from the border. | 164 // Invalidate the layout to pickup the new insets from the border. |
| 165 InvalidateLayout(); | 165 InvalidateLayout(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { | 168 void LabelButton::SetFocusPainter(scoped_ptr<Painter> focus_painter) { |
| 169 focus_painter_ = focus_painter.Pass(); | 169 focus_painter_ = focus_painter.Pass(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 gfx::Size LabelButton::GetPreferredSize() { | 172 gfx::Size LabelButton::GetPreferredSize() { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 SetTextColor(static_cast<ButtonState>(state), colors[state]); | 332 SetTextColor(static_cast<ButtonState>(state), colors[state]); |
| 333 explicitly_set_colors_[state] = false; | 333 explicitly_set_colors_[state] = false; |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 void LabelButton::UpdateImage() { | 338 void LabelButton::UpdateImage() { |
| 339 image_->SetImage(GetImage(state())); | 339 image_->SetImage(GetImage(state())); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void LabelButton::UpdateThemedBorder(LabelButtonBorder* label_button_border) { | 342 void LabelButton::UpdateThemedBorder(scoped_ptr<Border> label_button_border) { |
| 343 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 343 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 344 views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 344 views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
| 345 if (linux_ui) { | 345 if (linux_ui) { |
| 346 set_border(linux_ui->CreateNativeBorder(this, label_button_border)); | 346 SetBorder(linux_ui->CreateNativeBorder(this, label_button_border.Pass())); |
| 347 } else | 347 } else |
| 348 #endif | 348 #endif |
| 349 { | 349 { |
| 350 set_border(label_button_border); | 350 SetBorder(label_button_border.Pass()); |
| 351 } | 351 } |
| 352 } | 352 } |
| 353 | 353 |
| 354 void LabelButton::StateChanged() { | 354 void LabelButton::StateChanged() { |
| 355 const gfx::Size previous_image_size(image_->GetPreferredSize()); | 355 const gfx::Size previous_image_size(image_->GetPreferredSize()); |
| 356 UpdateImage(); | 356 UpdateImage(); |
| 357 const SkColor color = button_state_colors_[state()]; | 357 const SkColor color = button_state_colors_[state()]; |
| 358 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 358 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 359 label_->SetEnabledColor(color); | 359 label_->SetEnabledColor(color); |
| 360 label_->SetEnabled(state() != STATE_DISABLED); | 360 label_->SetEnabled(state() != STATE_DISABLED); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 return ui::NativeTheme::kNormal; | 401 return ui::NativeTheme::kNormal; |
| 402 } | 402 } |
| 403 | 403 |
| 404 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 404 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
| 405 ui::NativeTheme::ExtraParams* params) const { | 405 ui::NativeTheme::ExtraParams* params) const { |
| 406 GetExtraParams(params); | 406 GetExtraParams(params); |
| 407 return ui::NativeTheme::kHovered; | 407 return ui::NativeTheme::kHovered; |
| 408 } | 408 } |
| 409 | 409 |
| 410 } // namespace views | 410 } // namespace views |
| OLD | NEW |