Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5796)

Unified Diff: chrome/browser/ui/views/toolbar/toolbar_button.cc

Issue 1422593003: Made material design ink drop QUICK_ACTION animation more visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed varkha@'s comments and minor fixes. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 33cfcd013c9dc9d0e64e3a372ebb59925614c3ab..02d65364557baeb47e11e5bc10513594d265ded3 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_button.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc
@@ -34,7 +34,7 @@ ToolbarButton::ToolbarButton(views::ButtonListener* listener,
y_position_on_lbuttondown_(0),
ink_drop_animation_controller_(
views::InkDropAnimationControllerFactory::
- CreateInkDropAnimationController(this)),
+ CreateInkDropAnimationController(this, this)),
show_menu_factory_(this) {
set_context_menu_controller(this);
@@ -151,7 +151,13 @@ void ToolbarButton::OnMouseReleased(const ui::MouseEvent& event) {
void ToolbarButton::OnMouseCaptureLost() {
}
+void ToolbarButton::OnMouseEntered(const ui::MouseEvent& event) {
+ UpdateInkDropHoverState();
+}
+
void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) {
+ UpdateInkDropHoverState();
Peter Kasting 2015/11/11 21:41:38 Nit: It might be better to do this below the SetSt
+
// Starting a drag results in a MouseExited, we need to ignore it.
// A right click release triggers an exit event. We want to
// remain in a PUSHED state until the drop down menu closes.
@@ -179,19 +185,24 @@ void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) {
case ui::ET_GESTURE_LONG_PRESS:
ink_drop_state = views::InkDropState::SLOW_ACTION_PENDING;
break;
- case ui::ET_GESTURE_TAP:
- ink_drop_state = views::InkDropState::QUICK_ACTION;
- break;
case ui::ET_GESTURE_LONG_TAP:
ink_drop_state = views::InkDropState::SLOW_ACTION;
break;
+ case ui::ET_GESTURE_SCROLL_BEGIN:
case ui::ET_GESTURE_END:
- case ui::ET_GESTURE_TAP_CANCEL:
ink_drop_state = views::InkDropState::HIDDEN;
break;
default:
return;
}
+
+ if (ink_drop_state == views::InkDropState::HIDDEN &&
+ ink_drop_animation_controller_->WillAutoAnimateToHidden()) {
+ // Some InkDropStates automatically transition to the HIDDEN state so we
+ // don't make an explicit call. Explicitly animating to HIDDEN in this case
+ // would prematurely pre-empt these animations.
Peter Kasting 2015/11/11 21:41:38 Nit: I'd move this comment above the conditional,
+ return;
+ }
ink_drop_animation_controller_->AnimateToState(ink_drop_state);
}
@@ -214,6 +225,10 @@ ToolbarButton::CreateDefaultBorder() const {
return border.Pass();
}
+void ToolbarButton::OnEnabledChanged() {
+ UpdateInkDropHoverState();
+}
+
void ToolbarButton::ShowContextMenuForView(View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) {
@@ -346,6 +361,10 @@ gfx::Point ToolbarButton::CalculateInkDropCenter() const {
return GetLocalBounds().CenterPoint();
}
+void ToolbarButton::UpdateInkDropHoverState() {
+ ink_drop_animation_controller_->SetHovered(ShouldShowInkDropHover());
+}
+
const char* ToolbarButton::GetClassName() const {
return "ToolbarButton";
}

Powered by Google App Engine
This is Rietveld 408576698