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

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

Issue 1298513003: Implemented prototype for new ink drop specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Working prototype. Created 5 years, 4 months 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 835ccf2aa79112641295f60337ad902f7a8b45f1..89d05a2126b09c0217f73a92c81b384472ecc44e 100644
--- a/chrome/browser/ui/views/toolbar/toolbar_button.cc
+++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc
@@ -99,8 +99,11 @@ bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) {
base::TimeDelta::FromMilliseconds(kMenuTimerDelay));
}
- ink_drop_animation_controller_->AnimateToState(
- views::InkDropState::ACTION_PENDING);
+ // Button actions are only triggered by left and middle mouse clicks.
tdanderson 2015/08/19 22:11:18 Don't we also want to show feedback when pressing
bruthig 2015/08/20 20:35:35 That will be triggered by the AnimateToState(ACTIV
+ if (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) {
jonross 2015/08/19 22:13:36 Do you need to check the exclusivity of these clic
bruthig 2015/08/20 20:35:35 Negative, actions are still triggered when a butto
jonross 2015/08/21 15:14:48 Acknowledged.
+ ink_drop_animation_controller_->AnimateToState(
+ views::InkDropState::ACTION_PENDING);
+ }
return LabelButton::OnMousePressed(event);
}
@@ -162,11 +165,14 @@ void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
break;
case ui::ET_GESTURE_LONG_PRESS:
- ink_drop_state = views::InkDropState::SLOW_ACTION;
+ 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_END:
case ui::ET_GESTURE_TAP_CANCEL:
ink_drop_state = views::InkDropState::HIDDEN;
@@ -288,12 +294,16 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) {
menu_delegate.set_triggerable_event_flags(triggerable_event_flags());
menu_runner_.reset(new views::MenuRunner(menu_delegate.CreateMenu(),
views::MenuRunner::HAS_MNEMONICS));
+ ink_drop_animation_controller_->AnimateToState(
+ views::InkDropState::ACTIVATED);
jonross 2015/08/19 22:13:36 Consider refactoring these animations to be around
bruthig 2015/08/20 20:35:35 Done.
views::MenuRunner::RunResult result =
menu_runner_->RunMenuAt(GetWidget(),
jonross 2015/08/19 22:13:36 Blocking iirc?
bruthig 2015/08/20 20:35:35 Correct.
jonross 2015/08/21 15:14:48 Acknowledged.
NULL,
gfx::Rect(menu_position, gfx::Size(0, 0)),
views::MENU_ANCHOR_TOPLEFT,
source_type);
+ ink_drop_animation_controller_->AnimateToState(
+ views::InkDropState::DEACTIVATED);
if (result == views::MenuRunner::MENU_DELETED)
return;
} else {
@@ -301,18 +311,20 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) {
views::MenuItemView* menu = new views::MenuItemView(&menu_delegate);
menu_runner_.reset(
new views::MenuRunner(menu, views::MenuRunner::HAS_MNEMONICS));
+ ink_drop_animation_controller_->AnimateToState(
+ views::InkDropState::ACTIVATED);
views::MenuRunner::RunResult result =
menu_runner_->RunMenuAt(GetWidget(),
NULL,
gfx::Rect(menu_position, gfx::Size(0, 0)),
views::MENU_ANCHOR_TOPLEFT,
source_type);
+ ink_drop_animation_controller_->AnimateToState(
+ views::InkDropState::DEACTIVATED);
if (result == views::MenuRunner::MENU_DELETED)
return;
}
- ink_drop_animation_controller_->AnimateToState(views::InkDropState::HIDDEN);
-
menu_showing_ = false;
// Need to explicitly clear mouse handler so that events get sent
@@ -326,7 +338,19 @@ void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) {
}
void ToolbarButton::LayoutInkDrop() {
- ink_drop_animation_controller_->SetInkDropSize(size());
+ // TODO(bruthig): Get the constants from the theme provider.
jonross 2015/08/19 22:13:36 If you don't do this in the current review, please
bruthig 2015/08/20 20:35:35 Done.
+ gfx::Size ink_drop_size = gfx::Size(32, 32);
+ ink_drop_animation_controller_->SetInkDropSize(ink_drop_size, 5,
+ gfx::Size(24, 24), 2);
+ ink_drop_animation_controller_->SetInkDropOrigin(
+ gfx::Point((width() - ink_drop_size.width()) / 2,
+ (height() - ink_drop_size.height()) / 2));
+}
+
+void ToolbarButton::NotifyClick(const ui::Event& event) {
+ ink_drop_animation_controller_->AnimateToState(
+ views::InkDropState::QUICK_ACTION);
+ LabelButton::NotifyClick(event);
}
const char* ToolbarButton::GetClassName() const {

Powered by Google App Engine
This is Rietveld 408576698