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> | 5 #import <Cocoa/Cocoa.h> |
6 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 6 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 7 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
7 | 8 |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 | 10 |
10 @interface FastResizeView (PrivateMethods) | 11 @interface FastResizeView (PrivateMethods) |
11 // Lays out this views subviews. If fast resize mode is on, does not resize any | 12 // 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, | 13 // 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. | 14 // sets the subviews' frame to be equal to this view's bounds. |
14 - (void)layoutSubviews; | 15 - (void)layoutSubviews; |
15 @end | 16 @end |
16 | 17 |
17 @implementation FastResizeView | 18 @implementation FastResizeView |
18 | 19 |
| 20 - (id)initWithFrame:(NSRect)frameRect { |
| 21 if ((self = [super initWithFrame:frameRect])) { |
| 22 [self cr_setHostsSolidWhiteLayer]; |
| 23 } |
| 24 return self; |
| 25 } |
| 26 |
| 27 - (BOOL)isOpaque { |
| 28 return YES; |
| 29 } |
| 30 |
19 - (void)setFastResizeMode:(BOOL)fastResizeMode { | 31 - (void)setFastResizeMode:(BOOL)fastResizeMode { |
20 if (fastResizeMode_ == fastResizeMode) | 32 if (fastResizeMode_ == fastResizeMode) |
21 return; | 33 return; |
22 | 34 |
23 fastResizeMode_ = fastResizeMode; | 35 fastResizeMode_ = fastResizeMode; |
24 | 36 |
25 // Force a relayout when coming out of fast resize mode. | 37 // Force a relayout when coming out of fast resize mode. |
26 if (!fastResizeMode_) | 38 if (!fastResizeMode_) |
27 [self layoutSubviews]; | 39 [self layoutSubviews]; |
28 | 40 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 NSRect frame = [subview frame]; | 76 NSRect frame = [subview frame]; |
65 frame.origin.x = 0; | 77 frame.origin.x = 0; |
66 frame.origin.y = NSHeight(bounds) - NSHeight(frame); | 78 frame.origin.y = NSHeight(bounds) - NSHeight(frame); |
67 [subview setFrame:frame]; | 79 [subview setFrame:frame]; |
68 } else { | 80 } else { |
69 [subview setFrame:bounds]; | 81 [subview setFrame:bounds]; |
70 } | 82 } |
71 } | 83 } |
72 | 84 |
73 @end | 85 @end |
OLD | NEW |