1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_
#define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_
#import <Cocoa/Cocoa.h>
#include "base/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#import "ui/base/cocoa/tracking_area.h"
namespace ui {
struct NinePartImageIds;
}
// Sent when a user-initiated drag to resize the container is initiated.
extern NSString* const kBrowserActionGrippyDragStartedNotification;
// Sent when a user-initiated drag is resizing the container.
extern NSString* const kBrowserActionGrippyDraggingNotification;
// Sent when a user-initiated drag to resize the container has finished.
extern NSString* const kBrowserActionGrippyDragFinishedNotification;
// Sent when the Browser Actions container view is about to animate.
extern NSString* const kBrowserActionsContainerWillAnimate;
// Sent when the mouse enters the browser actions container (if tracking is
// enabled).
extern NSString* const kBrowserActionsContainerMouseEntered;
// Sent when a running animation has ended.
extern NSString* const kBrowserActionsContainerAnimationEnded;
// Key which is used to notify the translation with delta.
extern NSString* const kTranslationWithDelta;
// Sent when the container receives a key event that should be processed.
// The userInfo contains a single entry with the key event.
extern NSString* const kBrowserActionsContainerReceivedKeyEvent;
// The key into the userInfo dictionary to retrieve the key event (stored as an
// integer).
extern NSString* const kBrowserActionsContainerKeyEventKey;
// The possible key actions to process.
enum BrowserActionsContainerKeyAction {
BROWSER_ACTIONS_INCREMENT_FOCUS = 0,
BROWSER_ACTIONS_DECREMENT_FOCUS = 1,
BROWSER_ACTIONS_EXECUTE_CURRENT = 2,
BROWSER_ACTIONS_INVALID_KEY_ACTION = 3,
};
class BrowserActionsContainerViewSizeDelegate {
public:
virtual CGFloat GetMaxAllowedWidth() = 0;
virtual ~BrowserActionsContainerViewSizeDelegate() {}
};
// The view that encompasses the Browser Action buttons in the toolbar and
// provides mechanisms for resizing.
@interface BrowserActionsContainerView : NSView<NSAnimationDelegate> {
@private
// The frame encompasing the grippy used for resizing the container.
NSRect grippyRect_;
// Used to cache the original position within the container that initiated the
// drag.
NSPoint initialDragPoint_;
// The maximum width the container could want; i.e., the width required to
// display all the icons.
CGFloat maxDesiredWidth_;
// Whether the container is currently being resized by the user.
BOOL userIsResizing_;
// Whether the user can resize the container; this is disabled for overflow
// (where it would make no sense) and during highlighting, since this is a
// temporary and entirely browser-driven sequence in order to warn the user
// about potentially dangerous items.
BOOL resizable_;
// Whether or not the container is the overflow container, and is shown in the
// app menu.
BOOL isOverflow_;
// Whether the user is allowed to drag the grippy to the left. NO if all
// extensions are shown or the location bar has hit its minimum width (handled
// within toolbar_controller.mm).
BOOL canDragLeft_;
// Whether the user is allowed to drag the grippy to the right. NO if all
// extensions are hidden.
BOOL canDragRight_;
// When the left grippy is pinned, resizing the window has no effect on its
// position. This prevents it from overlapping with other elements as well
// as letting the container expand when the window is going from super small
// to large.
BOOL grippyPinned_;
// The nine-grid of the highlight to paint, if any.
scoped_ptr<ui::NinePartImageIds> highlight_;
// A tracking area to receive mouseEntered events, if tracking is enabled.
ui::ScopedCrTrackingArea trackingArea_;
// The size delegate, if any.
// Weak; delegate is responsible for adding/removing itself.
BrowserActionsContainerViewSizeDelegate* sizeDelegate_;
base::scoped_nsobject<NSViewAnimation> resizeAnimation_;
}
// Sets whether or not tracking (for mouseEntered events) is enabled.
- (void)setTrackingEnabled:(BOOL)enabled;
// Returns true if tracking is currently enabled.
- (BOOL)trackingEnabled;
// Sets whether or not the container is the overflow container.
- (void)setIsOverflow:(BOOL)isOverflow;
// Sets whether or not the container is highlighting.
- (void)setHighlight:(scoped_ptr<ui::NinePartImageIds>)highlight;
// Reeturns true if the container is currently highlighting.
- (BOOL)isHighlighting;
// Resizes the container to the given ideal width, optionally animating.
- (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate;
// Returns the frame of the container after the running animation has finished.
// If no animation is running, returns the container's current frame.
- (NSRect)animationEndFrame;
// Returns true if the view is animating.
- (BOOL)isAnimating;
// Stops any animation in progress.
- (void)stopAnimation;
@property(nonatomic) BOOL canDragLeft;
@property(nonatomic) BOOL canDragRight;
@property(nonatomic) BOOL grippyPinned;
@property(nonatomic) CGFloat maxDesiredWidth;
@property(readonly, nonatomic) BOOL userIsResizing;
@property(nonatomic) BrowserActionsContainerViewSizeDelegate* delegate;
@end
#endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTAINER_VIEW_
|