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/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "ui/base/dragdrop/drag_utils.h" | |
14 #include "ui/base/dragdrop/os_exchange_data.h" | 13 #include "ui/base/dragdrop/os_exchange_data.h" |
15 #include "ui/display/screen.h" | 14 #include "ui/display/screen.h" |
16 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
17 #include "ui/events/event_utils.h" | 16 #include "ui/events/event_utils.h" |
18 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/geometry/point.h" | 18 #include "ui/gfx/geometry/point.h" |
20 #include "ui/gfx/geometry/vector2d.h" | 19 #include "ui/gfx/geometry/vector2d.h" |
21 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
22 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
23 #include "ui/gfx/image/image_skia_rep.h" | 22 #include "ui/gfx/image/image_skia_rep.h" |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 gfx::Point widget_loc(press_loc); | 1245 gfx::Point widget_loc(press_loc); |
1247 View::ConvertPointToWidget(item, &widget_loc); | 1246 View::ConvertPointToWidget(item, &widget_loc); |
1248 | 1247 |
1249 float raster_scale = ScaleFactorForDragFromWidget(source->GetWidget()); | 1248 float raster_scale = ScaleFactorForDragFromWidget(source->GetWidget()); |
1250 gfx::Canvas canvas(item->size(), raster_scale, false /* opaque */); | 1249 gfx::Canvas canvas(item->size(), raster_scale, false /* opaque */); |
1251 item->PaintButton(&canvas, MenuItemView::PB_FOR_DRAG); | 1250 item->PaintButton(&canvas, MenuItemView::PB_FOR_DRAG); |
1252 gfx::ImageSkia image(gfx::ImageSkiaRep(canvas.GetBitmap(), raster_scale)); | 1251 gfx::ImageSkia image(gfx::ImageSkiaRep(canvas.GetBitmap(), raster_scale)); |
1253 | 1252 |
1254 OSExchangeData data; | 1253 OSExchangeData data; |
1255 item->GetDelegate()->WriteDragData(item, &data); | 1254 item->GetDelegate()->WriteDragData(item, &data); |
1256 drag_utils::SetDragImageOnDataObject(image, press_loc.OffsetFromOrigin(), | 1255 data.provider().SetDragImage(image, press_loc.OffsetFromOrigin()); |
1257 &data); | |
1258 | 1256 |
1259 StopScrolling(); | 1257 StopScrolling(); |
1260 int drag_ops = item->GetDelegate()->GetDragOperations(item); | 1258 int drag_ops = item->GetDelegate()->GetDragOperations(item); |
1261 did_initiate_drag_ = true; | 1259 did_initiate_drag_ = true; |
1262 base::WeakPtr<MenuController> this_ref = AsWeakPtr(); | 1260 base::WeakPtr<MenuController> this_ref = AsWeakPtr(); |
1263 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. | 1261 // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. |
1264 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops, | 1262 item->GetWidget()->RunShellDrag(NULL, data, widget_loc, drag_ops, |
1265 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | 1263 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
1266 // MenuController may have been deleted so check before accessing member | 1264 // MenuController may have been deleted so check before accessing member |
1267 // variables. | 1265 // variables. |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2716 if (hot_button_) | 2714 if (hot_button_) |
2717 hot_button_->SetHotTracked(false); | 2715 hot_button_->SetHotTracked(false); |
2718 hot_button_ = hot_button; | 2716 hot_button_ = hot_button; |
2719 if (hot_button) { | 2717 if (hot_button) { |
2720 hot_button->SetHotTracked(true); | 2718 hot_button->SetHotTracked(true); |
2721 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); | 2719 hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); |
2722 } | 2720 } |
2723 } | 2721 } |
2724 | 2722 |
2725 } // namespace views | 2723 } // namespace views |
OLD | NEW |