OLD | NEW |
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_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ |
7 | 7 |
8 // A class acting as the Objective-C controller for the Panel window | 8 // A class acting as the Objective-C controller for the Panel window |
9 // object. Handles interactions between Cocoa and the cross-platform | 9 // object. Handles interactions between Cocoa and the cross-platform |
10 // code. Each window has a single titlebar and is managed/owned by Panel. | 10 // code. Each window has a single titlebar and is managed/owned by Panel. |
11 | 11 |
12 #import <Cocoa/Cocoa.h> | 12 #import <Cocoa/Cocoa.h> |
13 | 13 |
14 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #import "chrome/browser/ui/cocoa/chrome_browser_window.h" | 16 #import "chrome/browser/ui/cocoa/chrome_browser_window.h" |
17 #include "chrome/browser/ui/panels/panel.h" | 17 #include "chrome/browser/ui/panels/panel.h" |
18 #import "ui/base/cocoa/tracking_area.h" | |
19 | 18 |
20 class PanelCocoa; | 19 class PanelCocoa; |
21 @class PanelTitlebarViewCocoa; | 20 @class PanelTitlebarViewCocoa; |
22 | 21 |
23 @interface PanelWindowCocoaImpl : ChromeBrowserWindow { | 22 @interface PanelWindowCocoaImpl : ChromeBrowserWindow { |
24 } | 23 } |
25 @end | 24 @end |
26 | 25 |
27 @interface PanelWindowControllerCocoa : NSWindowController | 26 @interface PanelWindowControllerCocoa : NSWindowController |
28 <NSWindowDelegate, | 27 <NSWindowDelegate, |
29 NSAnimationDelegate> { | 28 NSAnimationDelegate> { |
30 @private | 29 @private |
31 IBOutlet PanelTitlebarViewCocoa* titlebar_view_; | 30 IBOutlet PanelTitlebarViewCocoa* titlebar_view_; |
32 scoped_ptr<PanelCocoa> windowShim_; | 31 scoped_ptr<PanelCocoa> windowShim_; |
33 base::scoped_nsobject<NSString> pendingWindowTitle_; | 32 base::scoped_nsobject<NSString> pendingWindowTitle_; |
34 NSViewAnimation* boundsAnimation_; // Lifetime controlled manually, needs | 33 NSViewAnimation* boundsAnimation_; // Lifetime controlled manually, needs |
35 // more then just |release| to terminate. | 34 // more then just |release| to terminate. |
36 BOOL animateOnBoundsChange_; | 35 BOOL animateOnBoundsChange_; |
37 BOOL throbberShouldSpin_; | 36 BOOL throbberShouldSpin_; |
38 BOOL playingMinimizeAnimation_; | 37 BOOL playingMinimizeAnimation_; |
39 float animationStopToShowTitlebarOnly_; | 38 float animationStopToShowTitlebarOnly_; |
40 BOOL canBecomeKeyWindow_; | 39 BOOL canBecomeKeyWindow_; |
41 // Allow a panel to become key if activated via Panel logic, as opposed | 40 // Allow a panel to become key if activated via Panel logic, as opposed |
42 // to by default system selection. The system will prefer a panel | 41 // to by default system selection. The system will prefer a panel |
43 // window over other application windows due to panels having a higher | 42 // window over other application windows due to panels having a higher |
44 // priority NSWindowLevel, so we distinguish between the two scenarios. | 43 // priority NSWindowLevel, so we distinguish between the two scenarios. |
45 BOOL activationRequestedByPanel_; | 44 BOOL activationRequestedByPanel_; |
46 // Is user resizing in progress? | 45 base::scoped_nsobject<NSView> overlayView_; |
47 BOOL userResizing_; | |
48 // Tracks the whole window in order to receive NSMouseMoved event. | |
49 ui::ScopedCrTrackingArea trackingArea_; | |
50 } | 46 } |
51 | 47 |
52 // Load the window nib and do any Cocoa-specific initialization. | 48 // Load the window nib and do any Cocoa-specific initialization. |
53 - (id)initWithPanel:(PanelCocoa*)window; | 49 - (id)initWithPanel:(PanelCocoa*)window; |
54 | 50 |
55 - (Panel*)panel; | |
56 | |
57 - (void)webContentsInserted:(content::WebContents*)contents; | 51 - (void)webContentsInserted:(content::WebContents*)contents; |
58 - (void)webContentsDetached:(content::WebContents*)contents; | 52 - (void)webContentsDetached:(content::WebContents*)contents; |
59 | 53 |
60 - (void)updateWebContentsViewFrame; | 54 - (void)updateWebContentsViewFrame; |
61 | 55 |
62 // Sometimes (when we animate the size of the window) we want to stop resizing | 56 // Sometimes (when we animate the size of the window) we want to stop resizing |
63 // the WebContents's Cocoa view to avoid unnecessary rendering and issues | 57 // the WebContents's Cocoa view to avoid unnecessary rendering and issues |
64 // that can be caused by sizes near 0. | 58 // that can be caused by sizes near 0. |
65 - (void)disableWebContentsViewAutosizing; | 59 - (void)disableWebContentsViewAutosizing; |
66 - (void)enableWebContentsViewAutosizing; | 60 - (void)enableWebContentsViewAutosizing; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 130 |
137 // Adjust NSStatusWindowLevel based on whether panel is always on top | 131 // Adjust NSStatusWindowLevel based on whether panel is always on top |
138 // and whether the panel is minimized. The first version wraps the second | 132 // and whether the panel is minimized. The first version wraps the second |
139 // version using the current panel expanstion state. | 133 // version using the current panel expanstion state. |
140 - (void)updateWindowLevel; | 134 - (void)updateWindowLevel; |
141 - (void)updateWindowLevel:(BOOL)panelIsMinimized; | 135 - (void)updateWindowLevel:(BOOL)panelIsMinimized; |
142 | 136 |
143 // Adjusts NSWindowCollectionBehavior based on whether panel is always on top. | 137 // Adjusts NSWindowCollectionBehavior based on whether panel is always on top. |
144 - (void)updateWindowCollectionBehavior; | 138 - (void)updateWindowCollectionBehavior; |
145 | 139 |
146 // Updates the tracking area per the window size change. This is needed in | 140 // Turns on user-resizable corners/sides indications and enables live resize. |
147 // order to receive the NSMouseMoved notification. | 141 - (void)enableResizeByMouse:(BOOL)enable; |
148 - (void)updateTrackingArea; | |
149 | 142 |
150 // Turns on/off shadow effect around the window shape. | 143 // Turns on/off shadow effect around the window shape. |
151 - (void)showShadow:(BOOL)show; | 144 - (void)showShadow:(BOOL)show; |
152 | 145 |
153 // Minimize the window to the dock. | 146 // Minimize the window to the dock. |
154 - (void)miniaturize; | 147 - (void)miniaturize; |
155 // Returns true if the window is minimized to the dock. | 148 // Returns true if the window is minimized to the dock. |
156 - (BOOL)isMiniaturized; | 149 - (BOOL)isMiniaturized; |
157 | 150 |
158 // Returns true if the user-resizing is allowed for the edge/corner close to | |
159 // current mouse location. | |
160 - (BOOL)canResizeByMouseAtCurrentLocation; | |
161 | |
162 - (NSRect)frameRectForContentRect:(NSRect)contentRect; | 151 - (NSRect)frameRectForContentRect:(NSRect)contentRect; |
163 - (NSRect)contentRectForFrameRect:(NSRect)frameRect; | 152 - (NSRect)contentRectForFrameRect:(NSRect)frameRect; |
164 | 153 |
165 @end // @interface PanelWindowController | 154 @end // @interface PanelWindowController |
166 | 155 |
167 #endif // CHROME_BROWSER_UI_COCOA_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ | 156 #endif // CHROME_BROWSER_UI_COCOA_PANELS_PANEL_WINDOW_CONTROLLER_COCOA_H_ |
OLD | NEW |