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/button_drag_utils.h" | 5 #include "ui/views/button_drag_utils.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/base/dragdrop/drag_utils.h" | 8 #include "ui/base/dragdrop/drag_utils.h" |
9 #include "ui/base/dragdrop/os_exchange_data.h" | 9 #include "ui/base/dragdrop/os_exchange_data.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 gfx::Size prefsize = button.GetPreferredSize(); | 74 gfx::Size prefsize = button.GetPreferredSize(); |
75 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); | 75 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); |
76 | 76 |
77 gfx::Vector2d press_point; | 77 gfx::Vector2d press_point; |
78 if (press_pt) | 78 if (press_pt) |
79 press_point = press_pt->OffsetFromOrigin(); | 79 press_point = press_pt->OffsetFromOrigin(); |
80 else | 80 else |
81 press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2); | 81 press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2); |
82 | 82 |
83 // Render the image. | 83 // Render the image. |
84 scoped_ptr<gfx::Canvas> canvas( | 84 std::unique_ptr<gfx::Canvas> canvas( |
85 views::GetCanvasForDragImage(widget, prefsize)); | 85 views::GetCanvasForDragImage(widget, prefsize)); |
86 button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context()); | 86 button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context()); |
87 drag_utils::SetDragImageOnDataObject(*canvas, press_point, data); | 87 drag_utils::SetDragImageOnDataObject(*canvas, press_point, data); |
88 } | 88 } |
89 | 89 |
90 } // namespace button_drag_utils | 90 } // namespace button_drag_utils |
OLD | NEW |