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_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 6 #define CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_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 27 matching lines...) Expand all Loading... |
38 Panel* CreatePanel(Browser* browser); | 38 Panel* CreatePanel(Browser* browser); |
39 | 39 |
40 void Remove(Panel* panel); | 40 void Remove(Panel* panel); |
41 void RemoveAll(); | 41 void RemoveAll(); |
42 | 42 |
43 // Drags the given panel. | 43 // Drags the given panel. |
44 void StartDragging(Panel* panel); | 44 void StartDragging(Panel* panel); |
45 void Drag(int delta_x); | 45 void Drag(int delta_x); |
46 void EndDragging(bool cancelled); | 46 void EndDragging(bool cancelled); |
47 | 47 |
| 48 // Invoked when the preferred window size of the given panel might need to |
| 49 // get changed. |
| 50 void OnPreferredWindowSizeChanged( |
| 51 Panel* panel, const gfx::Size& preferred_window_size); |
| 52 |
48 // Returns true if we should bring up the titlebars, given the current mouse | 53 // Returns true if we should bring up the titlebars, given the current mouse |
49 // point. | 54 // point. |
50 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 55 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
51 | 56 |
52 // Brings up or down the titlebars for all minimized panels. | 57 // Brings up or down the titlebars for all minimized panels. |
53 void BringUpOrDownTitlebars(bool bring_up); | 58 void BringUpOrDownTitlebars(bool bring_up); |
54 | 59 |
55 // Returns the bottom position for the panel per its expansion state. If auto- | 60 // Returns the bottom position for the panel per its expansion state. If auto- |
56 // hide bottom bar is present, we want to move the minimized panel to the | 61 // hide bottom bar is present, we want to move the minimized panel to the |
57 // bottom of the screen, not the bottom of the work area. | 62 // bottom of the screen, not the bottom of the work area. |
58 int GetBottomPositionForExpansionState( | 63 int GetBottomPositionForExpansionState( |
59 Panel::ExpansionState expansion_state) const; | 64 Panel::ExpansionState expansion_state) const; |
60 | 65 |
61 int num_panels() const { return panels_.size(); } | 66 int num_panels() const { return panels_.size(); } |
62 bool is_dragging_panel() const; | 67 bool is_dragging_panel() const; |
63 | 68 |
64 #ifdef UNIT_TEST | 69 #ifdef UNIT_TEST |
65 const Panels& panels() const { return panels_; } | 70 const Panels& panels() const { return panels_; } |
66 static int horizontal_spacing() { return kPanelsHorizontalSpacing; } | 71 static int horizontal_spacing() { return kPanelsHorizontalSpacing; } |
67 | 72 |
68 const gfx::Rect& work_area() const { | 73 const gfx::Rect& work_area() const { |
69 return work_area_; | 74 return work_area_; |
70 } | 75 } |
71 | 76 |
72 void set_auto_hiding_desktop_bar( | 77 void set_auto_hiding_desktop_bar( |
73 AutoHidingDesktopBar* auto_hiding_desktop_bar) { | 78 AutoHidingDesktopBar* auto_hiding_desktop_bar) { |
74 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; | 79 auto_hiding_desktop_bar_ = auto_hiding_desktop_bar; |
75 } | 80 } |
76 | 81 |
| 82 void enable_auto_sizing(bool enabled) { |
| 83 auto_sizing_enabled_ = enabled; |
| 84 } |
| 85 |
77 void SetWorkAreaForTesting(const gfx::Rect& work_area) { | 86 void SetWorkAreaForTesting(const gfx::Rect& work_area) { |
78 SetWorkArea(work_area); | 87 SetWorkArea(work_area); |
79 } | 88 } |
80 #endif | 89 #endif |
81 | 90 |
82 private: | 91 private: |
83 enum TitlebarAction { | 92 enum TitlebarAction { |
84 NO_ACTION, | 93 NO_ACTION, |
85 BRING_UP, | 94 BRING_UP, |
86 BRING_DOWN | 95 BRING_DOWN |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 void DragRight(); | 130 void DragRight(); |
122 | 131 |
123 // Checks if the titlebars have been brought up or down. If not, do not wait | 132 // Checks if the titlebars have been brought up or down. If not, do not wait |
124 // for the notifications to trigger it any more, and start to bring them up or | 133 // for the notifications to trigger it any more, and start to bring them up or |
125 // down immediately. | 134 // down immediately. |
126 void DelayedBringUpOrDownTitlebarsCheck(); | 135 void DelayedBringUpOrDownTitlebarsCheck(); |
127 | 136 |
128 // Does the real job of bringing up or down the titlebars. | 137 // Does the real job of bringing up or down the titlebars. |
129 void DoBringUpOrDownTitlebars(bool bring_up); | 138 void DoBringUpOrDownTitlebars(bool bring_up); |
130 | 139 |
| 140 int GetMaxPanelWidth() const; |
| 141 int GetMaxPanelHeight() const; |
131 int GetRightMostAvaialblePosition() const; | 142 int GetRightMostAvaialblePosition() const; |
132 | 143 |
| 144 // Updates the maximum size of each panel as the result of adding, removing, |
| 145 // or sizing panels. |
| 146 void UpdateMaxSizeForAllPanels(); |
| 147 |
133 Panels panels_; | 148 Panels panels_; |
134 | 149 |
135 // Stores the panels that are pending to remove. We want to delay the removal | 150 // Stores the panels that are pending to remove. We want to delay the removal |
136 // when we're in the process of the dragging. | 151 // when we're in the process of the dragging. |
137 Panels panels_pending_to_remove_; | 152 Panels panels_pending_to_remove_; |
138 | 153 |
139 // The maximum work area avaialble. This area does not include the area taken | 154 // The maximum work area avaialble. This area does not include the area taken |
140 // by the always-visible (non-auto-hiding) desktop bars. | 155 // by the always-visible (non-auto-hiding) desktop bars. |
141 gfx::Rect work_area_; | 156 gfx::Rect work_area_; |
142 | 157 |
(...skipping 14 matching lines...) Expand all Loading... |
157 // the dragging happens. Then it is updated to the position that will be set | 172 // the dragging happens. Then it is updated to the position that will be set |
158 // to when the dragging ends. | 173 // to when the dragging ends. |
159 gfx::Rect dragging_panel_bounds_; | 174 gfx::Rect dragging_panel_bounds_; |
160 | 175 |
161 scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_; | 176 scoped_refptr<AutoHidingDesktopBar> auto_hiding_desktop_bar_; |
162 | 177 |
163 TitlebarAction delayed_titlebar_action_; | 178 TitlebarAction delayed_titlebar_action_; |
164 | 179 |
165 ScopedRunnableMethodFactory<PanelManager> method_factory_; | 180 ScopedRunnableMethodFactory<PanelManager> method_factory_; |
166 | 181 |
| 182 // Whether or not bounds will be updated when the preferred content size is |
| 183 // changed. The testing code could set this flag to false so that other tests |
| 184 // will not be affected. |
| 185 bool auto_sizing_enabled_; |
| 186 |
167 static const int kPanelsHorizontalSpacing = 4; | 187 static const int kPanelsHorizontalSpacing = 4; |
168 | 188 |
169 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 189 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
170 }; | 190 }; |
171 | 191 |
172 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 192 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
OLD | NEW |