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

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

Issue 2272783002: [Mac] Fix for fullscreen toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: The fullscreen changes Created 4 years, 3 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;
15 @class DropdownAnimation; 16 @class DropdownAnimation;
16 17
17 namespace fullscreen_mac { 18 namespace fullscreen_mac {
18 enum SlidingStyle { 19 enum SlidingStyle {
19 OMNIBOX_TABS_PRESENT = 0, // Tab strip and omnibox both visible. 20 OMNIBOX_TABS_PRESENT = 0, // 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 } // namespace fullscreen_mac 25 } // namespace fullscreen_mac
25 26
26 // Provides a controller to fullscreen toolbar for a single browser 27 // Provides a controller to fullscreen toolbar for a single browser
27 // window. This class handles running animations, showing and hiding the 28 // window. This class handles running animations, showing and hiding the
28 // floating dropdown bar, and managing the tracking area associated with the 29 // floating dropdown bar, and managing the tracking area associated with the
29 // dropdown. This class does not directly manage any views -- the 30 // dropdown. This class does not directly manage any views -- the
30 // BrowserWindowController is responsible for positioning and z-ordering views. 31 // BrowserWindowController is responsible for positioning and z-ordering views.
31 // 32 //
32 // Tracking areas are disabled while animations are running. If 33 // Tracking areas are disabled while animations are running. If
33 // |overlayFrameChanged:| is called while an animation is running, the 34 // |overlayFrameChanged:| is called while an animation is running, the
34 // controller saves the new frame and installs the appropriate tracking area 35 // controller saves the new frame and installs the appropriate tracking area
35 // when the animation finishes. This is largely done for ease of 36 // when the animation finishes. This is largely done for ease of
36 // implementation; it is easier to check the mouse location at each animation 37 // implementation; it is easier to check the mouse location at each animation
37 // step than it is to manage a constantly-changing tracking area. 38 // step than it is to manage a constantly-changing tracking area.
39 //
40
41 // The |toolbarFraction_| is usually set by |setMenuBarRevealProgress:|, which
42 // is called by MenuBarRevealHandler(). This makes the toolbar show/hide in
43 // sync with the menubar. However, there's an edge case that appears when the
44 // sliding style is set to OMNIBOX_TABS_HIDDEN. If the user interacts with the
45 // bottom half of the toolbar, the menubar will disappear and take the toolbar
46 // with it. This prevents users from interacting properly with the omnibox and
47 // bookmarks bar.
48 //
49 // To prevent the toolbar from disappearing when the user is still interacting
50 // with it, we lock its visibility so that the toolbar will remain, even after
51 // the menubar had disappeared. The tracking area is then used to check if the
52 // user is still interacting with the toolbar. Once we receive a mouse exit
53 // event, we release the visibility lock so that the toolbar can hidden by the
54 // menubar (if it's still there) or via a DropdownAnimation (if the menubar is
55 // gone).
56
57 // TODO (spqchan): Write tests for this class. See crbug.com/640064.
38 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { 58 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> {
39 @private 59 @private
40 // Our parent controller. 60 // Our parent controller.
41 BrowserWindowController* browserController_; // weak 61 BrowserWindowController* browserController_; // weak
42 62
43 // Whether or not we are in fullscreen mode. 63 // Whether or not we are in fullscreen mode.
44 BOOL inFullscreenMode_; 64 BOOL inFullscreenMode_;
45 65
66 // The content view for the window. This is nil when not in fullscreen mode.
67 NSView* contentView_; // weak
68
69 // The frame for the tracking area. The value is the toolbar overlay's frame
70 // with additional height added at the bottom.
71 NSRect trackingAreaFrame_;
72
73 // The tracking area associated with the toolbar overlay bar. This tracking
74 // area is used to keep the toolbar active if the menubar had animated out
75 // but the mouse is still on the toolbar.
76 base::scoped_nsobject<CrTrackingArea> trackingArea_;
77
46 // Pointer to the currently running animation. Is nil if no animation is 78 // Pointer to the currently running animation. Is nil if no animation is
47 // running. 79 // running.
48 base::scoped_nsobject<DropdownAnimation> currentAnimation_; 80 base::scoped_nsobject<DropdownAnimation> currentAnimation_;
49 81
50 // Timer for scheduled hiding of the toolbar when it had been revealed for 82 // Timer for scheduled hiding of the toolbar when it had been revealed for
51 // tabstrip changes. 83 // tabstrip changes.
52 base::scoped_nsobject<NSTimer> hideTimer_; 84 base::scoped_nsobject<NSTimer> hideTimer_;
53 85
54 // Tracks the currently requested system fullscreen mode, used to show or 86 // Tracks the currently requested system fullscreen mode, used to show or
55 // hide the menubar. This should be |kFullScreenModeNormal| when the window 87 // hide the menubar. This should be |kFullScreenModeNormal| when the window
(...skipping 24 matching lines...) Expand all
80 BOOL revealToolbarForTabStripChanges_; 112 BOOL revealToolbarForTabStripChanges_;
81 } 113 }
82 114
83 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle; 115 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle;
84 @property(nonatomic, assign) CGFloat toolbarFraction; 116 @property(nonatomic, assign) CGFloat toolbarFraction;
85 117
86 // Designated initializer. 118 // Designated initializer.
87 - (id)initWithBrowserController:(BrowserWindowController*)controller 119 - (id)initWithBrowserController:(BrowserWindowController*)controller
88 style:(fullscreen_mac::SlidingStyle)style; 120 style:(fullscreen_mac::SlidingStyle)style;
89 121
90 // Informs the controller that the browser has entered or exited presentation 122 // Informs the controller that the browser has entered or exited fullscreen
91 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called 123 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called
92 // after the window is setup, just before it is shown. |-exitFullscreenMode| 124 // after the window is setup, just before it is shown. |-exitFullscreenMode|
93 // should be called before any views are moved back to the non-fullscreen 125 // should be called before any views are moved back to the non-fullscreen
94 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, 126 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called,
95 // it must be balanced with a call to |-exitFullscreenMode| before the 127 // it must be balanced with a call to |-exitFullscreenMode| before the
96 // controller is released. 128 // controller is released.
97 - (void)setupFullscreenToolbarWithDropdown:(BOOL)showDropdown; 129 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView
130 showDropdown:(BOOL)showDropdown;
98 - (void)exitFullscreenMode; 131 - (void)exitFullscreenMode;
99 132
100 // Returns the amount by which the floating bar should be offset downwards (to 133 // Returns the amount by which the floating bar should be offset downwards (to
101 // avoid the menu) and by which the overlay view should be enlarged vertically. 134 // avoid the menu) and by which the overlay view should be enlarged vertically.
102 // Generally, this is > 0 when the window is on the primary screen and 0 135 // Generally, this is > 0 when the window is on the primary screen and 0
103 // otherwise. 136 // otherwise.
104 - (CGFloat)floatingBarVerticalOffset; 137 - (CGFloat)floatingBarVerticalOffset;
105 138
106 // Informs the controller that the overlay should be shown/hidden, possibly 139 // Informs the controller that the overlay should be shown/hidden, possibly
107 // with animation. 140 // with animation.
108 - (void)ensureOverlayShownWithAnimation:(BOOL)animate; 141 - (void)ensureOverlayShownWithAnimation:(BOOL)animate;
109 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate; 142 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate;
110 143
111 // Cancels any running animation and timers. 144 // Cancels any running animation and timers.
112 - (void)cancelAnimationAndTimer; 145 - (void)cancelAnimationAndTimer;
113 146
114 // Animates the toolbar dropping down to show changes to the tab strip. 147 // Animates the toolbar dropping down to show changes to the tab strip.
115 - (void)revealToolbarForTabStripChanges; 148 - (void)revealToolbarForTabStripChanges;
116 149
117 // In any fullscreen mode, the y offset to use for the content at the top of 150 // In any fullscreen mode, the y offset to use for the content at the top of
118 // the screen (tab strip, omnibox, bookmark bar, etc). 151 // the screen (tab strip, omnibox, bookmark bar, etc).
119 // Ranges from 0 to -22. 152 // Ranges from 0 to -22.
120 - (CGFloat)menubarOffset; 153 - (CGFloat)menubarOffset;
121 154
122 // Returns YES if the mouse is on the window's screen. This is used to check 155 // Returns YES if the mouse is on the window's screen. This is used to check
123 // if the menubar events belong to window's screen since the menubar would 156 // if the menubar events belong to window's screen since the menubar would
124 // only be revealed if the mouse is there. 157 // only be revealed if the mouse is there.
125 - (BOOL)isMouseOnScreen; 158 - (BOOL)isMouseOnScreen;
126 159
127 // Returns true if the browser is in the process of entering/exiting 160 // Sets |trackingAreaFrame_| from the given overlay frame.
161 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame;
162
163 // Returns YES if the browser is in the process of entering/exiting
128 // fullscreen. 164 // fullscreen.
129 - (BOOL)isFullscreenTransitionInProgress; 165 - (BOOL)isFullscreenTransitionInProgress;
130 166
167 // Returns YES if the browser in in fullscreen.
168 - (BOOL)isInFullscreen;
169
131 @end 170 @end
132 171
133 // Private methods exposed for testing. 172 // Private methods exposed for testing.
134 @interface FullscreenToolbarController (ExposedForTesting) 173 @interface FullscreenToolbarController (ExposedForTesting)
135 // Adjusts the AppKit Fullscreen options of the application. 174 // Adjusts the AppKit Fullscreen options of the application.
136 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; 175 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode;
137 176
138 // Callback for menu bar animations. 177 // Callback for menu bar animations.
139 - (void)setMenuBarRevealProgress:(CGFloat)progress; 178 - (void)setMenuBarRevealProgress:(CGFloat)progress;
140 179
141 // Updates the local state that reflects the fraction of the toolbar area that 180 // Updates the local state that reflects the fraction of the toolbar area that
142 // is showing. This function has the side effect of changing the AppKit 181 // is showing. This function has the side effect of changing the AppKit
143 // Fullscreen option for whether the menu bar is shown. 182 // Fullscreen option for whether the menu bar is shown. If the toolbar
183 // visibility is locked, the fraction will be updated to 1.0;
144 - (void)changeToolbarFraction:(CGFloat)fraction; 184 - (void)changeToolbarFraction:(CGFloat)fraction;
145 185
146 @end 186 @end
147 187
148 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ 188 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698