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/time.h" | 9 #include "base/time.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "ui/base/dragdrop/drag_utils.h" | 11 #include "ui/base/dragdrop/drag_utils.h" |
12 #include "ui/base/dragdrop/os_exchange_data.h" | 12 #include "ui/base/dragdrop/os_exchange_data.h" |
13 #include "ui/base/events.h" | 13 #include "ui/base/events.h" |
14 #include "ui/base/keycodes/keyboard_codes.h" | 14 #include "ui/base/keycodes/keyboard_codes.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/gfx/canvas_skia.h" | 16 #include "ui/gfx/canvas.h" |
17 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
18 #include "ui/views/controls/button/menu_button.h" | 18 #include "ui/views/controls/button/menu_button.h" |
19 #include "ui/views/controls/menu/menu_controller_delegate.h" | 19 #include "ui/views/controls/menu/menu_controller_delegate.h" |
20 #include "ui/views/controls/menu/menu_scroll_view_container.h" | 20 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
21 #include "ui/views/controls/menu/submenu_view.h" | 21 #include "ui/views/controls/menu/submenu_view.h" |
22 #include "ui/views/view_constants.h" | 22 #include "ui/views/view_constants.h" |
23 #include "ui/views/views_delegate.h" | 23 #include "ui/views/views_delegate.h" |
24 #include "ui/views/widget/root_view.h" | 24 #include "ui/views/widget/root_view.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 | 26 |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 MenuItemView* item = state_.item; | 829 MenuItemView* item = state_.item; |
830 DCHECK(item); | 830 DCHECK(item); |
831 // Points are in the coordinates of the submenu, need to map to that of | 831 // Points are in the coordinates of the submenu, need to map to that of |
832 // the selected item. Additionally source may not be the parent of | 832 // the selected item. Additionally source may not be the parent of |
833 // the selected item, so need to map to screen first then to item. | 833 // the selected item, so need to map to screen first then to item. |
834 gfx::Point press_loc(location); | 834 gfx::Point press_loc(location); |
835 View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc); | 835 View::ConvertPointToScreen(source->GetScrollViewContainer(), &press_loc); |
836 View::ConvertPointToView(NULL, item, &press_loc); | 836 View::ConvertPointToView(NULL, item, &press_loc); |
837 gfx::Point widget_loc(press_loc); | 837 gfx::Point widget_loc(press_loc); |
838 View::ConvertPointToWidget(item, &widget_loc); | 838 View::ConvertPointToWidget(item, &widget_loc); |
839 gfx::CanvasSkia canvas(gfx::Size(item->width(), item->height()), false); | 839 gfx::Canvas canvas(gfx::Size(item->width(), item->height()), false); |
840 item->PaintButton(&canvas, MenuItemView::PB_FOR_DRAG); | 840 item->PaintButton(&canvas, MenuItemView::PB_FOR_DRAG); |
841 | 841 |
842 OSExchangeData data; | 842 OSExchangeData data; |
843 item->GetDelegate()->WriteDragData(item, &data); | 843 item->GetDelegate()->WriteDragData(item, &data); |
844 drag_utils::SetDragImageOnDataObject(canvas, item->size(), press_loc, | 844 drag_utils::SetDragImageOnDataObject(canvas, item->size(), press_loc, |
845 &data); | 845 &data); |
846 StopScrolling(); | 846 StopScrolling(); |
847 int drag_ops = item->GetDelegate()->GetDragOperations(item); | 847 int drag_ops = item->GetDelegate()->GetDragOperations(item); |
848 drag_in_progress_ = true; | 848 drag_in_progress_ = true; |
849 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops); | 849 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops); |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2047 (!pending_state_.item->HasSubmenu() || | 2047 (!pending_state_.item->HasSubmenu() || |
2048 !pending_state_.item->GetSubmenu()->IsShowing())) { | 2048 !pending_state_.item->GetSubmenu()->IsShowing())) { |
2049 // On exit if the user hasn't selected an item with a submenu, move the | 2049 // On exit if the user hasn't selected an item with a submenu, move the |
2050 // selection back to the parent menu item. | 2050 // selection back to the parent menu item. |
2051 SetSelection(pending_state_.item->GetParentMenuItem(), | 2051 SetSelection(pending_state_.item->GetParentMenuItem(), |
2052 SELECTION_OPEN_SUBMENU); | 2052 SELECTION_OPEN_SUBMENU); |
2053 } | 2053 } |
2054 } | 2054 } |
2055 | 2055 |
2056 } // namespace views | 2056 } // namespace views |
OLD | NEW |