Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1053)

Side by Side Diff: chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_info.mm

Issue 10870094: Constrained window sheet controller (test patch) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rename Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_in fo.h"
6 #include "ui/base/cocoa/window_size_constants.h"
7
8 @implementation ConstrainedWindowSheetInfo
9
10 - (id)initWithSheet:(NSWindow*)sheet
11 parentView:(NSView*)parentView
12 overlayWindow:(NSWindow*)overlayWindow {
13 if ((self = [super init])) {
14 sheet_.reset([sheet retain]);
15 parentView_.reset([parentView retain]);
16 overlayWindow_.reset([overlayWindow retain]);
17 }
18 return self;
19 }
20
21 - (NSWindow*)sheet {
22 return sheet_;
23 }
24
25 - (NSView*)parentView {
26 return parentView_;
27 }
28
29 - (NSWindow*)overlayWindow {
30 return overlayWindow_;
31 }
32
33 - (void)setAnimation:(NSAnimation*)animation {
34 animation_.reset([animation retain]);
35 }
36
37 - (NSAnimation*)animation {
38 return animation_;
39 }
40
41 - (void)hideSheet {
42 // Stop any pending animations.
43 [animation_ stopAnimation];
44 animation_.reset();
45
46 // Hide the sheet by setting alpha to 0 and sizing it to 1x1. This is better
47 // than calling orderOut: because that could cause Spaces activation or
48 // window ordering changes.
49 [sheet_ setAlphaValue:0.0];
50 oldSheetAutoresizesSubviews_ = [[sheet_ contentView] autoresizesSubviews];
51 [[sheet_ contentView] setAutoresizesSubviews:NO];
52 NSRect overlayFrame = [overlayWindow_ frame];
53 oldSheetFrame_ = NSOffsetRect(
54 [sheet_ frame], -overlayFrame.origin.x, -overlayFrame.origin.y);
55 [sheet_ setFrame:ui::kWindowSizeDeterminedLater display:NO];
56
57 // Overlay window is already invisible so just stop accepting mouse events.
58 [overlayWindow_ setIgnoresMouseEvents:YES];
59
60 // Make sure the now invisible sheet doesn't keep keyboard focus
61 [[overlayWindow_ parentWindow] makeKeyWindow];
62 }
63
64 - (void)showSheet {
65 [overlayWindow_ setIgnoresMouseEvents:NO];
66
67 NSRect overlayFrame = [overlayWindow_ frame];
68 NSRect newSheetFrame = NSOffsetRect(
69 oldSheetFrame_, overlayFrame.origin.x, overlayFrame.origin.y);
70 [sheet_ setFrame:newSheetFrame display:NO];
71 [[sheet_ contentView] setAutoresizesSubviews:oldSheetAutoresizesSubviews_];
72 [sheet_ setAlphaValue:1.0];
73
74 [overlayWindow_ makeKeyWindow];
75 }
76
77 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698