OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/macros.h" | 9 #include "base/macros.h" |
9 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "base/scoped_observer.h" | 12 #include "base/scoped_observer.h" |
12 #include "chrome/browser/extensions/extension_toolbar_model.h" | 13 #include "chrome/browser/extensions/extension_toolbar_model.h" |
13 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" | 14 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_bubble_delegate.h" |
14 #include "ui/gfx/animation/tween.h" | 15 #include "ui/gfx/animation/tween.h" |
15 #include "ui/gfx/geometry/size.h" | 16 #include "ui/gfx/geometry/size.h" |
16 | 17 |
17 namespace extensions { | 18 namespace extensions { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 91 |
91 // Returns the width for the given number of icons. | 92 // Returns the width for the given number of icons. |
92 int IconCountToWidth(int icons) const; | 93 int IconCountToWidth(int icons) const; |
93 | 94 |
94 // Returns the number of icons that can fit within the given width. | 95 // Returns the number of icons that can fit within the given width. |
95 size_t WidthToIconCount(int width) const; | 96 size_t WidthToIconCount(int width) const; |
96 | 97 |
97 // Returns the number of icons that should be displayed. | 98 // Returns the number of icons that should be displayed. |
98 size_t GetIconCount() const; | 99 size_t GetIconCount() const; |
99 | 100 |
| 101 // Returns the actions in the proper order; this may differ from the |
| 102 // underlying order in the case of actions being popped out to show a popup. |
| 103 std::vector<ToolbarActionViewController*> GetActions() const; |
| 104 |
100 // Creates the toolbar actions. | 105 // Creates the toolbar actions. |
101 void CreateActions(); | 106 void CreateActions(); |
102 | 107 |
103 // Deletes all toolbar actions. | 108 // Deletes all toolbar actions. |
104 void DeleteActions(); | 109 void DeleteActions(); |
105 | 110 |
106 // Updates all the toolbar actions. | 111 // Updates all the toolbar actions. |
107 void Update(); | 112 void Update(); |
108 | 113 |
109 // Sets the width for the overflow menu rows. | 114 // Sets the width for the overflow menu rows. |
110 void SetOverflowRowWidth(int width); | 115 void SetOverflowRowWidth(int width); |
111 | 116 |
112 // Notifies the ToolbarActionsBar that a user completed a resize gesture, and | 117 // Notifies the ToolbarActionsBar that a user completed a resize gesture, and |
113 // the new width is |width|. | 118 // the new width is |width|. |
114 void OnResizeComplete(int width); | 119 void OnResizeComplete(int width); |
115 | 120 |
116 // Notifies the ToolbarActionsBar that a user completed a drag and drop event, | 121 // Notifies the ToolbarActionsBar that a user completed a drag and drop event, |
117 // and dragged the view from |dragged_index| to |dropped_index|. | 122 // and dragged the view from |dragged_index| to |dropped_index|. |
118 // |drag_type| indicates whether or not the icon was dragged between the | 123 // |drag_type| indicates whether or not the icon was dragged between the |
119 // overflow and main containers. | 124 // overflow and main containers. |
120 // The main container should handle all drag/drop notifications. | 125 // The main container should handle all drag/drop notifications. |
121 void OnDragDrop(int dragged_index, | 126 void OnDragDrop(int dragged_index, |
122 int dropped_index, | 127 int dropped_index, |
123 DragType drag_type); | 128 DragType drag_type); |
124 | 129 |
| 130 // Notifies the ToolbarActionsBar that the delegate finished animating. |
| 131 void OnAnimationEnded(); |
| 132 |
| 133 // Returns true if the given |action| is visible. |
| 134 bool IsActionVisible(const ToolbarActionViewController* action) const; |
| 135 |
| 136 // Pops out a given |action|, ensuring it is visible. |
| 137 // |closure| will be called once any animation is complete. |
| 138 void PopOutAction(ToolbarActionViewController* action, |
| 139 const base::Closure& closure); |
| 140 |
| 141 // Undoes the current "pop out"; i.e., moves the popped out action back into |
| 142 // overflow. |
| 143 void UndoPopOut(); |
| 144 |
125 // Sets the active popup owner to be |popup_owner|. | 145 // Sets the active popup owner to be |popup_owner|. |
126 void SetPopupOwner(ToolbarActionViewController* popup_owner); | 146 void SetPopupOwner(ToolbarActionViewController* popup_owner); |
127 | 147 |
128 // Hides the actively showing popup, if any. | 148 // Hides the actively showing popup, if any. |
129 void HideActivePopup(); | 149 void HideActivePopup(); |
130 | 150 |
131 // Returns the main (i.e., not overflow) controller for the given action. | 151 // Returns the main (i.e., not overflow) controller for the given action. |
132 ToolbarActionViewController* GetMainControllerForAction( | 152 ToolbarActionViewController* GetMainControllerForAction( |
133 ToolbarActionViewController* action); | 153 ToolbarActionViewController* action); |
134 | 154 |
135 const std::vector<ToolbarActionViewController*>& toolbar_actions() const { | 155 // Returns the underlying toolbar actions, but does not order them. Primarily |
| 156 // for use in testing. |
| 157 const std::vector<ToolbarActionViewController*>& toolbar_actions_unordered() |
| 158 const { |
136 return toolbar_actions_.get(); | 159 return toolbar_actions_.get(); |
137 } | 160 } |
138 bool enabled() const { return model_ != nullptr; } | 161 bool enabled() const { return model_ != nullptr; } |
139 bool suppress_layout() const { return suppress_layout_; } | 162 bool suppress_layout() const { return suppress_layout_; } |
140 bool suppress_animation() const { | 163 bool suppress_animation() const { |
141 return suppress_animation_ || disable_animations_for_testing_; | 164 return suppress_animation_ || disable_animations_for_testing_; |
142 } | 165 } |
143 bool is_highlighting() const { return model_ && model_->is_highlighting(); } | 166 bool is_highlighting() const { return model_ && model_->is_highlighting(); } |
144 const PlatformSettings& platform_settings() const { | 167 const PlatformSettings& platform_settings() const { |
145 return platform_settings_; | 168 return platform_settings_; |
146 } | 169 } |
147 ToolbarActionViewController* popup_owner() { return popup_owner_; } | 170 ToolbarActionViewController* popup_owner() { return popup_owner_; } |
| 171 ToolbarActionViewController* popped_out_action() { |
| 172 return popped_out_action_; |
| 173 } |
148 bool in_overflow_mode() const { return main_bar_ != nullptr; } | 174 bool in_overflow_mode() const { return main_bar_ != nullptr; } |
149 | 175 |
150 ToolbarActionsBarDelegate* delegate_for_test() { return delegate_; } | 176 ToolbarActionsBarDelegate* delegate_for_test() { return delegate_; } |
151 | 177 |
152 static void set_send_overflowed_action_changes_for_testing( | 178 static void set_send_overflowed_action_changes_for_testing( |
153 bool send_overflowed_action_changes) { | 179 bool send_overflowed_action_changes) { |
154 send_overflowed_action_changes_ = send_overflowed_action_changes; | 180 send_overflowed_action_changes_ = send_overflowed_action_changes; |
155 } | 181 } |
156 | 182 |
157 // During testing we can disable animations by setting this flag to true, | 183 // During testing we can disable animations by setting this flag to true, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // alter. | 269 // alter. |
244 static bool send_overflowed_action_changes_; | 270 static bool send_overflowed_action_changes_; |
245 | 271 |
246 // True if an action in the overflow menu wants to run. | 272 // True if an action in the overflow menu wants to run. |
247 bool overflowed_action_wants_to_run_; | 273 bool overflowed_action_wants_to_run_; |
248 | 274 |
249 // True if we have checked to see if there is an extension bubble that should | 275 // True if we have checked to see if there is an extension bubble that should |
250 // be displayed, and, if there is, shown that bubble. | 276 // be displayed, and, if there is, shown that bubble. |
251 bool checked_extension_bubble_; | 277 bool checked_extension_bubble_; |
252 | 278 |
| 279 // The action, if any, which is currently "popped out" of the overflow in |
| 280 // order to show a popup. |
| 281 ToolbarActionViewController* popped_out_action_; |
| 282 |
| 283 // The task to alert the |popped_out_action_| that animation has finished, and |
| 284 // it is fully popped out. |
| 285 base::Closure popped_out_closure_; |
| 286 |
253 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; | 287 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; |
254 | 288 |
255 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); | 289 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); |
256 }; | 290 }; |
257 | 291 |
258 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 292 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
OLD | NEW |