// 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-chromium file. #pragma once // A class acting as the Objective-C window controller for a window that has // tabs which can be dragged around. Tabs can be re-arranged within the same // window or dragged into other CTTabWindowController windows. This class doesn't // know anything about the actual tab implementation or model, as that is fairly // application-specific. It only provides an API to be overridden by subclasses // to fill in the details. // // This assumes that there will be a view in the nib, connected to // |tabContentArea_|, that indicates the content that it switched when switching // between tabs. It needs to be a regular NSView, not something like an NSBox // because the CTTabStripController makes certain assumptions about how it can // swap out subviews. // // The tab strip is placed outside the window's content area, overlapping the // title area and window controls and will be stretched to fill the width // of the window. #import @class CTTabStripView; @class CTTabView; @class KMToolbarRightView; @class KMUploadFilePanel; @class KMFileSearchView; @interface CTTabWindowController : NSWindowController @property(readonly, nonatomic) CTTabStripView* tabStripView; @property(readonly, nonatomic) NSView* tabContentArea; @property(readonly, nonatomic) NSView* rightStripView; @property(readonly, nonatomic) NSView* homeRightStripView; @property(readonly, nonatomic) NSView* fileSearchView; @property (strong) IBOutlet KMToolbarRightView *rightTabStripView_; @property(strong) IBOutlet KMToolbarRightView* homeRightTabStripView_; @property(weak, nonatomic) IBOutlet KMUploadFilePanel *fileUploadPanel; @property(weak, nonatomic) IBOutlet KMFileSearchView *fileSearchView_; // Used during tab dragging to turn on/off the overlay window when a tab // is torn off. If -deferPerformClose (below) is used, -removeOverlay will // cause the controller to be autoreleased before returning. - (void)showOverlay; - (void)removeOverlay; - (NSWindow*)overlayWindow; // Returns YES if it is ok to constrain the window's frame to fit the screen. - (BOOL)shouldConstrainFrameRect; // A collection of methods, stubbed out in this base class, that provide // the implementation of tab dragging based on whatever model is most // appropriate. // Layout the tabs based on the current ordering of the model. - (void)layoutTabs; // Creates a new window by pulling the given tab out and placing it in // the new window. Returns the controller for the new window. The size of the // new window will be the same size as this window. - (CTTabWindowController*)detachTabToNewWindow:(CTTabView*)tabView; // Make room in the tab strip for |tab| at the given x coordinate. Will hide the // new tab button while there's a placeholder. Subclasses need to call the // superclass implementation. - (void)insertPlaceholderForTab:(CTTabView*)tab frame:(NSRect)frame; // Removes the placeholder installed by |-insertPlaceholderForTab:atLocation:| // and restores the new tab button. Subclasses need to call the superclass // implementation. - (void)removePlaceholder; // The follow return YES if tab dragging/tab tearing (off the tab strip)/window // movement is currently allowed. Any number of things can choose to disable it, // such as pending animations. The default implementations always return YES. // Subclasses should override as appropriate. - (BOOL)tabDraggingAllowed; - (BOOL)tabTearingAllowed; - (BOOL)windowMovementAllowed; // Called when dragging of teared tab in an overlay window occurs -(void)willStartTearingTab; -(void)willEndTearingTab; -(void)didEndTearingTab; // Show or hide the new tab button. The button is hidden immediately, but // waits until the next call to |-layoutTabs| to show it again. @property(nonatomic, assign) BOOL showsNewTabButton; // Enables the content views to be transparent, showing the desktop behind the // window if set. Also controls how the CTTabStripView draws itself (so that it // will NOT draw transparently) @property(nonatomic, assign) BOOL enableTransparentContent; // Returns whether or not |tab| can still be fully seen in the tab strip or if // its current position would cause it be obscured by things such as the edge // of the window or the window decorations. Returns YES only if the entire tab // is visible. The default implementation always returns YES. - (BOOL)isTabFullyVisible:(CTTabView*)tab; // Called to check if the receiver can receive dragged tabs from // source. Return YES if so. The default implementation returns NO. - (BOOL)canReceiveFrom:(CTTabWindowController*)source; // Move a given tab view to the location of the current placeholder. If there is // no placeholder, it will go at the end. |controller| is the window controller // of a tab being dropped from a different window. It will be nil if the drag is // within the window, otherwise the tab is removed from that window before being // placed into this one. The implementation will call |-removePlaceholder| since // the drag is now complete. This also calls |-layoutTabs| internally so // clients do not need to call it again. - (void)moveTabView:(NSView*)view fromController:(CTTabWindowController*)controller; // Number of tabs in the tab strip. Useful, for example, to know if we're // dragging the only tab in the window. This includes pinned tabs (both live // and not). - (NSInteger)numberOfTabs; // YES if there are tabs in the tab strip which have content, allowing for // the notion of tabs in the tab strip that are placeholders, but // currently have no content. - (BOOL)hasLiveTabs; // Return the view of the active tab. - (NSView *)activeTabView; // The title of the active tab. - (NSString*)activeTabTitle; // Called to check whether or not this controller's window has a tab strip (YES // if it does, NO otherwise). The default implementation returns YES. - (BOOL)hasTabStrip; // Get/set whether a particular tab is draggable between windows. - (BOOL)isTabDraggable:(NSView*)tabView; - (void)setTab:(NSView*)tabView isDraggable:(BOOL)draggable; // Tell the window that it needs to call performClose: as soon as the current // drag is complete. This prevents a window (and its overlay) from going away // during a drag. - (void)deferPerformClose; @end @interface CTTabWindowController(ProtectedMethods) // Tells the tab strip to forget about this tab in preparation for it being // put into a different tab strip, such as during a drop on another window. - (void)detachTabView:(NSView*)view; // Called when the size of the window content area has changed. Override to // position specific views. Base class implementation does nothing. - (void)layoutSubviews; @end