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

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

Issue 1757993004: Added ink drop hover/ripple to menu hosting bookmark buttons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests. Created 4 years, 9 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 30 matching lines...) Expand all
41 const int MenuButton::kMenuMarkerPaddingRight = -1; 41 const int MenuButton::kMenuMarkerPaddingRight = -1;
42 42
43 //////////////////////////////////////////////////////////////////////////////// 43 ////////////////////////////////////////////////////////////////////////////////
44 // 44 //
45 // MenuButton::PressedLock 45 // MenuButton::PressedLock
46 // 46 //
47 //////////////////////////////////////////////////////////////////////////////// 47 ////////////////////////////////////////////////////////////////////////////////
48 48
49 MenuButton::PressedLock::PressedLock(MenuButton* menu_button) 49 MenuButton::PressedLock::PressedLock(MenuButton* menu_button)
50 : menu_button_(menu_button->weak_factory_.GetWeakPtr()) { 50 : menu_button_(menu_button->weak_factory_.GetWeakPtr()) {
51 menu_button_->IncrementPressedLocked(); 51 menu_button_->IncrementPressedLocked(true);
sky 2016/03/11 20:41:32 use delegating constructor.
bruthig 2016/03/11 21:58:20 Done.
52 }
53
54 MenuButton::PressedLock::PressedLock(MenuButton* menu_button,
55 bool first_menu_show)
56 : menu_button_(menu_button->weak_factory_.GetWeakPtr()) {
57 menu_button_->IncrementPressedLocked(first_menu_show);
52 } 58 }
53 59
54 MenuButton::PressedLock::~PressedLock() { 60 MenuButton::PressedLock::~PressedLock() {
55 if (menu_button_.get()) 61 if (menu_button_.get())
56 menu_button_->DecrementPressedLocked(); 62 menu_button_->DecrementPressedLocked();
57 } 63 }
58 64
59 //////////////////////////////////////////////////////////////////////////////// 65 ////////////////////////////////////////////////////////////////////////////////
60 // 66 //
61 // MenuButton - constructors, destructors, initialization 67 // MenuButton - constructors, destructors, initialization
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 LabelButton::StateChanged(); 367 LabelButton::StateChanged();
362 } 368 }
363 } 369 }
364 370
365 void MenuButton::NotifyClick(const ui::Event& event) { 371 void MenuButton::NotifyClick(const ui::Event& event) {
366 // We don't forward events to the normal button listener, instead using the 372 // We don't forward events to the normal button listener, instead using the
367 // MenuButtonListener. 373 // MenuButtonListener.
368 Activate(&event); 374 Activate(&event);
369 } 375 }
370 376
371 void MenuButton::IncrementPressedLocked() { 377 void MenuButton::IncrementPressedLocked(bool animate_ink_drop) {
372 ++pressed_lock_count_; 378 ++pressed_lock_count_;
373 if (increment_pressed_lock_called_) 379 if (increment_pressed_lock_called_)
374 *increment_pressed_lock_called_ = true; 380 *increment_pressed_lock_called_ = true;
375 should_disable_after_press_ = state() == STATE_DISABLED; 381 should_disable_after_press_ = state() == STATE_DISABLED;
376 if (state() != STATE_PRESSED && ink_drop_delegate()) 382 if (state() != STATE_PRESSED && ink_drop_delegate()) {
377 ink_drop_delegate()->OnAction(InkDropState::ACTIVATED); 383 if (animate_ink_drop)
384 ink_drop_delegate()->OnAction(InkDropState::ACTIVATED);
385 else
386 ink_drop_delegate()->SnapToActivated();
387 }
378 SetState(STATE_PRESSED); 388 SetState(STATE_PRESSED);
379 } 389 }
380 390
381 void MenuButton::DecrementPressedLocked() { 391 void MenuButton::DecrementPressedLocked() {
382 --pressed_lock_count_; 392 --pressed_lock_count_;
383 DCHECK_GE(pressed_lock_count_, 0); 393 DCHECK_GE(pressed_lock_count_, 0);
384 394
385 // If this was the last lock, manually reset state to the desired state. 395 // If this was the last lock, manually reset state to the desired state.
386 if (pressed_lock_count_ == 0) { 396 if (pressed_lock_count_ == 0) {
387 ButtonState desired_state = STATE_NORMAL; 397 ButtonState desired_state = STATE_NORMAL;
(...skipping 13 matching lines...) Expand all
401 if (!GetWidget()) { 411 if (!GetWidget()) {
402 NOTREACHED(); 412 NOTREACHED();
403 return 0; 413 return 0;
404 } 414 }
405 415
406 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); 416 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen();
407 return monitor_bounds.right() - 1; 417 return monitor_bounds.right() - 1;
408 } 418 }
409 419
410 } // namespace views 420 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698