summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/fullscreen_controller.h
blob: 06f1d428c42ec5c612f27b88a1f183536d9bae96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_
#define CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_

#import <Cocoa/Cocoa.h>

#import "base/cocoa_protocols_mac.h"
#include "chrome/browser/cocoa/location_bar_view_mac.h"

@class BrowserWindowController;

// Provides a controller to manage fullscreen mode for a single browser window.
// This class handles running animations, showing and hiding the floating
// dropdown bar, and managing the tracking area associated with the dropdown.
// This class does not directly manage any views -- the BrowserWindowController
// is responsible for positioning and z-ordering views.
//
// Tracking areas are disabled while animations are running.  If
// |overlayFrameChanged:| is called while an animation is running, the
// controller saves the new frame and installs the appropriate tracking area
// when the animation finishes.  This is largely done for ease of
// implementation; it is easier to check the mouse location at each animation
// step than it is to manage a constantly-changing tracking area.
@interface FullscreenController : NSObject<NSAnimationDelegate> {
  // Our parent controller.
  BrowserWindowController* browserController_;  // weak

  // The content view for the fullscreen window.  This is nil when not in
  // fullscreen mode.
  NSView* contentView_;  // weak

  // Whether or not we are in fullscreen mode.
  BOOL isFullscreen_;

  // The tracking area associated with the floating dropdown bar.  This tracking
  // area is attached to |contentView_|, because when the dropdown is completely
  // hidden, we still need to keep a 1px tall tracking area visible.  Attaching
  // to the content view allows us to do this.  |trackingArea_| can be nil if
  // not in fullscreen mode or during animations.
  scoped_nsobject<NSTrackingArea> trackingArea_;

  // Pointer to the currently running animation.  Is nil if no animation is
  // running.
  scoped_nsobject<NSAnimation> currentAnimation_;

  // Holds the current bounds of |trackingArea_|, even if |trackingArea_| is
  // currently nil.  Used to restore the tracking area when an animation
  // completes.
  NSRect trackingAreaBounds_;
}

// Designated initializer.
- (id)initWithBrowserController:(BrowserWindowController*)controller;

// Informs the controller that the browser has entered or exited fullscreen
// mode.  enterFullscreenForContentView:showDropdown: should be called after the
// fullscreen window is setup, just before it is shown.  exitFullscreen should
// be called before any views are moved back to the non-fullscreen window.
- (void)enterFullscreenForContentView:(NSView*)contentView
                         showDropdown:(BOOL)showDropdown;
- (void)exitFullscreen;

// Informs the controller that the overlay's frame has changed.  The controller
// uses this information to update its tracking areas.
- (void)overlayFrameChanged:(NSRect)frame;
@end

#endif  // CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_