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

Unified Diff: views/drag_utils_win.cc

Issue 113954: Refactors drag_utils. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: views/drag_utils_win.cc
===================================================================
--- views/drag_utils_win.cc (revision 17065)
+++ views/drag_utils_win.cc (working copy)
@@ -9,33 +9,11 @@
#include <shobjidl.h>
#include "app/gfx/canvas.h"
-#include "app/gfx/font.h"
-#include "app/l10n_util.h"
#include "app/os_exchange_data.h"
-#include "app/resource_bundle.h"
-#include "base/file_util.h"
#include "base/gfx/gdi_util.h"
-#include "base/gfx/point.h"
-#include "base/string_util.h"
-#include "googleurl/src/gurl.h"
-#include "grit/app_resources.h"
-#include "views/controls/button/text_button.h"
namespace drag_utils {
-// Maximum width of the link drag image in pixels.
-static const int kLinkDragImageMaxWidth = 200;
-static const int kLinkDragImageVPadding = 3;
-static const int kLinkDragImageVSpacing = 2;
-static const int kLinkDragImageHPadding = 4;
-static const SkColor kLinkDragImageBGColor = SkColorSetRGB(131, 146, 171);
-//static const SkColor kLinkDragImageBGColor = SkColorSetRGB(195, 217, 255);
-static const SkColor kLinkDragImageTextColor = SK_ColorBLACK;
-
-// File dragging pixel measurements
-static const int kFileDragImageMaxWidth = 200;
-static const SkColor kFileDragImageTextColor = SK_ColorBLACK;
-
static void SetDragImageOnDataObject(HBITMAP hbitmap,
int width,
int height,
@@ -80,71 +58,12 @@
return bitmap;
}
-void SetURLAndDragImage(const GURL& url,
- const std::wstring& title,
- const SkBitmap& icon,
- OSExchangeData* data) {
- DCHECK(url.is_valid() && data);
-
- data->SetURL(url, title);
-
- // Create a button to render the drag image for us.
- views::TextButton button(NULL,
- title.empty() ? UTF8ToWide(url.spec()) : title);
- button.set_max_width(kLinkDragImageMaxWidth);
- if (icon.isNull()) {
- button.SetIcon(*ResourceBundle::GetSharedInstance().GetBitmapNamed(
- IDR_DEFAULT_FAVICON));
- } else {
- button.SetIcon(icon);
- }
- gfx::Size prefsize = button.GetPreferredSize();
- button.SetBounds(0, 0, prefsize.width(), prefsize.height());
-
- // Render the image.
- gfx::Canvas canvas(prefsize.width(), prefsize.height(), false);
- button.Paint(&canvas, true);
- SetDragImageOnDataObject(canvas, prefsize.width(), prefsize.height(),
- prefsize.width() / 2, prefsize.height() / 2,
- data);
-}
-
-void CreateDragImageForFile(const std::wstring& file_name,
- SkBitmap* icon,
- IDataObject* data_object) {
- DCHECK(icon);
- DCHECK(data_object);
-
- // Set up our text portion
- const std::wstring& name = file_util::GetFilenameFromPath(file_name);
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- gfx::Font font = rb.GetFont(ResourceBundle::BaseFont);
-
- const int width = kFileDragImageMaxWidth;
- // Add +2 here to allow room for the halo.
- const int height = font.height() + icon->height() +
- kLinkDragImageVPadding + 2;
- gfx::Canvas canvas(width, height, false /* translucent */);
-
- // Paint the icon.
- canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0);
-
- // Paint the file name. We inset it one pixel to allow room for the halo.
- canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE,
- 1, icon->height() + kLinkDragImageVPadding + 1,
- width - 2, font.height(),
- gfx::Canvas::TEXT_ALIGN_CENTER);
-
- SetDragImageOnDataObject(canvas, width, height, width / 2,
- kLinkDragImageVPadding, data_object);
-}
-
void SetDragImageOnDataObject(const gfx::Canvas& canvas,
int width,
int height,
int cursor_x_offset,
int cursor_y_offset,
- IDataObject* data_object) {
+ OSExchangeData* data_object) {
DCHECK(data_object && width > 0 && height > 0);
// SetDragImageOnDataObject(HBITMAP) takes ownership of the bitmap.
HBITMAP bitmap = CreateBitmapFromCanvas(canvas, width, height);
« views/drag_utils_gtk.cc ('K') | « views/drag_utils_gtk.cc ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698