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 "chrome/browser/ui/cocoa/autofill/autofill_overlay_controller.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_overlay_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 10 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
11 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | 11 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
12 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" | 12 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" |
13 #include "skia/ext/skia_utils_mac.h" | 13 #include "skia/ext/skia_utils_mac.h" |
14 #include "third_party/skia/include/core/SkColor.h" | |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // Spacing around the message in the overlay view. | 18 // Spacing around the message in the overlay view. |
18 const CGFloat kOverlayLabelPadding = 34; | 19 const CGFloat kOverlayLabelPadding = 34; |
19 | 20 |
20 // Spacing below image and above text messages in overlay view. | 21 // Spacing below image and above text messages in overlay view. |
21 const CGFloat kOverlayImageVerticalPadding = 90; | 22 const CGFloat kOverlayImageVerticalPadding = 90; |
22 | 23 |
23 // TODO(groby): Unify colors with Views. | 24 // TODO(groby): Unify colors with Views. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 | 89 |
89 - (CGFloat)heightForWidth:(CGFloat)width { | 90 - (CGFloat)heightForWidth:(CGFloat)width { |
90 return NSHeight([label_ frame]) + autofill::kArrowHeight + | 91 return NSHeight([label_ frame]) + autofill::kArrowHeight + |
91 2 * kOverlayLabelPadding; | 92 2 * kOverlayLabelPadding; |
92 } | 93 } |
93 | 94 |
94 - (void)setMessage:(const autofill::DialogOverlayString&)message { | 95 - (void)setMessage:(const autofill::DialogOverlayString&)message { |
95 // We probably want to look at other multi-line messages somewhere. | 96 // We probably want to look at other multi-line messages somewhere. |
96 [label_ setFont:message.font.GetNativeFont()]; | 97 [label_ setFont:message.font.GetNativeFont()]; |
97 [label_ setStringValue:base::SysUTF16ToNSString(message.text)]; | 98 [label_ setStringValue:base::SysUTF16ToNSString(message.text)]; |
98 [label_ setTextColor:gfx::SkColorToCalibratedNSColor(message.text_color)]; | 99 [label_ setTextColor:gfx::SkColorToCalibratedNSColor(SK_ColorDKGRAY)]; |
groby-ooo-7-16
2014/01/08 18:44:53
If we don't use hand-tuned colors any more, I sugg
Sheridan Rawlins
2014/01/08 23:58:41
Done.
| |
99 | 100 |
100 // Resize only height, preserve width. This guarantees text stays centered in | 101 // Resize only height, preserve width. This guarantees text stays centered in |
101 // the dialog. | 102 // the dialog. |
102 NSSize labelSize = [label_ frame].size; | 103 NSSize labelSize = [label_ frame].size; |
103 labelSize.height = [[label_ cell] cellSize].height; | 104 labelSize.height = [[label_ cell] cellSize].height; |
104 [label_ setFrameSize:labelSize]; | 105 [label_ setFrameSize:labelSize]; |
105 | 106 |
106 [self setHidden:message.text.empty()]; | 107 [self setHidden:message.text.empty()]; |
107 } | 108 } |
108 | 109 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 [messageView_ setFrame:NSMakeRect(0, 0, NSWidth(bounds), messageHeight)]; | 178 [messageView_ setFrame:NSMakeRect(0, 0, NSWidth(bounds), messageHeight)]; |
178 [messageView_ performLayout]; | 179 [messageView_ performLayout]; |
179 | 180 |
180 NSSize imageSize = [[imageView_ image] size]; | 181 NSSize imageSize = [[imageView_ image] size]; |
181 [imageView_ setFrame:NSMakeRect( | 182 [imageView_ setFrame:NSMakeRect( |
182 0, NSMaxY([messageView_ frame]) + kOverlayImageVerticalPadding, | 183 0, NSMaxY([messageView_ frame]) + kOverlayImageVerticalPadding, |
183 NSWidth(bounds), imageSize.height)]; | 184 NSWidth(bounds), imageSize.height)]; |
184 } | 185 } |
185 | 186 |
186 @end | 187 @end |
OLD | NEW |