| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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_COCOA_FULLSCREEN_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ | 6 #define CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
| 10 | 10 |
| 11 #import "base/cocoa_protocols_mac.h" | 11 #import "base/cocoa_protocols_mac.h" |
| 12 #include "base/mac_util.h" | 12 #include "base/mac_util.h" |
| 13 #include "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" | 13 #include "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" |
| 14 | 14 |
| 15 @class BrowserWindowController; | 15 @class BrowserWindowController; |
| 16 @class DropdownAnimation; | 16 @class DropdownAnimation; |
| 17 @class FloatingBarBackingView; |
| 18 @class FullscreenWindow; |
| 17 | 19 |
| 18 // Provides a controller to manage fullscreen mode for a single browser window. | 20 // Provides a controller to manage fullscreen mode for a single browser window. |
| 19 // This class handles running animations, showing and hiding the floating | 21 // This class handles running animations, showing and hiding the floating |
| 20 // dropdown bar, and managing the tracking area associated with the dropdown. | 22 // dropdown bar, and managing the tracking area associated with the dropdown. |
| 21 // This class does not directly manage any views -- the BrowserWindowController | 23 // This class does not directly manage any views -- the BrowserWindowController |
| 22 // is responsible for positioning and z-ordering views. | 24 // is responsible for positioning and z-ordering views. |
| 23 // | 25 // |
| 24 // Tracking areas are disabled while animations are running. If | 26 // Tracking areas are disabled while animations are running. If |
| 25 // |overlayFrameChanged:| is called while an animation is running, the | 27 // |overlayFrameChanged:| is called while an animation is running, the |
| 26 // controller saves the new frame and installs the appropriate tracking area | 28 // controller saves the new frame and installs the appropriate tracking area |
| 27 // when the animation finishes. This is largely done for ease of | 29 // when the animation finishes. This is largely done for ease of |
| 28 // implementation; it is easier to check the mouse location at each animation | 30 // implementation; it is easier to check the mouse location at each animation |
| 29 // step than it is to manage a constantly-changing tracking area. | 31 // step than it is to manage a constantly-changing tracking area. |
| 30 @interface FullscreenController : NSObject<NSAnimationDelegate> { | 32 @interface FullscreenController : NSObject<NSAnimationDelegate> { |
| 31 @private | 33 @private |
| 34 scoped_nsobject<FullscreenWindow> fullscreenWindow_; |
| 35 |
| 36 // Lazily created view which draws the background for the floating set of bars |
| 37 // in fullscreen mode (for window types having a floating bar; it remains nil |
| 38 // for those which don't). |
| 39 scoped_nsobject<NSView> floatingBarBackingView_; |
| 40 |
| 32 // Our parent controller. | 41 // Our parent controller. |
| 33 BrowserWindowController* browserController_; // weak | 42 BrowserWindowController* browserController_; // weak |
| 34 | 43 |
| 35 // The content view for the fullscreen window. This is nil when not in | 44 // The content view for the fullscreen window. This is nil when not in |
| 36 // fullscreen mode. | 45 // fullscreen mode. |
| 37 NSView* contentView_; // weak | 46 NSView* contentView_; // weak |
| 38 | 47 |
| 39 // Whether or not we are in fullscreen mode. | 48 // Whether or not we are in fullscreen mode. |
| 40 BOOL isFullscreen_; | 49 BOOL isFullscreen_; |
| 41 | 50 |
| 51 // The proportion of the floating bar which is shown. |
| 52 CGFloat floatingBarShownFraction_; |
| 53 |
| 42 // The tracking area associated with the floating dropdown bar. This tracking | 54 // The tracking area associated with the floating dropdown bar. This tracking |
| 43 // area is attached to |contentView_|, because when the dropdown is completely | 55 // 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 | 56 // 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 | 57 // to the content view allows us to do this. |trackingArea_| can be nil if |
| 46 // not in fullscreen mode or during animations. | 58 // not in fullscreen mode or during animations. |
| 47 scoped_nsobject<NSTrackingArea> trackingArea_; | 59 scoped_nsobject<NSTrackingArea> trackingArea_; |
| 48 | 60 |
| 49 // 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 |
| 50 // running. | 62 // running. |
| 51 scoped_nsobject<DropdownAnimation> currentAnimation_; | 63 scoped_nsobject<DropdownAnimation> currentAnimation_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 81 // mode. |-enterFullscreenForContentView:showDropdown:| should be called after | 93 // mode. |-enterFullscreenForContentView:showDropdown:| should be called after |
| 82 // the fullscreen window is setup, just before it is shown. |-exitFullscreen| | 94 // 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 | 95 // should be called before any views are moved back to the non-fullscreen |
| 84 // window. If |-enterFullscreenForContentView:showDropdown:| is called, it must | 96 // window. If |-enterFullscreenForContentView:showDropdown:| is called, it must |
| 85 // be followed with a call to |-exitFullscreen| before the controller is | 97 // be followed with a call to |-exitFullscreen| before the controller is |
| 86 // released. | 98 // released. |
| 87 - (void)enterFullscreenForContentView:(NSView*)contentView | 99 - (void)enterFullscreenForContentView:(NSView*)contentView |
| 88 showDropdown:(BOOL)showDropdown; | 100 showDropdown:(BOOL)showDropdown; |
| 89 - (void)exitFullscreen; | 101 - (void)exitFullscreen; |
| 90 | 102 |
| 103 // Returns the FullscreenWindow associated with this controller. |
| 104 - (FullscreenWindow*)window; |
| 105 |
| 106 - (NSView*)floatingBarBackingView; |
| 107 |
| 91 // Returns the amount by which the floating bar should be offset downwards (to | 108 // 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. | 109 // 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 | 110 // Generally, this is > 0 when the fullscreen window is on the primary screen |
| 94 // and 0 otherwise. | 111 // and 0 otherwise. |
| 95 - (CGFloat)floatingBarVerticalOffset; | 112 - (CGFloat)floatingBarVerticalOffset; |
| 96 | 113 |
| 97 // Informs the controller that the overlay's frame has changed. The controller | 114 // Informs the controller that the overlay's frame has changed. The controller |
| 98 // uses this information to update its tracking areas. | 115 // uses this information to update its tracking areas. |
| 99 - (void)overlayFrameChanged:(NSRect)frame; | 116 - (void)overlayFrameChanged:(NSRect)frame; |
| 100 | 117 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 113 // effects, such as modifying the fullscreen mode (menu bar shown state). | 130 // effects, such as modifying the fullscreen mode (menu bar shown state). |
| 114 - (void)changeFloatingBarShownFraction:(CGFloat)fraction; | 131 - (void)changeFloatingBarShownFraction:(CGFloat)fraction; |
| 115 | 132 |
| 116 @end | 133 @end |
| 117 | 134 |
| 118 // Notification posted when we're about to enter or leave fullscreen. | 135 // Notification posted when we're about to enter or leave fullscreen. |
| 119 extern NSString* const kWillEnterFullscreenNotification; | 136 extern NSString* const kWillEnterFullscreenNotification; |
| 120 extern NSString* const kWillLeaveFullscreenNotification; | 137 extern NSString* const kWillLeaveFullscreenNotification; |
| 121 | 138 |
| 122 #endif // CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ | 139 #endif // CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ |
| OLD | NEW |