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

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: a bit more 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 // fullscreen toolbar, and managing the tracking area associated with the
29 // dropdown. This class does not directly manage any views -- the 30 // toolbar. 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
33 // |overlayFrameChanged:| is called while an animation is running, the 34 // TODO (spqchan): Write tests for this class. See crbug.com/640064.
34 // controller saves the new frame and installs the appropriate tracking area
35 // 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 // step than it is to manage a constantly-changing tracking area.
38 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { 35 @interface FullscreenToolbarController : NSObject<NSAnimationDelegate> {
39 @private 36 @private
40 // Our parent controller. 37 // Our parent controller.
41 BrowserWindowController* browserController_; // weak 38 BrowserWindowController* browserController_; // weak
42 39
43 // Whether or not we are in fullscreen mode. 40 // Whether or not we are in fullscreen mode.
44 BOOL inFullscreenMode_; 41 BOOL inFullscreenMode_;
45 42
43 // The content view for the window. This is nil when not in fullscreen mode.
44 NSView* contentView_; // weak
45
46 // The frame for the tracking area. The value is the toolbar overlay's frame
47 // with additional height added at the bottom.
48 NSRect trackingAreaFrame_;
49
50 // The tracking area associated with the toolbar overlay bar. This tracking
51 // area is used to keep the toolbar active if the menubar had animated out
52 // but the mouse is still on the toolbar.
53 base::scoped_nsobject<CrTrackingArea> trackingArea_;
54
46 // Pointer to the currently running animation. Is nil if no animation is 55 // Pointer to the currently running animation. Is nil if no animation is
47 // running. 56 // running.
48 base::scoped_nsobject<DropdownAnimation> currentAnimation_; 57 base::scoped_nsobject<DropdownAnimation> currentAnimation_;
49 58
50 // Timer for scheduled hiding of the toolbar when it had been revealed for 59 // Timer for scheduled hiding of the toolbar when it had been revealed for
51 // tabstrip changes. 60 // tabstrip changes.
52 base::scoped_nsobject<NSTimer> hideTimer_; 61 base::scoped_nsobject<NSTimer> hideTimer_;
53 62
54 // Tracks the currently requested system fullscreen mode, used to show or 63 // Tracks the currently requested system fullscreen mode, used to show or
55 // hide the menubar. This should be |kFullScreenModeNormal| when the window 64 // hide the menubar. This should be |kFullScreenModeNormal| when the window
56 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay 65 // is not main or not fullscreen, |kFullScreenModeHideAll| while the overlay
57 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If 66 // is hidden, and |kFullScreenModeHideDock| while the overlay is shown. If
58 // the window is not on the primary screen, this should always be 67 // the window is not on the primary screen, this should always be
59 // |kFullScreenModeNormal|. This value can get out of sync with the correct 68 // |kFullScreenModeNormal|. This value can get out of sync with the correct
60 // state if we miss a notification (which can happen when a window is closed). 69 // state if we miss a notification (which can happen when a window is closed).
61 // Used to track the current state and make sure we properly restore the menu 70 // Used to track the current state and make sure we properly restore the menu
62 // bar when this controller is destroyed. 71 // bar when this controller is destroyed.
63 base::mac::FullScreenMode systemFullscreenMode_; 72 base::mac::FullScreenMode systemFullscreenMode_;
64 73
65 // Whether the omnibox is hidden in fullscreen. 74 // Whether the omnibox is hidden in fullscreen.
66 fullscreen_mac::SlidingStyle slidingStyle_; 75 fullscreen_mac::SlidingStyle slidingStyle_;
67 76
68 // The fraction of the AppKit Menubar that is showing. Ranges from 0 to 1. 77 // The fraction of the AppKit Menubar that is showing. Ranges from 0 to 1.
69 // Only used in AppKit Fullscreen. 78 // Only used in AppKit Fullscreen.
70 CGFloat menubarFraction_; 79 CGFloat menubarFraction_;
71 80
72 // The fraction of the omnibox/tabstrip that is showing. Ranges from 0 to 1. 81 // The toolbar fraction set by the menu progress.
73 // Used in both AppKit and Immersive Fullscreen. 82 CGFloat toolbarFractionFromMenuProgress_;
74 CGFloat toolbarFraction_;
75 83
76 // A Carbon event handler that tracks the revealed fraction of the menu bar. 84 // A Carbon event handler that tracks the revealed fraction of the menu bar.
77 EventHandlerRef menuBarTrackingHandler_; 85 EventHandlerRef menuBarTrackingHandler_;
78 86
79 // True when the toolbar is dropped to show tabstrip changes. 87 // True when the toolbar is dropped to show tabstrip changes.
80 BOOL revealToolbarForTabStripChanges_; 88 BOOL isRevealingToolbarForTabStripChanges_;
89
90 // True when the toolbar should be animated back out via a DropdownAnimation.
91 // This is set to false at the end of the animation.
92 BOOL shouldAnimateToolbarOut_;
81 } 93 }
82 94
83 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle; 95 @property(nonatomic, assign) fullscreen_mac::SlidingStyle slidingStyle;
84 @property(nonatomic, assign) CGFloat toolbarFraction;
85 96
86 // Designated initializer. 97 // Designated initializer.
87 - (id)initWithBrowserController:(BrowserWindowController*)controller 98 - (id)initWithBrowserController:(BrowserWindowController*)controller
88 style:(fullscreen_mac::SlidingStyle)style; 99 style:(fullscreen_mac::SlidingStyle)style;
89 100
90 // Informs the controller that the browser has entered or exited presentation 101 // Informs the controller that the browser has entered or exited fullscreen
91 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called 102 // mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called
92 // after the window is setup, just before it is shown. |-exitFullscreenMode| 103 // 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 104 // should be called before any views are moved back to the non-fullscreen
94 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, 105 // window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called,
95 // it must be balanced with a call to |-exitFullscreenMode| before the 106 // it must be balanced with a call to |-exitFullscreenMode| before the
96 // controller is released. 107 // controller is released.
97 - (void)setupFullscreenToolbarWithDropdown:(BOOL)showDropdown; 108 - (void)setupFullscreenToolbarForContentView:(NSView*)contentView;
98 - (void)exitFullscreenMode; 109 - (void)exitFullscreenMode;
99 110
100 // Returns the amount by which the floating bar should be offset downwards (to 111 // 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. 112 // 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 113 // Generally, this is > 0 when the window is on the primary screen and 0
103 // otherwise. 114 // otherwise.
104 - (CGFloat)floatingBarVerticalOffset; 115 - (CGFloat)floatingBarVerticalOffset;
105 116
106 // Informs the controller that the overlay should be shown/hidden, possibly 117 // Informs the controller that the overlay should be shown/hidden, possibly
107 // with animation. 118 // with animation.
108 - (void)ensureOverlayShownWithAnimation:(BOOL)animate; 119 - (void)ensureOverlayShownWithAnimation:(BOOL)animate;
109 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate; 120 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate;
110 121
111 // Cancels any running animation and timers. 122 // Cancels any running animation and timers.
112 - (void)cancelAnimationAndTimer; 123 - (void)cancelAnimationAndTimer;
113 124
114 // Animates the toolbar dropping down to show changes to the tab strip. 125 // Animates the toolbar dropping down to show changes to the tab strip.
115 - (void)revealToolbarForTabStripChanges; 126 - (void)revealToolbarForTabStripChanges;
116 127
117 // In any fullscreen mode, the y offset to use for the content at the top of 128 // 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). 129 // the screen (tab strip, omnibox, bookmark bar, etc).
119 // Ranges from 0 to -22. 130 // Ranges from 0 to -22.
120 - (CGFloat)menubarOffset; 131 - (CGFloat)menubarOffset;
121 132
133 // Returns the fraction of the toolbar exposed at the top.
134 // It returns 1.0 if the toolbar is fully shown and 0.0 if the toolbar is
135 // hidden. Otherwise, if the toolbar is in progress of animating, it will
136 // return a float that ranges from (0, 1).
137 - (CGFloat)toolbarFraction;
138
122 // Returns YES if the mouse is on the window's screen. This is used to check 139 // 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 140 // if the menubar events belong to window's screen since the menubar would
124 // only be revealed if the mouse is there. 141 // only be revealed if the mouse is there.
125 - (BOOL)isMouseOnScreen; 142 - (BOOL)isMouseOnScreen;
126 143
127 // Returns true if the browser is in the process of entering/exiting 144 // Sets |trackingAreaFrame_| from the given overlay frame.
145 - (void)setTrackingAreaFromOverlayFrame:(NSRect)frame;
146
147 // Returns YES if the browser is in the process of entering/exiting
128 // fullscreen. 148 // fullscreen.
129 - (BOOL)isFullscreenTransitionInProgress; 149 - (BOOL)isFullscreenTransitionInProgress;
130 150
151 // Returns YES if the browser in in fullscreen.
152 - (BOOL)isInFullscreen;
153
154 // Updates the toolbar by updating the layout, menubar and dock.
155 - (void)updateToolbar;
156
131 @end 157 @end
132 158
133 // Private methods exposed for testing. 159 // Private methods exposed for testing.
134 @interface FullscreenToolbarController (ExposedForTesting) 160 @interface FullscreenToolbarController (ExposedForTesting)
135 // Adjusts the AppKit Fullscreen options of the application. 161 // Adjusts the AppKit Fullscreen options of the application.
136 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode; 162 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode;
137 163
138 // Callback for menu bar animations. 164 // Callback for menu bar animations.
139 - (void)setMenuBarRevealProgress:(CGFloat)progress; 165 - (void)setMenuBarRevealProgress:(CGFloat)progress;
140 166
141 // 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
143 // Fullscreen option for whether the menu bar is shown.
144 - (void)changeToolbarFraction:(CGFloat)fraction;
145
146 @end 167 @end
147 168
148 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_ 169 #endif // CHROME_BROWSER_UI_COCOA_FULLSCREEN_TOOLBAR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698