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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/base/dragdrop/drag_utils.h" | 10 #include "ui/base/dragdrop/drag_utils.h" |
11 #include "ui/base/dragdrop/os_exchange_data.h" | 11 #include "ui/base/dragdrop/os_exchange_data.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/gfx/canvas_skia.h" | 13 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
15 #include "ui/views/controls/button/text_button.h" | 15 #include "ui/views/controls/button/text_button.h" |
16 | 16 |
17 namespace button_drag_utils { | 17 namespace button_drag_utils { |
18 | 18 |
19 // Maximum width of the link drag image in pixels. | 19 // Maximum width of the link drag image in pixels. |
20 static const int kLinkDragImageMaxWidth = 200; | 20 static const int kLinkDragImageMaxWidth = 200; |
21 | 21 |
22 void SetURLAndDragImage(const GURL& url, | 22 void SetURLAndDragImage(const GURL& url, |
23 const string16& title, | 23 const string16& title, |
(...skipping 10 matching lines...) Expand all Loading... |
34 if (icon.isNull()) { | 34 if (icon.isNull()) { |
35 button.SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 35 button.SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
36 IDR_DEFAULT_FAVICON).ToSkBitmap()); | 36 IDR_DEFAULT_FAVICON).ToSkBitmap()); |
37 } else { | 37 } else { |
38 button.SetIcon(icon); | 38 button.SetIcon(icon); |
39 } | 39 } |
40 gfx::Size prefsize = button.GetPreferredSize(); | 40 gfx::Size prefsize = button.GetPreferredSize(); |
41 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); | 41 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); |
42 | 42 |
43 // Render the image. | 43 // Render the image. |
44 gfx::CanvasSkia canvas(prefsize, false); | 44 gfx::Canvas canvas(prefsize, false); |
45 button.PaintButton(&canvas, views::TextButton::PB_FOR_DRAG); | 45 button.PaintButton(&canvas, views::TextButton::PB_FOR_DRAG); |
46 drag_utils::SetDragImageOnDataObject(canvas, prefsize, | 46 drag_utils::SetDragImageOnDataObject(canvas, prefsize, |
47 gfx::Point(prefsize.width() / 2, prefsize.height() / 2), data); | 47 gfx::Point(prefsize.width() / 2, prefsize.height() / 2), data); |
48 } | 48 } |
49 | 49 |
50 } // namespace button_drag_utils | 50 } // namespace button_drag_utils |
OLD | NEW |