Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import "chrome/browser/ui/cocoa/autofill/autofill_header.h" | |
| 6 | |
| 7 #import "chrome/browser/ui/cocoa/autofill/autofill_account_chooser.h" | |
| 8 #include "base/strings/sys_string_conversions.h" | |
| 9 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | |
| 10 #include "chrome/browser/ui/chrome_style.h" | |
| 11 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" | |
| 12 | |
| 13 @implementation AutofillHeader | |
| 14 | |
| 15 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate { | |
| 16 if (self = [super initWithFrame:NSZeroRect]) { | |
| 17 delegate_ = delegate; | |
| 18 | |
| 19 accountChooser_.reset( | |
| 20 [[AutofillAccountChooser alloc] initWithFrame:NSZeroRect | |
| 21 delegate:delegate]); | |
| 22 | |
| 23 // Set dialog title. | |
| 24 title_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]); | |
| 25 [title_ setEditable:NO]; | |
| 26 [title_ setBordered:NO]; | |
| 27 [title_ setDrawsBackground:NO]; | |
| 28 [title_ setFont:[NSFont systemFontOfSize:15.0]]; | |
| 29 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())]; | |
| 30 [title_ sizeToFit]; | |
| 31 | |
| 32 [self setSubviews:@[accountChooser_, title_]]; | |
| 33 } | |
| 34 return self; | |
| 35 } | |
| 36 | |
| 37 - (BOOL)isFlipped { | |
| 38 return YES; | |
| 39 } | |
| 40 | |
| 41 - (NSView*)anchorView { | |
| 42 return [[accountChooser_ subviews] objectAtIndex:1]; | |
| 43 } | |
| 44 | |
| 45 - (void)update { | |
| 46 [accountChooser_ update]; | |
| 47 } | |
| 48 | |
| 49 - (CGFloat)heightForWidth:(int)width { | |
| 50 return chrome_style::kTitleTopPadding + | |
|
groby-ooo-7-16
2013/11/20 23:51:44
Why? Why not just have preferredSize return the ri
Ilya Sherman
2013/11/22 05:01:13
Well, I could do that right now, but I kept -heigh
groby-ooo-7-16
2013/11/22 14:51:37
If we need it anyways, that'd be kind of silly :)
Ilya Sherman
2013/11/23 00:23:54
Yeah, I was thinking about that too -- maybe heigh
| |
| 51 autofill::kAccountChooserHeight + | |
| 52 autofill::kDetailVerticalPadding; | |
| 53 } | |
| 54 | |
| 55 - (NSSize)preferredSize { | |
| 56 NOTREACHED(); // Only implemented as part of AutofillLayout protocol. | |
| 57 return NSZeroSize; | |
| 58 } | |
| 59 | |
| 60 - (void)performLayout { | |
| 61 NSRect bounds = [self bounds]; | |
| 62 | |
| 63 // TODO(isherman): Can updating the title string value be moved into -update: | |
| 64 // instead of here? | |
| 65 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())]; | |
|
groby-ooo-7-16
2013/11/20 23:51:44
Yes. No. Maybe. :)
No, because it resizes a dialo
Ilya Sherman
2013/11/22 05:01:13
I'm doin' it! :)
groby-ooo-7-16
2013/11/22 14:51:37
You might want to pay close attention to the redr
| |
| 66 [title_ sizeToFit]; | |
| 67 | |
| 68 // Align baseline of title with bottom of accountChooser. | |
| 69 base::scoped_nsobject<NSLayoutManager> layout_manager( | |
| 70 [[NSLayoutManager alloc] init]); | |
| 71 NSRect titleFrameRect = [title_ frame]; | |
| 72 titleFrameRect.origin.x = chrome_style::kHorizontalPadding; | |
| 73 titleFrameRect.origin.y = | |
| 74 chrome_style::kTitleTopPadding + NSHeight(titleFrameRect) - | |
| 75 [layout_manager defaultBaselineOffsetForFont:[title_ font]]; | |
| 76 [title_ setFrameOrigin:titleFrameRect.origin]; | |
| 77 | |
| 78 NSRect accountChooserFrameRect = | |
| 79 NSMakeRect(NSMaxX(titleFrameRect) + chrome_style::kHorizontalPadding, | |
| 80 chrome_style::kTitleTopPadding, | |
| 81 0, | |
| 82 autofill::kAccountChooserHeight); | |
| 83 accountChooserFrameRect.size.width = | |
| 84 NSMaxX(bounds) - NSMinX(accountChooserFrameRect) - | |
| 85 chrome_style::kHorizontalPadding; | |
| 86 [accountChooser_ setFrame:accountChooserFrameRect]; | |
| 87 [accountChooser_ performLayout]; | |
| 88 } | |
| 89 | |
| 90 @end | |
| OLD | NEW |