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 #import "chrome/browser/cocoa/fullscreen_controller.h" | 5 #import "chrome/browser/cocoa/fullscreen_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #import "chrome/browser/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/cocoa/browser_window_controller.h" |
10 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 10 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
11 | 11 |
12 | 12 |
13 namespace { | 13 namespace { |
14 // The activation zone for the main menu is 4 pixels high; if we make it any | 14 // The activation zone for the main menu is 4 pixels high; if we make it any |
15 // smaller, then the menu can be made to appear without the bar sliding down. | 15 // smaller, then the menu can be made to appear without the bar sliding down. |
16 const CGFloat kDropdownActivationZoneHeight = 4; | 16 const CGFloat kDropdownActivationZoneHeight = 4; |
17 const NSTimeInterval kDropdownAnimationDuration = 0.12; | 17 const NSTimeInterval kDropdownAnimationDuration = 0.12; |
18 const NSTimeInterval kMouseExitCheckDelay = 0.1; | 18 const NSTimeInterval kMouseExitCheckDelay = 0.1; |
19 // This show delay attempts to match the delay for the main menu. | 19 // This show delay attempts to match the delay for the main menu. |
20 const NSTimeInterval kDropdownShowDelay = 0.3; | 20 const NSTimeInterval kDropdownShowDelay = 0.3; |
21 const NSTimeInterval kDropdownHideDelay = 0.2; | 21 const NSTimeInterval kDropdownHideDelay = 0.2; |
22 | 22 |
23 // The amount by which the floating bar is offset downwards (to avoid the menu) | 23 // The amount by which the floating bar is offset downwards (to avoid the menu) |
24 // in fullscreen mode. | 24 // in fullscreen mode. (We can't use |-[NSMenu menuBarHeight]| since it returns |
25 const CGFloat kTabStripVerticalOffset = 14; | 25 // 0 when the menu bar is hidden.) |
| 26 const CGFloat kFloatingBarVerticalOffset = 22; |
26 | 27 |
27 } // end namespace | 28 } // end namespace |
28 | 29 |
29 | 30 |
30 // Helper class to manage animations for the fullscreen dropdown bar. Calls | 31 // Helper class to manage animations for the fullscreen dropdown bar. Calls |
31 // [FullscreenController changeFloatingBarShownFraction] once per animation | 32 // [FullscreenController changeFloatingBarShownFraction] once per animation |
32 // step. | 33 // step. |
33 @interface DropdownAnimation : NSAnimation { | 34 @interface DropdownAnimation : NSAnimation { |
34 @private | 35 @private |
35 FullscreenController* controller_; | 36 FullscreenController* controller_; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 204 } |
204 | 205 |
205 - (void)windowDidBecomeMain:(NSNotification*)notification { | 206 - (void)windowDidBecomeMain:(NSNotification*)notification { |
206 [self showActiveWindowUI]; | 207 [self showActiveWindowUI]; |
207 } | 208 } |
208 | 209 |
209 - (void)windowDidResignMain:(NSNotification*)notification { | 210 - (void)windowDidResignMain:(NSNotification*)notification { |
210 [self hideActiveWindowUI]; | 211 [self hideActiveWindowUI]; |
211 } | 212 } |
212 | 213 |
213 - (CGFloat)tabStripVerticalOffset { | 214 - (CGFloat)floatingBarVerticalOffset { |
214 return [self isWindowOnPrimaryScreen] ? kTabStripVerticalOffset : 0; | 215 return [self isWindowOnPrimaryScreen] ? kFloatingBarVerticalOffset : 0; |
215 } | 216 } |
216 | 217 |
217 - (void)overlayFrameChanged:(NSRect)frame { | 218 - (void)overlayFrameChanged:(NSRect)frame { |
218 if (!isFullscreen_) | 219 if (!isFullscreen_) |
219 return; | 220 return; |
220 | 221 |
221 // Make sure |trackingAreaBounds_| always reflects either the tracking area or | 222 // Make sure |trackingAreaBounds_| always reflects either the tracking area or |
222 // the desired tracking area. | 223 // the desired tracking area. |
223 trackingAreaBounds_ = frame; | 224 trackingAreaBounds_ = frame; |
224 // The tracking area should always be at least the height of activation zone. | 225 // The tracking area should always be at least the height of activation zone. |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 - (void)hideActiveWindowUI { | 590 - (void)hideActiveWindowUI { |
590 if (currentFullscreenMode_ != mac_util::kFullScreenModeNormal) { | 591 if (currentFullscreenMode_ != mac_util::kFullScreenModeNormal) { |
591 mac_util::ReleaseFullScreen(currentFullscreenMode_); | 592 mac_util::ReleaseFullScreen(currentFullscreenMode_); |
592 currentFullscreenMode_ = mac_util::kFullScreenModeNormal; | 593 currentFullscreenMode_ = mac_util::kFullScreenModeNormal; |
593 } | 594 } |
594 | 595 |
595 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 | 596 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 |
596 } | 597 } |
597 | 598 |
598 @end | 599 @end |
OLD | NEW |