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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 353 |
354 void LabelButton::UpdateImage() { | 354 void LabelButton::UpdateImage() { |
355 image_->SetImage(GetImage(state())); | 355 image_->SetImage(GetImage(state())); |
356 } | 356 } |
357 | 357 |
358 void LabelButton::UpdateThemedBorder() { | 358 void LabelButton::UpdateThemedBorder() { |
359 // Don't override borders set by others. | 359 // Don't override borders set by others. |
360 if (!border_is_themed_border_) | 360 if (!border_is_themed_border_) |
361 return; | 361 return; |
362 | 362 |
363 scoped_ptr<LabelButtonBorder> label_button_border = CreateDefaultBorder(); | 363 scoped_ptr<Border> border = CreateDefaultBorder().PassAs<Border>(); |
364 | |
365 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 364 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
366 views::LinuxUI* linux_ui = views::LinuxUI::instance(); | 365 views::LinuxUI* linux_ui = views::LinuxUI::instance(); |
367 if (linux_ui) { | 366 if (linux_ui) |
368 SetBorder(linux_ui->CreateNativeBorder( | 367 border = linux_ui->CreateNativeBorder(this, border.Pass()); |
369 this, label_button_border.PassAs<Border>())); | |
370 } else | |
371 #endif | 368 #endif |
372 { | |
373 SetBorder(label_button_border.PassAs<Border>()); | |
374 } | |
375 | 369 |
| 370 SetBorder(border.Pass()); |
376 border_is_themed_border_ = true; | 371 border_is_themed_border_ = true; |
377 } | 372 } |
378 | 373 |
379 void LabelButton::StateChanged() { | 374 void LabelButton::StateChanged() { |
380 const gfx::Size previous_image_size(image_->GetPreferredSize()); | 375 const gfx::Size previous_image_size(image_->GetPreferredSize()); |
381 UpdateImage(); | 376 UpdateImage(); |
382 const SkColor color = button_state_colors_[state()]; | 377 const SkColor color = button_state_colors_[state()]; |
383 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 378 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
384 label_->SetEnabledColor(color); | 379 label_->SetEnabledColor(color); |
385 label_->SetEnabled(state() != STATE_DISABLED); | 380 label_->SetEnabled(state() != STATE_DISABLED); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 return ui::NativeTheme::kNormal; | 424 return ui::NativeTheme::kNormal; |
430 } | 425 } |
431 | 426 |
432 ui::NativeTheme::State LabelButton::GetForegroundThemeState( | 427 ui::NativeTheme::State LabelButton::GetForegroundThemeState( |
433 ui::NativeTheme::ExtraParams* params) const { | 428 ui::NativeTheme::ExtraParams* params) const { |
434 GetExtraParams(params); | 429 GetExtraParams(params); |
435 return ui::NativeTheme::kHovered; | 430 return ui::NativeTheme::kHovered; |
436 } | 431 } |
437 | 432 |
438 } // namespace views | 433 } // namespace views |
OLD | NEW |