1c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Copyright (c) 2010 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ 621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ 73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#import <Cocoa/Cocoa.h> 10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Sent when a user-initiated drag to resize the container is initiated. 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochextern NSString* const kBrowserActionGrippyDragStartedNotification; 13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Sent when a user-initiated drag is resizing the container. 15c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochextern NSString* const kBrowserActionGrippyDraggingNotification; 16c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 17c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Sent when a user-initiated drag to resize the container has finished. 18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochextern NSString* const kBrowserActionGrippyDragFinishedNotification; 19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// The view that encompasses the Browser Action buttons in the toolbar and 21c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// provides mechanisms for resizing. 22c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@interface BrowserActionsContainerView : NSView { 23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch @private 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The frame encompasing the grippy used for resizing the container. 25c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NSRect grippyRect_; 26c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The end frame of the animation currently running for this container or 28c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // NSZeroRect if none is in progress. 29c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NSRect animationEndFrame_; 30c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Used to cache the original position within the container that initiated the 32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // drag. 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch NSPoint initialDragPoint_; 34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Used to cache the previous x-pos of the frame rect for resizing purposes. 36c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CGFloat lastXPos_; 37c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // The maximum width of the container. 39c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch CGFloat maxWidth_; 40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Whether the container is currently being resized by the user. 42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL userIsResizing_; 43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 44c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Whether the user can resize this at all. Resizing is disabled in incognito 45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // mode since any changes done in incognito mode are not saved anyway, and 46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // also to avoid a crash. http://crbug.com/42848 47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL resizable_; 48c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Whether the user is allowed to drag the grippy to the left. NO if all 50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // extensions are shown or the location bar has hit its minimum width (handled 51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // within toolbar_controller.mm). 52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL canDragLeft_; 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Whether the user is allowed to drag the grippy to the right. NO if all 55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // extensions are hidden. 56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL canDragRight_; 57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // When the left grippy is pinned, resizing the window has no effect on its 59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // position. This prevents it from overlapping with other elements as well 60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // as letting the container expand when the window is going from super small 61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // to large. 62c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch BOOL grippyPinned_; 63c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 64c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 65c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Resizes the container to the given ideal width, adjusting the |lastXPos_| so 66c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// that |resizeDeltaX| is accurate. 67c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; 68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 69c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Returns the change in the x-pos of the frame rect during resizing. Meant to 70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// be queried when a NSViewFrameDidChangeNotification is fired to determine 71c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// placement of surrounding elements. 72c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch- (CGFloat)resizeDeltaX; 73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(nonatomic, readonly) NSRect animationEndFrame; 75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(nonatomic) BOOL canDragLeft; 76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(nonatomic) BOOL canDragRight; 77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(nonatomic) BOOL grippyPinned; 78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(nonatomic,getter=isResizable) BOOL resizable; 79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(nonatomic) CGFloat maxWidth; 80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@property(readonly, nonatomic) BOOL userIsResizing; 81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch@end 83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 8421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ 85