OLD | NEW |
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_node_data.h" | 8 #include "ui/accessibility/ax_node_data.h" |
9 #include "ui/base/dragdrop/drag_drop_types.h" | 9 #include "ui/base/dragdrop/drag_drop_types.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 const int MenuButton::kMenuMarkerPaddingLeft = 3; | 37 const int MenuButton::kMenuMarkerPaddingLeft = 3; |
38 const int MenuButton::kMenuMarkerPaddingRight = -1; | 38 const int MenuButton::kMenuMarkerPaddingRight = -1; |
39 | 39 |
40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
41 // | 41 // |
42 // MenuButton::PressedLock | 42 // MenuButton::PressedLock |
43 // | 43 // |
44 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
45 | 45 |
46 MenuButton::PressedLock::PressedLock(MenuButton* menu_button) | 46 MenuButton::PressedLock::PressedLock(MenuButton* menu_button) |
47 : PressedLock(menu_button, false) {} | 47 : PressedLock(menu_button, false, nullptr) {} |
48 | 48 |
49 MenuButton::PressedLock::PressedLock(MenuButton* menu_button, | 49 MenuButton::PressedLock::PressedLock(MenuButton* menu_button, |
50 bool is_sibling_menu_show) | 50 bool is_sibling_menu_show, |
| 51 const ui::LocatedEvent* event) |
51 : menu_button_(menu_button->weak_factory_.GetWeakPtr()) { | 52 : menu_button_(menu_button->weak_factory_.GetWeakPtr()) { |
52 menu_button_->IncrementPressedLocked(is_sibling_menu_show); | 53 menu_button_->IncrementPressedLocked(is_sibling_menu_show, event); |
53 } | 54 } |
54 | 55 |
55 MenuButton::PressedLock::~PressedLock() { | 56 MenuButton::PressedLock::~PressedLock() { |
56 if (menu_button_.get()) | 57 if (menu_button_.get()) |
57 menu_button_->DecrementPressedLocked(); | 58 menu_button_->DecrementPressedLocked(); |
58 } | 59 } |
59 | 60 |
60 //////////////////////////////////////////////////////////////////////////////// | 61 //////////////////////////////////////////////////////////////////////////////// |
61 // | 62 // |
62 // MenuButton - constructors, destructors, initialization | 63 // MenuButton - constructors, destructors, initialization |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 LabelButton::StateChanged(old_state); | 360 LabelButton::StateChanged(old_state); |
360 } | 361 } |
361 } | 362 } |
362 | 363 |
363 void MenuButton::NotifyClick(const ui::Event& event) { | 364 void MenuButton::NotifyClick(const ui::Event& event) { |
364 // We don't forward events to the normal button listener, instead using the | 365 // We don't forward events to the normal button listener, instead using the |
365 // MenuButtonListener. | 366 // MenuButtonListener. |
366 Activate(&event); | 367 Activate(&event); |
367 } | 368 } |
368 | 369 |
369 void MenuButton::IncrementPressedLocked(bool snap_ink_drop_to_activated) { | 370 void MenuButton::IncrementPressedLocked(bool snap_ink_drop_to_activated, |
| 371 const ui::LocatedEvent* event) { |
370 ++pressed_lock_count_; | 372 ++pressed_lock_count_; |
371 if (increment_pressed_lock_called_) | 373 if (increment_pressed_lock_called_) |
372 *increment_pressed_lock_called_ = true; | 374 *increment_pressed_lock_called_ = true; |
373 should_disable_after_press_ = state() == STATE_DISABLED; | 375 should_disable_after_press_ = state() == STATE_DISABLED; |
374 if (state() != STATE_PRESSED) { | 376 if (state() != STATE_PRESSED) { |
375 if (snap_ink_drop_to_activated) | 377 if (snap_ink_drop_to_activated) |
376 GetInkDrop()->SnapToActivated(); | 378 GetInkDrop()->SnapToActivated(); |
377 else | 379 else |
378 AnimateInkDrop(InkDropState::ACTIVATED, nullptr /* event */); | 380 AnimateInkDrop(InkDropState::ACTIVATED, event); |
379 } | 381 } |
380 SetState(STATE_PRESSED); | 382 SetState(STATE_PRESSED); |
381 } | 383 } |
382 | 384 |
383 void MenuButton::DecrementPressedLocked() { | 385 void MenuButton::DecrementPressedLocked() { |
384 --pressed_lock_count_; | 386 --pressed_lock_count_; |
385 DCHECK_GE(pressed_lock_count_, 0); | 387 DCHECK_GE(pressed_lock_count_, 0); |
386 | 388 |
387 // If this was the last lock, manually reset state to the desired state. | 389 // If this was the last lock, manually reset state to the desired state. |
388 if (pressed_lock_count_ == 0) { | 390 if (pressed_lock_count_ == 0) { |
(...skipping 17 matching lines...) Expand all Loading... |
406 if (!GetWidget()) { | 408 if (!GetWidget()) { |
407 NOTREACHED(); | 409 NOTREACHED(); |
408 return 0; | 410 return 0; |
409 } | 411 } |
410 | 412 |
411 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); | 413 gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); |
412 return monitor_bounds.right() - 1; | 414 return monitor_bounds.right() - 1; |
413 } | 415 } |
414 | 416 |
415 } // namespace views | 417 } // namespace views |
OLD | NEW |