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

Unified Diff: ui/message_center/cocoa/notification_controller.mm

Issue 149433005: Adds a small icon to notifications, and connects it to synced notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits Created 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/message_center/cocoa/notification_controller.mm
diff --git a/ui/message_center/cocoa/notification_controller.mm b/ui/message_center/cocoa/notification_controller.mm
index ade983f15f817b173d31b062c83b7056a4f20009..367d957c8856434a555b00293f05eb1915133f34 100644
--- a/ui/message_center/cocoa/notification_controller.mm
+++ b/ui/message_center/cocoa/notification_controller.mm
@@ -200,11 +200,14 @@
// Creates a box that shows a border when the icon is not big enough to fill the
// space.
-- (NSBox*)createImageBox;
+- (NSBox*)createImageBox:(const gfx::Image&)notificationImage;
// Initializes the closeButton_ ivar with the configured button.
- (void)configureCloseButtonInFrame:(NSRect)rootFrame;
+// Initializes the smallImage_ ivar with the appropriate frame.
+- (void)configureSmallImageInFrame:(NSRect)rootFrame;
+
// Initializes title_ in the given frame.
- (void)configureTitleInFrame:(NSRect)rootFrame;
@@ -229,7 +232,7 @@
// it is too long.
- (base::string16)wrapText:(const base::string16&)text
forFont:(NSFont*)font
- maxNumberOfLines:(size_t)lines;
+ maxNumberOfLines:(size_t)lines;
@end
////////////////////////////////////////////////////////////////////////////////
@@ -264,6 +267,9 @@
[self configureCloseButtonInFrame:rootFrame];
[rootView addSubview:closeButton_];
+ [self configureSmallImageInFrame:rootFrame];
+ [[self view] addSubview:smallImage_];
+
// Create the title.
[self configureTitleInFrame:rootFrame];
[rootView addSubview:title_];
@@ -288,6 +294,8 @@
message_center::kNotificationPreferredImageWidth,
message_center::kNotificationIconSize);
+ [smallImage_ setImage:notification_->small_image().AsNSImage()];
+
// Update the icon.
[icon_ setImage:notification_->icon().AsNSImage()];
@@ -607,7 +615,7 @@
return imageBox.autorelease();
}
-- (NSBox*)createImageBox:(gfx::Image)notificationImage {
+- (NSBox*)createImageBox:(const gfx::Image&)notificationImage {
using message_center::kNotificationImageBorderSize;
using message_center::kNotificationPreferredImageWidth;
using message_center::kNotificationPreferredImageHeight;
@@ -643,11 +651,15 @@
}
- (void)configureCloseButtonInFrame:(NSRect)rootFrame {
- closeButton_.reset([[HoverImageButton alloc] initWithFrame:NSMakeRect(
- NSMaxX(rootFrame) - message_center::kControlButtonSize,
- NSMaxY(rootFrame) - message_center::kControlButtonSize,
- message_center::kControlButtonSize,
- message_center::kControlButtonSize)]);
+ // The close button is configured to be the same size as the small image.
+ int closeButtonOriginOffset =
+ message_center::kSmallImageSize + message_center::kSmallImagePadding;
+ NSRect closeButtonFrame =
+ NSMakeRect(NSMaxX(rootFrame) - closeButtonOriginOffset,
+ NSMaxY(rootFrame) - closeButtonOriginOffset,
+ message_center::kSmallImageSize,
+ message_center::kSmallImageSize);
+ closeButton_.reset([[HoverImageButton alloc] initWithFrame:closeButtonFrame]);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
[closeButton_ setDefaultImage:
rb.GetNativeImageNamed(IDR_NOTIFICATION_CLOSE).ToNSImage()];
@@ -670,6 +682,19 @@
forAttribute:NSAccessibilityTitleAttribute];
}
+- (void)configureSmallImageInFrame:(NSRect)rootFrame {
+ int smallImageXOffset =
+ message_center::kSmallImagePadding + message_center::kSmallImageSize;
+ NSRect smallImageFrame =
+ NSMakeRect(NSMaxX(rootFrame) - smallImageXOffset,
+ NSMinY(rootFrame) + message_center::kSmallImagePadding,
+ message_center::kSmallImageSize,
+ message_center::kSmallImageSize);
+ smallImage_.reset([[NSImageView alloc] initWithFrame:smallImageFrame]);
+ [smallImage_ setImageScaling:NSImageScaleProportionallyUpOrDown];
+ [smallImage_ setAutoresizingMask:NSViewMinYMargin];
+}
+
- (void)configureTitleInFrame:(NSRect)rootFrame {
NSRect frame = [self currentContentRect];
frame.size.height = 0;

Powered by Google App Engine
This is Rietveld 408576698