Chromium Code Reviews| 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 <deque> | 9 #include <deque> |
| 10 #include <vector> | 10 #include <vector> |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 14 | 14 |
| 15 class Browser; | 15 class Browser; |
| 16 class Panel; | 16 class Panel; |
| 17 | 17 |
| 18 // This class manages a set of panels. | 18 // This class manages a set of panels. |
| 19 class PanelManager { | 19 class PanelManager { |
| 20 public: | 20 public: |
| 21 // Returns a single instance. | 21 // Returns a single instance. |
| 22 static PanelManager* GetInstance(); | 22 static PanelManager* GetInstance(); |
| 23 | 23 |
| 24 ~PanelManager(); | 24 virtual ~PanelManager(); |
| 25 | |
| 26 // Removes the given panel. Both active and pending panel lists are checked. | |
| 27 // If an active panel is removed, pending panels could put on display if we | |
|
jennb
2011/06/27 23:18:02
Fix grammar in "pending planels could put on displ
jianli
2011/06/29 01:28:12
Could you suggest what need to change?
jennb
2011/06/29 21:10:09
..., pending panels will be displayed if space all
| |
| 28 // have spaces. | |
| 29 virtual void Remove(Panel* panel); | |
| 30 | |
| 31 // Minimizes the given panel to full extent, that is, we only show 3-pixel | |
| 32 // lines. | |
| 33 virtual void Minimize(Panel* panel); | |
| 34 | |
| 35 // Restores the given panel. If |titlebar_only| is true, we restore the panel | |
| 36 // to show the title bar only. Otherwise, we restore the panel fully. | |
| 37 virtual void Restore(Panel* panel, bool titlebar_only); | |
| 25 | 38 |
| 26 // Called when the display is changed, i.e. work area is updated. | 39 // Called when the display is changed, i.e. work area is updated. |
| 27 void OnDisplayChanged(); | 40 void OnDisplayChanged(); |
| 28 | 41 |
| 29 // Creates a panel and returns it. The panel might be queued for display | 42 // Creates a panel and returns it. The panel might be queued for display |
| 30 // later. | 43 // later. |
| 31 Panel* CreatePanel(Browser* browser); | 44 Panel* CreatePanel(Browser* browser); |
| 32 | 45 |
| 33 // Removes the given panel. Both active and pending panel lists are checked. | |
| 34 // If an active panel is removed, pending panels could put on display if we | |
| 35 // have spaces. | |
| 36 void Remove(Panel* panel); | |
| 37 | |
| 38 // Minimizes all panels. This only applies to active panels since only them | 46 // Minimizes all panels. This only applies to active panels since only them |
| 39 // are visible. | 47 // are visible. |
| 40 void MinimizeAll(); | 48 void MinimizeAll(); |
| 41 | 49 |
| 42 // Restores all panels. This only applies to active panels since only them | 50 // Restores all panels. This only applies to active panels since only them |
| 43 // are visible. | 51 // are visible. |
| 44 void RestoreAll(); | 52 void RestoreAll(); |
| 45 | 53 |
| 46 // Removes all active panels. Pending panels will be processed for display. | 54 // Removes all active panels. Pending panels will be processed for display. |
| 47 void RemoveAllActive(); | 55 void RemoveAllActive(); |
| 48 | 56 |
| 49 // Drags the given active panel. | 57 // Drags the given active panel. |
| 50 void StartDragging(Panel* panel); | 58 void StartDragging(Panel* panel); |
| 51 void Drag(int delta_x); | 59 void Drag(int delta_x); |
| 52 void EndDragging(bool cancelled); | 60 void EndDragging(bool cancelled); |
| 53 | 61 |
| 54 // Returns the number of active panels. | 62 // Returns the number of active panels. |
| 55 int active_count() const { return active_panels_.size(); } | 63 int active_count() const { return active_panels_.size(); } |
| 56 | 64 |
| 57 private: | 65 protected: |
|
dcheng
2011/06/24 08:13:18
I think the C++ guide prefers that data members be
jianli
2011/06/29 01:28:12
Not needed. Reverted.
| |
| 66 static PanelManager* Create(); | |
| 67 | |
| 58 typedef std::vector<Panel*> ActivePanels; | 68 typedef std::vector<Panel*> ActivePanels; |
| 59 typedef std::deque<Panel*> PendingPanels; | 69 typedef std::deque<Panel*> PendingPanels; |
| 60 | 70 |
| 61 PanelManager(); | 71 PanelManager(); |
| 62 | 72 |
| 63 // Handles all the panels that're delayed to be removed. | 73 // Handles all the panels that're delayed to be removed. |
| 64 void DelayedRemove(); | 74 void DelayedRemove(); |
| 65 | 75 |
| 66 // Does the remove. Called from Remove and DelayedRemove. | 76 // Does the remove. Called from Remove and DelayedRemove. |
| 67 void DoRemove(Panel* panel); | 77 void DoRemove(Panel* panel); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 | 119 |
| 110 // Original x coordinate of the panel to drag. This is used to get back to | 120 // Original x coordinate of the panel to drag. This is used to get back to |
| 111 // the original position when we cancel the dragging. | 121 // the original position when we cancel the dragging. |
| 112 int dragging_panel_original_x_; | 122 int dragging_panel_original_x_; |
| 113 | 123 |
| 114 // Bounds of the panel to drag. It is first set to the original bounds when | 124 // Bounds of the panel to drag. It is first set to the original bounds when |
| 115 // the dragging happens. Then it is updated to the position that will be set | 125 // the dragging happens. Then it is updated to the position that will be set |
| 116 // to when the dragging ends. | 126 // to when the dragging ends. |
| 117 gfx::Rect dragging_panel_bounds_; | 127 gfx::Rect dragging_panel_bounds_; |
| 118 | 128 |
| 129 private: | |
| 119 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 130 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
| 120 }; | 131 }; |
| 121 | 132 |
| 122 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 133 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| OLD | NEW |