| OLD | NEW |
| 1 // Copyright (c) 2011 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 #ifndef UI_VIEWS_DRAG_UTILS_H_ | 5 #ifndef UI_VIEWS_DRAG_UTILS_H_ |
| 6 #define UI_VIEWS_DRAG_UTILS_H_ | 6 #define UI_VIEWS_DRAG_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
| 14 | 14 |
| 15 class GURL; | 15 class GURL; |
| 16 class SkBitmap; | 16 class SkBitmap; |
| 17 | 17 |
| 18 namespace gfx { | 18 namespace gfx { |
| 19 class Canvas; | 19 class CanvasSkia; |
| 20 class Point; | 20 class Point; |
| 21 class Size; | 21 class Size; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace ui { | 24 namespace ui { |
| 25 class OSExchangeData; | 25 class OSExchangeData; |
| 26 } | 26 } |
| 27 using ui::OSExchangeData; | 27 using ui::OSExchangeData; |
| 28 | 28 |
| 29 namespace drag_utils { | 29 namespace drag_utils { |
| 30 | 30 |
| 31 // Sets url and title on data as well as setting a suitable image for dragging. | 31 // Sets url and title on data as well as setting a suitable image for dragging. |
| 32 // The image looks like that of the bookmark buttons. | 32 // The image looks like that of the bookmark buttons. |
| 33 VIEWS_EXPORT void SetURLAndDragImage(const GURL& url, | 33 VIEWS_EXPORT void SetURLAndDragImage(const GURL& url, |
| 34 const string16& title, | 34 const string16& title, |
| 35 const SkBitmap& icon, | 35 const SkBitmap& icon, |
| 36 ui::OSExchangeData* data); | 36 ui::OSExchangeData* data); |
| 37 | 37 |
| 38 // Creates a dragging image to be displayed when the user drags a file from | 38 // Creates a dragging image to be displayed when the user drags a file from |
| 39 // Chrome (via the download manager, for example). The drag image is set into | 39 // Chrome (via the download manager, for example). The drag image is set into |
| 40 // the supplied data_object. 'file_name' can be a full path, but the directory | 40 // the supplied data_object. 'file_name' can be a full path, but the directory |
| 41 // portion will be truncated in the drag image. | 41 // portion will be truncated in the drag image. |
| 42 VIEWS_EXPORT void CreateDragImageForFile(const FilePath& file_name, | 42 VIEWS_EXPORT void CreateDragImageForFile(const FilePath& file_name, |
| 43 const SkBitmap* icon, | 43 const SkBitmap* icon, |
| 44 ui::OSExchangeData* data_object); | 44 ui::OSExchangeData* data_object); |
| 45 | 45 |
| 46 // Sets the drag image on data_object from the supplied canvas. width/height | 46 // Sets the drag image on data_object from the supplied canvas. width/height |
| 47 // are the size of the image to use, and the offsets give the location of | 47 // are the size of the image to use, and the offsets give the location of |
| 48 // the hotspot for the drag image. | 48 // the hotspot for the drag image. |
| 49 VIEWS_EXPORT void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 49 VIEWS_EXPORT void SetDragImageOnDataObject(const gfx::CanvasSkia& canvas, |
| 50 const gfx::Size& size, | 50 const gfx::Size& size, |
| 51 const gfx::Point& cursor_offset, | 51 const gfx::Point& cursor_offset, |
| 52 ui::OSExchangeData* data_object); | 52 ui::OSExchangeData* data_object); |
| 53 | 53 |
| 54 // Sets the drag image on data_object from the supplied bitmap. width/height | 54 // Sets the drag image on data_object from the supplied bitmap. width/height |
| 55 // are the size of the image to use, and the offsets give the location of | 55 // are the size of the image to use, and the offsets give the location of |
| 56 // the hotspot for the drag image. | 56 // the hotspot for the drag image. |
| 57 VIEWS_EXPORT void SetDragImageOnDataObject(const SkBitmap& bitmap, | 57 VIEWS_EXPORT void SetDragImageOnDataObject(const SkBitmap& bitmap, |
| 58 const gfx::Size& size, | 58 const gfx::Size& size, |
| 59 const gfx::Point& cursor_offset, | 59 const gfx::Point& cursor_offset, |
| 60 ui::OSExchangeData* data_object); | 60 ui::OSExchangeData* data_object); |
| 61 | 61 |
| 62 } // namespace drag_utils | 62 } // namespace drag_utils |
| 63 | 63 |
| 64 #endif // UI_VIEWS_DRAG_UTILS_H_ | 64 #endif // UI_VIEWS_DRAG_UTILS_H_ |
| OLD | NEW |