| 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_DOCKED_PANEL_COLLECTION_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_COLLECTION_H_ |
| 6 #define CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_COLLECTION_H_ | 6 #define CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_COLLECTION_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <set> | 9 #include <set> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "chrome/browser/ui/panels/display_settings_provider.h" | 12 #include "chrome/browser/ui/panels/display_settings_provider.h" |
| 13 #include "chrome/browser/ui/panels/panel.h" | 13 #include "chrome/browser/ui/panels/panel.h" |
| 14 #include "chrome/browser/ui/panels/panel_collection.h" | 14 #include "chrome/browser/ui/panels/panel_collection.h" |
| 15 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" | 15 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 | 17 |
| 18 class PanelManager; | 18 class PanelManager; |
| 19 | 19 |
| 20 // This class manages a group of panels that could be docked to the bottom of | 20 // This class manages a group of panels that could be docked to the bottom of |
| 21 // screen. | 21 // screen. |
| 22 class DockedPanelCollection : | 22 class DockedPanelCollection : |
| 23 public PanelCollection, | 23 public PanelCollection, |
| 24 public PanelMouseWatcherObserver, | 24 public PanelMouseWatcherObserver, |
| 25 public DisplaySettingsProvider::DesktopBarObserver { | 25 public DisplaySettingsProvider::DesktopBarObserver { |
| 26 public: | 26 public: |
| 27 typedef std::list<Panel*> Panels; | 27 typedef std::list<Panel*> Panels; |
| 28 | 28 |
| 29 explicit DockedPanelCollection(PanelManager* panel_manager); | 29 explicit DockedPanelCollection(PanelManager* panel_manager); |
| 30 virtual ~DockedPanelCollection(); | 30 ~DockedPanelCollection() override; |
| 31 | 31 |
| 32 // PanelCollection OVERRIDES: | 32 // PanelCollection OVERRIDES: |
| 33 virtual void OnDisplayChanged() override; | 33 void OnDisplayChanged() override; |
| 34 | 34 |
| 35 // Rearranges the positions of the panels in the collection | 35 // Rearranges the positions of the panels in the collection |
| 36 // and reduces their width when there is not enough room. | 36 // and reduces their width when there is not enough room. |
| 37 // This is called when the display space has been changed, i.e. working | 37 // This is called when the display space has been changed, i.e. working |
| 38 // area being changed or a panel being closed. | 38 // area being changed or a panel being closed. |
| 39 virtual void RefreshLayout() override; | 39 void RefreshLayout() override; |
| 40 | 40 |
| 41 // Adds a panel to the collection. The panel may be a newly created panel or | 41 // Adds a panel to the collection. The panel may be a newly created panel or |
| 42 // one that is transitioning from another grouping of panels. | 42 // one that is transitioning from another grouping of panels. |
| 43 virtual void AddPanel(Panel* panel, | 43 void AddPanel(Panel* panel, PositioningMask positioning_mask) override; |
| 44 PositioningMask positioning_mask) override; | 44 void RemovePanel(Panel* pane, RemovalReason reasonl) override; |
| 45 virtual void RemovePanel(Panel* pane, RemovalReason reasonl) override; | 45 void CloseAll() override; |
| 46 virtual void CloseAll() override; | 46 void ResizePanelWindow(Panel* panel, |
| 47 virtual void ResizePanelWindow( | 47 const gfx::Size& preferred_window_size) override; |
| 48 Panel* panel, | 48 panel::Resizability GetPanelResizability(const Panel* panel) const override; |
| 49 const gfx::Size& preferred_window_size) override; | 49 void OnPanelResizedByMouse(Panel* panel, |
| 50 virtual panel::Resizability GetPanelResizability( | 50 const gfx::Rect& new_bounds) override; |
| 51 const Panel* panel) const override; | 51 void OnPanelAttentionStateChanged(Panel* panel) override; |
| 52 virtual void OnPanelResizedByMouse(Panel* panel, | 52 void OnPanelTitlebarClicked(Panel* panel, |
| 53 const gfx::Rect& new_bounds) override; | 53 panel::ClickModifier modifier) override; |
| 54 virtual void OnPanelAttentionStateChanged(Panel* panel) override; | 54 void ActivatePanel(Panel* panel) override; |
| 55 virtual void OnPanelTitlebarClicked(Panel* panel, | 55 void MinimizePanel(Panel* panel) override; |
| 56 panel::ClickModifier modifier) override; | 56 void RestorePanel(Panel* panel) override; |
| 57 virtual void ActivatePanel(Panel* panel) override; | 57 void OnMinimizeButtonClicked(Panel* panel, |
| 58 virtual void MinimizePanel(Panel* panel) override; | 58 panel::ClickModifier modifier) override; |
| 59 virtual void RestorePanel(Panel* panel) override; | 59 void OnRestoreButtonClicked(Panel* panel, |
| 60 virtual void OnMinimizeButtonClicked(Panel* panel, | 60 panel::ClickModifier modifier) override; |
| 61 panel::ClickModifier modifier) override; | 61 bool CanShowMinimizeButton(const Panel* panel) const override; |
| 62 virtual void OnRestoreButtonClicked(Panel* panel, | 62 bool CanShowRestoreButton(const Panel* panel) const override; |
| 63 panel::ClickModifier modifier) override; | 63 bool IsPanelMinimized(const Panel* panel) const override; |
| 64 virtual bool CanShowMinimizeButton(const Panel* panel) const override; | 64 bool UsesAlwaysOnTopPanels() const override; |
| 65 virtual bool CanShowRestoreButton(const Panel* panel) const override; | 65 void SavePanelPlacement(Panel* panel) override; |
| 66 virtual bool IsPanelMinimized(const Panel* panel) const override; | 66 void RestorePanelToSavedPlacement() override; |
| 67 virtual bool UsesAlwaysOnTopPanels() const override; | 67 void DiscardSavedPanelPlacement() override; |
| 68 virtual void SavePanelPlacement(Panel* panel) override; | 68 void UpdatePanelOnCollectionChange(Panel* panel) override; |
| 69 virtual void RestorePanelToSavedPlacement() override; | 69 void OnPanelExpansionStateChanged(Panel* panel) override; |
| 70 virtual void DiscardSavedPanelPlacement() override; | 70 void OnPanelActiveStateChanged(Panel* panel) override; |
| 71 virtual void UpdatePanelOnCollectionChange(Panel* panel) override; | 71 gfx::Rect GetInitialPanelBounds( |
| 72 virtual void OnPanelExpansionStateChanged(Panel* panel) override; | |
| 73 virtual void OnPanelActiveStateChanged(Panel* panel) override; | |
| 74 virtual gfx::Rect GetInitialPanelBounds( | |
| 75 const gfx::Rect& requested_bounds) const override; | 72 const gfx::Rect& requested_bounds) const override; |
| 76 | 73 |
| 77 // Returns true if we should bring up the titlebars, given the current mouse | 74 // Returns true if we should bring up the titlebars, given the current mouse |
| 78 // point. | 75 // point. |
| 79 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 76 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
| 80 | 77 |
| 81 // Brings up or down the titlebars for all minimized panels. | 78 // Brings up or down the titlebars for all minimized panels. |
| 82 void BringUpOrDownTitlebars(bool bring_up); | 79 void BringUpOrDownTitlebars(bool bring_up); |
| 83 | 80 |
| 84 // Returns the bottom position for the panel per its expansion state. If auto- | 81 // Returns the bottom position for the panel per its expansion state. If auto- |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 struct PanelPlacement { | 118 struct PanelPlacement { |
| 122 Panel* panel; | 119 Panel* panel; |
| 123 // Used to remember the panel to the left of |panel|, if any, for use when | 120 // Used to remember the panel to the left of |panel|, if any, for use when |
| 124 // restoring the position of |panel|. | 121 // restoring the position of |panel|. |
| 125 Panel* left_panel; | 122 Panel* left_panel; |
| 126 | 123 |
| 127 PanelPlacement() : panel(NULL), left_panel(NULL) { } | 124 PanelPlacement() : panel(NULL), left_panel(NULL) { } |
| 128 }; | 125 }; |
| 129 | 126 |
| 130 // Overridden from PanelMouseWatcherObserver: | 127 // Overridden from PanelMouseWatcherObserver: |
| 131 virtual void OnMouseMove(const gfx::Point& mouse_position) override; | 128 void OnMouseMove(const gfx::Point& mouse_position) override; |
| 132 | 129 |
| 133 // Overridden from DisplaySettingsProvider::DesktopBarObserver: | 130 // Overridden from DisplaySettingsProvider::DesktopBarObserver: |
| 134 virtual void OnAutoHidingDesktopBarVisibilityChanged( | 131 void OnAutoHidingDesktopBarVisibilityChanged( |
| 135 DisplaySettingsProvider::DesktopBarAlignment alignment, | 132 DisplaySettingsProvider::DesktopBarAlignment alignment, |
| 136 DisplaySettingsProvider::DesktopBarVisibility visibility) override; | 133 DisplaySettingsProvider::DesktopBarVisibility visibility) override; |
| 137 virtual void OnAutoHidingDesktopBarThicknessChanged( | 134 void OnAutoHidingDesktopBarThicknessChanged( |
| 138 DisplaySettingsProvider::DesktopBarAlignment alignment, | 135 DisplaySettingsProvider::DesktopBarAlignment alignment, |
| 139 int thickness) override; | 136 int thickness) override; |
| 140 | 137 |
| 141 // Schedules a layout refresh with a short delay to avoid too much flicker. | 138 // Schedules a layout refresh with a short delay to avoid too much flicker. |
| 142 void ScheduleLayoutRefresh(); | 139 void ScheduleLayoutRefresh(); |
| 143 | 140 |
| 144 // Keep track of the minimized panels to control mouse watching. | 141 // Keep track of the minimized panels to control mouse watching. |
| 145 void UpdateMinimizedPanelCount(); | 142 void UpdateMinimizedPanelCount(); |
| 146 | 143 |
| 147 // Minimizes or restores all panels in the collection. | 144 // Minimizes or restores all panels in the collection. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Owned by MessageLoop after posting. | 187 // Owned by MessageLoop after posting. |
| 191 base::WeakPtrFactory<DockedPanelCollection> titlebar_action_factory_; | 188 base::WeakPtrFactory<DockedPanelCollection> titlebar_action_factory_; |
| 192 | 189 |
| 193 // Owned by MessageLoop after posting. | 190 // Owned by MessageLoop after posting. |
| 194 base::WeakPtrFactory<DockedPanelCollection> refresh_action_factory_; | 191 base::WeakPtrFactory<DockedPanelCollection> refresh_action_factory_; |
| 195 | 192 |
| 196 DISALLOW_COPY_AND_ASSIGN(DockedPanelCollection); | 193 DISALLOW_COPY_AND_ASSIGN(DockedPanelCollection); |
| 197 }; | 194 }; |
| 198 | 195 |
| 199 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_COLLECTION_H_ | 196 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_COLLECTION_H_ |
| OLD | NEW |