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/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/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 443 |
444 void MenuController::OnMouseDragged(SubmenuView* source, | 444 void MenuController::OnMouseDragged(SubmenuView* source, |
445 const ui::MouseEvent& event) { | 445 const ui::MouseEvent& event) { |
446 MenuPart part = GetMenuPart(source, event.location()); | 446 MenuPart part = GetMenuPart(source, event.location()); |
447 UpdateScrolling(part); | 447 UpdateScrolling(part); |
448 | 448 |
449 if (!blocking_run_) | 449 if (!blocking_run_) |
450 return; | 450 return; |
451 | 451 |
452 if (possible_drag_) { | 452 if (possible_drag_) { |
453 if (View::ExceededDragThreshold(event.x() - press_pt_.x(), | 453 if (View::ExceededDragThreshold(event.location() - press_pt_)) |
454 event.y() - press_pt_.y())) { | |
455 StartDrag(source, press_pt_); | 454 StartDrag(source, press_pt_); |
456 } | |
457 return; | 455 return; |
458 } | 456 } |
459 MenuItemView* mouse_menu = NULL; | 457 MenuItemView* mouse_menu = NULL; |
460 if (part.type == MenuPart::MENU_ITEM) { | 458 if (part.type == MenuPart::MENU_ITEM) { |
461 if (!part.menu) | 459 if (!part.menu) |
462 part.menu = source->GetMenuItem(); | 460 part.menu = source->GetMenuItem(); |
463 else | 461 else |
464 mouse_menu = part.menu; | 462 mouse_menu = part.menu; |
465 SetSelection(part.menu ? part.menu : state_.item, SELECTION_OPEN_SUBMENU); | 463 SetSelection(part.menu ? part.menu : state_.item, SELECTION_OPEN_SUBMENU); |
466 } else if (part.type == MenuPart::NONE) { | 464 } else if (part.type == MenuPart::NONE) { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc); | 850 View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc); |
853 View::ConvertPointToTarget(NULL, item, &press_loc); | 851 View::ConvertPointToTarget(NULL, item, &press_loc); |
854 gfx::Point widget_loc(press_loc); | 852 gfx::Point widget_loc(press_loc); |
855 View::ConvertPointToWidget(item, &widget_loc); | 853 View::ConvertPointToWidget(item, &widget_loc); |
856 scoped_ptr<gfx::Canvas> canvas(views::GetCanvasForDragImage( | 854 scoped_ptr<gfx::Canvas> canvas(views::GetCanvasForDragImage( |
857 source->GetWidget(), gfx::Size(item->width(), item->height()))); | 855 source->GetWidget(), gfx::Size(item->width(), item->height()))); |
858 item->PaintButton(canvas.get(), MenuItemView::PB_FOR_DRAG); | 856 item->PaintButton(canvas.get(), MenuItemView::PB_FOR_DRAG); |
859 | 857 |
860 OSExchangeData data; | 858 OSExchangeData data; |
861 item->GetDelegate()->WriteDragData(item, &data); | 859 item->GetDelegate()->WriteDragData(item, &data); |
862 drag_utils::SetDragImageOnDataObject(*canvas, item->size(), press_loc, | 860 drag_utils::SetDragImageOnDataObject(*canvas, item->size(), |
| 861 press_loc.OffsetFromOrigin(), |
863 &data); | 862 &data); |
864 StopScrolling(); | 863 StopScrolling(); |
865 int drag_ops = item->GetDelegate()->GetDragOperations(item); | 864 int drag_ops = item->GetDelegate()->GetDragOperations(item); |
866 drag_in_progress_ = true; | 865 drag_in_progress_ = true; |
867 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops); | 866 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops); |
868 drag_in_progress_ = false; | 867 drag_in_progress_ = false; |
869 | 868 |
870 if (GetActiveInstance() == this) { | 869 if (GetActiveInstance() == this) { |
871 if (showing_) { | 870 if (showing_) { |
872 // We're still showing, close all menus. | 871 // We're still showing, close all menus. |
(...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 | 2136 |
2138 gfx::Screen* MenuController::GetScreen() { | 2137 gfx::Screen* MenuController::GetScreen() { |
2139 #if defined(USE_AURA) | 2138 #if defined(USE_AURA) |
2140 return gfx::Screen::GetScreenFor(root_window_); | 2139 return gfx::Screen::GetScreenFor(root_window_); |
2141 #else | 2140 #else |
2142 return gfx::Screen::GetNativeScreen(); | 2141 return gfx::Screen::GetNativeScreen(); |
2143 #endif | 2142 #endif |
2144 } | 2143 } |
2145 | 2144 |
2146 } // namespace views | 2145 } // namespace views |
OLD | NEW |