Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: chrome/browser/ui/panels/panel_manager.h

Issue 7646003: Support auto-hide taskbar for panels on Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/task.h"
14 #include "chrome/browser/ui/panels/auto_hide_bottom_bar.h"
12 #include "chrome/browser/ui/panels/panel.h" 15 #include "chrome/browser/ui/panels/panel.h"
13 #include "ui/gfx/rect.h" 16 #include "ui/gfx/rect.h"
14 17
15 class Browser; 18 class Browser;
16 class Panel; 19 class Panel;
17 20
18 // This class manages a set of panels. 21 // This class manages a set of panels.
19 class PanelManager { 22 class PanelManager : public AutoHideBottomBar::Observer,
23 public base::RefCountedThreadSafe<PanelManager> {
Dmitry Titov 2011/08/22 22:35:53 Why the PanelManager is refcounted? it is a single
jianli 2011/08/22 23:28:10 Needed by PostTask. Added comment for it.
20 public: 24 public:
21 // Returns a single instance. 25 // Returns a single instance.
22 static PanelManager* GetInstance(); 26 static PanelManager* GetInstance();
23 27
24 ~PanelManager(); 28 ~PanelManager();
25 29
26 // Called when the display is changed, i.e. work area is updated. 30 // Called when the display is changed, i.e. work area is updated.
27 void OnDisplayChanged(); 31 void OnDisplayChanged();
28 32
29 // Creates a panel and returns it. The panel might be queued for display 33 // Creates a panel and returns it. The panel might be queued for display
30 // later. 34 // later.
31 Panel* CreatePanel(Browser* browser); 35 Panel* CreatePanel(Browser* browser);
32 36
33 void Remove(Panel* panel); 37 void Remove(Panel* panel);
34 void RemoveAll(); 38 void RemoveAll();
35 39
36 // Drags the given panel. 40 // Drags the given panel.
37 void StartDragging(Panel* panel); 41 void StartDragging(Panel* panel);
38 void Drag(int delta_x); 42 void Drag(int delta_x);
39 void EndDragging(bool cancelled); 43 void EndDragging(bool cancelled);
40 44
41 // Should we bring up the titlebar, given the current mouse point? 45 // Should we bring up the titlebar, given the current mouse point?
42 bool ShouldBringUpTitlebarForAllMinimizedPanels(int mouse_x, 46 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const;
43 int mouse_y) const;
44 47
45 // Brings up or down the title-bar for all minimized panels. 48 // Brings up or down the titlebars for all minimized panels.
46 void BringUpOrDownTitlebarForAllMinimizedPanels(bool bring_up); 49 void BringUpOrDownTitlebars(bool bring_up);
50
51 // Returns the bottom position for the panel per its expansion state. If auto-
52 // hide bottom bar is present, we want to move the minimized panel to the
53 // bottom of the screen, not the bottom of the work area.
54 int GetBottomPositionForExpansionState(
55 Panel::ExpansionState expansion_state) const;
47 56
48 int num_panels() const { return panels_.size(); } 57 int num_panels() const { return panels_.size(); }
49 bool is_dragging_panel() const; 58 bool is_dragging_panel() const;
50 59
51 private: 60 private:
52 friend class PanelBrowserTest; 61 friend class BasePanelBrowserTest;
62
63 enum DelayedTitlebarAction {
64 NO_ACTION,
65 BRING_UP,
66 BRING_DOWN
67 };
53 68
54 typedef std::vector<Panel*> Panels; 69 typedef std::vector<Panel*> Panels;
55 70
71 // For testing only.
72 static void CreateForTesting(const gfx::Rect& work_area,
73 AutoHideBottomBar* auto_hide_bottom_bar);
74
56 PanelManager(); 75 PanelManager();
76 void Init();
77
78 // Overridden from AutoHideBottomBar::Observer:
79 virtual void OnAutoHideBottomBarVisibilityChanged(
80 AutoHideBottomBar::Visibility visibility) OVERRIDE;
81 virtual void OnAutoHideBottomBarHeightChanged(int height) OVERRIDE;
57 82
58 // Applies the new work area. This is called by OnDisplayChanged and the test 83 // Applies the new work area. This is called by OnDisplayChanged and the test
59 // code. 84 // code.
60 void SetWorkArea(const gfx::Rect& work_area); 85 void SetWorkArea(const gfx::Rect& work_area);
61 86
62 // Handles all the panels that're delayed to be removed. 87 // Handles all the panels that're delayed to be removed.
63 void DelayedRemove(); 88 void DelayedRemove();
64 89
65 // Does the remove. Called from Remove and DelayedRemove. 90 // Does the remove. Called from Remove and DelayedRemove.
66 void DoRemove(Panel* panel); 91 void DoRemove(Panel* panel);
(...skipping 10 matching lines...) Expand all
77 bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change); 102 bool ComputeBoundsForNextPanel(gfx::Rect* bounds, bool allow_size_change);
78 103
79 // Finds one panel to close so that we may have space for the new panel 104 // Finds one panel to close so that we may have space for the new panel
80 // created by |extension|. 105 // created by |extension|.
81 void FindAndClosePanelOnOverflow(const Extension* extension); 106 void FindAndClosePanelOnOverflow(const Extension* extension);
82 107
83 // Help functions to drag the given panel. 108 // Help functions to drag the given panel.
84 void DragLeft(); 109 void DragLeft();
85 void DragRight(); 110 void DragRight();
86 111
112 void DelayedBringUpOrDownTitlebarsCheck();
113 void DoBringUpOrDownTitlebars(bool bring_up);
114
87 Panels panels_; 115 Panels panels_;
88 116
89 // Stores the panels that are pending to remove. We want to delay the removal 117 // Stores the panels that are pending to remove. We want to delay the removal
90 // when we're in the process of the dragging. 118 // when we're in the process of the dragging.
91 Panels panels_pending_to_remove_; 119 Panels panels_pending_to_remove_;
92 120
93 // Current work area used in computing the panel bounds. 121 // Current work area used in computing the panel bounds.
122 // If the always-on-top bottom bar, like Windows taskbar or MacOSX dock, is
123 // always visible, it should not be included in the work area. Otherwise, the
124 // work area includes the potential area that would be taken by the bottom
125 // bar when it becomes visible.
94 gfx::Rect work_area_; 126 gfx::Rect work_area_;
95 127
96 // Used in computing the bounds of the next panel. 128 // Used in computing the bounds of the next panel.
97 int max_width_; 129 int max_width_;
98 int max_height_; 130 int max_height_;
99 int min_x_;
100 int current_x_; 131 int current_x_;
101 int bottom_edge_y_;
102 132
103 // Panel to drag. 133 // Panel to drag.
104 size_t dragging_panel_index_; 134 size_t dragging_panel_index_;
105 135
106 // Original x coordinate of the panel to drag. This is used to get back to 136 // Original x coordinate of the panel to drag. This is used to get back to
107 // the original position when we cancel the dragging. 137 // the original position when we cancel the dragging.
108 int dragging_panel_original_x_; 138 int dragging_panel_original_x_;
109 139
110 // Bounds of the panel to drag. It is first set to the original bounds when 140 // Bounds of the panel to drag. It is first set to the original bounds when
111 // the dragging happens. Then it is updated to the position that will be set 141 // the dragging happens. Then it is updated to the position that will be set
112 // to when the dragging ends. 142 // to when the dragging ends.
113 gfx::Rect dragging_panel_bounds_; 143 gfx::Rect dragging_panel_bounds_;
114 144
145 scoped_refptr<AutoHideBottomBar> auto_hide_bottom_bar_;
146
147 DelayedTitlebarAction delayed_titlebar_action_;
148
149 ScopedRunnableMethodFactory<PanelManager> method_factory_;
150
115 DISALLOW_COPY_AND_ASSIGN(PanelManager); 151 DISALLOW_COPY_AND_ASSIGN(PanelManager);
116 }; 152 };
117 153
118 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_ 154 #endif // CHROME_BROWSER_UI_PANELS_PANEL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698