OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_CONTROLLER_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_CONTROLLER_H_ | |
7 #pragma once | |
8 | |
9 #import <Cocoa/Cocoa.h> | |
10 | |
11 #import "base/mac/cocoa_protocols.h" | |
12 #include "base/mac/mac_util.h" | |
13 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | |
14 | |
15 @class BrowserWindowController; | |
16 @class DropdownAnimation; | |
17 | |
18 // Provides a controller to manage fullscreen mode for a single browser window. | |
19 // This class handles running animations, showing and hiding the floating | |
20 // dropdown bar, and managing the tracking area associated with the dropdown. | |
21 // This class does not directly manage any views -- the BrowserWindowController | |
22 // is responsible for positioning and z-ordering views. | |
23 // | |
24 // Tracking areas are disabled while animations are running. If | |
25 // |overlayFrameChanged:| is called while an animation is running, the | |
26 // controller saves the new frame and installs the appropriate tracking area | |
27 // when the animation finishes. This is largely done for ease of | |
28 // implementation; it is easier to check the mouse location at each animation | |
29 // step than it is to manage a constantly-changing tracking area. | |
30 @interface FullscreenController : NSObject<NSAnimationDelegate> { | |
31 @private | |
32 // Our parent controller. | |
33 BrowserWindowController* browserController_; // weak | |
34 | |
35 // The content view for the fullscreen window. This is nil when not in | |
36 // fullscreen mode. | |
37 NSView* contentView_; // weak | |
38 | |
39 // Whether or not we are in fullscreen mode. | |
40 BOOL isFullscreen_; | |
41 | |
42 // The tracking area associated with the floating dropdown bar. This tracking | |
43 // area is attached to |contentView_|, because when the dropdown is completely | |
44 // hidden, we still need to keep a 1px tall tracking area visible. Attaching | |
45 // to the content view allows us to do this. |trackingArea_| can be nil if | |
46 // not in fullscreen mode or during animations. | |
47 scoped_nsobject<NSTrackingArea> trackingArea_; | |
48 | |
49 // Pointer to the currently running animation. Is nil if no animation is | |
50 // running. | |
51 scoped_nsobject<DropdownAnimation> currentAnimation_; | |
52 | |
53 // Timers for scheduled showing/hiding of the bar (which are always done with | |
54 // animation). | |
55 scoped_nsobject<NSTimer> showTimer_; | |
56 scoped_nsobject<NSTimer> hideTimer_; | |
57 | |
58 // Holds the current bounds of |trackingArea_|, even if |trackingArea_| is | |
59 // currently nil. Used to restore the tracking area when an animation | |
60 // completes. | |
61 NSRect trackingAreaBounds_; | |
62 | |
63 // Tracks the currently requested fullscreen mode. This should be | |
64 // |kFullScreenModeNormal| when the window is not main or not fullscreen, | |
65 // |kFullScreenModeHideAll| while the overlay is hidden, and | |
66 // |kFullScreenModeHideDock| while the overlay is shown. If the window is not | |
67 // on the primary screen, this should always be |kFullScreenModeNormal|. This | |
68 // value can get out of sync with the correct state if we miss a notification | |
69 // (which can happen when a fullscreen window is closed). Used to track the | |
70 // current state and make sure we properly restore the menu bar when this | |
71 // controller is destroyed. | |
72 base::mac::FullScreenMode currentFullscreenMode_; | |
73 } | |
74 | |
75 @property(readonly, nonatomic) BOOL isFullscreen; | |
76 | |
77 // Designated initializer. | |
78 - (id)initWithBrowserController:(BrowserWindowController*)controller; | |
79 | |
80 // Informs the controller that the browser has entered or exited fullscreen | |
81 // mode. |-enterFullscreenForContentView:showDropdown:| should be called after | |
82 // the fullscreen window is setup, just before it is shown. |-exitFullscreen| | |
83 // should be called before any views are moved back to the non-fullscreen | |
84 // window. If |-enterFullscreenForContentView:showDropdown:| is called, it must | |
85 // be followed with a call to |-exitFullscreen| before the controller is | |
86 // released. | |
87 - (void)enterFullscreenForContentView:(NSView*)contentView | |
88 showDropdown:(BOOL)showDropdown; | |
89 - (void)exitFullscreen; | |
90 | |
91 // Returns the amount by which the floating bar should be offset downwards (to | |
92 // avoid the menu) and by which the overlay view should be enlarged vertically. | |
93 // Generally, this is > 0 when the fullscreen window is on the primary screen | |
94 // and 0 otherwise. | |
95 - (CGFloat)floatingBarVerticalOffset; | |
96 | |
97 // Informs the controller that the overlay's frame has changed. The controller | |
98 // uses this information to update its tracking areas. | |
99 - (void)overlayFrameChanged:(NSRect)frame; | |
100 | |
101 // Informs the controller that the overlay should be shown/hidden, possibly with | |
102 // animation, possibly after a delay (only applicable for the animated case). | |
103 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay; | |
104 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay; | |
105 | |
106 // Cancels any running animation and timers. | |
107 - (void)cancelAnimationAndTimers; | |
108 | |
109 // Gets the current floating bar shown fraction. | |
110 - (CGFloat)floatingBarShownFraction; | |
111 | |
112 // Sets a new current floating bar shown fraction. NOTE: This function has side | |
113 // effects, such as modifying the fullscreen mode (menu bar shown state). | |
114 - (void)changeFloatingBarShownFraction:(CGFloat)fraction; | |
115 | |
116 @end | |
117 | |
118 // Notification posted when we're about to enter or leave fullscreen. | |
119 extern NSString* const kWillEnterFullscreenNotification; | |
120 extern NSString* const kWillLeaveFullscreenNotification; | |
121 | |
122 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_CONTROLLER_H_ | |
OLD | NEW |