OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> | |
6 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 5 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
7 | 6 |
| 7 #import <Cocoa/Cocoa.h> |
| 8 |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/command_line.h" |
| 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "ui/base/cocoa/animation_utils.h" |
| 13 #include "ui/base/ui_base_switches.h" |
9 | 14 |
10 @interface FastResizeView (PrivateMethods) | 15 @interface FastResizeView (PrivateMethods) |
11 // Lays out this views subviews. If fast resize mode is on, does not resize any | 16 // Lays out this views subviews. If fast resize mode is on, does not resize any |
12 // subviews and instead pegs them to the top left. If fast resize mode is off, | 17 // subviews and instead pegs them to the top left. If fast resize mode is off, |
13 // sets the subviews' frame to be equal to this view's bounds. | 18 // sets the subviews' frame to be equal to this view's bounds. |
14 - (void)layoutSubviews; | 19 - (void)layoutSubviews; |
15 @end | 20 @end |
16 | 21 |
17 @implementation FastResizeView | 22 @implementation FastResizeView |
18 | 23 |
| 24 - (id)initWithFrame:(NSRect)frameRect { |
| 25 if ((self = [super initWithFrame:frameRect])) { |
| 26 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 27 switches::kDisableCoreAnimation)) { |
| 28 ScopedCAActionDisabler disabler; |
| 29 base::scoped_nsobject<CALayer> layer([[CALayer alloc] init]); |
| 30 [layer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)]; |
| 31 [self setLayer:layer]; |
| 32 [self setWantsLayer:YES]; |
| 33 } |
| 34 } |
| 35 return self; |
| 36 } |
| 37 |
| 38 - (BOOL)isOpaque { |
| 39 return YES; |
| 40 } |
| 41 |
19 - (void)setFastResizeMode:(BOOL)fastResizeMode { | 42 - (void)setFastResizeMode:(BOOL)fastResizeMode { |
20 if (fastResizeMode_ == fastResizeMode) | 43 if (fastResizeMode_ == fastResizeMode) |
21 return; | 44 return; |
22 | 45 |
23 fastResizeMode_ = fastResizeMode; | 46 fastResizeMode_ = fastResizeMode; |
24 | 47 |
25 // Force a relayout when coming out of fast resize mode. | 48 // Force a relayout when coming out of fast resize mode. |
26 if (!fastResizeMode_) | 49 if (!fastResizeMode_) |
27 [self layoutSubviews]; | 50 [self layoutSubviews]; |
28 | 51 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 NSRect frame = [subview frame]; | 87 NSRect frame = [subview frame]; |
65 frame.origin.x = 0; | 88 frame.origin.x = 0; |
66 frame.origin.y = NSHeight(bounds) - NSHeight(frame); | 89 frame.origin.y = NSHeight(bounds) - NSHeight(frame); |
67 [subview setFrame:frame]; | 90 [subview setFrame:frame]; |
68 } else { | 91 } else { |
69 [subview setFrame:bounds]; | 92 [subview setFrame:bounds]; |
70 } | 93 } |
71 } | 94 } |
72 | 95 |
73 @end | 96 @end |
OLD | NEW |