Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ |
| 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ | 6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #import "ui/base/cocoa/tracking_area.h" | 11 #import "ui/base/cocoa/tracking_area.h" |
| 12 | 12 |
| 13 // Sent when a user-initiated drag to resize the container is initiated. | 13 // Sent when a user-initiated drag to resize the container is initiated. |
| 14 extern NSString* const kBrowserActionGrippyDragStartedNotification; | 14 extern NSString* const kBrowserActionGrippyDragStartedNotification; |
| 15 | 15 |
| 16 // Sent when a user-initiated drag is resizing the container. | 16 // Sent when a user-initiated drag is resizing the container. |
| 17 extern NSString* const kBrowserActionGrippyDraggingNotification; | 17 extern NSString* const kBrowserActionGrippyDraggingNotification; |
| 18 | 18 |
| 19 // Sent when a user-initiated drag to resize the container has finished. | 19 // Sent when a user-initiated drag to resize the container has finished. |
| 20 extern NSString* const kBrowserActionGrippyDragFinishedNotification; | 20 extern NSString* const kBrowserActionGrippyDragFinishedNotification; |
| 21 | 21 |
| 22 // Sent before the dragging will resize the container. | |
| 23 extern NSString* const kBrowserActionGrippyWillDragNotification; | |
| 24 | |
| 25 // Sent when the Browser Actions container view is about to animate. | 22 // Sent when the Browser Actions container view is about to animate. |
| 26 extern NSString* const kBrowserActionsContainerWillAnimate; | 23 extern NSString* const kBrowserActionsContainerWillAnimate; |
| 27 | 24 |
| 28 // Sent when the mouse enters the browser actions container (if tracking is | 25 // Sent when the mouse enters the browser actions container (if tracking is |
| 29 // enabled). | 26 // enabled). |
| 30 extern NSString* const kBrowserActionsContainerMouseEntered; | 27 extern NSString* const kBrowserActionsContainerMouseEntered; |
| 31 | 28 |
| 32 // Key which is used to notify the translation with delta. | 29 // Key which is used to notify the translation with delta. |
| 33 extern NSString* const kTranslationWithDelta; | 30 extern NSString* const kTranslationWithDelta; |
| 34 | 31 |
| 32 class BrowserActionsContainerViewSizeDelegate { | |
| 33 public: | |
| 34 virtual CGFloat GetMaxAllowedWidth() = 0; | |
| 35 virtual ~BrowserActionsContainerViewSizeDelegate() {} | |
| 36 }; | |
| 37 | |
| 35 // The view that encompasses the Browser Action buttons in the toolbar and | 38 // The view that encompasses the Browser Action buttons in the toolbar and |
| 36 // provides mechanisms for resizing. | 39 // provides mechanisms for resizing. |
| 37 @interface BrowserActionsContainerView : NSView { | 40 @interface BrowserActionsContainerView : NSView { |
| 38 @private | 41 @private |
| 39 // The frame encompasing the grippy used for resizing the container. | 42 // The frame encompasing the grippy used for resizing the container. |
| 40 NSRect grippyRect_; | 43 NSRect grippyRect_; |
| 41 | 44 |
| 42 // Used to cache the original position within the container that initiated the | 45 // Used to cache the original position within the container that initiated the |
| 43 // drag. | 46 // drag. |
| 44 NSPoint initialDragPoint_; | 47 NSPoint initialDragPoint_; |
| 45 | 48 |
| 46 // Used to cache the previous x-pos of the frame rect for resizing purposes. | 49 // Used to cache the previous x-pos of the frame rect for resizing purposes. |
| 47 CGFloat lastXPos_; | 50 CGFloat lastXPos_; |
| 48 | 51 |
| 49 // The maximum width of the container. | 52 // The maximum width the container could want; i.e., the width required to |
| 50 CGFloat maxWidth_; | 53 // display all the icons. |
| 54 CGFloat maxDesiredWidth_; | |
| 51 | 55 |
| 52 // Whether the container is currently being resized by the user. | 56 // Whether the container is currently being resized by the user. |
| 53 BOOL userIsResizing_; | 57 BOOL userIsResizing_; |
| 54 | 58 |
| 55 // Whether the user can resize this at all. Resizing is disabled in incognito | 59 // Whether the user can resize this at all. Resizing is disabled in incognito |
| 56 // mode since any changes done in incognito mode are not saved anyway, and | 60 // mode since any changes done in incognito mode are not saved anyway, and |
| 57 // also to avoid a crash. http://crbug.com/42848 | 61 // also to avoid a crash. http://crbug.com/42848 |
| 58 BOOL resizable_; | 62 BOOL resizable_; |
| 59 | 63 |
| 60 // Whether the user is allowed to drag the grippy to the left. NO if all | 64 // Whether the user is allowed to drag the grippy to the left. NO if all |
| 61 // extensions are shown or the location bar has hit its minimum width (handled | 65 // extensions are shown or the location bar has hit its minimum width (handled |
| 62 // within toolbar_controller.mm). | 66 // within toolbar_controller.mm). |
| 63 BOOL canDragLeft_; | 67 BOOL canDragLeft_; |
| 64 | 68 |
| 65 // Whether the user is allowed to drag the grippy to the right. NO if all | 69 // Whether the user is allowed to drag the grippy to the right. NO if all |
| 66 // extensions are hidden. | 70 // extensions are hidden. |
| 67 BOOL canDragRight_; | 71 BOOL canDragRight_; |
| 68 | 72 |
| 69 // When the left grippy is pinned, resizing the window has no effect on its | 73 // When the left grippy is pinned, resizing the window has no effect on its |
| 70 // position. This prevents it from overlapping with other elements as well | 74 // position. This prevents it from overlapping with other elements as well |
| 71 // as letting the container expand when the window is going from super small | 75 // as letting the container expand when the window is going from super small |
| 72 // to large. | 76 // to large. |
| 73 BOOL grippyPinned_; | 77 BOOL grippyPinned_; |
| 74 | 78 |
| 75 // A tracking area to receive mouseEntered events, if tracking is enabled. | 79 // A tracking area to receive mouseEntered events, if tracking is enabled. |
| 76 ui::ScopedCrTrackingArea trackingArea_; | 80 ui::ScopedCrTrackingArea trackingArea_; |
| 77 | 81 |
| 82 // The size delegate, if any. | |
|
Avi (use Gerrit)
2015/03/13 23:26:03
Document lifetime requirements and ownership seman
Devlin
2015/03/14 00:03:14
Done.
| |
| 83 BrowserActionsContainerViewSizeDelegate* sizeDelegate_; | |
| 84 | |
| 78 base::scoped_nsobject<NSViewAnimation> resizeAnimation_; | 85 base::scoped_nsobject<NSViewAnimation> resizeAnimation_; |
| 79 } | 86 } |
| 80 | 87 |
| 81 // Sets whether or not tracking (for mouseEntered events) is enabled. | 88 // Sets whether or not tracking (for mouseEntered events) is enabled. |
| 82 - (void)setTrackingEnabled:(BOOL)enabled; | 89 - (void)setTrackingEnabled:(BOOL)enabled; |
| 83 | 90 |
| 84 // Resizes the container to the given ideal width, adjusting the |lastXPos_| so | 91 // Resizes the container to the given ideal width, adjusting the |lastXPos_| so |
| 85 // that |resizeDeltaX| is accurate. | 92 // that |resizeDeltaX| is accurate. |
| 86 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; | 93 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; |
| 87 | 94 |
| 88 // Returns the change in the x-pos of the frame rect during resizing. Meant to | 95 // Returns the change in the x-pos of the frame rect during resizing. Meant to |
| 89 // be queried when a NSViewFrameDidChangeNotification is fired to determine | 96 // be queried when a NSViewFrameDidChangeNotification is fired to determine |
| 90 // placement of surrounding elements. | 97 // placement of surrounding elements. |
| 91 - (CGFloat)resizeDeltaX; | 98 - (CGFloat)resizeDeltaX; |
| 92 | 99 |
| 93 // Returns the frame of the container after the running animation has finished. | 100 // Returns the frame of the container after the running animation has finished. |
| 94 // If no animation is running, returns the container's current frame. | 101 // If no animation is running, returns the container's current frame. |
| 95 - (NSRect)animationEndFrame; | 102 - (NSRect)animationEndFrame; |
| 96 | 103 |
| 97 // Returns true if the view is animating. | 104 // Returns true if the view is animating. |
| 98 - (BOOL)isAnimating; | 105 - (BOOL)isAnimating; |
| 99 | 106 |
| 100 // Stops any animation in progress. | 107 // Stops any animation in progress. |
| 101 - (void)stopAnimation; | 108 - (void)stopAnimation; |
| 102 | 109 |
| 103 @property(nonatomic) BOOL canDragLeft; | 110 @property(nonatomic) BOOL canDragLeft; |
| 104 @property(nonatomic) BOOL canDragRight; | 111 @property(nonatomic) BOOL canDragRight; |
| 105 @property(nonatomic) BOOL grippyPinned; | 112 @property(nonatomic) BOOL grippyPinned; |
| 106 @property(nonatomic,getter=isResizable) BOOL resizable; | 113 @property(nonatomic,getter=isResizable) BOOL resizable; |
| 107 @property(nonatomic) CGFloat maxWidth; | 114 @property(nonatomic) CGFloat maxDesiredWidth; |
| 108 @property(readonly, nonatomic) BOOL userIsResizing; | 115 @property(readonly, nonatomic) BOOL userIsResizing; |
| 116 @property(nonatomic) BrowserActionsContainerViewSizeDelegate* delegate; | |
| 109 | 117 |
| 110 @end | 118 @end |
| 111 | 119 |
| 112 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ | 120 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ |
| OLD | NEW |