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 25 matching lines...) Expand all Loading... |
36 SetDragImage(url, title, icon, press_pt, data, widget); | 36 SetDragImage(url, title, icon, press_pt, data, widget); |
37 } | 37 } |
38 | 38 |
39 void SetDragImage(const GURL& url, | 39 void SetDragImage(const GURL& url, |
40 const base::string16& title, | 40 const base::string16& title, |
41 const gfx::ImageSkia& icon, | 41 const gfx::ImageSkia& icon, |
42 const gfx::Point* press_pt, | 42 const gfx::Point* press_pt, |
43 ui::OSExchangeData* data, | 43 ui::OSExchangeData* data, |
44 views::Widget* widget) { | 44 views::Widget* widget) { |
45 // Create a button to render the drag image for us. | 45 // Create a button to render the drag image for us. |
46 views::LabelButton button(NULL, | 46 views::LabelButton button(nullptr); |
47 title.empty() ? base::UTF8ToUTF16(url.spec()) | 47 button.InitAsTextbutton(title.empty() ? base::UTF8ToUTF16(url.spec()) |
48 : title); | 48 : title); |
49 button.SetTextSubpixelRenderingEnabled(false); | 49 button.SetTextSubpixelRenderingEnabled(false); |
50 const ui::NativeTheme* theme = | 50 const ui::NativeTheme* theme = |
51 widget ? widget->GetNativeTheme() : ui::NativeTheme::instance(); | 51 widget ? widget->GetNativeTheme() : ui::NativeTheme::instance(); |
52 button.SetTextColor(views::Button::STATE_NORMAL, | 52 button.SetTextColor(views::Button::STATE_NORMAL, |
53 theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor)); | 53 theme->GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor)); |
54 gfx::ShadowValues shadows( | 54 gfx::ShadowValues shadows( |
55 10, | 55 10, |
56 gfx::ShadowValue(gfx::Vector2d(0, 0), 1.0f, | 56 gfx::ShadowValue(gfx::Vector2d(0, 0), 1.0f, |
57 theme->GetSystemColor( | 57 theme->GetSystemColor( |
58 ui::NativeTheme::kColorId_LabelBackgroundColor))); | 58 ui::NativeTheme::kColorId_LabelBackgroundColor))); |
(...skipping 16 matching lines...) Expand all Loading... |
75 press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2); | 75 press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2); |
76 | 76 |
77 // Render the image. | 77 // Render the image. |
78 scoped_ptr<gfx::Canvas> canvas( | 78 scoped_ptr<gfx::Canvas> canvas( |
79 views::GetCanvasForDragImage(widget, prefsize)); | 79 views::GetCanvasForDragImage(widget, prefsize)); |
80 button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context()); | 80 button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context()); |
81 drag_utils::SetDragImageOnDataObject(*canvas, press_point, data); | 81 drag_utils::SetDragImageOnDataObject(*canvas, press_point, data); |
82 } | 82 } |
83 | 83 |
84 } // namespace button_drag_utils | 84 } // namespace button_drag_utils |
OLD | NEW |