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 #ifndef CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
7 | 7 |
8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 12 #include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
13 | 13 |
14 @class BrowserWindowController; | 14 @class BrowserWindowController; |
| 15 @class CrTrackingArea; |
15 @class DropdownAnimation; | 16 @class DropdownAnimation; |
16 | 17 |
17 namespace fullscreen_mac { | 18 namespace fullscreen_mac { |
18 enum SlidingStyle { | 19 enum SlidingStyle { |
19 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible. | 20 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible. |
20 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. | 21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. |
21 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never | 22 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never |
22 // shown. | 23 // shown. |
23 }; | 24 }; |
24 } // namespace fullscreen_mac | 25 } // namespace fullscreen_mac |
25 | 26 |
26 // TODO(erikchen): This controller is misnamed. It manages the sliding tab | 27 // Provides a controller to fullscreen toolbar for a single browser |
27 // strip and omnibox in all fullscreen modes. | |
28 | |
29 // Provides a controller to manage presentation mode for a single browser | |
30 // window. This class handles running animations, showing and hiding the | 28 // window. This class handles running animations, showing and hiding the |
31 // floating dropdown bar, and managing the tracking area associated with the | 29 // floating dropdown bar, and managing the tracking area associated with the |
32 // dropdown. This class does not directly manage any views -- the | 30 // dropdown. This class does not directly manage any views -- the |
33 // BrowserWindowController is responsible for positioning and z-ordering views. | 31 // BrowserWindowController is responsible for positioning and z-ordering views. |
34 // | 32 // |
35 // Tracking areas are disabled while animations are running. If | 33 // Tracking areas are disabled while animations are running. If |
36 // |overlayFrameChanged:| is called while an animation is running, the | 34 // |overlayFrameChanged:| is called while an animation is running, the |
37 // controller saves the new frame and installs the appropriate tracking area | 35 // controller saves the new frame and installs the appropriate tracking area |
38 // when the animation finishes. This is largely done for ease of | 36 // when the animation finishes. This is largely done for ease of |
39 // implementation; it is easier to check the mouse location at each animation | 37 // implementation; it is easier to check the mouse location at each animation |
40 // step than it is to manage a constantly-changing tracking area. | 38 // step than it is to manage a constantly-changing tracking area. |
41 @interface PresentationModeController : NSObject<NSAnimationDelegate> { | 39 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { |
42 @private | 40 @private |
43 // Our parent controller. | 41 // Our parent controller. |
44 BrowserWindowController* browserController_; // weak | 42 BrowserWindowController* browserController_; // weak |
45 | 43 |
46 // The content view for the window. This is nil when not in presentation | 44 // The content view for the window. This is nil when not in presentation |
47 // mode. | 45 // mode. |
48 NSView* contentView_; // weak | 46 NSView* contentView_; // weak |
49 | 47 |
50 // YES while this controller is in the process of entering presentation mode. | 48 // YES while this controller is in the process of setting up for fullscreen. |
51 BOOL enteringPresentationMode_; | 49 BOOL settingUp_; |
52 | 50 |
53 // Whether or not we are in presentation mode. | 51 // Whether or not we are in fullscreen mode. |
54 BOOL inPresentationMode_; | 52 BOOL inFullscreenMode_; |
55 | 53 |
56 // The tracking area associated with the floating dropdown bar. This tracking | 54 // The tracking area associated with the floating dropdown bar. This tracking |
57 // area is attached to |contentView_|, because when the dropdown is completely | 55 // area is attached to |contentView_|, because when the dropdown is completely |
58 // hidden, we still need to keep a 1px tall tracking area visible. Attaching | 56 // hidden, we still need to keep a 1px tall tracking area visible. Attaching |
59 // to the content view allows us to do this. |trackingArea_| can be nil if | 57 // to the content view allows us to do this. |trackingArea_| can be nil if |
60 // not in presentation mode or during animations. | 58 // not in presentation mode or during animations. |
61 base::scoped_nsobject<NSTrackingArea> trackingArea_; | 59 base::scoped_nsobject<CrTrackingArea> trackingArea_; |
62 | 60 |
63 // Pointer to the currently running animation. Is nil if no animation is | 61 // Pointer to the currently running animation. Is nil if no animation is |
64 // running. | 62 // running. |
65 base::scoped_nsobject<DropdownAnimation> currentAnimation_; | 63 base::scoped_nsobject<DropdownAnimation> currentAnimation_; |
66 | 64 |
67 // Timers for scheduled showing/hiding of the bar (which are always done with | 65 // Timers for scheduled showing/hiding of the bar (which are always done with |
68 // animation). | 66 // animation). |
69 base::scoped_nsobject<NSTimer> showTimer_; | 67 base::scoped_nsobject<NSTimer> showTimer_; |
70 base::scoped_nsobject<NSTimer> hideTimer_; | 68 base::scoped_nsobject<NSTimer> hideTimer_; |
71 | 69 |
(...skipping 24 matching lines...) Expand all Loading... |
96 // Used in both AppKit and Immersive Fullscreen. | 94 // Used in both AppKit and Immersive Fullscreen. |
97 CGFloat toolbarFraction_; | 95 CGFloat toolbarFraction_; |
98 | 96 |
99 // A Carbon event handler that tracks the revealed fraction of the menu bar. | 97 // A Carbon event handler that tracks the revealed fraction of the menu bar. |
100 EventHandlerRef menuBarTrackingHandler_; | 98 EventHandlerRef menuBarTrackingHandler_; |
101 | 99 |
102 // True when the toolbar is dropped to show tabstrip changes. | 100 // True when the toolbar is dropped to show tabstrip changes. |
103 BOOL revealToolbarForTabStripChanges_; | 101 BOOL revealToolbarForTabStripChanges_; |
104 } | 102 } |
105 | 103 |
106 @property(readonly, nonatomic) BOOL inPresentationMode; | |
107 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle; | 104 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle; |
108 @property(nonatomic, assign) CGFloat toolbarFraction; | 105 @property(nonatomic, assign) CGFloat toolbarFraction; |
109 | 106 |
110 // Designated initializer. | 107 // Designated initializer. |
111 - (id)initWithBrowserController:(BrowserWindowController*)controller | 108 - (id)initWithBrowserController:(BrowserWindowController*)controller |
112 style:(fullscreen_mac::SlidingStyle)style; | 109 style:(fullscreen_mac::SlidingStyle)style; |
113 | 110 |
114 // Informs the controller that the browser has entered or exited presentation | 111 // Informs the controller that the browser has entered or exited presentation |
115 // mode. |-enterPresentationModeForContentView:showDropdown:| should be called | 112 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called |
116 // after the window is setup, just before it is shown. |-exitPresentationMode| | 113 // after the window is setup, just before it is shown. |-exitFullscreenMode| |
117 // should be called before any views are moved back to the non-fullscreen | 114 // should be called before any views are moved back to the non-fullscreen |
118 // window. If |-enterPresentationModeForContentView:showDropdown:| is called, | 115 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, |
119 // it must be balanced with a call to |-exitPresentationMode| before the | 116 // it must be balanced with a call to |-exitFullscreenMode| before the |
120 // controller is released. | 117 // controller is released. |
121 - (void)enterPresentationModeForContentView:(NSView*)contentView | 118 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView |
122 showDropdown:(BOOL)showDropdown; | 119 showDropdown:(BOOL)showDropdown; |
123 - (void)exitPresentationMode; | 120 - (void)exitFullscreenMode; |
124 | 121 |
125 // Returns the amount by which the floating bar should be offset downwards (to | 122 // Returns the amount by which the floating bar should be offset downwards (to |
126 // avoid the menu) and by which the overlay view should be enlarged vertically. | 123 // avoid the menu) and by which the overlay view should be enlarged vertically. |
127 // Generally, this is > 0 when the window is on the primary screen and 0 | 124 // Generally, this is > 0 when the window is on the primary screen and 0 |
128 // otherwise. | 125 // otherwise. |
129 - (CGFloat)floatingBarVerticalOffset; | 126 - (CGFloat)floatingBarVerticalOffset; |
130 | 127 |
131 // Informs the controller that the overlay's frame has changed. The controller | 128 // Informs the controller that the overlay's frame has changed. The controller |
132 // uses this information to update its tracking areas. | 129 // uses this information to update its tracking areas. |
133 - (void)overlayFrameChanged:(NSRect)frame; | 130 - (void)overlayFrameChanged:(NSRect)frame; |
(...skipping 17 matching lines...) Expand all Loading... |
151 // Returns true if the window is the main window. | 148 // Returns true if the window is the main window. |
152 - (BOOL)isMainWindow; | 149 - (BOOL)isMainWindow; |
153 | 150 |
154 // Returns true if the browser is in the process of entering/exiting | 151 // Returns true if the browser is in the process of entering/exiting |
155 // fullscreen. | 152 // fullscreen. |
156 - (BOOL)isFullscreenTransitionInProgress; | 153 - (BOOL)isFullscreenTransitionInProgress; |
157 | 154 |
158 @end | 155 @end |
159 | 156 |
160 // Private methods exposed for testing. | 157 // Private methods exposed for testing. |
161 @interface PresentationModeController (ExposedForTesting) | 158 @interface FullscreenToolbarController (ExposedForTesting) |
162 // Adjusts the AppKit Fullscreen options of the application. | 159 // Adjusts the AppKit Fullscreen options of the application. |
163 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; | 160 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; |
164 | 161 |
165 // Callback for menu bar animations. | 162 // Callback for menu bar animations. |
166 - (void)setMenuBarRevealProgress:(CGFloat)progress; | 163 - (void)setMenuBarRevealProgress:(CGFloat)progress; |
167 | 164 |
168 // Updates the local state that reflects the fraction of the toolbar area that | 165 // Updates the local state that reflects the fraction of the toolbar area that |
169 // is showing. This function has the side effect of changing the AppKit | 166 // is showing. This function has the side effect of changing the AppKit |
170 // Fullscreen option for whether the menu bar is shown. | 167 // Fullscreen option for whether the menu bar is shown. |
171 - (void)changeToolbarFraction:(CGFloat)fraction; | 168 - (void)changeToolbarFraction:(CGFloat)fraction; |
172 | 169 |
173 @end | 170 @end |
174 | 171 |
175 // Notification posted when we're about to enter or leave fullscreen. | 172 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
176 extern NSString* const kWillEnterFullscreenNotification; | |
177 extern NSString* const kWillLeaveFullscreenNotification; | |
178 | |
179 #endif // CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ | |
OLD | NEW |