OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/cocoa/underlay_opengl_hosting_window.h" | 5 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
6 | 6 |
7 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 | 113 |
114 if (windowStyle & NSTitledWindowMask) { | 114 if (windowStyle & NSTitledWindowMask) { |
115 // Only fiddle with shadows if the window is a proper window with a | 115 // Only fiddle with shadows if the window is a proper window with a |
116 // title bar and all. (The invisible opaque area technique only works on | 116 // title bar and all. (The invisible opaque area technique only works on |
117 // > 10.5, but that is guaranteed by this point.) | 117 // > 10.5, but that is guaranteed by this point.) |
118 [self _setContentHasShadow:NO]; | 118 [self _setContentHasShadow:NO]; |
119 | 119 |
120 NSView* rootView = [[self contentView] superview]; | 120 NSView* rootView = [[self contentView] superview]; |
121 const NSRect rootBounds = [rootView bounds]; | 121 const NSRect rootBounds = [rootView bounds]; |
122 | 122 |
123 const CGFloat kEdgeInset = 16; | 123 // On 10.7/8, the bottom corners of the window are rounded by magic at a |
124 const CGFloat kAlphaValueJustOpaqueEnough = 0.002; | 124 // deeper level than the NSThemeFrame, so it is OK to have the opaques |
125 // go all the way to the bottom. | |
126 const CGFloat kTopEdgeInset = 16; | |
127 const CGFloat kAlphaValueJustOpaqueEnough = 0.003; | |
Nico
2012/06/01 17:07:23
Why the alpha value tweak?
| |
125 | 128 |
126 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: | 129 scoped_nsobject<NSView> leftOpaque([[OpaqueView alloc] initWithFrame: |
127 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds) + kEdgeInset, | 130 NSMakeRect(NSMinX(rootBounds), NSMinY(rootBounds), |
128 1, NSHeight(rootBounds) - 2 * kEdgeInset)]); | 131 1, NSHeight(rootBounds) - kTopEdgeInset)]); |
129 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | | 132 [leftOpaque setAutoresizingMask:NSViewMaxXMargin | |
130 NSViewHeightSizable]; | 133 NSViewHeightSizable]; |
131 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 134 [leftOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
132 [rootView addSubview:leftOpaque]; | 135 [rootView addSubview:leftOpaque]; |
133 | 136 |
134 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: | 137 scoped_nsobject<NSView> rightOpaque([[OpaqueView alloc] initWithFrame: |
135 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds) + kEdgeInset, | 138 NSMakeRect(NSMaxX(rootBounds) - 1, NSMinY(rootBounds), |
136 1, NSHeight(rootBounds) - 2 * kEdgeInset)]); | 139 1, NSHeight(rootBounds) - kTopEdgeInset)]); |
137 [rightOpaque setAutoresizingMask:NSViewMinXMargin | | 140 [rightOpaque setAutoresizingMask:NSViewMinXMargin | |
138 NSViewHeightSizable]; | 141 NSViewHeightSizable]; |
139 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; | 142 [rightOpaque setAlphaValue:kAlphaValueJustOpaqueEnough]; |
140 [rootView addSubview:rightOpaque]; | 143 [rootView addSubview:rightOpaque]; |
141 } | 144 } |
142 } | 145 } |
143 } | 146 } |
144 | 147 |
145 return self; | 148 return self; |
146 } | 149 } |
147 | 150 |
148 @end | 151 @end |
OLD | NEW |