 Chromium Code Reviews
 Chromium Code Reviews Issue 240703004:
  Fix the remaining subpixel antialiasing bugs in the notification center.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 240703004:
  Fix the remaining subpixel antialiasing bugs in the notification center.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/settings_entry_view.h" | 5 #import "ui/message_center/cocoa/settings_entry_view.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 | 8 | 
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" | 
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 | 48 | 
| 49 // The amount of space we want, based on the spec and the intrinsic text space | 49 // The amount of space we want, based on the spec and the intrinsic text space | 
| 50 // included by Cocoa. | 50 // included by Cocoa. | 
| 51 const int kCorrectedIconTextPadding = | 51 const int kCorrectedIconTextPadding = | 
| 52 kInternalHorizontalSpacing - kIntrinsicTextLeftPadding; | 52 kInternalHorizontalSpacing - kIntrinsicTextLeftPadding; | 
| 53 | 53 | 
| 54 // We want a certain amount of space to the right of the learn more button, | 54 // We want a certain amount of space to the right of the learn more button, | 
| 55 // this metric incorporates the intrinsic learn more blank space to compute it. | 55 // this metric incorporates the intrinsic learn more blank space to compute it. | 
| 56 const int kCorrectedEntryRightPadding = | 56 const int kCorrectedEntryRightPadding = | 
| 57 kInternalHorizontalSpacing - kIntrinsicLearnMorePadding; | 57 kInternalHorizontalSpacing - kIntrinsicLearnMorePadding; | 
| 58 //////////////////////////////////////////////////////////////////////////////// | |
| 
Robert Sesek
2014/04/17 13:31:51
nit: blank lines around
 
dewittj
2014/04/17 16:58:57
Done.
 | |
| 59 @interface MCSettingsButton : NSButton | |
| 60 @end | |
| 61 | |
| 62 @implementation MCSettingsButton | |
| 63 // drawRect: needs to fill the button with a background, otherwise we don't get | |
| 64 // subpixel antialiasing. | |
| 65 - (void)drawRect:(NSRect)dirtyRect { | |
| 66 NSColor* color = gfx::SkColorToCalibratedNSColor( | |
| 67 message_center::kMessageCenterBackgroundColor); | |
| 68 [color set]; | |
| 69 NSRectFill(dirtyRect); | |
| 70 [super drawRect:dirtyRect]; | |
| 71 } | |
| 72 @end | |
| 58 | 73 | 
| 59 @interface MCSettingsButtonCell : NSButtonCell { | 74 @interface MCSettingsButtonCell : NSButtonCell { | 
| 60 // A checkbox's regular image is the checkmark image. This additional image | 75 // A checkbox's regular image is the checkmark image. This additional image | 
| 61 // is used for the favicon or app icon shown next to the checkmark. | 76 // is used for the favicon or app icon shown next to the checkmark. | 
| 62 base::scoped_nsobject<NSImage> extraImage_; | 77 base::scoped_nsobject<NSImage> extraImage_; | 
| 63 } | 78 } | 
| 64 - (void)setExtraImage:(NSImage*)extraImage; | 79 - (void)setExtraImage:(NSImage*)extraImage; | 
| 65 @end | 80 @end | 
| 66 | 81 | 
| 67 @implementation MCSettingsButtonCell | 82 @implementation MCSettingsButtonCell | 
| 83 - (BOOL)isOpaque { | |
| 84 return YES; | |
| 85 } | |
| 86 | |
| 68 - (void)setExtraImage:(NSImage*)extraImage { | 87 - (void)setExtraImage:(NSImage*)extraImage { | 
| 69 extraImage_.reset([extraImage retain]); | 88 extraImage_.reset([extraImage retain]); | 
| 70 } | 89 } | 
| 71 | 90 | 
| 72 - (NSRect)drawTitle:(NSAttributedString*)title | 91 - (NSRect)drawTitle:(NSAttributedString*)title | 
| 73 withFrame:(NSRect)frame | 92 withFrame:(NSRect)frame | 
| 74 inView:(NSView*)controlView { | 93 inView:(NSView*)controlView { | 
| 75 CGFloat inset = kCorrectedCheckmarkRightPadding; | 94 CGFloat inset = kCorrectedCheckmarkRightPadding; | 
| 76 // drawTitle:withFrame:inView: draws the checkmark image. Draw the extra | 95 // drawTitle:withFrame:inView: draws the checkmark image. Draw the extra | 
| 77 // image as part of the checkbox's text. | 96 // image as part of the checkbox's text. | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 rect.size.width += kEntryIconSize + kCorrectedIconTextPadding; | 145 rect.size.width += kEntryIconSize + kCorrectedIconTextPadding; | 
| 127 | 146 | 
| 128 if (NSPointInRect(point, rect)) | 147 if (NSPointInRect(point, rect)) | 
| 129 result = NSCellHitContentArea | NSCellHitTrackableArea; | 148 result = NSCellHitContentArea | NSCellHitTrackableArea; | 
| 130 } | 149 } | 
| 131 return result; | 150 return result; | 
| 132 } | 151 } | 
| 133 @end | 152 @end | 
| 134 | 153 | 
| 135 @implementation MCSettingsEntryView | 154 @implementation MCSettingsEntryView | 
| 136 | |
| 137 - (id)initWithController:(MCSettingsController*)controller | 155 - (id)initWithController:(MCSettingsController*)controller | 
| 138 notifier:(message_center::Notifier*)notifier | 156 notifier:(message_center::Notifier*)notifier | 
| 139 frame:(NSRect)frame | 157 frame:(NSRect)frame | 
| 140 hasSeparator:(BOOL)hasSeparator { | 158 hasSeparator:(BOOL)hasSeparator { | 
| 141 if ((self = [super initWithFrame:frame])) { | 159 if ((self = [super initWithFrame:frame])) { | 
| 142 [self setBoxType:NSBoxCustom]; | 160 [self setBoxType:NSBoxCustom]; | 
| 143 [self setBorderType:NSNoBorder]; | 161 [self setBorderType:NSNoBorder]; | 
| 144 [self setTitlePosition:NSNoTitle]; | 162 [self setTitlePosition:NSNoTitle]; | 
| 145 [self setContentViewMargins:NSZeroSize]; | 163 [self setContentViewMargins:NSZeroSize]; | 
| 146 | 164 | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 [learnMoreButton_ setHoverImage:rb.GetNativeImageNamed( | 229 [learnMoreButton_ setHoverImage:rb.GetNativeImageNamed( | 
| 212 IDR_NOTIFICATION_ADVANCED_SETTINGS_HOVER).ToNSImage()]; | 230 IDR_NOTIFICATION_ADVANCED_SETTINGS_HOVER).ToNSImage()]; | 
| 213 [learnMoreButton_ setPressedImage:rb.GetNativeImageNamed( | 231 [learnMoreButton_ setPressedImage:rb.GetNativeImageNamed( | 
| 214 IDR_NOTIFICATION_ADVANCED_SETTINGS_PRESSED).ToNSImage()]; | 232 IDR_NOTIFICATION_ADVANCED_SETTINGS_PRESSED).ToNSImage()]; | 
| 215 [learnMoreButton_ setBordered:NO]; | 233 [learnMoreButton_ setBordered:NO]; | 
| 216 [learnMoreButton_ setTarget:self]; | 234 [learnMoreButton_ setTarget:self]; | 
| 217 [learnMoreButton_ setAction:@selector(learnMoreClicked:)]; | 235 [learnMoreButton_ setAction:@selector(learnMoreClicked:)]; | 
| 218 } | 236 } | 
| 219 | 237 | 
| 220 if (!checkbox_.get()) { | 238 if (!checkbox_.get()) { | 
| 221 checkbox_.reset([[NSButton alloc] initWithFrame:checkboxFrame]); | 239 checkbox_.reset([[MCSettingsButton alloc] initWithFrame:checkboxFrame]); | 
| 222 [self addSubview:checkbox_]; | 240 [self addSubview:checkbox_]; | 
| 223 } else { | 241 } else { | 
| 224 [checkbox_ setFrame:checkboxFrame]; | 242 [checkbox_ setFrame:checkboxFrame]; | 
| 225 } | 243 } | 
| 226 | 244 | 
| 227 base::scoped_nsobject<MCSettingsButtonCell> cell([[MCSettingsButtonCell alloc] | 245 base::scoped_nsobject<MCSettingsButtonCell> cell([[MCSettingsButtonCell alloc] | 
| 228 initTextCell:base::SysUTF16ToNSString(notifier_->name)]); | 246 initTextCell:base::SysUTF16ToNSString(notifier_->name)]); | 
| 229 if ([notifierIcon_ isValid]) | 247 if ([notifierIcon_ isValid]) | 
| 230 [cell setExtraImage:notifierIcon_]; | 248 [cell setExtraImage:notifierIcon_]; | 
| 231 | 249 | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 | 282 | 
| 265 // Testing API ///////////////////////////////////////////////////////////////// | 283 // Testing API ///////////////////////////////////////////////////////////////// | 
| 266 | 284 | 
| 267 - (void)clickLearnMore { | 285 - (void)clickLearnMore { | 
| 268 [learnMoreButton_ performClick:nil]; | 286 [learnMoreButton_ performClick:nil]; | 
| 269 } | 287 } | 
| 270 | 288 | 
| 271 @end | 289 @end | 
| 272 | 290 | 
| 273 /////////////////////////////////////////////////////////////////////////////// | 291 /////////////////////////////////////////////////////////////////////////////// | 
| OLD | NEW |