15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#import <Cocoa/Cocoa.h>
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <vector>
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
11eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "base/mac/scoped_nsobject.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/scoped_vector.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)@protocol ConstrainedWindowSheet;
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This class manages multiple tab modal sheets for a single parent window. Each
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// tab can have a single sheet and only the active tab's sheet will be visible.
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A tab in this case is the |parentView| passed to |-showSheet:forParentView:|.
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@interface ConstrainedWindowSheetController : NSObject {
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) @private
21eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::scoped_nsobject<NSMutableArray> sheets_;
22eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::scoped_nsobject<NSWindow> parentWindow_;
23eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  base::scoped_nsobject<NSView> activeView_;
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Returns a sheet controller for |parentWindow|. If a sheet controller does not
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// exist yet then one will be created.
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (ConstrainedWindowSheetController*)
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    controllerForParentWindow:(NSWindow*)parentWindow;
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Find a controller that's managing the given sheet. If no such controller
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// exists then nil is returned.
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)+ (ConstrainedWindowSheetController*)
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)    controllerForSheet:(id<ConstrainedWindowSheet>)sheet;
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Find the sheet attached to the given overlay window.
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)+ (id<ConstrainedWindowSheet>)sheetForOverlayWindow:(NSWindow*)overlayWindow;
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Shows the given sheet over |parentView|. If |parentView| is not the active
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// view then the sheet is not shown until the |parentView| becomes active.
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)- (void)showSheet:(id<ConstrainedWindowSheet>)sheet
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    forParentView:(NSView*)parentView;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Calculates the position of the sheet for the given window size.
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)- (NSPoint)originForSheet:(id<ConstrainedWindowSheet>)sheet
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)           withWindowSize:(NSSize)size;
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Closes the given sheet.
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)- (void)closeSheet:(id<ConstrainedWindowSheet>)sheet;
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Make |parentView| the current active view. If |parentView| has an attached
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// sheet then the sheet is made visible.
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (void)parentViewDidBecomeActive:(NSView*)parentView;
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Run a pulse animation for the given sheet. This does nothing if the sheet
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// is not visible.
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)- (void)pulseSheet:(id<ConstrainedWindowSheet>)sheet;
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Gets the number of sheets attached to the controller's window.
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (int)sheetCount;
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_
65