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/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace user_prefs { | 23 namespace user_prefs { |
24 class PrefRegistrySyncable; | 24 class PrefRegistrySyncable; |
25 } | 25 } |
26 | 26 |
27 class ToolbarActionsBarDelegate; | 27 class ToolbarActionsBarDelegate; |
28 class ToolbarActionViewController; | 28 class ToolbarActionViewController; |
29 | 29 |
30 // A platform-independent version of the container for toolbar actions, | 30 // A platform-independent version of the container for toolbar actions, |
31 // including extension actions and component actions. | 31 // including extension actions and component actions. |
32 // This class manages the order of the actions, the actions' state, and owns the | 32 // |
33 // action controllers, in addition to interfacing with the toolbar actions | 33 // This is a per-window instance, unlike the ToolbarActionsModel, which is |
34 // model. Further, it manages dimensions for the bar, excluding animations. | 34 // per-profile. In most cases, ordering and visible count will be identical |
| 35 // between the base model and the window; however, there are exceptions in the |
| 36 // case of very small windows (which may be too narrow to display all the |
| 37 // icons), or windows in which an action is "popped out", resulting in a |
| 38 // re-ordering. |
| 39 // |
35 // This can come in two flavors, main and "overflow". The main bar is visible | 40 // This can come in two flavors, main and "overflow". The main bar is visible |
36 // next to the omnibox, and the overflow bar is visible inside the chrome | 41 // next to the omnibox, and the overflow bar is visible inside the chrome |
37 // (fka wrench) menu. The main bar can have only a single row of icons with | 42 // (fka wrench) menu. The main bar can have only a single row of icons with |
38 // flexible width, whereas the overflow bar has multiple rows of icons with a | 43 // flexible width, whereas the overflow bar has multiple rows of icons with a |
39 // fixed width (the width of the menu). | 44 // fixed width (the width of the menu). |
40 class ToolbarActionsBar : public ToolbarActionsModel::Observer { | 45 class ToolbarActionsBar : public ToolbarActionsModel::Observer { |
41 public: | 46 public: |
42 // A struct to contain the platform settings. | 47 // A struct to contain the platform settings. |
43 struct PlatformSettings { | 48 struct PlatformSettings { |
44 explicit PlatformSettings(bool in_overflow_mode); | 49 explicit PlatformSettings(bool in_overflow_mode); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Returns the [minimum|maximum] possible width for the toolbar. | 99 // Returns the [minimum|maximum] possible width for the toolbar. |
95 int GetMinimumWidth() const; | 100 int GetMinimumWidth() const; |
96 int GetMaximumWidth() const; | 101 int GetMaximumWidth() const; |
97 | 102 |
98 // Returns the width for the given number of icons. | 103 // Returns the width for the given number of icons. |
99 int IconCountToWidth(int icons) const; | 104 int IconCountToWidth(int icons) const; |
100 | 105 |
101 // Returns the number of icons that can fit within the given width. | 106 // Returns the number of icons that can fit within the given width. |
102 size_t WidthToIconCount(int width) const; | 107 size_t WidthToIconCount(int width) const; |
103 | 108 |
104 // Returns the number of icons that should be displayed. | 109 // Returns the number of icons that should be displayed if space allows. |
105 size_t GetIconCount() const; | 110 size_t GetIconCount() const; |
106 | 111 |
| 112 // Returns the starting index (inclusive) for displayable icons. |
| 113 size_t GetStartIndexInBounds() const; |
| 114 |
| 115 // Returns the ending index (exclusive) for displayable icons. |
| 116 size_t GetEndIndexInBounds() const; |
| 117 |
| 118 // Returns true if an overflow container is necessary to display any other |
| 119 // icons for this particular window. This is different than |
| 120 // ToolbarActionsModel::all_icons_visible() because the ToolbarActionsBar |
| 121 // is limited to a single window, whereas the model is the underlying model |
| 122 // of *all* windows, independent of size. As such, the model is identical |
| 123 // between a very wide window and a very narrow window, and the user's stored |
| 124 // preference may be to have all icons visible. But if the very narrow window |
| 125 // doesn't have the width to display all those actions, some will need to be |
| 126 // implicitly pushed to the overflow, even though the user's global preference |
| 127 // has not changed. |
| 128 bool NeedsOverflow() const; |
| 129 |
107 // Returns the frame (bounds) that the specified index should have, taking | 130 // Returns the frame (bounds) that the specified index should have, taking |
108 // into account if this is the main or overflow bar. If this is the overflow | 131 // into account if this is the main or overflow bar. If this is the overflow |
109 // bar and the index should not be displayed (i.e., it is shown on the main | 132 // bar and the index should not be displayed (i.e., it is shown on the main |
110 // bar), returns an empty rect. | 133 // bar), returns an empty rect. |
111 gfx::Rect GetFrameForIndex(size_t index) const; | 134 gfx::Rect GetFrameForIndex(size_t index) const; |
112 | 135 |
113 // Returns the actions in the proper order; this may differ from the | 136 // Returns the actions in the proper order; this may differ from the |
114 // underlying order in the case of actions being popped out to show a popup. | 137 // underlying order in the case of actions being popped out to show a popup. |
115 std::vector<ToolbarActionViewController*> GetActions() const; | 138 std::vector<ToolbarActionViewController*> GetActions() const; |
116 | 139 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // The controller of the bubble to show once animation finishes, if any. | 310 // The controller of the bubble to show once animation finishes, if any. |
288 scoped_ptr<extensions::ExtensionMessageBubbleController> | 311 scoped_ptr<extensions::ExtensionMessageBubbleController> |
289 pending_extension_bubble_controller_; | 312 pending_extension_bubble_controller_; |
290 | 313 |
291 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; | 314 base::WeakPtrFactory<ToolbarActionsBar> weak_ptr_factory_; |
292 | 315 |
293 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); | 316 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBar); |
294 }; | 317 }; |
295 | 318 |
296 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ | 319 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_H_ |
OLD | NEW |