OLD | NEW |
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 "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" |
6 | 6 |
| 7 #include <algorithm> |
| 8 #include <cmath> |
| 9 |
7 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" | 10 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" |
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
9 #import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" | 12 #import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" |
10 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" | 13 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" |
11 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
12 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 15 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
13 #include "ui/base/cocoa/window_size_constants.h" | 16 #include "ui/base/cocoa/window_size_constants.h" |
14 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
15 | 18 |
16 @interface AutofillMainContainer (Private) | 19 @interface AutofillMainContainer (Private) |
(...skipping 25 matching lines...) Expand all Loading... |
42 detailsContainer_.reset( | 45 detailsContainer_.reset( |
43 [[AutofillDetailsContainer alloc] initWithController:controller_]); | 46 [[AutofillDetailsContainer alloc] initWithController:controller_]); |
44 NSSize frameSize = [[detailsContainer_ view] frame].size; | 47 NSSize frameSize = [[detailsContainer_ view] frame].size; |
45 [[detailsContainer_ view] setFrameOrigin: | 48 [[detailsContainer_ view] setFrameOrigin: |
46 NSMakePoint(0, NSHeight([buttonContainer_ frame]))]; | 49 NSMakePoint(0, NSHeight([buttonContainer_ frame]))]; |
47 frameSize.height += NSHeight([buttonContainer_ frame]); | 50 frameSize.height += NSHeight([buttonContainer_ frame]); |
48 [[self view] setFrameSize:frameSize]; | 51 [[self view] setFrameSize:frameSize]; |
49 [[self view] addSubview:[detailsContainer_ view]]; | 52 [[self view] addSubview:[detailsContainer_ view]]; |
50 } | 53 } |
51 | 54 |
| 55 - (NSSize)preferredSize { |
| 56 // The buttons never change size, so rely on container. |
| 57 NSSize buttonSize = [buttonContainer_ frame].size; |
| 58 NSSize detailsSize = [detailsContainer_ preferredSize]; |
| 59 |
| 60 NSSize size = NSMakeSize(std::max(buttonSize.width, detailsSize.width), |
| 61 buttonSize.height + detailsSize.height); |
| 62 |
| 63 return size; |
| 64 } |
| 65 |
| 66 - (void)performLayout { |
| 67 // Assume that the frame for the container is set already. |
| 68 [detailsContainer_ performLayout]; |
| 69 } |
| 70 |
52 - (void)buildWindowButtonsForFrame:(NSRect)frame { | 71 - (void)buildWindowButtonsForFrame:(NSRect)frame { |
53 if (buttonContainer_.get()) | 72 if (buttonContainer_.get()) |
54 return; | 73 return; |
55 | 74 |
56 buttonContainer_.reset([[GTMWidthBasedTweaker alloc] initWithFrame: | 75 buttonContainer_.reset([[GTMWidthBasedTweaker alloc] initWithFrame: |
57 ui::kWindowSizeDeterminedLater]); | 76 ui::kWindowSizeDeterminedLater]); |
58 [buttonContainer_ | 77 [buttonContainer_ |
59 setAutoresizingMask:(NSViewMinXMargin | NSViewMaxYMargin)]; | 78 setAutoresizingMask:(NSViewMinXMargin | NSViewMaxYMargin)]; |
60 | 79 |
61 scoped_nsobject<NSButton> button( | 80 scoped_nsobject<NSButton> button( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 112 |
94 - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section { | 113 - (AutofillSectionContainer*)sectionForId:(autofill::DialogSection)section { |
95 return [detailsContainer_ sectionForId:section]; | 114 return [detailsContainer_ sectionForId:section]; |
96 } | 115 } |
97 | 116 |
98 - (void)modelChanged { | 117 - (void)modelChanged { |
99 [detailsContainer_ modelChanged]; | 118 [detailsContainer_ modelChanged]; |
100 } | 119 } |
101 | 120 |
102 @end | 121 @end |
OLD | NEW |