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_PRESENTATION_MODE_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ |
7 | 7 |
| 8 #include <Carbon/Carbon.h> |
8 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
9 | 10 |
10 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
11 #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" |
12 | 13 |
13 @class BrowserWindowController; | 14 @class BrowserWindowController; |
14 @class DropdownAnimation; | 15 @class DropdownAnimation; |
15 | 16 |
| 17 namespace fullscreen_mac { |
| 18 enum SlidingStyle { |
| 19 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible. |
| 20 OMNIBOX_PRESENT, // Tab strip hidden. |
| 21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. |
| 22 }; |
| 23 } // namespace fullscreen_mac |
| 24 |
| 25 // TODO(erikchen): This controller is misnamed. It manages the sliding tab |
| 26 // strip and omnibox in all fullscreen modes. |
| 27 |
16 // Provides a controller to manage presentation mode for a single browser | 28 // Provides a controller to manage presentation mode for a single browser |
17 // window. This class handles running animations, showing and hiding the | 29 // window. This class handles running animations, showing and hiding the |
18 // floating dropdown bar, and managing the tracking area associated with the | 30 // floating dropdown bar, and managing the tracking area associated with the |
19 // dropdown. This class does not directly manage any views -- the | 31 // dropdown. This class does not directly manage any views -- the |
20 // BrowserWindowController is responsible for positioning and z-ordering views. | 32 // BrowserWindowController is responsible for positioning and z-ordering views. |
21 // | 33 // |
22 // Tracking areas are disabled while animations are running. If | 34 // Tracking areas are disabled while animations are running. If |
23 // |overlayFrameChanged:| is called while an animation is running, the | 35 // |overlayFrameChanged:| is called while an animation is running, the |
24 // controller saves the new frame and installs the appropriate tracking area | 36 // controller saves the new frame and installs the appropriate tracking area |
25 // when the animation finishes. This is largely done for ease of | 37 // when the animation finishes. This is largely done for ease of |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Tracks the currently requested system fullscreen mode, used to show or hide | 76 // Tracks the currently requested system fullscreen mode, used to show or hide |
65 // the menubar. This should be |kFullScreenModeNormal| when the window is not | 77 // the menubar. This should be |kFullScreenModeNormal| when the window is not |
66 // main or not fullscreen, |kFullScreenModeHideAll| while the overlay is | 78 // main or not fullscreen, |kFullScreenModeHideAll| while the overlay is |
67 // hidden, and |kFullScreenModeHideDock| while the overlay is shown. If the | 79 // hidden, and |kFullScreenModeHideDock| while the overlay is shown. If the |
68 // window is not on the primary screen, this should always be | 80 // window is not on the primary screen, this should always be |
69 // |kFullScreenModeNormal|. This value can get out of sync with the correct | 81 // |kFullScreenModeNormal|. This value can get out of sync with the correct |
70 // state if we miss a notification (which can happen when a window is closed). | 82 // state if we miss a notification (which can happen when a window is closed). |
71 // Used to track the current state and make sure we properly restore the menu | 83 // Used to track the current state and make sure we properly restore the menu |
72 // bar when this controller is destroyed. | 84 // bar when this controller is destroyed. |
73 base::mac::FullScreenMode systemFullscreenMode_; | 85 base::mac::FullScreenMode systemFullscreenMode_; |
| 86 |
| 87 // Whether the omnibox is hidden in fullscreen. |
| 88 fullscreen_mac::SlidingStyle slidingStyle_; |
| 89 |
| 90 // The fraction of the AppKit Menubar that is showing. Ranges from 0 to 1. |
| 91 // Only used in AppKit Fullscreen. |
| 92 CGFloat menubarFraction_; |
| 93 |
| 94 // The fraction of the omnibox/tabstrip that is showing. Ranges from 0 to 1. |
| 95 // Used in both AppKit and Immersive Fullscreen. |
| 96 CGFloat toolbarFraction_; |
| 97 |
| 98 // A Carbon event handler that tracks the revealed fraction of the menu bar. |
| 99 EventHandlerRef menuBarTrackingHandler_; |
74 } | 100 } |
75 | 101 |
76 @property(readonly, nonatomic) BOOL inPresentationMode; | 102 @property(readonly, nonatomic) BOOL inPresentationMode; |
| 103 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle; |
| 104 @property(nonatomic, assign) CGFloat toolbarFraction; |
77 | 105 |
78 // Designated initializer. | 106 // Designated initializer. |
79 - (id)initWithBrowserController:(BrowserWindowController*)controller; | 107 - (id)initWithBrowserController:(BrowserWindowController*)controller |
| 108 style:(fullscreen_mac::SlidingStyle)style; |
80 | 109 |
81 // Informs the controller that the browser has entered or exited presentation | 110 // Informs the controller that the browser has entered or exited presentation |
82 // mode. |-enterPresentationModeForContentView:showDropdown:| should be called | 111 // mode. |-enterPresentationModeForContentView:showDropdown:| should be called |
83 // after the window is setup, just before it is shown. |-exitPresentationMode| | 112 // after the window is setup, just before it is shown. |-exitPresentationMode| |
84 // 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 |
85 // window. If |-enterPresentationModeForContentView:showDropdown:| is called, | 114 // window. If |-enterPresentationModeForContentView:showDropdown:| is called, |
86 // it must be balanced with a call to |-exitPresentationMode| before the | 115 // it must be balanced with a call to |-exitPresentationMode| before the |
87 // controller is released. | 116 // controller is released. |
88 - (void)enterPresentationModeForContentView:(NSView*)contentView | 117 - (void)enterPresentationModeForContentView:(NSView*)contentView |
89 showDropdown:(BOOL)showDropdown; | 118 showDropdown:(BOOL)showDropdown; |
(...skipping 10 matching lines...) Expand all Loading... |
100 - (void)overlayFrameChanged:(NSRect)frame; | 129 - (void)overlayFrameChanged:(NSRect)frame; |
101 | 130 |
102 // Informs the controller that the overlay should be shown/hidden, possibly with | 131 // Informs the controller that the overlay should be shown/hidden, possibly with |
103 // animation, possibly after a delay (only applicable for the animated case). | 132 // animation, possibly after a delay (only applicable for the animated case). |
104 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay; | 133 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay; |
105 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay; | 134 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay; |
106 | 135 |
107 // Cancels any running animation and timers. | 136 // Cancels any running animation and timers. |
108 - (void)cancelAnimationAndTimers; | 137 - (void)cancelAnimationAndTimers; |
109 | 138 |
110 // Gets the current floating bar shown fraction. | 139 // In any fullscreen mode, the y offset to use for the content at the top of |
111 - (CGFloat)floatingBarShownFraction; | 140 // the screen (tab strip, omnibox, bookmark bar, etc). |
112 | 141 // Ranges from 0 to -22. |
113 // Sets a new current floating bar shown fraction. NOTE: This function has side | 142 - (CGFloat)menubarOffset; |
114 // effects, such as modifying the system fullscreen mode (menu bar shown state). | |
115 - (void)changeFloatingBarShownFraction:(CGFloat)fraction; | |
116 | 143 |
117 @end | 144 @end |
118 | 145 |
119 // Notification posted when we're about to enter or leave fullscreen. | 146 // Notification posted when we're about to enter or leave fullscreen. |
120 extern NSString* const kWillEnterFullscreenNotification; | 147 extern NSString* const kWillEnterFullscreenNotification; |
121 extern NSString* const kWillLeaveFullscreenNotification; | 148 extern NSString* const kWillLeaveFullscreenNotification; |
122 | 149 |
123 #endif // CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ | 150 #endif // CHROME_BROWSER_UI_COCOA_PRESENTATION_MODE_CONTROLLER_H_ |
OLD | NEW |