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 "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_animation
.h" | 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_animation
.h" |
8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" | 8 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
9 | 9 |
10 @implementation CustomConstrainedWindowSheet | 10 @implementation CustomConstrainedWindowSheet |
11 | 11 |
12 - (id)initWithCustomWindow:(NSWindow*)customWindow { | 12 - (id)initWithCustomWindow:(NSWindow*)customWindow { |
13 if ((self = [super init])) { | 13 if ((self = [super init])) { |
14 customWindow_.reset([customWindow retain]); | 14 customWindow_.reset([customWindow retain]); |
15 } | 15 } |
16 return self; | 16 return self; |
17 } | 17 } |
18 | 18 |
19 - (void)showSheetForWindow:(NSWindow*)window { | 19 - (void)showSheetForWindow:(NSWindow*)window { |
20 scoped_nsobject<NSAnimation> animation( | 20 base::scoped_nsobject<NSAnimation> animation( |
21 [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]); | 21 [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]); |
22 [window addChildWindow:customWindow_ | 22 [window addChildWindow:customWindow_ |
23 ordered:NSWindowAbove]; | 23 ordered:NSWindowAbove]; |
24 [self unhideSheet]; | 24 [self unhideSheet]; |
25 [self updateSheetPosition]; | 25 [self updateSheetPosition]; |
26 [customWindow_ makeKeyAndOrderFront:nil]; | 26 [customWindow_ makeKeyAndOrderFront:nil]; |
27 [animation startAnimation]; | 27 [animation startAnimation]; |
28 } | 28 } |
29 | 29 |
30 - (void)closeSheetWithAnimation:(BOOL)withAnimation { | 30 - (void)closeSheetWithAnimation:(BOOL)withAnimation { |
31 if (withAnimation) { | 31 if (withAnimation) { |
32 scoped_nsobject<NSAnimation> animation( | 32 base::scoped_nsobject<NSAnimation> animation( |
33 [[ConstrainedWindowAnimationHide alloc] initWithWindow:customWindow_]); | 33 [[ConstrainedWindowAnimationHide alloc] initWithWindow:customWindow_]); |
34 [animation startAnimation]; | 34 [animation startAnimation]; |
35 } | 35 } |
36 | 36 |
37 [[customWindow_ parentWindow] removeChildWindow:customWindow_]; | 37 [[customWindow_ parentWindow] removeChildWindow:customWindow_]; |
38 [customWindow_ close]; | 38 [customWindow_ close]; |
39 } | 39 } |
40 | 40 |
41 - (void)hideSheet { | 41 - (void)hideSheet { |
42 [customWindow_ setAlphaValue:0.0]; | 42 [customWindow_ setAlphaValue:0.0]; |
43 } | 43 } |
44 | 44 |
45 - (void)unhideSheet { | 45 - (void)unhideSheet { |
46 [customWindow_ setAlphaValue:1.0]; | 46 [customWindow_ setAlphaValue:1.0]; |
47 } | 47 } |
48 | 48 |
49 - (void)pulseSheet { | 49 - (void)pulseSheet { |
50 scoped_nsobject<NSAnimation> animation( | 50 base::scoped_nsobject<NSAnimation> animation( |
51 [[ConstrainedWindowAnimationPulse alloc] initWithWindow:customWindow_]); | 51 [[ConstrainedWindowAnimationPulse alloc] initWithWindow:customWindow_]); |
52 [animation startAnimation]; | 52 [animation startAnimation]; |
53 } | 53 } |
54 | 54 |
55 - (void)makeSheetKeyAndOrderFront { | 55 - (void)makeSheetKeyAndOrderFront { |
56 [customWindow_ makeKeyAndOrderFront:nil]; | 56 [customWindow_ makeKeyAndOrderFront:nil]; |
57 } | 57 } |
58 | 58 |
59 - (void)updateSheetPosition { | 59 - (void)updateSheetPosition { |
60 ConstrainedWindowSheetController* controller = | 60 ConstrainedWindowSheetController* controller = |
61 [ConstrainedWindowSheetController controllerForSheet:self]; | 61 [ConstrainedWindowSheetController controllerForSheet:self]; |
62 NSPoint origin = [controller originForSheet:self | 62 NSPoint origin = [controller originForSheet:self |
63 withWindowSize:[customWindow_ frame].size]; | 63 withWindowSize:[customWindow_ frame].size]; |
64 [customWindow_ setFrameOrigin:origin]; | 64 [customWindow_ setFrameOrigin:origin]; |
65 } | 65 } |
66 | 66 |
67 @end | 67 @end |
OLD | NEW |