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

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

Issue 14735009: mac: Minor tweaks to notifications code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: tweak text metrics Created 7 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
« no previous file with comments | « no previous file | ui/message_center/cocoa/popup_collection.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 202e5244d53a4d520df8ab6741a89418329bee0e..0483905e9d9293292c0827bfb4f60148bcca12cb 100644
--- a/ui/message_center/cocoa/notification_controller.mm
+++ b/ui/message_center/cocoa/notification_controller.mm
@@ -14,13 +14,6 @@
#include "ui/message_center/message_center_constants.h"
#include "ui/message_center/notification.h"
-namespace {
-
-// Compensates for padding already provided by UI elements involved.
-const int kTextTopPaddingAdjustment = -6;
-
-} // namespace
-
@interface MCNotificationController (Private)
// Configures a NSBox to be borderless, titleless, and otherwise appearance-
// free.
@@ -100,27 +93,36 @@ const int kTextTopPaddingAdjustment = -6;
// Update the icon.
[icon_ setImage:notification_->icon().AsNSImage()];
+ // The message_center:: constants are relative to capHeight at the top and
+ // relative to the baseline at the bottom, but NSTextField uses the full line
+ // height for its height.
+ CGFloat titleTopGap = [[title_ font] ascender] - [[title_ font] capHeight];
+ CGFloat titleBottomGap = fabs([[title_ font] descender]);
+ CGFloat titlePadding = message_center::kTextTopPadding - titleTopGap;
+
+ CGFloat messageTopGap =
+ [[message_ font] ascender] - [[message_ font] capHeight];
+ CGFloat messagePadding =
+ message_center::kTextTopPadding - titleBottomGap - messageTopGap;
+
// Set the title and recalculate the frame.
[title_ setStringValue:base::SysUTF16ToNSString(notification_->title())];
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title_];
NSRect titleFrame = [title_ frame];
- titleFrame.origin.y = NSMaxY(rootFrame) - message_center::kTextTopPadding -
- NSHeight(titleFrame);
+ titleFrame.origin.y = NSMaxY(rootFrame) - titlePadding - NSHeight(titleFrame);
// Set the message and recalculate the frame.
[message_ setStringValue:base::SysUTF16ToNSString(notification_->message())];
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:message_];
NSRect messageFrame = [message_ frame];
- messageFrame.origin.y = NSMinY(titleFrame) - message_center::kTextTopPadding -
- NSHeight(messageFrame);
+ messageFrame.origin.y =
+ NSMinY(titleFrame) - messagePadding - NSHeight(messageFrame);
messageFrame.size.height = NSHeight([message_ frame]);
// In this basic notification UI, the message body is the bottom-most
// vertical element. If it is out of the rootView's bounds, resize the view.
- if (NSMinY(messageFrame) <
- message_center::kTextTopPadding + kTextTopPaddingAdjustment) {
- CGFloat delta = message_center::kTextTopPadding +
- kTextTopPaddingAdjustment - NSMinY(messageFrame);
+ if (NSMinY(messageFrame) < messagePadding) {
+ CGFloat delta = messagePadding - NSMinY(messageFrame);
rootFrame.size.height += delta;
titleFrame.origin.y += delta;
messageFrame.origin.y += delta;
« no previous file with comments | « no previous file | ui/message_center/cocoa/popup_collection.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698