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