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

Side by Side Diff: ui/views/drag_utils.cc

Issue 24175004: Remove dependency on ui::ScaleFactor from ui/gfx (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix new usage of scale in FastShowPickler Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/controls/menu/native_menu_win.cc ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/drag_utils.h" 5 #include "ui/views/drag_utils.h"
6 6
7 #include "ui/gfx/canvas.h" 7 #include "ui/gfx/canvas.h"
8 #include "ui/gfx/size.h" 8 #include "ui/gfx/size.h"
9 9
10 #if defined(USE_AURA) 10 #if defined(USE_AURA)
11 #include "ui/aura/client/drag_drop_client.h" 11 #include "ui/aura/client/drag_drop_client.h"
12 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
13 #include "ui/aura/window.h" 13 #include "ui/aura/window.h"
14 #include "ui/gfx/display.h" 14 #include "ui/gfx/display.h"
15 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
16 #include "ui/views/widget/widget.h" 16 #include "ui/views/widget/widget.h"
17 #elif defined(OS_WIN) 17 #elif defined(OS_WIN)
18 #include "ui/base/dragdrop/drag_drop_types.h" 18 #include "ui/base/dragdrop/drag_drop_types.h"
19 #include "ui/base/dragdrop/drag_source_win.h" 19 #include "ui/base/dragdrop/drag_source_win.h"
20 #include "ui/base/dragdrop/os_exchange_data_provider_win.h" 20 #include "ui/base/dragdrop/os_exchange_data_provider_win.h"
21 #else 21 #else
22 #error 22 #error
23 #endif 23 #endif
24 24
25 ui::ScaleFactor GetDeviceScaleFactorForNativeView(views::Widget* widget) { 25 float GetDeviceScaleForNativeView(views::Widget* widget) {
26 ui::ScaleFactor device_scale_factor = ui::SCALE_FACTOR_100P; 26 float device_scale = 1.0f;
27 #if defined(USE_AURA) 27 #if defined(USE_AURA)
28 // The following code should work on other platforms as well. But we do not 28 // The following code should work on other platforms as well. But we do not
29 // yet care about device scale factor on other platforms. So to keep drag and 29 // yet care about device scale factor on other platforms. So to keep drag and
30 // drop behavior on other platforms un-touched, we wrap this in the #if guard. 30 // drop behavior on other platforms un-touched, we wrap this in the #if guard.
31 if (widget && widget->GetNativeView()) { 31 if (widget && widget->GetNativeView()) {
32 gfx::NativeView view = widget->GetNativeView(); 32 gfx::NativeView view = widget->GetNativeView();
33 gfx::Display display = gfx::Screen::GetScreenFor(view)-> 33 gfx::Display display = gfx::Screen::GetScreenFor(view)->
34 GetDisplayNearestWindow(view); 34 GetDisplayNearestWindow(view);
35 device_scale_factor = ui::GetScaleFactorFromScale( 35 device_scale = display.device_scale_factor();
36 display.device_scale_factor());
37 } 36 }
38 #endif 37 #endif
39 return device_scale_factor; 38 return device_scale;
40 } 39 }
41 40
42 namespace views { 41 namespace views {
43 42
44 void RunShellDrag(gfx::NativeView view, 43 void RunShellDrag(gfx::NativeView view,
45 const ui::OSExchangeData& data, 44 const ui::OSExchangeData& data,
46 const gfx::Point& location, 45 const gfx::Point& location,
47 int operation, 46 int operation,
48 ui::DragDropTypes::DragEventSource source) { 47 ui::DragDropTypes::DragEventSource source) {
49 #if defined(USE_AURA) 48 #if defined(USE_AURA)
50 gfx::Point root_location(location); 49 gfx::Point root_location(location);
51 aura::RootWindow* root_window = view->GetRootWindow(); 50 aura::RootWindow* root_window = view->GetRootWindow();
52 aura::Window::ConvertPointToTarget(view, root_window, &root_location); 51 aura::Window::ConvertPointToTarget(view, root_window, &root_location);
53 if (aura::client::GetDragDropClient(root_window)) { 52 if (aura::client::GetDragDropClient(root_window)) {
54 aura::client::GetDragDropClient(root_window)->StartDragAndDrop( 53 aura::client::GetDragDropClient(root_window)->StartDragAndDrop(
55 data, root_window, view, root_location, operation, source); 54 data, root_window, view, root_location, operation, source);
56 } 55 }
57 #elif defined(OS_WIN) 56 #elif defined(OS_WIN)
58 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin); 57 scoped_refptr<ui::DragSourceWin> drag_source(new ui::DragSourceWin);
59 DWORD effects; 58 DWORD effects;
60 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data), 59 DoDragDrop(ui::OSExchangeDataProviderWin::GetIDataObject(data),
61 drag_source, 60 drag_source,
62 ui::DragDropTypes::DragOperationToDropEffect(operation), 61 ui::DragDropTypes::DragOperationToDropEffect(operation),
63 &effects); 62 &effects);
64 #endif 63 #endif
65 } 64 }
66 65
67 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget, 66 gfx::Canvas* GetCanvasForDragImage(views::Widget* widget,
68 const gfx::Size& canvas_size) { 67 const gfx::Size& canvas_size) {
69 ui::ScaleFactor device_scale_factor = 68 float device_scale = GetDeviceScaleForNativeView(widget);
70 GetDeviceScaleFactorForNativeView(widget); 69 return new gfx::Canvas(canvas_size, device_scale, false);
71 return new gfx::Canvas(canvas_size, device_scale_factor, false);
72 } 70 }
73 71
74 } // namespace views 72 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/native_menu_win.cc ('k') | ui/views/win/hwnd_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698