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

Side by Side Diff: ui/views/controls/button/custom_button.cc

Issue 2070143003: Add MD ink drop ripple to app list button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b612539_shelf_button_ripple
Patch Set: Added tests + Addressed review comments Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/controls/button/custom_button.h" 5 #include "ui/views/controls/button/custom_button.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/base/material_design/material_design_controller.h" 8 #include "ui/base/material_design/material_design_controller.h"
9 #include "ui/events/event.h" 9 #include "ui/events/event.h"
10 #include "ui/events/event_utils.h" 10 #include "ui/events/event_utils.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) { 155 if (IsTriggerableEvent(event) && notify_action_ == NOTIFY_ON_PRESS) {
156 NotifyClick(event); 156 NotifyClick(event);
157 // NOTE: We may be deleted at this point (by the listener's notification 157 // NOTE: We may be deleted at this point (by the listener's notification
158 // handler). 158 // handler).
159 } 159 }
160 return true; 160 return true;
161 } 161 }
162 162
163 bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) { 163 bool CustomButton::OnMouseDragged(const ui::MouseEvent& event) {
164 if (state_ != STATE_DISABLED) { 164 if (state_ != STATE_DISABLED) {
165 bool should_enter_pushed = ShouldEnterPushedState(event); 165 const bool should_enter_pushed = ShouldEnterPushedState(event);
166 const bool should_show_pending =
167 should_enter_pushed && notify_action_ == NOTIFY_ON_RELEASE && !InDrag();
166 if (HitTestPoint(event.location())) { 168 if (HitTestPoint(event.location())) {
167 SetState(should_enter_pushed ? STATE_PRESSED : STATE_HOVERED); 169 SetState(should_enter_pushed ? STATE_PRESSED : STATE_HOVERED);
168 if (!InDrag() && should_enter_pushed && 170 if (should_show_pending &&
bruthig 2016/06/20 14:44:33 Can you add/update some tests for this new logic?
mohsen 2016/06/21 06:33:23 Done.
169 ink_drop()->GetTargetInkDropState() == views::InkDropState::HIDDEN) { 171 ink_drop()->GetTargetInkDropState() == views::InkDropState::HIDDEN) {
170 AnimateInkDrop(views::InkDropState::ACTION_PENDING); 172 AnimateInkDrop(views::InkDropState::ACTION_PENDING);
171 } 173 }
172 } else { 174 } else {
173 SetState(STATE_NORMAL); 175 SetState(STATE_NORMAL);
174 if (!InDrag() && should_enter_pushed && 176 if (should_show_pending &&
175 ink_drop()->GetTargetInkDropState() == 177 ink_drop()->GetTargetInkDropState() ==
176 views::InkDropState::ACTION_PENDING) { 178 views::InkDropState::ACTION_PENDING) {
177 AnimateInkDrop(views::InkDropState::HIDDEN); 179 AnimateInkDrop(views::InkDropState::HIDDEN);
178 } 180 }
179 } 181 }
180 } 182 }
181 return true; 183 return true;
182 } 184 }
183 185
184 void CustomButton::OnMouseReleased(const ui::MouseEvent& event) { 186 void CustomButton::OnMouseReleased(const ui::MouseEvent& event) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 AnimateInkDrop(InkDropState::ACTION_TRIGGERED); 466 AnimateInkDrop(InkDropState::ACTION_TRIGGERED);
465 Button::NotifyClick(event); 467 Button::NotifyClick(event);
466 } 468 }
467 469
468 void CustomButton::OnClickCanceled(const ui::Event& event) { 470 void CustomButton::OnClickCanceled(const ui::Event& event) {
469 AnimateInkDrop(views::InkDropState::HIDDEN); 471 AnimateInkDrop(views::InkDropState::HIDDEN);
470 Button::OnClickCanceled(event); 472 Button::OnClickCanceled(event);
471 } 473 }
472 474
473 } // namespace views 475 } // namespace views
OLDNEW
« ash/shelf/shelf_view_unittest.cc ('K') | « ui/views/animation/ink_drop_host_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698