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

Unified Diff: ui/views/controls/menu/menu_controller.cc

Issue 378333003: Allow menus to stay open during a child view's drag and drop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test Fix Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/menu/menu_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/menu/menu_controller.cc
diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc
index d5b5a84e8f1b707fee0e9cf27f48c8fd0dc5d789..3f59112e743250fca4ffda6a3c1bd89243b30788 100644
--- a/ui/views/controls/menu/menu_controller.cc
+++ b/ui/views/controls/menu/menu_controller.cc
@@ -294,6 +294,7 @@ MenuItemView* MenuController::Run(Widget* parent,
exit_type_ = EXIT_NONE;
possible_drag_ = false;
drag_in_progress_ = false;
+ did_initiate_drag_ = false;
closing_event_time_ = base::TimeDelta();
menu_start_time_ = base::TimeTicks::Now();
menu_start_mouse_press_loc_ = gfx::Point();
@@ -782,6 +783,20 @@ void MenuController::OnDragExitedScrollButton(SubmenuView* source) {
StopScrolling();
}
+void MenuController::OnDragWillStart() {
+ DCHECK(!drag_in_progress_);
+ drag_in_progress_ = true;
+}
+
+void MenuController::OnDragComplete(bool should_close) {
+ DCHECK(drag_in_progress_);
+ drag_in_progress_ = false;
+ if (showing_ && should_close && GetActiveInstance() == this) {
+ CloseAllNestedMenus();
+ Cancel(EXIT_ALL);
+ }
+}
+
void MenuController::UpdateSubmenuSelection(SubmenuView* submenu) {
if (submenu->IsShowing()) {
gfx::Point point = GetScreen()->GetCursorScreenPoint();
@@ -970,19 +985,11 @@ void MenuController::StartDrag(SubmenuView* source,
&data);
StopScrolling();
int drag_ops = item->GetDelegate()->GetDragOperations(item);
- drag_in_progress_ = true;
+ did_initiate_drag_ = true;
// TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
- drag_in_progress_ = false;
-
- if (GetActiveInstance() == this) {
- if (showing_) {
- // We're still showing, close all menus.
- CloseAllNestedMenus();
- Cancel(EXIT_ALL);
- } // else case, drop was on us.
- } // else case, someone canceled us, don't do anything
+ did_initiate_drag_ = false;
}
bool MenuController::OnKeyDown(ui::KeyboardCode key_code) {
@@ -1071,6 +1078,7 @@ MenuController::MenuController(ui::NativeTheme* theme,
owner_(NULL),
possible_drag_(false),
drag_in_progress_(false),
+ did_initiate_drag_(false),
valid_drop_coordinates_(false),
last_drop_operation_(MenuDelegate::DROP_UNKNOWN),
showing_submenu_(false),
« no previous file with comments | « ui/views/controls/menu/menu_controller.h ('k') | ui/views/controls/menu/menu_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698