Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_manager.h |
| =================================================================== |
| --- chrome/browser/ui/panels/panel_manager.h (revision 97852) |
| +++ chrome/browser/ui/panels/panel_manager.h (working copy) |
| @@ -8,7 +8,10 @@ |
| #include <vector> |
| #include "base/basictypes.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/task.h" |
| +#include "chrome/browser/ui/panels/auto_hide_bottom_bar.h" |
| #include "chrome/browser/ui/panels/panel.h" |
| #include "ui/gfx/rect.h" |
| @@ -16,12 +19,14 @@ |
| class Panel; |
| // This class manages a set of panels. |
| -class PanelManager { |
| +// Note that the ref count is needed by using PostTask in the implementation. |
| +class PanelManager : public AutoHideBottomBar::Observer, |
| + public base::RefCountedThreadSafe<PanelManager> { |
| public: |
| // Returns a single instance. |
| static PanelManager* GetInstance(); |
| - ~PanelManager(); |
| + virtual ~PanelManager(); |
| // Called when the display is changed, i.e. work area is updated. |
| void OnDisplayChanged(); |
| @@ -39,22 +44,51 @@ |
| void EndDragging(bool cancelled); |
| // Should we bring up the titlebar, given the current mouse point? |
|
jennb
2011/08/23 20:28:34
Nit: Change comment to "Returns true if we should
jianli
2011/08/26 00:18:16
Done.
|
| - bool ShouldBringUpTitlebarForAllMinimizedPanels(int mouse_x, |
| - int mouse_y) const; |
| + bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
| - // Brings up or down the title-bar for all minimized panels. |
| - void BringUpOrDownTitlebarForAllMinimizedPanels(bool bring_up); |
| + // Brings up or down the titlebars for all minimized panels. |
| + void BringUpOrDownTitlebars(bool bring_up); |
| + // Returns the bottom position for the panel per its expansion state. If auto- |
| + // hide bottom bar is present, we want to move the minimized panel to the |
| + // bottom of the screen, not the bottom of the work area. |
| + int GetBottomPositionForExpansionState( |
| + Panel::ExpansionState expansion_state) const; |
| + |
| int num_panels() const { return panels_.size(); } |
| bool is_dragging_panel() const; |
| +#ifdef UNIT_TEST |
| + // Creates a PanelManager instance with the specified work area and bottom |
| + // bar handler, for the testing purpose. We cannot instantiate the default |
|
jennb
2011/08/23 20:28:34
nit: s/for the testing purpose/for testing purpose
jianli
2011/08/26 00:18:16
Done.
|
| + // PanelManager instance by calling PanelManager::GetInstance() in the test |
|
jennb
2011/08/23 20:28:34
Must the PanelManager instance be instantiated in
jianli
2011/08/26 00:18:16
Done.
|
| + // setup routine because the message loop needed by the default bottom bar |
| + // handler has not yet been initialized. |
| + static void CreateForTesting(const gfx::Rect& work_area, |
| + AutoHideBottomBar* auto_hide_bottom_bar) { |
| + CreateForTestingHelper(work_area, auto_hide_bottom_bar); |
| + } |
| +#endif |
| + |
| private: |
| - friend class PanelBrowserTest; |
| + enum DelayedTitlebarAction { |
|
jennb
2011/08/23 20:28:34
Drop 'Delay' prefix. How you use it later brings a
jianli
2011/08/26 00:18:16
Done.
|
| + NO_ACTION, |
| + BRING_UP, |
| + BRING_DOWN |
| + }; |
| typedef std::vector<Panel*> Panels; |
| PanelManager(); |
| + // This is only called from the default PanelManager creation logic. |
| + void Init(); |
| + |
| + // Overridden from AutoHideBottomBar::Observer: |
| + virtual void OnAutoHideBottomBarVisibilityChanged( |
| + AutoHideBottomBar::Visibility visibility) OVERRIDE; |
| + virtual void OnAutoHideBottomBarHeightChanged(int height) OVERRIDE; |
| + |
| // Applies the new work area. This is called by OnDisplayChanged and the test |
| // code. |
| void SetWorkArea(const gfx::Rect& work_area); |
| @@ -84,6 +118,13 @@ |
| void DragLeft(); |
| void DragRight(); |
| + void DelayedBringUpOrDownTitlebarsCheck(); |
|
jennb
2011/08/23 20:28:34
Comment? What is it checking?
jianli
2011/08/26 00:18:16
Done.
|
| + void DoBringUpOrDownTitlebars(bool bring_up); |
| + |
| + // For testing only. |
| + static void CreateForTestingHelper(const gfx::Rect& work_area, |
|
jennb
2011/08/23 20:28:34
Why is a helper needed?
jianli
2011/08/26 00:18:16
Removed. Not needed any more.
|
| + AutoHideBottomBar* auto_hide_bottom_bar); |
| + |
| Panels panels_; |
| // Stores the panels that are pending to remove. We want to delay the removal |
| @@ -91,14 +132,16 @@ |
| Panels panels_pending_to_remove_; |
| // Current work area used in computing the panel bounds. |
| + // If the always-on-top bottom bar, like Windows taskbar or MacOSX dock, is |
| + // always visible, it should not be included in the work area. Otherwise, the |
| + // work area includes the potential area that would be taken by the bottom |
| + // bar when it becomes visible. |
| gfx::Rect work_area_; |
| // Used in computing the bounds of the next panel. |
| int max_width_; |
| int max_height_; |
| - int min_x_; |
| int current_x_; |
| - int bottom_edge_y_; |
| // Panel to drag. |
| size_t dragging_panel_index_; |
| @@ -112,6 +155,12 @@ |
| // to when the dragging ends. |
| gfx::Rect dragging_panel_bounds_; |
| + scoped_refptr<AutoHideBottomBar> auto_hide_bottom_bar_; |
| + |
| + DelayedTitlebarAction delayed_titlebar_action_; |
| + |
| + ScopedRunnableMethodFactory<PanelManager> method_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(PanelManager); |
| }; |