OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_PANELS_DETACHED_PANEL_COLLECTION_H_ | |
6 #define CHROME_BROWSER_UI_PANELS_DETACHED_PANEL_COLLECTION_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/macros.h" | |
11 #include "chrome/browser/ui/panels/panel.h" | |
12 #include "chrome/browser/ui/panels/panel_collection.h" | |
13 #include "ui/gfx/geometry/point.h" | |
14 #include "ui/gfx/geometry/rect.h" | |
15 | |
16 class PanelManager; | |
17 | |
18 // This class manages a group of free-floating panels. | |
19 class DetachedPanelCollection : public PanelCollection { | |
20 public: | |
21 typedef std::list<Panel*> Panels; | |
22 typedef bool (*PanelsComparer)(Panel* panel1, Panel* panel2); | |
23 | |
24 explicit DetachedPanelCollection(PanelManager* panel_manager); | |
25 ~DetachedPanelCollection() override; | |
26 | |
27 // PanelCollection OVERRIDES: | |
28 void OnDisplayChanged() override; | |
29 void RefreshLayout() override; | |
30 void AddPanel(Panel* panel, PositioningMask positioning_mask) override; | |
31 void RemovePanel(Panel* panel, RemovalReason reason) override; | |
32 void CloseAll() override; | |
33 void ResizePanelWindow(Panel* panel, | |
34 const gfx::Size& preferred_window_size) override; | |
35 panel::Resizability GetPanelResizability(const Panel* panel) const override; | |
36 void OnPanelResizedByMouse(Panel* panel, | |
37 const gfx::Rect& new_bounds) override; | |
38 void OnPanelAttentionStateChanged(Panel* panel) override; | |
39 void OnPanelTitlebarClicked(Panel* panel, | |
40 panel::ClickModifier modifier) override; | |
41 void ActivatePanel(Panel* panel) override; | |
42 void MinimizePanel(Panel* panel) override; | |
43 void RestorePanel(Panel* panel) override; | |
44 void OnMinimizeButtonClicked(Panel* panel, | |
45 panel::ClickModifier modifier) override; | |
46 void OnRestoreButtonClicked(Panel* panel, | |
47 panel::ClickModifier modifier) override; | |
48 bool CanShowMinimizeButton(const Panel* panel) const override; | |
49 bool CanShowRestoreButton(const Panel* panel) const override; | |
50 bool IsPanelMinimized(const Panel* panel) const override; | |
51 bool UsesAlwaysOnTopPanels() const override; | |
52 void SavePanelPlacement(Panel* panel) override; | |
53 void RestorePanelToSavedPlacement() override; | |
54 void DiscardSavedPanelPlacement() override; | |
55 void UpdatePanelOnCollectionChange(Panel* panel) override; | |
56 void OnPanelExpansionStateChanged(Panel* panel) override; | |
57 void OnPanelActiveStateChanged(Panel* panel) override; | |
58 gfx::Rect GetInitialPanelBounds( | |
59 const gfx::Rect& requested_bounds) const override; | |
60 | |
61 bool HasPanel(Panel* panel) const; | |
62 | |
63 void SortPanels(PanelsComparer comparer); | |
64 | |
65 int num_panels() const { return panels_.size(); } | |
66 const Panels& panels() const { return panels_; } | |
67 | |
68 // Returns default top-left to use for a detached panel whose position is | |
69 // not specified during panel creation. | |
70 gfx::Point GetDefaultPanelOrigin(); | |
71 | |
72 private: | |
73 // Offset the default panel top-left position by kPanelTilePixels. Wrap | |
74 // around to initial position if position goes beyond display area. | |
75 void ComputeNextDefaultPanelOrigin(); | |
76 | |
77 struct PanelPlacement { | |
78 Panel* panel; | |
79 gfx::Point position; | |
80 | |
81 PanelPlacement() : panel(NULL) { } | |
82 }; | |
83 | |
84 PanelManager* panel_manager_; // Weak, owns us. | |
85 | |
86 // Collection of all panels. | |
87 Panels panels_; | |
88 | |
89 // Used to save the placement information for a panel. | |
90 PanelPlacement saved_panel_placement_; | |
91 | |
92 // Default top-left position to use for next detached panel if position is | |
93 // unspecified by panel creator. | |
94 gfx::Point default_panel_origin_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(DetachedPanelCollection); | |
97 }; | |
98 | |
99 #endif // CHROME_BROWSER_UI_PANELS_DETACHED_PANEL_COLLECTION_H_ | |
OLD | NEW |