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

Unified Diff: chrome/browser/ui/views/message_center/web_notification_tray_win.cc

Issue 14192025: Update message center systray icon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/message_center/web_notification_tray_win.cc
diff --git a/chrome/browser/ui/views/message_center/web_notification_tray_win.cc b/chrome/browser/ui/views/message_center/web_notification_tray_win.cc
index 0db887f058a9cf26ed9f09828e712735ce80b3d6..acc5a4b9e301a652b2ac4acc4d32e374433e4aef 100644
--- a/chrome/browser/ui/views/message_center/web_notification_tray_win.cc
+++ b/chrome/browser/ui/views/message_center/web_notification_tray_win.cc
@@ -19,8 +19,11 @@
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/win/hwnd_util.h"
+#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/rect.h"
#include "ui/gfx/screen.h"
+#include "ui/gfx/size.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_tray_delegate.h"
#include "ui/message_center/views/message_bubble_base.h"
@@ -33,6 +36,10 @@ namespace {
// Tray constants
const int kScreenEdgePadding = 2;
+const int kSystemTrayWidth = 16;
+const int kSystemTrayHeight = 16;
+const int kNumberOfSystemTraySprites = 10;
+
gfx::Rect GetCornerAnchorRect() {
// TODO(dewittj): Use the preference to determine which corner to anchor from.
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
@@ -72,12 +79,36 @@ gfx::Rect GetMouseAnchorRect(gfx::Point cursor) {
return mouse_anchor_rect;
}
-gfx::ImageSkia GetIcon(bool has_unread) {
+gfx::ImageSkia GetIcon(int unread_count) {
+ bool has_unread = unread_count > 0;
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- gfx::ImageSkia* icon = rb.GetImageSkiaNamed(
- has_unread ? IDR_NOTIFICATION_TRAY_LIT : IDR_NOTIFICATION_TRAY_DIM);
- DCHECK(icon);
- return *icon;
+ if (!has_unread)
+ return *rb.GetImageSkiaNamed(IDR_NOTIFICATION_TRAY_DIM);
Jun Mukai 2013/04/19 19:00:50 Do we use DIM for the default icon? not LIT? Bette
dewittj 2013/04/19 22:10:28 I had the correct icon, but didn't change the name
+
+ // TODO(dewittj): Use scale factors other than 100P.
+ scoped_ptr<gfx::Canvas> canvas(new gfx::Canvas(
+ gfx::Size(kSystemTrayWidth, kSystemTrayHeight),
+ ui::SCALE_FACTOR_100P,
+ false));
+
+ // Draw the attention-grabbing background image.
+ canvas->DrawImageInt(*rb.GetImageSkiaNamed(IDR_NOTIFICATION_TRAY_LIT), 0, 0);
+
+ // |numbers| is a sprite map with the image of a number from 1-9 and 9+. They
+ // are arranged horizontally, and have a transparent background.
+ gfx::ImageSkia* numbers = rb.GetImageSkiaNamed(IDR_NOTIFICATION_TRAY_NUMBERS);
+
+ // Assume that the last sprite is the catch-all for higher numbers of
+ // notifications.
+ int effective_unread = std::min(unread_count, kNumberOfSystemTraySprites);
+ int x_offset = (effective_unread - 1) * kSystemTrayWidth;
+
+ canvas->DrawImageInt(*numbers,
+ x_offset, 0, kSystemTrayWidth, kSystemTrayHeight,
+ 0, 0, kSystemTrayWidth, kSystemTrayHeight,
+ false);
+
+ return gfx::ImageSkia(canvas->ExtractImageRep());
}
} // namespace
@@ -213,7 +244,7 @@ gfx::NativeView WebNotificationTrayWin::GetBubbleWindowContainer() {
void WebNotificationTrayWin::UpdateStatusIcon() {
int unread_notifications = message_center()->UnreadNotificationCount();
- status_icon_->SetImage(GetIcon(unread_notifications > 0));
+ status_icon_->SetImage(GetIcon(unread_notifications));
string16 product_name(l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME));
if (unread_notifications > 0) {
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698