Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h

Issue 1009613002: [Toolbar UI Mac] Fix omnibox minimum width (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avi's Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
83 // Weak; delegate is responsible for adding/removing itself.
84 BrowserActionsContainerViewSizeDelegate* sizeDelegate_;
85
78 base::scoped_nsobject<NSViewAnimation> resizeAnimation_; 86 base::scoped_nsobject<NSViewAnimation> resizeAnimation_;
79 } 87 }
80 88
81 // Sets whether or not tracking (for mouseEntered events) is enabled. 89 // Sets whether or not tracking (for mouseEntered events) is enabled.
82 - (void)setTrackingEnabled:(BOOL)enabled; 90 - (void)setTrackingEnabled:(BOOL)enabled;
83 91
84 // Resizes the container to the given ideal width, adjusting the |lastXPos_| so 92 // Resizes the container to the given ideal width, adjusting the |lastXPos_| so
85 // that |resizeDeltaX| is accurate. 93 // that |resizeDeltaX| is accurate.
86 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate; 94 - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate;
87 95
88 // Returns the change in the x-pos of the frame rect during resizing. Meant to 96 // 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 97 // be queried when a NSViewFrameDidChangeNotification is fired to determine
90 // placement of surrounding elements. 98 // placement of surrounding elements.
91 - (CGFloat)resizeDeltaX; 99 - (CGFloat)resizeDeltaX;
92 100
93 // Returns the frame of the container after the running animation has finished. 101 // Returns the frame of the container after the running animation has finished.
94 // If no animation is running, returns the container's current frame. 102 // If no animation is running, returns the container's current frame.
95 - (NSRect)animationEndFrame; 103 - (NSRect)animationEndFrame;
96 104
97 // Returns true if the view is animating. 105 // Returns true if the view is animating.
98 - (BOOL)isAnimating; 106 - (BOOL)isAnimating;
99 107
100 // Stops any animation in progress. 108 // Stops any animation in progress.
101 - (void)stopAnimation; 109 - (void)stopAnimation;
102 110
103 @property(nonatomic) BOOL canDragLeft; 111 @property(nonatomic) BOOL canDragLeft;
104 @property(nonatomic) BOOL canDragRight; 112 @property(nonatomic) BOOL canDragRight;
105 @property(nonatomic) BOOL grippyPinned; 113 @property(nonatomic) BOOL grippyPinned;
106 @property(nonatomic,getter=isResizable) BOOL resizable; 114 @property(nonatomic,getter=isResizable) BOOL resizable;
107 @property(nonatomic) CGFloat maxWidth; 115 @property(nonatomic) CGFloat maxDesiredWidth;
108 @property(readonly, nonatomic) BOOL userIsResizing; 116 @property(readonly, nonatomic) BOOL userIsResizing;
117 @property(nonatomic) BrowserActionsContainerViewSizeDelegate* delegate;
109 118
110 @end 119 @end
111 120
112 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_ 121 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698