| 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 <memory> | 10 #include <memory> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 extern NSString* const kBrowserActionsContainerKeyEventKey; | 42 extern NSString* const kBrowserActionsContainerKeyEventKey; |
| 43 | 43 |
| 44 // The possible key actions to process. | 44 // The possible key actions to process. |
| 45 enum BrowserActionsContainerKeyAction { | 45 enum BrowserActionsContainerKeyAction { |
| 46 BROWSER_ACTIONS_INCREMENT_FOCUS = 0, | 46 BROWSER_ACTIONS_INCREMENT_FOCUS = 0, |
| 47 BROWSER_ACTIONS_DECREMENT_FOCUS = 1, | 47 BROWSER_ACTIONS_DECREMENT_FOCUS = 1, |
| 48 BROWSER_ACTIONS_EXECUTE_CURRENT = 2, | 48 BROWSER_ACTIONS_EXECUTE_CURRENT = 2, |
| 49 BROWSER_ACTIONS_INVALID_KEY_ACTION = 3, | 49 BROWSER_ACTIONS_INVALID_KEY_ACTION = 3, |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 class BrowserActionsContainerViewSizeDelegate { | |
| 53 public: | |
| 54 virtual CGFloat GetMaxAllowedWidth() = 0; | |
| 55 virtual ~BrowserActionsContainerViewSizeDelegate() {} | |
| 56 }; | |
| 57 | |
| 58 // The view that encompasses the Browser Action buttons in the toolbar and | 52 // The view that encompasses the Browser Action buttons in the toolbar and |
| 59 // provides mechanisms for resizing. | 53 // provides mechanisms for resizing. |
| 60 @interface BrowserActionsContainerView : NSView<NSAnimationDelegate> { | 54 @interface BrowserActionsContainerView : NSView<NSAnimationDelegate> { |
| 61 @private | 55 @private |
| 62 // The frame encompasing the grippy used for resizing the container. | 56 // The frame encompasing the grippy used for resizing the container. |
| 63 NSRect grippyRect_; | 57 NSRect grippyRect_; |
| 64 | 58 |
| 65 // Used to cache the original position within the container that initiated the | 59 // Remember where in the grippy the drag began. |
| 66 // drag. | 60 CGFloat dragOffset_; |
| 67 NSPoint initialDragPoint_; | |
| 68 | |
| 69 // The maximum width the container could want; i.e., the width required to | |
| 70 // display all the icons. | |
| 71 CGFloat maxDesiredWidth_; | |
| 72 | 61 |
| 73 // Whether the container is currently being resized by the user. | 62 // Whether the container is currently being resized by the user. |
| 74 BOOL userIsResizing_; | 63 BOOL userIsResizing_; |
| 75 | 64 |
| 76 // Whether the user can resize the container; this is disabled for overflow | 65 // Whether the user can resize the container; this is disabled for overflow |
| 77 // (where it would make no sense) and during highlighting, since this is a | 66 // (where it would make no sense) and during highlighting, since this is a |
| 78 // temporary and entirely browser-driven sequence in order to warn the user | 67 // temporary and entirely browser-driven sequence in order to warn the user |
| 79 // about potentially dangerous items. | 68 // about potentially dangerous items. |
| 80 BOOL resizable_; | 69 BOOL resizable_; |
| 81 | 70 |
| 82 // Whether or not the container is the overflow container, and is shown in the | 71 // Whether or not the container is the overflow container, and is shown in the |
| 83 // app menu. | 72 // app menu. |
| 84 BOOL isOverflow_; | 73 BOOL isOverflow_; |
| 85 | 74 |
| 86 // Whether the user is allowed to drag the grippy to the left. NO if all | |
| 87 // extensions are shown or the location bar has hit its minimum width (handled | |
| 88 // within toolbar_controller.mm). | |
| 89 BOOL canDragLeft_; | |
| 90 | |
| 91 // Whether the user is allowed to drag the grippy to the right. NO if all | |
| 92 // extensions are hidden. | |
| 93 BOOL canDragRight_; | |
| 94 | |
| 95 // When the left grippy is pinned, resizing the window has no effect on its | 75 // When the left grippy is pinned, resizing the window has no effect on its |
| 96 // position. This prevents it from overlapping with other elements as well | 76 // position. This prevents it from overlapping with other elements as well |
| 97 // as letting the container expand when the window is going from super small | 77 // as letting the container expand when the window is going from super small |
| 98 // to large. | 78 // to large. |
| 99 BOOL grippyPinned_; | 79 BOOL grippyPinned_; |
| 100 | 80 |
| 101 // The nine-grid of the highlight to paint, if any. | 81 // The nine-grid of the highlight to paint, if any. |
| 102 std::unique_ptr<ui::NinePartImageIds> highlight_; | 82 std::unique_ptr<ui::NinePartImageIds> highlight_; |
| 103 | 83 |
| 104 // The size delegate, if any. | |
| 105 // Weak; delegate is responsible for adding/removing itself. | |
| 106 BrowserActionsContainerViewSizeDelegate* sizeDelegate_; | |
| 107 | |
| 108 base::scoped_nsobject<NSViewAnimation> resizeAnimation_; | 84 base::scoped_nsobject<NSViewAnimation> resizeAnimation_; |
| 109 } | 85 } |
| 110 | 86 |
| 111 // Sets whether or not the container is the overflow container. | 87 // Sets whether or not the container is the overflow container. |
| 112 - (void)setIsOverflow:(BOOL)isOverflow; | 88 - (void)setIsOverflow:(BOOL)isOverflow; |
| 113 | 89 |
| 114 // Sets whether or not the container is highlighting. | 90 // Sets whether or not the container is highlighting. |
| 115 - (void)setHighlight:(std::unique_ptr<ui::NinePartImageIds>)highlight; | 91 - (void)setHighlight:(std::unique_ptr<ui::NinePartImageIds>)highlight; |
| 116 | 92 |
| 117 // Reeturns true if the container is currently highlighting. | 93 // Reeturns true if the container is currently highlighting. |
| 118 - (BOOL)isHighlighting; | 94 - (BOOL)isHighlighting; |
| 119 | 95 |
| 120 // Resizes the container to the given ideal width, optionally animating. | 96 // Resizes the container to the given ideal width, optionally animating. |
| 121 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; | 97 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; |
| 122 | 98 |
| 123 // Returns the frame of the container after the running animation has finished. | 99 // Returns the frame of the container after the running animation has finished. |
| 124 // If no animation is running, returns the container's current frame. | 100 // If no animation is running, returns the container's current frame. |
| 125 - (NSRect)animationEndFrame; | 101 - (NSRect)animationEndFrame; |
| 126 | 102 |
| 127 // Returns true if the view is animating. | 103 // Returns true if the view is animating. |
| 128 - (BOOL)isAnimating; | 104 - (BOOL)isAnimating; |
| 129 | 105 |
| 130 // Stops any animation in progress. | 106 // Stops any animation in progress. |
| 131 - (void)stopAnimation; | 107 - (void)stopAnimation; |
| 132 | 108 |
| 133 @property(nonatomic) BOOL canDragLeft; | 109 @property(nonatomic) CGFloat minWidth; |
| 134 @property(nonatomic) BOOL canDragRight; | 110 @property(nonatomic) CGFloat maxWidth; |
| 135 @property(nonatomic) BOOL grippyPinned; | 111 @property(nonatomic) BOOL grippyPinned; |
| 136 @property(nonatomic) CGFloat maxDesiredWidth; | |
| 137 @property(readonly, nonatomic) BOOL userIsResizing; | 112 @property(readonly, nonatomic) BOOL userIsResizing; |
| 138 @property(nonatomic) BrowserActionsContainerViewSizeDelegate* delegate; | |
| 139 | 113 |
| 140 @end | 114 @end |
| 141 | 115 |
| 142 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ | 116 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ |
| OLD | NEW |