| 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" |
| 11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/timer.h" | 13 #include "base/timer.h" |
| 14 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" | 14 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" |
| 15 #include "chrome/browser/ui/panels/panel.h" | 15 #include "chrome/browser/ui/panels/panel.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 | 17 |
| 18 // TODO(jennb): Clean up by removing functions below that cause this | 18 // TODO(jennb): Clean up by removing functions below that cause this |
| 19 // to be required. | 19 // to be required. |
| 20 #ifdef UNIT_TEST | 20 #ifdef UNIT_TEST |
| 21 #include "chrome/browser/ui/panels/panel_strip.h" | 21 #include "chrome/browser/ui/panels/panel_strip.h" |
| 22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" | 22 #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 class Browser; | 25 class Browser; |
| 26 class PanelMouseWatcher; | 26 class PanelMouseWatcher; |
| 27 class PanelOverflowStrip; |
| 27 class PanelStrip; | 28 class PanelStrip; |
| 28 | 29 |
| 29 // This class manages a set of panels. | 30 // This class manages a set of panels. |
| 30 class PanelManager : public AutoHidingDesktopBar::Observer { | 31 class PanelManager : public AutoHidingDesktopBar::Observer { |
| 31 public: | 32 public: |
| 32 typedef std::vector<Panel*> Panels; | 33 typedef std::vector<Panel*> Panels; |
| 33 | 34 |
| 34 // Returns a single instance. | 35 // Returns a single instance. |
| 35 static PanelManager* GetInstance(); | 36 static PanelManager* GetInstance(); |
| 36 | 37 |
| 37 // Called when the display is changed, i.e. work area is updated. | 38 // Called when the display is changed, i.e. work area is updated. |
| 38 void OnDisplayChanged(); | 39 void OnDisplayChanged(); |
| 39 | 40 |
| 40 // Creates a panel and returns it. The panel might be queued for display | 41 // Creates a panel and returns it. The panel might be queued for display |
| 41 // later. | 42 // later. |
| 42 Panel* CreatePanel(Browser* browser); | 43 Panel* CreatePanel(Browser* browser); |
| 43 | 44 |
| 44 void Remove(Panel* panel); | 45 void Remove(Panel* panel); |
| 45 void RemoveAll(); | 46 void RemoveAll(); |
| 46 | 47 |
| 47 // Asynchronous confirmation of panel having been removed. | 48 // Asynchronous confirmation of panel having been removed. |
| 48 void OnPanelRemoved(Panel* panel); | 49 void OnPanelRemoved(Panel* panel); |
| 49 | 50 |
| 50 // Drags the given panel. | 51 // Drags the given panel. |
| 51 void StartDragging(Panel* panel); | 52 void StartDragging(Panel* panel); |
| 52 void Drag(int delta_x); | 53 void Drag(int delta_x); |
| 53 void EndDragging(bool cancelled); | 54 void EndDragging(bool cancelled); |
| 54 | 55 |
| 55 // Invoked when a panel's expansion state changes. | 56 // Invoked when a panel's expansion state changes. |
| 56 void OnPanelExpansionStateChanged(Panel::ExpansionState old_state, | 57 void OnPanelExpansionStateChanged(Panel* panel, |
| 57 Panel::ExpansionState new_state); | 58 Panel::ExpansionState old_state); |
| 58 | 59 |
| 59 // Invoked when the preferred window size of the given panel might need to | 60 // Invoked when the preferred window size of the given panel might need to |
| 60 // get changed. | 61 // get changed. |
| 61 void OnPreferredWindowSizeChanged( | 62 void OnPreferredWindowSizeChanged( |
| 62 Panel* panel, const gfx::Size& preferred_window_size); | 63 Panel* panel, const gfx::Size& preferred_window_size); |
| 63 | 64 |
| 64 // Returns true if we should bring up the titlebars, given the current mouse | 65 // Returns true if we should bring up the titlebars, given the current mouse |
| 65 // point. | 66 // point. |
| 66 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 67 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
| 67 | 68 |
| 68 // Brings up or down the titlebars for all minimized panels. | 69 // Brings up or down the titlebars for all minimized panels. |
| 69 void BringUpOrDownTitlebars(bool bring_up); | 70 void BringUpOrDownTitlebars(bool bring_up); |
| 70 | 71 |
| 71 // Returns the bottom position for the panel per its expansion state. If auto- | |
| 72 // hide bottom bar is present, we want to move the minimized panel to the | |
| 73 // bottom of the screen, not the bottom of the work area. | |
| 74 int GetBottomPositionForExpansionState( | |
| 75 Panel::ExpansionState expansion_state) const; | |
| 76 | |
| 77 // Returns the next browser window which could be either panel window or | 72 // Returns the next browser window which could be either panel window or |
| 78 // tabbed window, to switch to if the given panel is going to be deactivated. | 73 // tabbed window, to switch to if the given panel is going to be deactivated. |
| 79 // Returns NULL if such window cannot be found. | 74 // Returns NULL if such window cannot be found. |
| 80 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; | 75 BrowserWindow* GetNextBrowserWindowToActivate(Panel* panel) const; |
| 81 | 76 |
| 82 int num_panels() const; | 77 int num_panels() const; |
| 83 bool is_dragging_panel() const; | 78 bool is_dragging_panel() const; |
| 84 int StartingRightPosition() const; | 79 int StartingRightPosition() const; |
| 85 const Panels& panels() const; | 80 const Panels& panels() const; |
| 86 | 81 |
| 87 // Moves a panel to the overflow strip. The panel does not currently | |
| 88 // belong in any other strip. | |
| 89 // |is_new| is true if the panel was just created. | |
| 90 void MoveToOverflowStrip(Panel* panel, bool is_new); | |
| 91 | |
| 92 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { | 82 AutoHidingDesktopBar* auto_hiding_desktop_bar() const { |
| 93 return auto_hiding_desktop_bar_; | 83 return auto_hiding_desktop_bar_; |
| 94 } | 84 } |
| 95 | 85 |
| 96 PanelMouseWatcher* mouse_watcher() const { | 86 PanelMouseWatcher* mouse_watcher() const { |
| 97 return panel_mouse_watcher_.get(); | 87 return panel_mouse_watcher_.get(); |
| 98 } | 88 } |
| 99 | 89 |
| 100 PanelStrip* panel_strip() const { | 90 PanelStrip* panel_strip() const { |
| 101 return panel_strip_.get(); | 91 return panel_strip_.get(); |
| 102 } | 92 } |
| 103 | 93 |
| 104 bool is_full_screen() const { return is_full_screen_; } | 94 bool is_full_screen() const { return is_full_screen_; } |
| 95 PanelOverflowStrip* panel_overflow_strip() const { |
| 96 return panel_overflow_strip_.get(); |
| 97 } |
| 105 | 98 |
| 106 #ifdef UNIT_TEST | 99 #ifdef UNIT_TEST |
| 107 static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } | 100 static int horizontal_spacing() { return PanelStrip::horizontal_spacing(); } |
| 108 | 101 |
| 109 const gfx::Rect& work_area() const { | 102 const gfx::Rect& work_area() const { |
| 110 return work_area_; | 103 return work_area_; |
| 111 } | 104 } |
| 112 | 105 |
| 113 void set_auto_hiding_desktop_bar( | 106 void set_auto_hiding_desktop_bar( |
| 114 AutoHidingDesktopBar* auto_hiding_desktop_bar) { | 107 AutoHidingDesktopBar* auto_hiding_desktop_bar) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. | 148 // Adjusts the work area to exclude the influence of auto-hiding desktop bars. |
| 156 void AdjustWorkAreaForAutoHidingDesktopBars(); | 149 void AdjustWorkAreaForAutoHidingDesktopBars(); |
| 157 | 150 |
| 158 // Positions the various groupings of panels. | 151 // Positions the various groupings of panels. |
| 159 void Layout(); | 152 void Layout(); |
| 160 | 153 |
| 161 // Tests if the current active app is in full screen mode. | 154 // Tests if the current active app is in full screen mode. |
| 162 void CheckFullScreenMode(); | 155 void CheckFullScreenMode(); |
| 163 | 156 |
| 164 scoped_ptr<PanelStrip> panel_strip_; | 157 scoped_ptr<PanelStrip> panel_strip_; |
| 158 scoped_ptr<PanelOverflowStrip> panel_overflow_strip_; |
| 165 | 159 |
| 166 // Use a mouse watcher to know when to bring up titlebars to "peek" at | 160 // Use a mouse watcher to know when to bring up titlebars to "peek" at |
| 167 // minimized panels. Mouse movement is only tracked when there is a minimized | 161 // minimized panels. Mouse movement is only tracked when there is a minimized |
| 168 // panel. | 162 // panel. |
| 169 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; | 163 scoped_ptr<PanelMouseWatcher> panel_mouse_watcher_; |
| 170 | 164 |
| 171 // The maximum work area avaialble. This area does not include the area taken | 165 // The maximum work area avaialble. This area does not include the area taken |
| 172 // by the always-visible (non-auto-hiding) desktop bars. | 166 // by the always-visible (non-auto-hiding) desktop bars. |
| 173 gfx::Rect work_area_; | 167 gfx::Rect work_area_; |
| 174 | 168 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 188 // Timer used to track if the current active app is in full screen mode. | 182 // Timer used to track if the current active app is in full screen mode. |
| 189 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; | 183 base::RepeatingTimer<PanelManager> full_screen_mode_timer_; |
| 190 | 184 |
| 191 // True if current active app is in full screen mode. | 185 // True if current active app is in full screen mode. |
| 192 bool is_full_screen_; | 186 bool is_full_screen_; |
| 193 | 187 |
| 194 DISALLOW_COPY_AND_ASSIGN(PanelManager); | 188 DISALLOW_COPY_AND_ASSIGN(PanelManager); |
| 195 }; | 189 }; |
| 196 | 190 |
| 197 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ | 191 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ |
| OLD | NEW |