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

Side by Side Diff: ui/message_center/cocoa/notification_controller.mm

Issue 13560002: Added padding below text in notifications. (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "ui/message_center/cocoa/notification_controller.h" 5 #import "ui/message_center/cocoa/notification_controller.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "skia/ext/skia_utils_mac.h" 9 #include "skia/ext/skia_utils_mac.h"
10 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 10 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Create the title. 72 // Create the title.
73 [self configureTitleInFrame:rootFrame]; 73 [self configureTitleInFrame:rootFrame];
74 [rootView addSubview:title_]; 74 [rootView addSubview:title_];
75 75
76 // Create the message body. 76 // Create the message body.
77 [self configureBodyInFrame:rootFrame maxY:NSMinY([title_ frame])]; 77 [self configureBodyInFrame:rootFrame maxY:NSMinY([title_ frame])];
78 [rootView addSubview:message_]; 78 [rootView addSubview:message_];
79 79
80 // In this basic notification UI, the message body is the bottom-most 80 // In this basic notification UI, the message body is the bottom-most
81 // vertical element. If it is out of the rootView's bounds, resize the view. 81 // vertical element. If it is out of the rootView's bounds, resize the view.
82 if (NSMinY([message_ frame]) < message_center::kTextTopPadding) { 82 if (NSMinY([message_ frame]) < message_center::kTextTopPadding - 6) {
83 rootFrame.size.height += message_center::kTextTopPadding - 83 rootFrame.size.height += message_center::kTextTopPadding - 6 -
84 NSMinY([message_ frame]); 84 NSMinY([message_ frame]);
85 } 85 }
86 86
87 [rootView setFrame:rootFrame]; 87 [rootView setFrame:rootFrame];
88 } 88 }
89 89
90 - (void)close:(id)sender { 90 - (void)close:(id)sender {
91 observer_->OnRemoveNotification(notification_->id(), /*by_user=*/true); 91 observer_->OnRemoveNotification(notification_->id(), /*by_user=*/true);
92 } 92 }
93 93
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 NSRect frame = [self currentContentRect]; 152 NSRect frame = [self currentContentRect];
153 153
154 title_.reset([self newLabelWithFrame:NSMakeRect(0, 0, NSWidth(frame), 0)]); 154 title_.reset([self newLabelWithFrame:NSMakeRect(0, 0, NSWidth(frame), 0)]);
155 [title_ setAutoresizingMask:NSViewMinYMargin]; 155 [title_ setAutoresizingMask:NSViewMinYMargin];
156 [title_ setStringValue:base::SysUTF16ToNSString(notification_->title())]; 156 [title_ setStringValue:base::SysUTF16ToNSString(notification_->title())];
157 [title_ setFont:[NSFont messageFontOfSize:message_center::kTitleFontSize]]; 157 [title_ setFont:[NSFont messageFontOfSize:message_center::kTitleFontSize]];
158 158
159 CGFloat delta = 159 CGFloat delta =
160 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title_]; 160 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title_];
161 frame.size.height = delta; 161 frame.size.height = delta;
162 frame.origin.y = NSMaxY(rootFrame) - message_center::kTextTopPadding - delta; 162 frame.origin.y = NSMaxY(rootFrame) - message_center::kTextTopPadding - 6 -
163 delta;
163 [title_ setFrame:frame]; 164 [title_ setFrame:frame];
164 } 165 }
165 166
166 - (void)configureBodyInFrame:(NSRect)rootFrame maxY:(CGFloat)maxY { 167 - (void)configureBodyInFrame:(NSRect)rootFrame maxY:(CGFloat)maxY {
167 NSRect frame = [self currentContentRect]; 168 NSRect frame = [self currentContentRect];
168 169
169 message_.reset([self newLabelWithFrame:NSMakeRect(0, 0, NSWidth(frame), 0)]); 170 message_.reset([self newLabelWithFrame:NSMakeRect(0, 0, NSWidth(frame), 0)]);
170 [message_ setAutoresizingMask:NSViewMinYMargin]; 171 [message_ setAutoresizingMask:NSViewMinYMargin];
171 [message_ setStringValue:base::SysUTF16ToNSString(notification_->message())]; 172 [message_ setStringValue:base::SysUTF16ToNSString(notification_->message())];
172 [message_ setFont: 173 [message_ setFont:
173 [NSFont messageFontOfSize:message_center::kMessageFontSize]]; 174 [NSFont messageFontOfSize:message_center::kMessageFontSize]];
174 175
175 CGFloat delta = 176 CGFloat delta =
176 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:message_]; 177 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:message_];
177 frame.size.height = delta; 178 frame.size.height = delta;
178 frame.origin.y = maxY - message_center::kTextTopPadding - delta; 179 frame.origin.y = maxY - message_center::kTextTopPadding - 6 - delta;
179 [message_ setFrame:frame]; 180 [message_ setFrame:frame];
180 } 181 }
181 182
182 - (NSTextField*)newLabelWithFrame:(NSRect)frame { 183 - (NSTextField*)newLabelWithFrame:(NSRect)frame {
183 NSTextField* label = [[NSTextField alloc] initWithFrame:frame]; 184 NSTextField* label = [[NSTextField alloc] initWithFrame:frame];
184 [label setDrawsBackground:NO]; 185 [label setDrawsBackground:NO];
185 [label setBezeled:NO]; 186 [label setBezeled:NO];
186 [label setEditable:NO]; 187 [label setEditable:NO];
187 [label setSelectable:NO]; 188 [label setSelectable:NO];
188 [label setTextColor:gfx::SkColorToCalibratedNSColor( 189 [label setTextColor:gfx::SkColorToCalibratedNSColor(
189 message_center::kRegularTextColor)]; 190 message_center::kRegularTextColor)];
190 return label; 191 return label;
191 } 192 }
192 193
193 - (NSRect)currentContentRect { 194 - (NSRect)currentContentRect {
194 DCHECK(icon_); 195 DCHECK(icon_);
195 DCHECK(closeButton_); 196 DCHECK(closeButton_);
196 197
197 NSRect iconFrame, contentFrame; 198 NSRect iconFrame, contentFrame;
198 NSDivideRect([[self view] bounds], &iconFrame, &contentFrame, 199 NSDivideRect([[self view] bounds], &iconFrame, &contentFrame,
199 NSWidth([icon_ frame]) + message_center::kIconToTextPadding, 200 NSWidth([icon_ frame]) + message_center::kIconToTextPadding,
200 NSMinXEdge); 201 NSMinXEdge);
201 contentFrame.size.width -= NSWidth([closeButton_ frame]); 202 contentFrame.size.width -= NSWidth([closeButton_ frame]);
202 return contentFrame; 203 return contentFrame;
203 } 204 }
204 205
205 @end 206 @end
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/message_center_constants.cc » ('j') | ui/message_center/message_center_constants.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698