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

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

Issue 2430403003: [Mac] Refactor the fullscreen toolbar animation (Closed)
Patch Set: Fix for erikchen 3 Created 4 years, 1 month 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; 15 @class CrTrackingArea;
16 @class DropdownAnimation;
17 @class FullscreenMenubarTracker; 16 @class FullscreenMenubarTracker;
17 class FullscreenToolbarAnimationController;
18 18
19 enum class FullscreenSlidingStyle { 19 enum class FullscreenSlidingStyle {
20 OMNIBOX_TABS_PRESENT, // Tab strip and omnibox both visible. 20 OMNIBOX_TABS_PRESENT, // Tab strip and omnibox both visible.
21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden. 21 OMNIBOX_TABS_HIDDEN, // Tab strip and omnibox both hidden.
22 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never 22 OMNIBOX_TABS_NONE, // Tab strip and omnibox both hidden and never
23 // shown. 23 // shown.
24 }; 24 };
25 25
26 // Provides a controller to fullscreen toolbar for a single browser 26 // Provides a controller to fullscreen toolbar for a single browser
27 // window. This class handles running animations, showing and hiding the 27 // window. This class handles running animations, showing and hiding the
28 // fullscreen toolbar, and managing the tracking area associated with the 28 // fullscreen toolbar, and managing the tracking area associated with the
29 // toolbar. This class does not directly manage any views -- the 29 // toolbar. This class does not directly manage any views -- the
30 // BrowserWindowController is responsible for positioning and z-ordering views. 30 // BrowserWindowController is responsible for positioning and z-ordering views.
31 // 31 //
32 32
33 // TODO (spqchan): Write tests for this class. See crbug.com/640064. 33 // TODO (spqchan): Write tests for this class. See crbug.com/640064.
34 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { 34 @interface FullscreenToolbarController : NSObject {
35 @private 35 @private
36 // Our parent controller. 36 // Our parent controller.
37 BrowserWindowController* browserController_; // weak 37 BrowserWindowController* browserController_; // weak
38 38
39 // Whether or not we are in fullscreen mode. 39 // Whether or not we are in fullscreen mode.
40 BOOL inFullscreenMode_; 40 BOOL inFullscreenMode_;
41 41
42 // 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.
43 NSView* contentView_; // weak 43 NSView* contentView_; // weak
44 44
45 // 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
46 // with additional height added at the bottom. 46 // with additional height added at the bottom.
47 NSRect trackingAreaFrame_; 47 NSRect trackingAreaFrame_;
48 48
49 // The tracking area associated with the toolbar overlay bar. This tracking 49 // The tracking area associated with the toolbar overlay bar. This tracking
50 // 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
51 // but the mouse is still on the toolbar. 51 // but the mouse is still on the toolbar.
52 base::scoped_nsobject<CrTrackingArea> trackingArea_; 52 base::scoped_nsobject<CrTrackingArea> trackingArea_;
53 53
54 // Updates the fullscreen toolbar layout for changes in the menubar. This 54 // Updates the fullscreen toolbar layout for changes in the menubar. This
55 // object is only set when the browser is in fullscreen mode. 55 // object is only set when the browser is in fullscreen mode.
56 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_; 56 base::scoped_nsobject<FullscreenMenubarTracker> menubarTracker_;
57 57
58 // Pointer to the currently running animation. Is nil if no animation is 58 // Manages the toolbar animations for the OMNIBOX_TABS_HIDDEN style.
59 // running. 59 std::unique_ptr<FullscreenToolbarAnimationController> animationController_;
60 base::scoped_nsobject<DropdownAnimation> currentAnimation_;
61
62 // Timer for scheduled hiding of the toolbar when it had been revealed for
63 // tabstrip changes.
64 base::scoped_nsobject<NSTimer> hideTimer_;
65 60
66 // Tracks the currently requested system fullscreen mode, used to show or 61 // Tracks the currently requested system fullscreen mode, used to show or
67 // hide the menubar. This should be |kFullScreenModeNormal| when the window 62 // hide the menubar. This should be |kFullScreenModeNormal| when the window
68 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay 63 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay
69 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If 64 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If
70 // the window is not on the primary screen, this should always be 65 // the window is not on the primary screen, this should always be
71 // |kFullScreenModeNormal|. This value can get out of sync with the correct 66 // |kFullScreenModeNormal|. This value can get out of sync with the correct
72 // state if we miss a notification (which can happen when a window is closed). 67 // state if we miss a notification (which can happen when a window is closed).
73 // Used to track the current state and make sure we properly restore the menu 68 // Used to track the current state and make sure we properly restore the menu
74 // bar when this controller is destroyed. 69 // bar when this controller is destroyed.
75 base::mac::FullScreenMode systemFullscreenMode_; 70 base::mac::FullScreenMode systemFullscreenMode_;
76 71
77 // Whether the omnibox is hidden in fullscreen. 72 // Whether the omnibox is hidden in fullscreen.
78 FullscreenSlidingStyle slidingStyle_; 73 FullscreenSlidingStyle slidingStyle_;
79
80 // True when the toolbar is dropped to show tabstrip changes.
81 BOOL isRevealingToolbarForTabStripChanges_;
82
83 // True when the toolbar should be animated back out via a DropdownAnimation.
84 // This is set and unset in hideTimer: and mouseExited:. It's set to YES
85 // before it calls animateToolbarVisibility: and then set to NO after the
86 // animation has started.
87 BOOL shouldAnimateToolbarOut_;
88
89 // True when the toolbar is animating in/out for changes in the toolbar
90 // visibility locks.
91 BOOL isLockingBarVisibility_;
92 BOOL isReleasingBarVisibility_;
93 } 74 }
94 75
95 @property(nonatomic, assign) FullscreenSlidingStyle slidingStyle; 76 @property(nonatomic, assign) FullscreenSlidingStyle slidingStyle;
96 77
97 // Designated initializer. 78 // Designated initializer.
98 - (id)initWithBrowserController:(BrowserWindowController*)controller 79 - (id)initWithBrowserController:(BrowserWindowController*)controller
99 style:(FullscreenSlidingStyle)style; 80 style:(FullscreenSlidingStyle)style;
100 81
101 // Informs the controller that the browser has entered or exited fullscreen 82 // Informs the controller that the browser has entered or exited fullscreen
102 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called 83 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called
103 // after the window is setup, just before it is shown. |-exitFullscreenMode| 84 // after the window is setup, just before it is shown. |-exitFullscreenMode|
104 // should be called before any views are moved back to the non-fullscreen 85 // should be called before any views are moved back to the non-fullscreen
105 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, 86 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called,
106 // it must be balanced with a call to |-exitFullscreenMode| before the 87 // it must be balanced with a call to |-exitFullscreenMode| before the
107 // controller is released. 88 // controller is released.
108 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView; 89 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView;
109 - (void)exitFullscreenMode; 90 - (void)exitFullscreenMode;
110 91
111 // Shows/hides the toolbar with animation to reflect changes for the toolbar
112 // visibility locks. lockBarVisibilityWithAnimation: should only be called when
113 // the lock state goes from unlocked to locked. Likewise,
114 // releaseBarVisibilityWithAnimation: should only be called whenthe lock state
115 // goes from locked to unlocked.
116 - (void)lockBarVisibilityWithAnimation:(BOOL)animate;
117 - (void)releaseBarVisibilityWithAnimation:(BOOL)animate;
118
119 // Informs the controller that the overlay should be shown/hidden, possibly 92 // Informs the controller that the overlay should be shown/hidden, possibly
120 // with animation. 93 // with animation.
121 - (void)ensureOverlayShownWithAnimation:(BOOL)animate; 94 - (void)ensureOverlayShownWithAnimation:(BOOL)animate;
122 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate; 95 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate;
123 96
124 // Cancels any running animation and timers. 97 // Cancels any running animation and timers.
125 - (void)cancelAnimationAndTimer; 98 - (void)cancelAnimationAndTimer;
126 99
127 // Animates the toolbar dropping down to show changes to the tab strip. 100 // Animates the toolbar dropping down to show changes to the tab strip.
128 - (void)revealToolbarForTabStripChanges; 101 - (void)revealToolbarForTabStripChanges;
129 102
130 // In any fullscreen mode, the y offset to use for the content at the top of 103 // In any fullscreen mode, the y offset to use for the content at the top of
131 // the screen (tab strip, omnibox, bookmark bar, etc). 104 // the screen (tab strip, omnibox, bookmark bar, etc).
132 // Ranges from 0 to -22. 105 // Ranges from 0 to -22.
133 - (CGFloat)menubarOffset; 106 - (CGFloat)menubarOffset;
134 107
135 // Returns the fraction of the toolbar exposed at the top. 108 // Returns the fraction of the toolbar exposed at the top.
136 // It returns 1.0 if the toolbar is fully shown and 0.0 if the toolbar is 109 // It returns 1.0 if the toolbar is fully shown and 0.0 if the toolbar is
137 // hidden. Otherwise, if the toolbar is in progress of animating, it will 110 // hidden. Otherwise, if the toolbar is in progress of animating, it will
138 // return a float that ranges from (0, 1). 111 // return a float that ranges from (0, 1).
139 - (CGFloat)toolbarFraction; 112 - (CGFloat)toolbarFraction;
140 113
114 // Returns YES if the fullscreen toolbar must be shown.
115 - (BOOL)mustShowFullscreenToolbar;
116
141 // Returns YES if the mouse is on the window's screen. This is used to check 117 // Returns YES if the mouse is on the window's screen. This is used to check
142 // if the menubar events belong to window's screen since the menubar would 118 // if the menubar events belong to window's screen since the menubar would
143 // only be revealed if the mouse is there. 119 // only be revealed if the mouse is there.
144 - (BOOL)isMouseOnScreen; 120 - (BOOL)isMouseOnScreen;
145 121
146 // Sets |trackingAreaFrame_| from the given overlay frame. 122 // Sets |trackingAreaFrame_| from the given overlay frame.
147 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame; 123 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame;
148 124
149 // Returns YES if the browser is in the process of entering/exiting 125 // Returns YES if the browser is in the process of entering/exiting
150 // fullscreen. 126 // fullscreen.
(...skipping 14 matching lines...) Expand all
165 @interface FullscreenToolbarController (ExposedForTesting) 141 @interface FullscreenToolbarController (ExposedForTesting)
166 // Adjusts the AppKit Fullscreen options of the application. 142 // Adjusts the AppKit Fullscreen options of the application.
167 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; 143 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode;
168 144
169 // Callback for menu bar animations. 145 // Callback for menu bar animations.
170 - (void)setMenuBarRevealProgress:(CGFloat)progress; 146 - (void)setMenuBarRevealProgress:(CGFloat)progress;
171 147
172 @end 148 @end
173 149
174 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ 150 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698