summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-27 19:12:31 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-27 19:12:31 +0000
commitcbb79e16a8a4e926d765cd119381a260e0c6e3a9 (patch)
treebefc212bf931fcdce896dbe35d4e508372f73282
parent1c0fb257023da8f7cb1b8d734b5873dd9eadc8bc (diff)
downloadchromium_src-cbb79e16a8a4e926d765cd119381a260e0c6e3a9.zip
chromium_src-cbb79e16a8a4e926d765cd119381a260e0c6e3a9.tar.gz
chromium_src-cbb79e16a8a4e926d765cd119381a260e0c6e3a9.tar.bz2
Render drag images with LabelButton.
Replaces one of the last remaining TextButton instances. Uses a blurred shadow on the text instead of a halo. Uses theme colors instead of forced black/white. See before/after pics at http://crbug.com/155363#c121 BUG=155363 TEST=Bookmark/URL drag images look okay. R=sky@chromium.org Review URL: https://codereview.chromium.org/356833011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280376 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ui/views/button_drag_utils.cc28
1 files changed, 19 insertions, 9 deletions
diff --git a/ui/views/button_drag_utils.cc b/ui/views/button_drag_utils.cc
index 2c4f25a..59a1a4a 100644
--- a/ui/views/button_drag_utils.cc
+++ b/ui/views/button_drag_utils.cc
@@ -12,8 +12,9 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/image/image.h"
-#include "ui/views/controls/button/text_button.h"
+#include "ui/views/controls/button/label_button.h"
#include "ui/views/drag_utils.h"
+#include "ui/views/widget/widget.h"
#include "url/gurl.h"
namespace button_drag_utils {
@@ -39,15 +40,24 @@ void SetDragImage(const GURL& url,
ui::OSExchangeData* data,
views::Widget* widget) {
// Create a button to render the drag image for us.
- views::TextButton button(NULL,
- title.empty() ? base::UTF8ToUTF16(url.spec())
- : title);
- button.set_max_width(kLinkDragImageMaxWidth);
+ views::LabelButton button(NULL,
+ title.empty() ? base::UTF8ToUTF16(url.spec())
+ : title);
+ button.SetTextSubpixelRenderingEnabled(false);
+ const ui::NativeTheme* theme =
+ widget ? widget->GetNativeTheme() : ui::NativeTheme::instance();
+ button.SetTextColor(views::Button::STATE_NORMAL,
+ theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonEnabledColor));
+ gfx::ShadowValues shadows(10, gfx::ShadowValue(gfx::Point(0,0), 1.0f,
+ theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonBackgroundColor)));
+ button.SetTextShadows(shadows);
+ button.set_max_size(gfx::Size(kLinkDragImageMaxWidth, 0));
if (icon.isNull()) {
- button.SetIcon(*ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_DEFAULT_FAVICON).ToImageSkia());
+ button.SetImage(views::Button::STATE_NORMAL,
+ *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
+ IDR_DEFAULT_FAVICON).ToImageSkia());
} else {
- button.SetIcon(icon);
+ button.SetImage(views::Button::STATE_NORMAL, icon);
}
gfx::Size prefsize = button.GetPreferredSize();
button.SetBounds(0, 0, prefsize.width(), prefsize.height());
@@ -61,7 +71,7 @@ void SetDragImage(const GURL& url,
// Render the image.
scoped_ptr<gfx::Canvas> canvas(
views::GetCanvasForDragImage(widget, prefsize));
- button.PaintButton(canvas.get(), views::TextButton::PB_FOR_DRAG);
+ button.Paint(canvas.get(), views::CullSet());
drag_utils::SetDragImageOnDataObject(*canvas, press_point, data);
}