| 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_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_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 CrTrackingArea; |
| 16 @class DropdownAnimation; | 16 @class DropdownAnimation; |
| 17 @class FullscreenMenubarTracker; |
| 17 | 18 |
| 18 enum class FullscreenSlidingStyle { | 19 enum class FullscreenSlidingStyle { |
| 19 OMNIBOX_TABS_PRESENT, // Tab strip and omnibox both visible. | 20 OMNIBOX_TABS_PRESENT, // 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 | 25 |
| 25 // State of the menubar in the window's screen. | |
| 26 enum class FullscreenMenubarState { | |
| 27 SHOWN, // Menubar is fully shown. | |
| 28 HIDDEN, // Menubar is fully hidden. | |
| 29 SHOWING, // Menubar is animating in. | |
| 30 HIDING, // Menubar is animating out. | |
| 31 }; | |
| 32 | |
| 33 // Provides a controller to fullscreen toolbar for a single browser | 26 // Provides a controller to fullscreen toolbar for a single browser |
| 34 // window. This class handles running animations, showing and hiding the | 27 // window. This class handles running animations, showing and hiding the |
| 35 // fullscreen toolbar, and managing the tracking area associated with the | 28 // fullscreen toolbar, and managing the tracking area associated with the |
| 36 // toolbar. This class does not directly manage any views -- the | 29 // toolbar. This class does not directly manage any views -- the |
| 37 // BrowserWindowController is responsible for positioning and z-ordering views. | 30 // BrowserWindowController is responsible for positioning and z-ordering views. |
| 38 // | 31 // |
| 39 | 32 |
| 40 // TODO (spqchan): Write tests for this class. See crbug.com/640064. | 33 // TODO (spqchan): Write tests for this class. See crbug.com/640064. |
| 41 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { | 34 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { |
| 42 @private | 35 @private |
| 43 // Our parent controller. | 36 // Our parent controller. |
| 44 BrowserWindowController* browserController_; // weak | 37 BrowserWindowController* browserController_; // weak |
| 45 | 38 |
| 46 // Whether or not we are in fullscreen mode. | 39 // Whether or not we are in fullscreen mode. |
| 47 BOOL inFullscreenMode_; | 40 BOOL inFullscreenMode_; |
| 48 | 41 |
| 49 // The content view for the window. This is nil when not in fullscreen mode. | 42 // The content view for the window. This is nil when not in fullscreen mode. |
| 50 NSView* contentView_; // weak | 43 NSView* contentView_; // weak |
| 51 | 44 |
| 52 // The frame for the tracking area. The value is the toolbar overlay's frame | 45 // The frame for the tracking area. The value is the toolbar overlay's frame |
| 53 // with additional height added at the bottom. | 46 // with additional height added at the bottom. |
| 54 NSRect trackingAreaFrame_; | 47 NSRect trackingAreaFrame_; |
| 55 | 48 |
| 56 // The tracking area associated with the toolbar overlay bar. This tracking | 49 // The tracking area associated with the toolbar overlay bar. This tracking |
| 57 // area is used to keep the toolbar active if the menubar had animated out | 50 // area is used to keep the toolbar active if the menubar had animated out |
| 58 // but the mouse is still on the toolbar. | 51 // but the mouse is still on the toolbar. |
| 59 base::scoped_nsobject<CrTrackingArea> trackingArea_; | 52 base::scoped_nsobject<CrTrackingArea> trackingArea_; |
| 60 | 53 |
| 54 // Updates the fullscreen toolbar layout for changes in the menubar. This |
| 55 // object is only set when the browser is in fullscreen mode. |
| 56 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; |
| 57 |
| 61 // Pointer to the currently running animation. Is nil if no animation is | 58 // Pointer to the currently running animation. Is nil if no animation is |
| 62 // running. | 59 // running. |
| 63 base::scoped_nsobject<DropdownAnimation> currentAnimation_; | 60 base::scoped_nsobject<DropdownAnimation> currentAnimation_; |
| 64 | 61 |
| 65 // Timer for scheduled hiding of the toolbar when it had been revealed for | 62 // Timer for scheduled hiding of the toolbar when it had been revealed for |
| 66 // tabstrip changes. | 63 // tabstrip changes. |
| 67 base::scoped_nsobject<NSTimer> hideTimer_; | 64 base::scoped_nsobject<NSTimer> hideTimer_; |
| 68 | 65 |
| 69 // Tracks the currently requested system fullscreen mode, used to show or | 66 // Tracks the currently requested system fullscreen mode, used to show or |
| 70 // hide the menubar. This should be |kFullScreenModeNormal| when the window | 67 // hide the menubar. This should be |kFullScreenModeNormal| when the window |
| 71 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay | 68 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay |
| 72 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If | 69 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If |
| 73 // the window is not on the primary screen, this should always be | 70 // the window is not on the primary screen, this should always be |
| 74 // |kFullScreenModeNormal|. This value can get out of sync with the correct | 71 // |kFullScreenModeNormal|. This value can get out of sync with the correct |
| 75 // state if we miss a notification (which can happen when a window is closed). | 72 // state if we miss a notification (which can happen when a window is closed). |
| 76 // Used to track the current state and make sure we properly restore the menu | 73 // Used to track the current state and make sure we properly restore the menu |
| 77 // bar when this controller is destroyed. | 74 // bar when this controller is destroyed. |
| 78 base::mac::FullScreenMode systemFullscreenMode_; | 75 base::mac::FullScreenMode systemFullscreenMode_; |
| 79 | 76 |
| 80 // Whether the omnibox is hidden in fullscreen. | 77 // Whether the omnibox is hidden in fullscreen. |
| 81 FullscreenSlidingStyle slidingStyle_; | 78 FullscreenSlidingStyle slidingStyle_; |
| 82 | 79 |
| 83 // The fraction of the AppKit Menubar that is showing. Ranges from 0 to 1. | |
| 84 // Only used in AppKit Fullscreen. | |
| 85 CGFloat menubarFraction_; | |
| 86 | |
| 87 // The state of the menubar in fullscreen. | |
| 88 FullscreenMenubarState menubarState_; | |
| 89 | |
| 90 // A Carbon event handler that tracks the revealed fraction of the menu bar. | |
| 91 EventHandlerRef menuBarTrackingHandler_; | |
| 92 | |
| 93 // True when the toolbar is dropped to show tabstrip changes. | 80 // True when the toolbar is dropped to show tabstrip changes. |
| 94 BOOL isRevealingToolbarForTabStripChanges_; | 81 BOOL isRevealingToolbarForTabStripChanges_; |
| 95 | 82 |
| 96 // True when the toolbar should be animated back out via a DropdownAnimation. | 83 // True when the toolbar should be animated back out via a DropdownAnimation. |
| 97 // This is set and unset in hideTimer: and mouseExited:. It's set to YES | 84 // This is set and unset in hideTimer: and mouseExited:. It's set to YES |
| 98 // before it calls animateToolbarVisibility: and then set to NO after the | 85 // before it calls animateToolbarVisibility: and then set to NO after the |
| 99 // animation has started. | 86 // animation has started. |
| 100 BOOL shouldAnimateToolbarOut_; | 87 BOOL shouldAnimateToolbarOut_; |
| 101 | 88 |
| 102 // True when the toolbar is animating in/out for changes in the toolbar | 89 // True when the toolbar is animating in/out for changes in the toolbar |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 // Informs the controller that the browser has entered or exited fullscreen | 101 // Informs the controller that the browser has entered or exited fullscreen |
| 115 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called | 102 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called |
| 116 // after the window is setup, just before it is shown. |-exitFullscreenMode| | 103 // 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 | 104 // should be called before any views are moved back to the non-fullscreen |
| 118 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, | 105 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, |
| 119 // it must be balanced with a call to |-exitFullscreenMode| before the | 106 // it must be balanced with a call to |-exitFullscreenMode| before the |
| 120 // controller is released. | 107 // controller is released. |
| 121 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView; | 108 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView; |
| 122 - (void)exitFullscreenMode; | 109 - (void)exitFullscreenMode; |
| 123 | 110 |
| 124 // Returns the amount by which the floating bar should be offset downwards (to | |
| 125 // avoid the menu) and by which the overlay view should be enlarged vertically. | |
| 126 // Generally, this is > 0 when the window is on the primary screen and 0 | |
| 127 // otherwise. | |
| 128 - (CGFloat)floatingBarVerticalOffset; | |
| 129 | |
| 130 // Shows/hides the toolbar with animation to reflect changes for the toolbar | 111 // Shows/hides the toolbar with animation to reflect changes for the toolbar |
| 131 // visibility locks. lockBarVisibilityWithAnimation: should only be called when | 112 // visibility locks. lockBarVisibilityWithAnimation: should only be called when |
| 132 // the lock state goes from unlocked to locked. Likewise, | 113 // the lock state goes from unlocked to locked. Likewise, |
| 133 // releaseBarVisibilityWithAnimation: should only be called whenthe lock state | 114 // releaseBarVisibilityWithAnimation: should only be called whenthe lock state |
| 134 // goes from locked to unlocked. | 115 // goes from locked to unlocked. |
| 135 - (void)lockBarVisibilityWithAnimation:(BOOL)animate; | 116 - (void)lockBarVisibilityWithAnimation:(BOOL)animate; |
| 136 - (void)releaseBarVisibilityWithAnimation:(BOOL)animate; | 117 - (void)releaseBarVisibilityWithAnimation:(BOOL)animate; |
| 137 | 118 |
| 138 // Informs the controller that the overlay should be shown/hidden, possibly | 119 // Informs the controller that the overlay should be shown/hidden, possibly |
| 139 // with animation. | 120 // with animation. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 168 // Returns YES if the browser is in the process of entering/exiting | 149 // Returns YES if the browser is in the process of entering/exiting |
| 169 // fullscreen. | 150 // fullscreen. |
| 170 - (BOOL)isFullscreenTransitionInProgress; | 151 - (BOOL)isFullscreenTransitionInProgress; |
| 171 | 152 |
| 172 // Returns YES if the browser in in fullscreen. | 153 // Returns YES if the browser in in fullscreen. |
| 173 - (BOOL)isInFullscreen; | 154 - (BOOL)isInFullscreen; |
| 174 | 155 |
| 175 // Updates the toolbar by updating the layout, menubar and dock. | 156 // Updates the toolbar by updating the layout, menubar and dock. |
| 176 - (void)updateToolbar; | 157 - (void)updateToolbar; |
| 177 | 158 |
| 159 // Returns |browserController_|. |
| 160 - (BrowserWindowController*)browserWindowController; |
| 161 |
| 178 @end | 162 @end |
| 179 | 163 |
| 180 // Private methods exposed for testing. | 164 // Private methods exposed for testing. |
| 181 @interface FullscreenToolbarController (ExposedForTesting) | 165 @interface FullscreenToolbarController (ExposedForTesting) |
| 182 // Adjusts the AppKit Fullscreen options of the application. | 166 // Adjusts the AppKit Fullscreen options of the application. |
| 183 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; | 167 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; |
| 184 | 168 |
| 185 // Callback for menu bar animations. | 169 // Callback for menu bar animations. |
| 186 - (void)setMenuBarRevealProgress:(CGFloat)progress; | 170 - (void)setMenuBarRevealProgress:(CGFloat)progress; |
| 187 | 171 |
| 188 @end | 172 @end |
| 189 | 173 |
| 190 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ | 174 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ |
| OLD | NEW |