OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PANELS_PANEL_STRIP_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // All panels in the strip are contained within the bounds of the strip. | 23 // All panels in the strip are contained within the bounds of the strip. |
24 class PanelStrip : public PanelMouseWatcherObserver { | 24 class PanelStrip : public PanelMouseWatcherObserver { |
25 public: | 25 public: |
26 typedef std::vector<Panel*> Panels; | 26 typedef std::vector<Panel*> Panels; |
27 | 27 |
28 explicit PanelStrip(PanelManager* panel_manager); | 28 explicit PanelStrip(PanelManager* panel_manager); |
29 virtual ~PanelStrip(); | 29 virtual ~PanelStrip(); |
30 | 30 |
31 // Sets the bounds of the panel strip. | 31 // Sets the bounds of the panel strip. |
32 // |bounds| is in screen coordinates. | 32 // |bounds| is in screen coordinates. |
33 void SetBounds(const gfx::Rect bounds); | 33 void SetDisplayArea(const gfx::Rect& area); |
34 | 34 |
35 // Adds a panel to the strip. The panel may be a newly created panel or one | 35 // Adds a panel to the strip. The panel may be a newly created panel or one |
36 // that is transitioning from another grouping of panels. | 36 // that is transitioning from another grouping of panels. |
37 void AddPanel(Panel* panel); | 37 void AddPanel(Panel* panel); |
38 | 38 |
39 // Returns |false| if the panel is not in the strip. | 39 // Returns |false| if the panel is not in the strip. |
40 bool Remove(Panel* panel); | 40 bool Remove(Panel* panel); |
41 void RemoveAll(); | 41 void RemoveAll(); |
42 | 42 |
43 // Drags the given panel. | 43 // Drags the given panel. |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 void AddNewPanel(Panel* panel); | 105 void AddNewPanel(Panel* panel); |
106 void AddExistingPanel(Panel* panel); | 106 void AddExistingPanel(Panel* panel); |
107 | 107 |
108 // Keep track of the minimized panels to control mouse watching. | 108 // Keep track of the minimized panels to control mouse watching. |
109 void IncrementMinimizedPanels(); | 109 void IncrementMinimizedPanels(); |
110 void DecrementMinimizedPanels(); | 110 void DecrementMinimizedPanels(); |
111 | 111 |
112 // Handles all the panels that're delayed to be removed. | 112 // Handles all the panels that're delayed to be removed. |
113 void DelayedRemove(); | 113 void DelayedRemove(); |
114 | 114 |
115 // Does the remove. Called from Remove and DelayedRemove. | 115 // Does the actual remove. Caller is responsible for rearranging |
116 void DoRemove(Panel* panel); | 116 // the panel strip if necessary. |
| 117 // Returns |false| if panel is not in the strip. |
| 118 bool DoRemove(Panel* panel); |
117 | 119 |
118 // Rearranges the positions of the panels starting from the given iterator. | 120 // Rearranges the positions of the panels in the strip. |
| 121 // Handles moving panels to/from overflow area as needed. |
119 // This is called when the display space has been changed, i.e. working | 122 // This is called when the display space has been changed, i.e. working |
120 // area being changed or a panel being closed. | 123 // area being changed or a panel being closed. |
121 void Rearrange(Panels::iterator iter_to_start, int rightmost_position); | 124 void Rearrange(); |
122 | 125 |
123 // Help functions to drag the given panel. | 126 // Help functions to drag the given panel. |
124 void DragLeft(); | 127 void DragLeft(); |
125 void DragRight(); | 128 void DragRight(); |
126 | 129 |
127 // Does the real job of bringing up or down the titlebars. | 130 // Does the real job of bringing up or down the titlebars. |
128 void DoBringUpOrDownTitlebars(bool bring_up); | 131 void DoBringUpOrDownTitlebars(bool bring_up); |
129 // The callback for a delyed task, checks if it still need to perform | 132 // The callback for a delyed task, checks if it still need to perform |
130 // the delayed action. | 133 // the delayed action. |
131 void DelayedBringUpOrDownTitlebarsCheck(); | 134 void DelayedBringUpOrDownTitlebarsCheck(); |
132 | 135 |
133 int GetRightMostAvailablePosition() const; | 136 int GetRightMostAvailablePosition() const; |
134 | 137 |
| 138 // Moves the panel from the panel strip to the overflow area because |
| 139 // the panel will not fit within the bounds of the panel strip. |
| 140 // Overflow may occur when new panels are added, the bounds of the strip |
| 141 // changes, a panel's size grows, a panel is moved from overflow into |
| 142 // the strip, etc. |
| 143 void MovePanelToOverflow(Panel* panel, bool is_new); |
| 144 |
| 145 // Moves panels to the overflow area, starting from the last panel. |
| 146 // |overflow_point| is the index of the first panel to oveflow. |
| 147 void MovePanelsToOverflow(size_t overflow_point); |
| 148 |
| 149 // Adds zero or more panels from overflow as will fit in the panel strip. |
| 150 void MovePanelsFromOverflowIfNeeded(); |
| 151 |
135 PanelManager* panel_manager_; // Weak, owns us. | 152 PanelManager* panel_manager_; // Weak, owns us. |
136 | 153 |
137 // All panels in the panel strip must fit within this area. | 154 // All panels in the panel strip must fit within this area. |
138 gfx::Rect strip_bounds_; | 155 gfx::Rect display_area_; |
139 | 156 |
140 Panels panels_; | 157 Panels panels_; |
141 | 158 |
142 // Stores the panels that are pending to remove. We want to delay the removal | 159 // Stores the panels that are pending to remove. We want to delay the removal |
143 // when we're in the process of the dragging. | 160 // when we're in the process of the dragging. |
144 Panels panels_pending_to_remove_; | 161 Panels panels_pending_to_remove_; |
145 | 162 |
146 int minimized_panel_count_; | 163 int minimized_panel_count_; |
147 bool are_titlebars_up_; | 164 bool are_titlebars_up_; |
148 | 165 |
149 // Panel to drag. | 166 // Panel to drag. |
150 size_t dragging_panel_index_; | 167 size_t dragging_panel_index_; |
151 | 168 |
152 // Original x coordinate of the panel to drag. This is used to get back to | 169 // Original x coordinate of the panel to drag. This is used to get back to |
153 // the original position when we cancel the dragging. | 170 // the original position when we cancel the dragging. |
154 int dragging_panel_original_x_; | 171 int dragging_panel_original_x_; |
155 | 172 |
156 // Bounds of the panel to drag. It is first set to the original bounds when | 173 // Bounds of the panel to drag. It is first set to the original bounds when |
157 // the dragging happens. Then it is updated to the position that will be set | 174 // the dragging happens. Then it is updated to the position that will be set |
158 // to when the dragging ends. | 175 // to when the dragging ends. |
159 gfx::Rect dragging_panel_bounds_; | 176 gfx::Rect dragging_panel_bounds_; |
160 | 177 |
161 // Delayed transitions support. Sometimes transitions between minimized and | 178 // Delayed transitions support. Sometimes transitions between minimized and |
162 // title-only states are delayed, for better usability with Taskbars/Docks. | 179 // title-only states are delayed, for better usability with Taskbars/Docks. |
163 TitlebarAction delayed_titlebar_action_; | 180 TitlebarAction delayed_titlebar_action_; |
164 bool remove_delays_for_testing_; | 181 bool remove_delays_for_testing_; |
165 // Owned by MessageLoop after posting. | 182 // Owned by MessageLoop after posting. |
166 base::WeakPtrFactory<PanelStrip> titlebar_action_factory_; | 183 base::WeakPtrFactory<PanelStrip> titlebar_action_factory_; |
167 | 184 |
| 185 // Factory used for moving new panels to overflow after a delay. |
| 186 base::WeakPtrFactory<PanelStrip> overflow_action_factory_; |
| 187 |
168 static const int kPanelsHorizontalSpacing = 4; | 188 static const int kPanelsHorizontalSpacing = 4; |
169 | 189 |
170 // Absolute minimum width and height for panels, including non-client area. | 190 // Absolute minimum width and height for panels, including non-client area. |
171 // Should only be big enough to accomodate a close button on the reasonably | 191 // Should only be big enough to accomodate a close button on the reasonably |
172 // recognisable titlebar. | 192 // recognisable titlebar. |
173 static const int kPanelMinWidth; | 193 static const int kPanelMinWidth; |
174 static const int kPanelMinHeight; | 194 static const int kPanelMinHeight; |
175 | 195 |
176 DISALLOW_COPY_AND_ASSIGN(PanelStrip); | 196 DISALLOW_COPY_AND_ASSIGN(PanelStrip); |
177 }; | 197 }; |
178 | 198 |
179 #endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ | 199 #endif // CHROME_BROWSER_UI_PANELS_PANEL_STRIP_H_ |
OLD | NEW |