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

Side by Side Diff: ui/views/button_drag_utils.cc

Issue 2649133008: Remove another use of old CreateShadowDrawLooper. (Closed)
Patch Set: Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 : title); 51 : title);
52 button.SetTextSubpixelRenderingEnabled(false); 52 button.SetTextSubpixelRenderingEnabled(false);
53 const ui::NativeTheme* theme = widget->GetNativeTheme(); 53 const ui::NativeTheme* theme = widget->GetNativeTheme();
54 button.SetTextColor(views::Button::STATE_NORMAL, 54 button.SetTextColor(views::Button::STATE_NORMAL,
55 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor)); 55 theme->GetSystemColor(ui::NativeTheme::kColorId_TextfieldDefaultColor));
56 56
57 SkColor bg_color = theme->GetSystemColor( 57 SkColor bg_color = theme->GetSystemColor(
58 ui::NativeTheme::kColorId_TextfieldDefaultBackground); 58 ui::NativeTheme::kColorId_TextfieldDefaultBackground);
59 if (widget->IsTranslucentWindowOpacitySupported()) { 59 if (widget->IsTranslucentWindowOpacitySupported()) {
60 button.SetTextShadows(gfx::ShadowValues( 60 button.SetTextShadows(gfx::ShadowValues(
61 10, gfx::ShadowValue(gfx::Vector2d(0, 0), 1.0f, bg_color))); 61 10, gfx::ShadowValue(gfx::Vector2d(0, 0), 2.0f, bg_color)));
62 } else { 62 } else {
63 button.set_background(views::Background::CreateSolidBackground(bg_color)); 63 button.set_background(views::Background::CreateSolidBackground(bg_color));
64 button.SetBorder(button.CreateDefaultBorder()); 64 button.SetBorder(button.CreateDefaultBorder());
65 } 65 }
66 button.SetMaxSize(gfx::Size(kLinkDragImageMaxWidth, 0)); 66 button.SetMaxSize(gfx::Size(kLinkDragImageMaxWidth, 0));
67 if (icon.isNull()) { 67 if (icon.isNull()) {
68 button.SetImage(views::Button::STATE_NORMAL, 68 button.SetImage(views::Button::STATE_NORMAL,
69 *ui::ResourceBundle::GetSharedInstance().GetImageNamed( 69 *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
70 IDR_DEFAULT_FAVICON).ToImageSkia()); 70 IDR_DEFAULT_FAVICON).ToImageSkia());
71 } else { 71 } else {
72 button.SetImage(views::Button::STATE_NORMAL, icon); 72 button.SetImage(views::Button::STATE_NORMAL, icon);
73 } 73 }
74 gfx::Size prefsize = button.GetPreferredSize(); 74 gfx::Size prefsize = button.GetPreferredSize();
75 button.SetBounds(0, 0, prefsize.width(), prefsize.height()); 75 button.SetBounds(0, 0, prefsize.width(), prefsize.height());
76 76
77 gfx::Vector2d press_point; 77 gfx::Vector2d press_point;
78 if (press_pt) 78 if (press_pt)
79 press_point = press_pt->OffsetFromOrigin(); 79 press_point = press_pt->OffsetFromOrigin();
80 else 80 else
81 press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2); 81 press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2);
82 82
83 // Render the image. 83 // Render the image.
84 std::unique_ptr<gfx::Canvas> canvas( 84 std::unique_ptr<gfx::Canvas> canvas(
85 views::GetCanvasForDragImage(widget, prefsize)); 85 views::GetCanvasForDragImage(widget, prefsize));
86 button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context()); 86 button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context());
87 drag_utils::SetDragImageOnDataObject(*canvas, press_point, data); 87 drag_utils::SetDragImageOnDataObject(*canvas, press_point, data);
88 } 88 }
89 89
90 } // namespace button_drag_utils 90 } // namespace button_drag_utils
OLDNEW
« no previous file with comments | « ui/gfx/render_text.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698