Chromium Code Reviews| Index: chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.mm |
| diff --git a/chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.mm b/chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0938ede8521ecf3308f207afcd747b54ce83f2ff |
| --- /dev/null |
| +++ b/chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.mm |
| @@ -0,0 +1,83 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h" |
| + |
| +#include "base/mac/scoped_nsobject.h" |
| + |
| +@implementation AutofillPopUpCell |
|
sail
2013/06/28 03:08:56
Move below implementation of AutofillPopUpButton t
groby-ooo-7-16
2013/06/28 18:49:52
Done.
|
| + |
| +@synthesize invalid = invalid_; |
| + |
| +// Draw a bezel that's highlighted. |
| +- (void)drawBezelWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
| + if (invalid_) { |
|
sail
2013/06/28 03:08:56
Do early return?
Also comment why you don't need t
groby-ooo-7-16
2013/06/28 18:49:52
Because I stupidly only tested the invalid path -
|
| + NSRect localFrame = NSZeroRect; |
| + localFrame.size = cellFrame.size; |
| + |
| + base::scoped_nsobject<NSImage> bezelImage( |
| + [[NSImage alloc] initWithSize:cellFrame.size]); |
| + |
| + // Get a snapshot of the original bezel. |
| + [bezelImage lockFocus]; |
| + [super drawBezelWithFrame:localFrame inView:[NSView focusView]]; |
|
sail
2013/06/28 03:08:56
can't you just pass controlView here?
groby-ooo-7-16
2013/06/28 18:49:52
It's moot with the new rendering code, but the doc
|
| + [bezelImage unlockFocus]; |
| + |
| + // Copy bezel. |
| + base::scoped_nsobject<NSImage> finalImage([bezelImage copyWithZone:nil]); |
|
sail
2013/06/28 03:08:56
I don't think you need this. You can do everything
groby-ooo-7-16
2013/06/28 18:49:52
I originally misunderstood the grouping here - yes
|
| + |
| + // Replace all of bezel with highlight color to get solid-colored bezel. |
| + [finalImage lockFocus]; |
| + [[NSColor redColor] set]; |
| + NSRectFillUsingOperation(localFrame, NSCompositeSourceAtop); |
| + |
| + // Finally, mix colored area and bezel image. |
| + [bezelImage drawAtPoint:NSZeroPoint |
| + fromRect:NSZeroRect |
| + operation:NSCompositePlusDarker |
| + fraction:1]; |
| + [finalImage unlockFocus]; |
| + |
| + // And draw the resulting bezel. |
| + [finalImage drawAtPoint:cellFrame.origin |
| + fromRect:NSZeroRect |
| + operation:NSCompositeSourceOver |
| + fraction:1]; |
| + } |
| +} |
| + |
| +- (NSString*)fieldValue { |
| + return [self titleOfSelectedItem]; |
| +} |
| + |
| +- (void)setFieldValue:(NSString*)fieldValue { |
| + [self selectItemWithTitle:fieldValue]; |
| +} |
| + |
| +@end |
| + |
| + |
| +@implementation AutofillPopUpButton |
| + |
| ++ (Class)cellClass { |
| + return [AutofillPopUpCell class]; |
| +} |
| + |
| +- (BOOL)invalid { |
| + return [[self cell] invalid]; |
| +} |
| + |
| +- (void)setInvalid:(BOOL)invalid { |
| + [[self cell] setInvalid:invalid]; |
| +} |
| + |
| +- (NSString*)fieldValue { |
| + return [[self cell] fieldValue]; |
| +} |
| + |
| +- (void)setFieldValue:(NSString*)fieldValue { |
| + [[self cell] setFieldValue:fieldValue]; |
| +} |
| + |
| +@end |