diff options
author | skrul@google.com <skrul@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 20:01:08 +0000 |
---|---|---|
committer | skrul@google.com <skrul@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 20:01:08 +0000 |
commit | 6806d48ab1ce1f7dc3104033467581959368c28e (patch) | |
tree | 7875e66662af55969be0b3e668525c5a6b336b84 /app | |
parent | e08d7b463a5c82d253def91b20c8ed1756e8d337 (diff) | |
download | chromium_src-6806d48ab1ce1f7dc3104033467581959368c28e.zip chromium_src-6806d48ab1ce1f7dc3104033467581959368c28e.tar.gz chromium_src-6806d48ab1ce1f7dc3104033467581959368c28e.tar.bz2 |
Implement dragging icon for dragging bookmarks in views/gtk.
Review URL: http://codereview.chromium.org/270068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app')
-rw-r--r-- | app/gfx/canvas.cc | 2 | ||||
-rw-r--r-- | app/gfx/canvas.h | 2 | ||||
-rw-r--r-- | app/os_exchange_data_provider_gtk.cc | 23 | ||||
-rw-r--r-- | app/os_exchange_data_provider_gtk.h | 14 |
4 files changed, 37 insertions, 4 deletions
diff --git a/app/gfx/canvas.cc b/app/gfx/canvas.cc index 2cef3de..306531c4 100644 --- a/app/gfx/canvas.cc +++ b/app/gfx/canvas.cc @@ -248,7 +248,7 @@ void Canvas::TileImageInt(const SkBitmap& bitmap, int src_x, int src_y, restore(); } -SkBitmap Canvas::ExtractBitmap() { +SkBitmap Canvas::ExtractBitmap() const { const SkBitmap& device_bitmap = getDevice()->accessBitmap(false); // Make a bitmap to return, and a canvas to draw into it. We don't just want diff --git a/app/gfx/canvas.h b/app/gfx/canvas.h index 553ec94..90cfad8 100644 --- a/app/gfx/canvas.h +++ b/app/gfx/canvas.h @@ -180,7 +180,7 @@ class Canvas : public skia::PlatformCanvas { int dest_x, int dest_y, int w, int h); // Extracts a bitmap from the contents of this canvas. - SkBitmap ExtractBitmap(); + SkBitmap ExtractBitmap() const; #if defined(OS_LINUX) // Applies current matrix on the canvas to the cairo context. This should be diff --git a/app/os_exchange_data_provider_gtk.cc b/app/os_exchange_data_provider_gtk.cc index 597a5ae..dbae20e 100644 --- a/app/os_exchange_data_provider_gtk.cc +++ b/app/os_exchange_data_provider_gtk.cc @@ -16,15 +16,23 @@ OSExchangeDataProviderGtk::OSExchangeDataProviderGtk( const std::set<GdkAtom>& known_custom_formats) : known_formats_(known_formats), known_custom_formats_(known_custom_formats), - formats_(0) { + formats_(0), + drag_image_(NULL), + cursor_offset_x_(0), + cursor_offset_y_(0) { } OSExchangeDataProviderGtk::OSExchangeDataProviderGtk() : known_formats_(0), - formats_(0) { + formats_(0), + drag_image_(NULL), + cursor_offset_x_(0), + cursor_offset_y_(0) { } OSExchangeDataProviderGtk::~OSExchangeDataProviderGtk() { + if (drag_image_) + g_object_unref(drag_image_); } bool OSExchangeDataProviderGtk::HasDataForAllFormats( @@ -218,6 +226,17 @@ bool OSExchangeDataProviderGtk::GetPlainTextURL(GURL* url) const { return true; } +void OSExchangeDataProviderGtk::SetDragImage(GdkPixbuf* drag_image, + int cursor_offset_x, + int cursor_offset_y) { + if (drag_image_) + g_object_unref(drag_image_); + g_object_ref(drag_image); + drag_image_ = drag_image; + cursor_offset_x_ = cursor_offset_x; + cursor_offset_y_ = cursor_offset_y; +} + /////////////////////////////////////////////////////////////////////////////// // OSExchangeData, public: diff --git a/app/os_exchange_data_provider_gtk.h b/app/os_exchange_data_provider_gtk.h index ffbb182..9a56a2d 100644 --- a/app/os_exchange_data_provider_gtk.h +++ b/app/os_exchange_data_provider_gtk.h @@ -69,6 +69,15 @@ class OSExchangeDataProviderGtk : public OSExchangeData::Provider { virtual bool HasFile() const; virtual bool HasCustomFormat(OSExchangeData::CustomFormat format) const; + // Set the image and cursor offset data for this drag. Will + // increment the ref count of pixbuf. + void SetDragImage(GdkPixbuf* pixbuf, + int cursor_offset_x, + int cursor_offset_y); + GdkPixbuf* drag_image() const { return drag_image_; } + int cursor_offset_x() const { return cursor_offset_x_; } + int cursor_offset_y() const { return cursor_offset_y_; } + private: typedef std::map<OSExchangeData::CustomFormat, Pickle> PickleData; @@ -99,6 +108,11 @@ class OSExchangeDataProviderGtk : public OSExchangeData::Provider { // PICKLED_DATA contents. PickleData pickle_data_; + // Drag image and offset data. + GdkPixbuf* drag_image_; + int cursor_offset_x_; + int cursor_offset_y_; + DISALLOW_COPY_AND_ASSIGN(OSExchangeDataProviderGtk); }; |