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

Unified Diff: ash/shelf/app_list_button.cc

Issue 2002293002: Use vector icon for Ash shelf launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove include Created 4 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: ash/shelf/app_list_button.cc
diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc
index a57e12378802c6ebd7720ab4f09aae6c80058aa8..62a73eb99779e8b0ae12b6dd020ee1c21d2bfd3c 100644
--- a/ash/shelf/app_list_button.cc
+++ b/ash/shelf/app_list_button.cc
@@ -19,8 +19,20 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icons_public.h"
#include "ui/views/painter.h"
+namespace {
+// Width and height of the launcher icon, which includes 2px of internal
+// padding at each side.
+const int kLauncherIconSize = 18;
tdanderson 2016/05/23 21:18:24 So if I remember our conversation correctly, the v
Evan Stade 2016/05/23 22:11:57 Overall, yes. One way to add to the padding would
+
+// Color of the launcher icon.
+// TODO(tdanderson): Move Ash color constants to a common location.
+const SkColor kLauncherIconColor = SK_ColorWHITE;
+} // namespace
+
namespace ash {
AppListButton::AppListButton(ShelfView* shelf_view)
@@ -109,19 +121,17 @@ void AppListButton::OnPaint(gfx::Canvas* canvas) {
else
background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL;
}
+
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
const gfx::ImageSkia* background_image =
rb.GetImageNamed(background_image_id).ToImageSkia();
- // TODO(mgiuca): When the "classic" app list is removed, also remove this
- // resource and its icon file.
- int foreground_image_id = app_list::switches::IsExperimentalAppListEnabled()
- ? IDR_ASH_SHELF_ICON_APPLIST
- : IDR_ASH_SHELF_ICON_APPLIST_CLASSIC;
- const gfx::ImageSkia* forground_image =
- rb.GetImageNamed(foreground_image_id).ToImageSkia();
+
+ const gfx::ImageSkia& foreground_image =
+ gfx::CreateVectorIcon(gfx::VectorIconId::SEARCH,
+ kLauncherIconSize, kLauncherIconColor);
gfx::Rect contents_bounds = GetContentsBounds();
- gfx::Rect background_bounds, forground_bounds;
+ gfx::Rect background_bounds, foreground_bounds;
wm::ShelfAlignment alignment = shelf_view_->shelf()->alignment();
background_bounds.set_size(background_image->size());
@@ -140,20 +150,20 @@ void AppListButton::OnPaint(gfx::Canvas* canvas) {
(contents_bounds.width() - background_image->width()) / 2);
}
- forground_bounds.set_size(forground_image->size());
- forground_bounds.set_x(background_bounds.x() +
+ foreground_bounds.set_size(foreground_image.size());
+ foreground_bounds.set_x(background_bounds.x() +
std::max(0,
- (background_bounds.width() - forground_bounds.width()) / 2));
- forground_bounds.set_y(background_bounds.y() +
+ (background_bounds.width() - foreground_bounds.width()) / 2));
+ foreground_bounds.set_y(background_bounds.y() +
std::max(0,
- (background_bounds.height() - forground_bounds.height()) / 2));
+ (background_bounds.height() - foreground_bounds.height()) / 2));
canvas->DrawImageInt(*background_image,
background_bounds.x(),
background_bounds.y());
- canvas->DrawImageInt(*forground_image,
- forground_bounds.x(),
- forground_bounds.y());
+ canvas->DrawImageInt(foreground_image,
+ foreground_bounds.x(),
+ foreground_bounds.y());
views::Painter::PaintFocusPainter(this, canvas, focus_painter());
}

Powered by Google App Engine
This is Rietveld 408576698