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

Unified Diff: ui/views/controls/button/menu_button.cc

Issue 1411833006: Refactoring to make adding ink drop animations easier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor ink drop animations (simplify MenuButton) 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: ui/views/controls/button/menu_button.cc
diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc
index 1225e67f5057482bc8db59bf65543a12a7f14603..cd46faa4535f5cfb08e2439131ef1fcd25a1a558 100644
--- a/ui/views/controls/button/menu_button.cc
+++ b/ui/views/controls/button/menu_button.cc
@@ -18,6 +18,7 @@
#include "ui/gfx/text_constants.h"
#include "ui/resources/grit/ui_resources.h"
#include "ui/strings/grit/ui_strings.h"
+#include "ui/views/animation/ink_drop_delegate.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/mouse_constants.h"
@@ -126,6 +127,9 @@ bool MenuButton::Activate() {
// We don't set our state here. It's handled in the MenuController code or
// by our click listener.
+ InkDropDelegate* ink_drop_delegate = GetInkDropDelegate();
bruthig 2015/11/19 16:49:53 Would it make things easier if GetInkDropDelegate(
varkha 2015/11/19 23:34:35 Done. May remove InkDropAnimationControllerStub la
+ if (ink_drop_delegate)
+ ink_drop_delegate->OnAction(InkDropState::QUICK_ACTION);
listener_->OnMenuButtonClicked(this, menu_position);
if (destroyed) {
@@ -145,12 +149,6 @@ bool MenuButton::Activate() {
return true;
}
-void MenuButton::WillNotActivate() {
- if (listener_) {
- listener_->OnMenuButtonClickCanceled(this);
- }
-}
-
void MenuButton::OnPaint(gfx::Canvas* canvas) {
LabelButton::OnPaint(canvas);
@@ -179,13 +177,20 @@ const char* MenuButton::GetClassName() const {
}
bool MenuButton::OnMousePressed(const ui::MouseEvent& event) {
+ if (event.IsOnlyLeftMouseButton()) {
+ InkDropDelegate* ink_drop_delegate = GetInkDropDelegate();
+ if (ink_drop_delegate)
+ ink_drop_delegate->OnAction(InkDropState::ACTION_PENDING);
bruthig 2015/11/19 16:49:53 I don't think a MenuButton can know for certain th
varkha 2015/11/19 23:34:35 Done.
+ }
+
if (request_focus_on_press())
RequestFocus();
if (state() != STATE_DISABLED && ShouldEnterPushedState(event) &&
HitTestPoint(event.location())) {
TimeDelta delta = TimeTicks::Now() - menu_closed_time_;
- if (delta.InMilliseconds() > kMinimumMsBetweenButtonClicks)
+ if (delta.InMilliseconds() > kMinimumMsBetweenButtonClicks) {
return Activate();
+ }
}
return true;
}
@@ -195,7 +200,9 @@ void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
HitTestPoint(event.location()) && !InDrag()) {
Activate();
} else {
- WillNotActivate();
+ InkDropDelegate* ink_drop_delegate = GetInkDropDelegate();
+ if (ink_drop_delegate)
+ ink_drop_delegate->OnAction(InkDropState::HIDDEN);
bruthig 2015/11/19 16:49:53 Somewhat similar concerns here to the ones in OnMo
varkha 2015/11/19 23:34:35 Will need to rethink what happens in asynchronous
LabelButton::OnMouseReleased(event);
}
}

Powered by Google App Engine
This is Rietveld 408576698