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

Side by Side 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: 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 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/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 if (submenu->IsShowing()) { 786 if (submenu->IsShowing()) {
787 gfx::Point point = GetScreen()->GetCursorScreenPoint(); 787 gfx::Point point = GetScreen()->GetCursorScreenPoint();
788 const SubmenuView* root_submenu = 788 const SubmenuView* root_submenu =
789 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu(); 789 submenu->GetMenuItem()->GetRootMenuItem()->GetSubmenu();
790 View::ConvertPointFromScreen( 790 View::ConvertPointFromScreen(
791 root_submenu->GetWidget()->GetRootView(), &point); 791 root_submenu->GetWidget()->GetRootView(), &point);
792 HandleMouseLocation(submenu, point); 792 HandleMouseLocation(submenu, point);
793 } 793 }
794 } 794 }
795 795
796 void MenuController::OnDragWillStart() {
sky 2014/07/14 15:19:05 Position should match that of header.
Devlin 2014/07/16 16:00:45 Whoops! Done.
797 drag_in_progress_ = true;
sky 2014/07/14 15:19:05 Before this add a DCHECK(!drag_in_progress_).
Devlin 2014/07/16 16:00:45 Done.
798 }
799
800 void MenuController::OnDragComplete(bool should_close) {
801 drag_in_progress_ = false;
sky 2014/07/14 15:19:05 And DCHECK(drag_in_progress_)
Devlin 2014/07/16 16:00:45 Done.
802 if (GetActiveInstance() == this && showing_ && should_close) {
sky 2014/07/14 15:19:05 move the showing_ and should_close checks first.
Devlin 2014/07/16 16:00:45 Done.
803 CloseAllNestedMenus();
804 Cancel(EXIT_ALL);
805 }
806 }
807
796 void MenuController::OnWidgetDestroying(Widget* widget) { 808 void MenuController::OnWidgetDestroying(Widget* widget) {
797 DCHECK_EQ(owner_, widget); 809 DCHECK_EQ(owner_, widget);
798 owner_->RemoveObserver(this); 810 owner_->RemoveObserver(this);
799 owner_ = NULL; 811 owner_ = NULL;
800 message_loop_->ClearOwner(); 812 message_loop_->ClearOwner();
801 } 813 }
802 814
803 // static 815 // static
804 void MenuController::TurnOffMenuSelectionHoldForTest() { 816 void MenuController::TurnOffMenuSelectionHoldForTest() {
805 menu_selection_hold_time_ms = -1; 817 menu_selection_hold_time_ms = -1;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 source->GetWidget(), gfx::Size(item->width(), item->height()))); 975 source->GetWidget(), gfx::Size(item->width(), item->height())));
964 item->PaintButton(canvas.get(), MenuItemView::PB_FOR_DRAG); 976 item->PaintButton(canvas.get(), MenuItemView::PB_FOR_DRAG);
965 977
966 OSExchangeData data; 978 OSExchangeData data;
967 item->GetDelegate()->WriteDragData(item, &data); 979 item->GetDelegate()->WriteDragData(item, &data);
968 drag_utils::SetDragImageOnDataObject(*canvas, 980 drag_utils::SetDragImageOnDataObject(*canvas,
969 press_loc.OffsetFromOrigin(), 981 press_loc.OffsetFromOrigin(),
970 &data); 982 &data);
971 StopScrolling(); 983 StopScrolling();
972 int drag_ops = item->GetDelegate()->GetDragOperations(item); 984 int drag_ops = item->GetDelegate()->GetDragOperations(item);
973 drag_in_progress_ = true;
974 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. 985 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
975 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops, 986 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops,
976 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 987 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
977 drag_in_progress_ = false;
978
979 if (GetActiveInstance() == this) {
980 if (showing_) {
981 // We're still showing, close all menus.
982 CloseAllNestedMenus();
983 Cancel(EXIT_ALL);
984 } // else case, drop was on us.
985 } // else case, someone canceled us, don't do anything
986 } 988 }
987 989
988 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) { 990 bool MenuController::OnKeyDown(ui::KeyboardCode key_code) {
989 DCHECK(blocking_run_); 991 DCHECK(blocking_run_);
990 992
991 switch (key_code) { 993 switch (key_code) {
992 case ui::VKEY_UP: 994 case ui::VKEY_UP:
993 IncrementSelection(-1); 995 IncrementSelection(-1);
994 break; 996 break;
995 997
(...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2291 } 2293 }
2292 } 2294 }
2293 2295
2294 gfx::Screen* MenuController::GetScreen() { 2296 gfx::Screen* MenuController::GetScreen() {
2295 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2297 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2296 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2298 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2297 : gfx::Screen::GetNativeScreen(); 2299 : gfx::Screen::GetNativeScreen();
2298 } 2300 }
2299 2301
2300 } // namespace views 2302 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698