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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_ 6#define CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_ 7 8#import <Cocoa/Cocoa.h> 9#include <vector> 10 11#include "base/mac/scoped_nsobject.h" 12#include "base/memory/scoped_vector.h" 13 14@protocol ConstrainedWindowSheet; 15 16// This class manages multiple tab modal sheets for a single parent window. Each 17// tab can have a single sheet and only the active tab's sheet will be visible. 18// A tab in this case is the |parentView| passed to |-showSheet:forParentView:|. 19@interface ConstrainedWindowSheetController : NSObject { 20 @private 21 base::scoped_nsobject<NSMutableArray> sheets_; 22 base::scoped_nsobject<NSWindow> parentWindow_; 23 base::scoped_nsobject<NSView> activeView_; 24} 25 26// Returns a sheet controller for |parentWindow|. If a sheet controller does not 27// exist yet then one will be created. 28+ (ConstrainedWindowSheetController*) 29 controllerForParentWindow:(NSWindow*)parentWindow; 30 31// Find a controller that's managing the given sheet. If no such controller 32// exists then nil is returned. 33+ (ConstrainedWindowSheetController*) 34 controllerForSheet:(id<ConstrainedWindowSheet>)sheet; 35 36// Find the sheet attached to the given overlay window. 37+ (id<ConstrainedWindowSheet>)sheetForOverlayWindow:(NSWindow*)overlayWindow; 38 39// Shows the given sheet over |parentView|. If |parentView| is not the active 40// view then the sheet is not shown until the |parentView| becomes active. 41- (void)showSheet:(id<ConstrainedWindowSheet>)sheet 42 forParentView:(NSView*)parentView; 43 44// Calculates the position of the sheet for the given window size. 45- (NSPoint)originForSheet:(id<ConstrainedWindowSheet>)sheet 46 withWindowSize:(NSSize)size; 47 48// Closes the given sheet. 49- (void)closeSheet:(id<ConstrainedWindowSheet>)sheet; 50 51// Make |parentView| the current active view. If |parentView| has an attached 52// sheet then the sheet is made visible. 53- (void)parentViewDidBecomeActive:(NSView*)parentView; 54 55// Run a pulse animation for the given sheet. This does nothing if the sheet 56// is not visible. 57- (void)pulseSheet:(id<ConstrainedWindowSheet>)sheet; 58 59// Gets the number of sheets attached to the controller's window. 60- (int)sheetCount; 61 62@end 63 64#endif // CHROME_BROWSER_UI_COCOA_CONSTRAINED_WINDOW_CONSTRAINED_WINDOW_SHEET_CONTROLLER_H_ 65