Chromium Code Reviews| Index: chrome/browser/ui/views/toolbar/toolbar_button.cc |
| diff --git a/chrome/browser/ui/views/toolbar/toolbar_button.cc b/chrome/browser/ui/views/toolbar/toolbar_button.cc |
| index 1c85d9a85d1f6753d74424d2fcfdd05a60ad7fa2..7ad5df804f7030567b690862107556b435a10e0e 100644 |
| --- a/chrome/browser/ui/views/toolbar/toolbar_button.cc |
| +++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc |
| @@ -36,6 +36,7 @@ ToolbarButton::ToolbarButton(views::ButtonListener* listener, |
| // The ink drop animation is only targeted at ChromeOS because there is |
| // concern it will conflict with OS level touch feedback in a bad way. |
| if (ui::MaterialDesignController::IsModeMaterial()) { |
| + SetPaintToLayer(true); |
|
jonross
2015/08/07 17:14:31
Will this now always be the responsibility of the
bruthig
2015/08/07 22:00:45
Yes, the reason being that the InkDropHost could p
tdanderson
2015/08/10 16:31:01
It may be a good idea to include this in a comment
bruthig
2015/08/10 21:57:15
Done. See documentation for the InkDropHost.
|
| ink_drop_animation_controller_.reset( |
| new views::InkDropAnimationController(this)); |
| layer()->SetFillsBoundsOpaquely(false); |
| @@ -86,6 +87,12 @@ gfx::Size ToolbarButton::GetPreferredSize() const { |
| return size; |
| } |
| +void ToolbarButton::Layout() { |
| + LabelButton::Layout(); |
| + if (ui::MaterialDesignController::IsModeMaterial()) |
| + LayoutInkDrop(); |
| +} |
| + |
| bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { |
| if (enabled() && ShouldShowMenu() && |
| IsTriggerableEvent(event) && HitTestPoint(event.location())) { |
| @@ -102,6 +109,11 @@ bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { |
| ui::GetMenuSourceTypeForEvent(event)), |
| base::TimeDelta::FromMilliseconds(kMenuTimerDelay)); |
| } |
| + |
| + if (ui::MaterialDesignController::IsModeMaterial()) |
| + ink_drop_animation_controller_->AnimateToState( |
| + views::InkDropState::ACTION_PENDING); |
| + |
| return LabelButton::OnMousePressed(event); |
| } |
| @@ -129,6 +141,9 @@ void ToolbarButton::OnMouseReleased(const ui::MouseEvent& event) { |
| if (IsTriggerableEvent(event)) |
| show_menu_factory_.InvalidateWeakPtrs(); |
| + |
| + if (ui::MaterialDesignController::IsModeMaterial()) |
| + ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); |
| } |
| void ToolbarButton::OnMouseCaptureLost() { |
| @@ -149,6 +164,30 @@ void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { |
| return; |
| } |
| + if (ui::MaterialDesignController::IsModeMaterial()) { |
| + switch (event->type()) { |
| + case ui::ET_GESTURE_TAP_DOWN: |
| + ink_drop_animation_controller_->AnimateToState( |
| + views::InkDropState::ACTION_PENDING); |
| + break; |
| + case ui::ET_GESTURE_LONG_PRESS: |
| + ink_drop_animation_controller_->AnimateToState( |
| + views::InkDropState::SLOW_ACTION); |
| + break; |
| + case ui::ET_GESTURE_TAP: |
| + ink_drop_animation_controller_->AnimateToState( |
| + views::InkDropState::QUICK_ACTION); |
| + break; |
| + case ui::ET_GESTURE_END: |
| + case ui::ET_GESTURE_TAP_CANCEL: |
|
jonross
2015/08/07 17:14:31
We won't receive these if TAP_DOWN is not marked a
bruthig
2015/08/07 22:00:45
Done.
tdanderson
2015/08/10 16:31:01
Did you verify this? It seems to me that the imple
jonross
2015/08/10 20:32:02
Well I would be concerned about each usage of the
bruthig
2015/08/10 21:57:15
I could call LabelButton::OnGestureEvent(...) befo
tdanderson
2015/08/11 12:57:36
I would prefer that, but I don't think it's necess
bruthig
2015/08/11 14:31:10
Done.
|
| + ink_drop_animation_controller_->AnimateToState( |
| + views::InkDropState::HIDDEN); |
| + break; |
| + default: |
| + break; |
| + } |
| + } |
| + |
| LabelButton::OnGestureEvent(event); |
| } |
| @@ -201,6 +240,15 @@ void ToolbarButton::ShowContextMenuForView(View* source, |
| ShowDropDownMenu(source_type); |
| } |
| +void ToolbarButton::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| + layer()->Add(ink_drop_layer); |
| + layer()->StackAtBottom(ink_drop_layer); |
| +} |
| + |
| +void ToolbarButton::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| + layer()->Remove(ink_drop_layer); |
| +} |
| + |
| bool ToolbarButton::ShouldEnterPushedState(const ui::Event& event) { |
| // Enter PUSHED state on press with Left or Right mouse button or on taps. |
| // Remain in this state while the context menu is open. |
| @@ -285,6 +333,9 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) { |
| return; |
| } |
| + if (ui::MaterialDesignController::IsModeMaterial()) |
| + ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN); |
|
jonross
2015/08/07 17:14:31
Can the transition to Hidden be triggered twice fo
bruthig
2015/08/07 22:00:45
My thinking is that the InkDropAnimationController
jonross
2015/08/10 20:32:02
Acknowledged.
|
| + |
| menu_showing_ = false; |
| // Need to explicitly clear mouse handler so that events get sent |
| @@ -297,6 +348,10 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) { |
| SetState(STATE_NORMAL); |
| } |
| +void ToolbarButton::LayoutInkDrop() { |
| + ink_drop_animation_controller_->SetSize(gfx::Size(width(), height())); |
| +} |
| + |
| const char* ToolbarButton::GetClassName() const { |
| return "ToolbarButton"; |
| } |