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

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

Issue 2042073002: Centered flood fill style ink drop ripples on mouse/touch points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Polished for review. 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/menu_button.h" 5 #include "ui/views/controls/button/menu_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_view_state.h" 8 #include "ui/accessibility/ax_view_state.h"
9 #include "ui/base/dragdrop/drag_drop_types.h" 9 #include "ui/base/dragdrop/drag_drop_types.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // The menu was deleted while showing. Don't attempt any processing. 141 // The menu was deleted while showing. Don't attempt any processing.
142 return false; 142 return false;
143 } 143 }
144 144
145 increment_pressed_lock_called_ = nullptr; 145 increment_pressed_lock_called_ = nullptr;
146 destroyed_flag_ = nullptr; 146 destroyed_flag_ = nullptr;
147 147
148 menu_closed_time_ = TimeTicks::Now(); 148 menu_closed_time_ = TimeTicks::Now();
149 149
150 if (!increment_pressed_lock_called && pressed_lock_count_ == 0) 150 if (!increment_pressed_lock_called && pressed_lock_count_ == 0)
151 AnimateInkDrop(InkDropState::ACTION_TRIGGERED); 151 AnimateInkDrop(InkDropState::ACTION_TRIGGERED, event);
152 152
153 // We must return false here so that the RootView does not get stuck 153 // We must return false here so that the RootView does not get stuck
154 // sending all mouse pressed events to us instead of the appropriate 154 // sending all mouse pressed events to us instead of the appropriate
155 // target. 155 // target.
156 return false; 156 return false;
157 } 157 }
158 158
159 AnimateInkDrop(InkDropState::HIDDEN); 159 AnimateInkDrop(InkDropState::HIDDEN, event);
160 return true; 160 return true;
161 } 161 }
162 162
163 bool MenuButton::IsTriggerableEventType(const ui::Event& event) { 163 bool MenuButton::IsTriggerableEventType(const ui::Event& event) {
164 if (event.IsMouseEvent()) { 164 if (event.IsMouseEvent()) {
165 const ui::MouseEvent& mouseev = static_cast<const ui::MouseEvent&>(event); 165 const ui::MouseEvent& mouseev = static_cast<const ui::MouseEvent&>(event);
166 // Active on left mouse button only, to prevent a menu from being activated 166 // Active on left mouse button only, to prevent a menu from being activated
167 // when a right-click would also activate a context menu. 167 // when a right-click would also activate a context menu.
168 if (!mouseev.IsOnlyLeftMouseButton()) 168 if (!mouseev.IsOnlyLeftMouseButton())
169 return false; 169 return false;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 return Activate(&event); 215 return Activate(&event);
216 } 216 }
217 return true; 217 return true;
218 } 218 }
219 219
220 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) { 220 void MenuButton::OnMouseReleased(const ui::MouseEvent& event) {
221 if (state() != STATE_DISABLED && IsTriggerableEvent(event) && 221 if (state() != STATE_DISABLED && IsTriggerableEvent(event) &&
222 HitTestPoint(event.location()) && !InDrag()) { 222 HitTestPoint(event.location()) && !InDrag()) {
223 Activate(&event); 223 Activate(&event);
224 } else { 224 } else {
225 AnimateInkDrop(InkDropState::HIDDEN); 225 AnimateInkDrop(InkDropState::HIDDEN, &event);
226 LabelButton::OnMouseReleased(event); 226 LabelButton::OnMouseReleased(event);
227 } 227 }
228 } 228 }
229 229
230 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) { 230 void MenuButton::OnMouseEntered(const ui::MouseEvent& event) {
231 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked. 231 if (pressed_lock_count_ == 0) // Ignore mouse movement if state is locked.
232 LabelButton::OnMouseEntered(event); 232 LabelButton::OnMouseEntered(event);
233 } 233 }
234 234
235 void MenuButton::OnMouseExited(const ui::MouseEvent& event) { 235 void MenuButton::OnMouseExited(const ui::MouseEvent& event) {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 void MenuButton::IncrementPressedLocked(bool snap_ink_drop_to_activated) { 370 void MenuButton::IncrementPressedLocked(bool snap_ink_drop_to_activated) {
371 ++pressed_lock_count_; 371 ++pressed_lock_count_;
372 if (increment_pressed_lock_called_) 372 if (increment_pressed_lock_called_)
373 *increment_pressed_lock_called_ = true; 373 *increment_pressed_lock_called_ = true;
374 should_disable_after_press_ = state() == STATE_DISABLED; 374 should_disable_after_press_ = state() == STATE_DISABLED;
375 if (state() != STATE_PRESSED) { 375 if (state() != STATE_PRESSED) {
376 if (snap_ink_drop_to_activated) 376 if (snap_ink_drop_to_activated)
377 ink_drop()->SnapToActivated(); 377 ink_drop()->SnapToActivated();
378 else 378 else
379 AnimateInkDrop(InkDropState::ACTIVATED); 379 AnimateInkDrop(InkDropState::ACTIVATED, nullptr /* event */);
380 } 380 }
381 SetState(STATE_PRESSED); 381 SetState(STATE_PRESSED);
382 } 382 }
383 383
384 void MenuButton::DecrementPressedLocked() { 384 void MenuButton::DecrementPressedLocked() {
385 --pressed_lock_count_; 385 --pressed_lock_count_;
386 DCHECK_GE(pressed_lock_count_, 0); 386 DCHECK_GE(pressed_lock_count_, 0);
387 387
388 // If this was the last lock, manually reset state to the desired state. 388 // If this was the last lock, manually reset state to the desired state.
389 if (pressed_lock_count_ == 0) { 389 if (pressed_lock_count_ == 0) {
390 ButtonState desired_state = STATE_NORMAL; 390 ButtonState desired_state = STATE_NORMAL;
391 if (should_disable_after_press_) { 391 if (should_disable_after_press_) {
392 desired_state = STATE_DISABLED; 392 desired_state = STATE_DISABLED;
393 should_disable_after_press_ = false; 393 should_disable_after_press_ = false;
394 } else if (ShouldEnterHoveredState()) { 394 } else if (ShouldEnterHoveredState()) {
395 desired_state = STATE_HOVERED; 395 desired_state = STATE_HOVERED;
396 } 396 }
397 SetState(desired_state); 397 SetState(desired_state);
398 // The widget may be null during shutdown. If so, it doesn't make sense to 398 // The widget may be null during shutdown. If so, it doesn't make sense to
399 // try to add an ink drop effect. 399 // try to add an ink drop effect.
400 if (GetWidget() && state() != STATE_PRESSED) 400 if (GetWidget() && state() != STATE_PRESSED)
401 AnimateInkDrop(InkDropState::DEACTIVATED); 401 AnimateInkDrop(InkDropState::DEACTIVATED, nullptr /* event */);
402 } 402 }
403 } 403 }
404 404
405 int MenuButton::GetMaximumScreenXCoordinate() { 405 int MenuButton::GetMaximumScreenXCoordinate() {
406 if (!GetWidget()) { 406 if (!GetWidget()) {
407 NOTREACHED(); 407 NOTREACHED();
408 return 0; 408 return 0;
409 } 409 }
410 410
411 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 411 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
412 return monitor_bounds.right() - 1; 412 return monitor_bounds.right() - 1;
413 } 413 }
414 414
415 } // namespace views 415 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698