| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_STACKED_PANEL_COLLECTION_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ | 6 #define CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "chrome/browser/ui/panels/panel_collection.h" | 11 #include "chrome/browser/ui/panels/panel_collection.h" |
| 12 #include "chrome/browser/ui/panels/panel_constants.h" |
| 12 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
| 13 | 14 |
| 15 class NativePanelStack; |
| 14 class PanelManager; | 16 class PanelManager; |
| 17 namespace gfx { |
| 18 class Vector2d; |
| 19 } |
| 15 | 20 |
| 16 class StackedPanelCollection : public PanelCollection { | 21 class StackedPanelCollection : public PanelCollection { |
| 17 public: | 22 public: |
| 18 typedef std::list<Panel*> Panels; | 23 typedef std::list<Panel*> Panels; |
| 19 | 24 |
| 20 explicit StackedPanelCollection(PanelManager* panel_manager); | 25 explicit StackedPanelCollection(PanelManager* panel_manager); |
| 21 virtual ~StackedPanelCollection(); | 26 virtual ~StackedPanelCollection(); |
| 22 | 27 |
| 23 // PanelCollection OVERRIDES: | 28 // PanelCollection OVERRIDES: |
| 24 virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE; | 29 virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; | 51 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; |
| 47 virtual void SavePanelPlacement(Panel* panel) OVERRIDE; | 52 virtual void SavePanelPlacement(Panel* panel) OVERRIDE; |
| 48 virtual void RestorePanelToSavedPlacement() OVERRIDE; | 53 virtual void RestorePanelToSavedPlacement() OVERRIDE; |
| 49 virtual void DiscardSavedPanelPlacement() OVERRIDE; | 54 virtual void DiscardSavedPanelPlacement() OVERRIDE; |
| 50 virtual void UpdatePanelOnCollectionChange(Panel* panel) OVERRIDE; | 55 virtual void UpdatePanelOnCollectionChange(Panel* panel) OVERRIDE; |
| 51 virtual void OnPanelActiveStateChanged(Panel* panel) OVERRIDE; | 56 virtual void OnPanelActiveStateChanged(Panel* panel) OVERRIDE; |
| 52 | 57 |
| 53 Panel* GetPanelAbove(Panel* panel) const; | 58 Panel* GetPanelAbove(Panel* panel) const; |
| 54 bool HasPanel(Panel* panel) const; | 59 bool HasPanel(Panel* panel) const; |
| 55 | 60 |
| 56 bool empty() const { return panels_.empty(); } | 61 void MoveAllDraggingPanelsInstantly(const gfx::Vector2d& delta_origin); |
| 62 |
| 63 NativePanelStack* native_stack() const { return native_stack_; } |
| 57 int num_panels() const { return panels_.size(); } | 64 int num_panels() const { return panels_.size(); } |
| 58 const Panels& panels() const { return panels_; } | 65 const Panels& panels() const { return panels_; } |
| 59 Panel* top_panel() const { return panels_.front(); } | 66 Panel* top_panel() const { return panels_.empty() ? NULL : panels_.front(); } |
| 60 Panel* bottom_panel() const { return panels_.back(); } | 67 Panel* bottom_panel() const { |
| 68 return panels_.empty() ? NULL : panels_.back(); |
| 69 } |
| 61 | 70 |
| 62 private: | 71 private: |
| 63 PanelManager* panel_manager_; // Weak, owns us. | 72 struct PanelPlacement { |
| 73 Panel* panel; |
| 74 gfx::Point position; |
| 75 // Used to remember the top panel, if different from |panel|, for use when |
| 76 // restoring it. When there're only 2 panels in the stack and the bottom |
| 77 // panel is being dragged out of the stack, both panels will be moved to |
| 78 // the detached collection. We need to track the top panel in order to |
| 79 // put it back to the same stack of the dragging panel. |
| 80 Panel* top_panel; |
| 81 |
| 82 PanelPlacement() : panel(NULL), top_panel(NULL) { } |
| 83 }; |
| 84 |
| 85 PanelManager* panel_manager_; |
| 86 |
| 87 NativePanelStack* native_stack_; // Weak, owns us. |
| 64 | 88 |
| 65 Panels panels_; // The top panel is in the front of the list. | 89 Panels panels_; // The top panel is in the front of the list. |
| 66 | 90 |
| 91 // Used to save the placement information for a panel. |
| 92 PanelPlacement saved_panel_placement_; |
| 93 |
| 67 DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection); | 94 DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection); |
| 68 }; | 95 }; |
| 69 | 96 |
| 70 #endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ | 97 #endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ |
| OLD | NEW |