Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h

Issue 2256993002: [Mac] Reworked FullscreenToolbarController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for erikchen Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
16 @class DropdownAnimation; 15 @class DropdownAnimation;
17 16
18 namespace fullscreen_mac { 17 namespace fullscreen_mac {
19 enum SlidingStyle { 18 enum SlidingStyle {
20 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible. 19 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible.
21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. 20 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden.
22 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never 21 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never
23 // shown. 22 // shown.
24 }; 23 };
25 } // namespace fullscreen_mac 24 } // namespace fullscreen_mac
26 25
27 // Provides a controller to fullscreen toolbar for a single browser 26 // Provides a controller to fullscreen toolbar for a single browser
28 // window. This class handles running animations, showing and hiding the 27 // window. This class handles running animations, showing and hiding the
29 // floating dropdown bar, and managing the tracking area associated with the 28 // floating dropdown bar, and managing the tracking area associated with the
30 // dropdown. This class does not directly manage any views -- the 29 // dropdown. This class does not directly manage any views -- the
31 // BrowserWindowController is responsible for positioning and z-ordering views. 30 // BrowserWindowController is responsible for positioning and z-ordering views.
32 // 31 //
33 // Tracking areas are disabled while animations are running. If 32 // Tracking areas are disabled while animations are running. If
34 // |overlayFrameChanged:| is called while an animation is running, the 33 // |overlayFrameChanged:| is called while an animation is running, the
35 // controller saves the new frame and installs the appropriate tracking area 34 // controller saves the new frame and installs the appropriate tracking area
36 // when the animation finishes. This is largely done for ease of 35 // when the animation finishes. This is largely done for ease of
37 // 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
38 // step than it is to manage a constantly-changing tracking area. 37 // step than it is to manage a constantly-changing tracking area.
39 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { 38 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> {
40 @private 39 @private
41 // Our parent controller. 40 // Our parent controller.
42 BrowserWindowController* browserController_; // weak 41 BrowserWindowController* browserController_; // weak
43 42
44 // The content view for the window. This is nil when not in presentation
45 // mode.
46 NSView* contentView_; // weak
47
48 // YES while this controller is in the process of setting up for fullscreen.
49 BOOL settingUp_;
50
51 // Whether or not we are in fullscreen mode. 43 // Whether or not we are in fullscreen mode.
52 BOOL inFullscreenMode_; 44 BOOL inFullscreenMode_;
53 45
54 // The tracking area associated with the floating dropdown bar. This tracking
55 // area is attached to |contentView_|, because when the dropdown is completely
56 // hidden, we still need to keep a 1px tall tracking area visible. Attaching
57 // to the content view allows us to do this. |trackingArea_| can be nil if
58 // not in presentation mode or during animations.
59 base::scoped_nsobject<CrTrackingArea> trackingArea_;
60
61 // Pointer to the currently running animation. Is nil if no animation is 46 // Pointer to the currently running animation. Is nil if no animation is
62 // running. 47 // running.
63 base::scoped_nsobject<DropdownAnimation> currentAnimation_; 48 base::scoped_nsobject<DropdownAnimation> currentAnimation_;
64 49
65 // Timers for scheduled showing/hiding of the bar (which are always done with 50 // Timer for scheduled hiding of the toolbar when it had been revealed for
66 // animation). 51 // tabstrip changes.
67 base::scoped_nsobject<NSTimer> showTimer_;
68 base::scoped_nsobject<NSTimer> hideTimer_; 52 base::scoped_nsobject<NSTimer> hideTimer_;
69 53
70 // Holds the current bounds of |trackingArea_|, even if |trackingArea_| is 54 // Tracks the currently requested system fullscreen mode, used to show or
71 // currently nil. Used to restore the tracking area when an animation 55 // hide the menubar. This should be |kFullScreenModeNormal| when the window
72 // completes. 56 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay
73 NSRect trackingAreaBounds_; 57 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If
74 58 // the window is not on the primary screen, this should always be
75 // Tracks the currently requested system fullscreen mode, used to show or hide
76 // the menubar. This should be |kFullScreenModeNormal| when the window is not
77 // main or not fullscreen, |kFullScreenModeHideAll| while the overlay is
78 // hidden, and |kFullScreenModeHideDock| while the overlay is shown. If the
79 // window is not on the primary screen, this should always be
80 // |kFullScreenModeNormal|. This value can get out of sync with the correct 59 // |kFullScreenModeNormal|. This value can get out of sync with the correct
81 // state if we miss a notification (which can happen when a window is closed). 60 // state if we miss a notification (which can happen when a window is closed).
82 // Used to track the current state and make sure we properly restore the menu 61 // Used to track the current state and make sure we properly restore the menu
83 // bar when this controller is destroyed. 62 // bar when this controller is destroyed.
84 base::mac::FullScreenMode systemFullscreenMode_; 63 base::mac::FullScreenMode systemFullscreenMode_;
85 64
86 // Whether the omnibox is hidden in fullscreen. 65 // Whether the omnibox is hidden in fullscreen.
87 fullscreen_mac::SlidingStyle slidingStyle_; 66 fullscreen_mac::SlidingStyle slidingStyle_;
88 67
89 // The fraction of the AppKit Menubar that is showing. Ranges from 0 to 1. 68 // The fraction of the AppKit Menubar that is showing. Ranges from 0 to 1.
(...skipping 18 matching lines...) Expand all
108 - (id)initWithBrowserController:(BrowserWindowController*)controller 87 - (id)initWithBrowserController:(BrowserWindowController*)controller
109 style:(fullscreen_mac::SlidingStyle)style; 88 style:(fullscreen_mac::SlidingStyle)style;
110 89
111 // Informs the controller that the browser has entered or exited presentation 90 // Informs the controller that the browser has entered or exited presentation
112 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called 91 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called
113 // after the window is setup, just before it is shown. |-exitFullscreenMode| 92 // after the window is setup, just before it is shown. |-exitFullscreenMode|
114 // should be called before any views are moved back to the non-fullscreen 93 // should be called before any views are moved back to the non-fullscreen
115 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, 94 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called,
116 // it must be balanced with a call to |-exitFullscreenMode| before the 95 // it must be balanced with a call to |-exitFullscreenMode| before the
117 // controller is released. 96 // controller is released.
118 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView 97 - (void)setupFullscreenToolbarWithDropdown:(BOOL)showDropdown;
119 showDropdown:(BOOL)showDropdown;
120 - (void)exitFullscreenMode; 98 - (void)exitFullscreenMode;
121 99
122 // Returns the amount by which the floating bar should be offset downwards (to 100 // Returns the amount by which the floating bar should be offset downwards (to
123 // avoid the menu) and by which the overlay view should be enlarged vertically. 101 // avoid the menu) and by which the overlay view should be enlarged vertically.
124 // Generally, this is > 0 when the window is on the primary screen and 0 102 // Generally, this is > 0 when the window is on the primary screen and 0
125 // otherwise. 103 // otherwise.
126 - (CGFloat)floatingBarVerticalOffset; 104 - (CGFloat)floatingBarVerticalOffset;
127 105
128 // Informs the controller that the overlay's frame has changed. The controller 106 // Informs the controller that the overlay should be shown/hidden, possibly
129 // uses this information to update its tracking areas. 107 // with animation.
130 - (void)overlayFrameChanged:(NSRect)frame; 108 - (void)ensureOverlayShownWithAnimation:(BOOL)animate;
131 109 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate;
132 // Informs the controller that the overlay should be shown/hidden, possibly with
133 // animation, possibly after a delay (only applicable for the animated case).
134 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay;
135 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay;
136 110
137 // Cancels any running animation and timers. 111 // Cancels any running animation and timers.
138 - (void)cancelAnimationAndTimers; 112 - (void)cancelAnimationAndTimer;
139 113
140 // Animates the toolbar dropping down to show changes to the tab strip. 114 // Animates the toolbar dropping down to show changes to the tab strip.
141 - (void)revealToolbarForTabStripChanges; 115 - (void)revealToolbarForTabStripChanges;
142 116
143 // In any fullscreen mode, the y offset to use for the content at the top of 117 // In any fullscreen mode, the y offset to use for the content at the top of
144 // the screen (tab strip, omnibox, bookmark bar, etc). 118 // the screen (tab strip, omnibox, bookmark bar, etc).
145 // Ranges from 0 to -22. 119 // Ranges from 0 to -22.
146 - (CGFloat)menubarOffset; 120 - (CGFloat)menubarOffset;
147 121
148 // Returns true if the window is the main window. 122 // Returns YES if the mouse is on the window's screen. This is used to check
149 - (BOOL)isMainWindow; 123 // if the menubar events belong to window's screen since the menubar would
124 // only be revealed if the mouse is there.
125 - (BOOL)isMouseOnScreen;
150 126
151 // Returns true if the browser is in the process of entering/exiting 127 // Returns true if the browser is in the process of entering/exiting
152 // fullscreen. 128 // fullscreen.
153 - (BOOL)isFullscreenTransitionInProgress; 129 - (BOOL)isFullscreenTransitionInProgress;
154 130
155 @end 131 @end
156 132
157 // Private methods exposed for testing. 133 // Private methods exposed for testing.
158 @interface FullscreenToolbarController (ExposedForTesting) 134 @interface FullscreenToolbarController (ExposedForTesting)
159 // Adjusts the AppKit Fullscreen options of the application. 135 // Adjusts the AppKit Fullscreen options of the application.
160 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; 136 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode;
161 137
162 // Callback for menu bar animations. 138 // Callback for menu bar animations.
163 - (void)setMenuBarRevealProgress:(CGFloat)progress; 139 - (void)setMenuBarRevealProgress:(CGFloat)progress;
164 140
165 // Updates the local state that reflects the fraction of the toolbar area that 141 // Updates the local state that reflects the fraction of the toolbar area that
166 // is showing. This function has the side effect of changing the AppKit 142 // is showing. This function has the side effect of changing the AppKit
167 // Fullscreen option for whether the menu bar is shown. 143 // Fullscreen option for whether the menu bar is shown.
168 - (void)changeToolbarFraction:(CGFloat)fraction; 144 - (void)changeToolbarFraction:(CGFloat)fraction;
169 145
170 @end 146 @end
171 147
172 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ 148 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller_private.mm ('k') | chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698