Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/bubble_icon_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/bubble_icon_view.cc b/chrome/browser/ui/views/location_bar/bubble_icon_view.cc |
| index cc38fb2150f7fa8c7e6e2961e9abcd896ab8cc3f..112ca97116708a8b8df7a0c5c4803b4564dcc6a2 100644 |
| --- a/chrome/browser/ui/views/location_bar/bubble_icon_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/bubble_icon_view.cc |
| @@ -12,14 +12,24 @@ |
| #include "ui/gfx/color_utils.h" |
| #include "ui/gfx/paint_vector_icon.h" |
| #include "ui/native_theme/native_theme.h" |
| +#include "ui/views/animation/button_ink_drop_delegate.h" |
| #include "ui/views/bubble/bubble_delegate.h" |
| BubbleIconView::BubbleIconView(CommandUpdater* command_updater, int command_id) |
| : command_updater_(command_updater), |
| command_id_(command_id), |
| active_(false), |
| - suppress_mouse_released_action_(false) { |
| + suppress_mouse_released_action_(false), |
| + ink_drop_delegate_(new views::ButtonInkDropDelegate(this, this)) { |
| SetAccessibilityFocusable(true); |
| + |
| + const int kInkDropLargeSize = 32; |
| + const int kInkDropLargeCornerRadius = 5; |
| + const int kInkDropSmallSize = 24; |
| + const int kInkDropSmallCornerRadius = 2; |
| + ink_drop_delegate_->SetInkDropSize( |
| + kInkDropLargeSize, kInkDropLargeCornerRadius, kInkDropSmallSize, |
| + kInkDropSmallCornerRadius); |
| } |
| BubbleIconView::~BubbleIconView() { |
| @@ -44,9 +54,17 @@ bool BubbleIconView::GetTooltipText(const gfx::Point& p, |
| return views::ImageView::GetTooltipText(p, tooltip); |
| } |
| +void BubbleIconView::Layout() { |
| + ImageView::Layout(); |
| + if (ink_drop_delegate_) |
| + ink_drop_delegate_->OnLayout(); |
| +} |
| + |
| bool BubbleIconView::OnMousePressed(const ui::MouseEvent& event) { |
| // If the bubble is showing then don't reshow it when the mouse is released. |
| suppress_mouse_released_action_ = IsBubbleShowing(); |
| + if (!suppress_mouse_released_action_ && event.IsOnlyLeftMouseButton()) |
| + ink_drop_delegate_->OnAction(views::InkDropState::ACTION_PENDING); |
| // We want to show the bubble on mouse release; that is the standard behavior |
| // for buttons. |
| @@ -62,8 +80,14 @@ void BubbleIconView::OnMouseReleased(const ui::MouseEvent& event) { |
| return; |
| } |
| - if (event.IsOnlyLeftMouseButton() && HitTestPoint(event.location())) |
| - ExecuteCommand(EXECUTE_SOURCE_MOUSE); |
| + if (event.IsLeftMouseButton()) { |
| + if (HitTestPoint(event.location())) { |
| + ink_drop_delegate_->OnAction(views::InkDropState::ACTIVATED); |
| + ExecuteCommand(EXECUTE_SOURCE_MOUSE); |
| + } else { |
| + ink_drop_delegate_->OnAction(views::InkDropState::HIDDEN); |
| + } |
| + } |
| } |
| bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { |
| @@ -75,6 +99,10 @@ bool BubbleIconView::OnKeyPressed(const ui::KeyEvent& event) { |
| return false; |
| } |
| +void BubbleIconView::OnBubbleClosing() { |
| + ink_drop_delegate_->OnAction(views::InkDropState::DEACTIVATED); |
| +} |
| + |
| void BubbleIconView::ViewHierarchyChanged( |
| const ViewHierarchyChangedDetails& details) { |
| ImageView::ViewHierarchyChanged(details); |
| @@ -88,11 +116,30 @@ void BubbleIconView::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| void BubbleIconView::OnGestureEvent(ui::GestureEvent* event) { |
| if (event->type() == ui::ET_GESTURE_TAP) { |
| + ink_drop_delegate_->OnAction(views::InkDropState::ACTIVATED); |
| ExecuteCommand(EXECUTE_SOURCE_GESTURE); |
| event->SetHandled(); |
| } |
| } |
| +void BubbleIconView::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| + SetPaintToLayer(true); |
|
bruthig
2015/12/11 17:43:38
Does this configuration actually paint the ripple
varkha
2016/01/26 01:19:18
I have changed BubbleIconView to have ImageView as
|
| + SetFillsBoundsOpaquely(false); |
| + SetPaintToLayer(true); |
| + SetFillsBoundsOpaquely(false); |
| + |
| + layer()->Add(ink_drop_layer); |
| + layer()->StackAtBottom(ink_drop_layer); |
| +} |
| + |
| +void BubbleIconView::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| + layer()->Remove(ink_drop_layer); |
| + |
| + SetFillsBoundsOpaquely(true); |
| + SetPaintToLayer(false); |
| + SetPaintToLayer(false); |
| +} |
| + |
| void BubbleIconView::ExecuteCommand(ExecuteSource source) { |
| OnExecuting(source); |
| if (command_updater_) |
| @@ -109,6 +156,10 @@ void BubbleIconView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| bubble->OnAnchorBoundsChanged(); |
| } |
| +gfx::Point BubbleIconView::CalculateInkDropCenter() const { |
| + return GetLocalBounds().CenterPoint(); |
| +} |
| + |
| void BubbleIconView::UpdateIcon() { |
| if (SetRasterIcon()) |
| return; |