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