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