| 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/gfx/animation/throb_animation.h" | 15 #include "ui/gfx/animation/throb_animation.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/color_utils.h" | 17 #include "ui/gfx/color_utils.h" |
| 18 #include "ui/gfx/font_list.h" | 18 #include "ui/gfx/font_list.h" |
| 19 #include "ui/gfx/geometry/vector2d.h" | 19 #include "ui/gfx/geometry/vector2d.h" |
| 20 #include "ui/native_theme/native_theme.h" | 20 #include "ui/native_theme/native_theme.h" |
| 21 #include "ui/views/animation/flood_fill_ink_drop_animation.h" | 21 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 22 #include "ui/views/animation/ink_drop_hover.h" | 22 #include "ui/views/animation/ink_drop_hover.h" |
| 23 #include "ui/views/background.h" | 23 #include "ui/views/background.h" |
| 24 #include "ui/views/controls/button/label_button_border.h" | 24 #include "ui/views/controls/button/label_button_border.h" |
| 25 #include "ui/views/painter.h" | 25 #include "ui/views/painter.h" |
| 26 #include "ui/views/style/platform_style.h" | 26 #include "ui/views/style/platform_style.h" |
| 27 #include "ui/views/window/dialog_delegate.h" | 27 #include "ui/views/window/dialog_delegate.h" |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // The default spacing between the icon and text. | 31 // The default spacing between the icon and text. |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 ink_drop_container_->SetVisible(true); | 412 ink_drop_container_->SetVisible(true); |
| 413 ink_drop_container_->layer()->Add(ink_drop_layer); | 413 ink_drop_container_->layer()->Add(ink_drop_layer); |
| 414 } | 414 } |
| 415 | 415 |
| 416 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 416 void LabelButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 417 image()->SetPaintToLayer(false); | 417 image()->SetPaintToLayer(false); |
| 418 ink_drop_container_->layer()->Remove(ink_drop_layer); | 418 ink_drop_container_->layer()->Remove(ink_drop_layer); |
| 419 ink_drop_container_->SetVisible(false); | 419 ink_drop_container_->SetVisible(false); |
| 420 } | 420 } |
| 421 | 421 |
| 422 std::unique_ptr<views::InkDropAnimation> LabelButton::CreateInkDropAnimation() | 422 std::unique_ptr<views::InkDropRipple> LabelButton::CreateInkDropRipple() const { |
| 423 const { | 423 return GetText().empty() ? CustomButton::CreateInkDropRipple() |
| 424 return GetText().empty() | 424 : base::WrapUnique(new views::FloodFillInkDropRipple( |
| 425 ? CustomButton::CreateInkDropAnimation() | 425 GetLocalBounds(), GetInkDropCenter(), |
| 426 : base::WrapUnique(new views::FloodFillInkDropAnimation( | 426 GetInkDropBaseColor())); |
| 427 GetLocalBounds(), GetInkDropCenter(), | |
| 428 GetInkDropBaseColor())); | |
| 429 } | 427 } |
| 430 | 428 |
| 431 std::unique_ptr<views::InkDropHover> LabelButton::CreateInkDropHover() const { | 429 std::unique_ptr<views::InkDropHover> LabelButton::CreateInkDropHover() const { |
| 432 if (!ShouldShowInkDropHover()) | 430 if (!ShouldShowInkDropHover()) |
| 433 return nullptr; | 431 return nullptr; |
| 434 return GetText().empty() ? CustomButton::CreateInkDropHover() | 432 return GetText().empty() ? CustomButton::CreateInkDropHover() |
| 435 : base::WrapUnique(new views::InkDropHover( | 433 : base::WrapUnique(new views::InkDropHover( |
| 436 size(), kInkDropSmallCornerRadius, | 434 size(), kInkDropSmallCornerRadius, |
| 437 GetInkDropCenter(), GetInkDropBaseColor())); | 435 GetInkDropCenter(), GetInkDropBaseColor())); |
| 438 } | 436 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 void LabelButton::ResetLabelEnabledColor() { | 562 void LabelButton::ResetLabelEnabledColor() { |
| 565 const SkColor color = | 563 const SkColor color = |
| 566 explicitly_set_colors_[state()] | 564 explicitly_set_colors_[state()] |
| 567 ? button_state_colors_[state()] | 565 ? button_state_colors_[state()] |
| 568 : PlatformStyle::TextColorForButton(button_state_colors_, *this); | 566 : PlatformStyle::TextColorForButton(button_state_colors_, *this); |
| 569 if (state() != STATE_DISABLED && label_->enabled_color() != color) | 567 if (state() != STATE_DISABLED && label_->enabled_color() != color) |
| 570 label_->SetEnabledColor(color); | 568 label_->SetEnabledColor(color); |
| 571 } | 569 } |
| 572 | 570 |
| 573 } // namespace views | 571 } // namespace views |
| OLD | NEW |