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_STRIP_H_ | 5 #ifndef CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
6 #define CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ | 6 #define CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" | 13 #include "chrome/browser/ui/panels/auto_hiding_desktop_bar.h" |
14 #include "chrome/browser/ui/panels/panel.h" | 14 #include "chrome/browser/ui/panels/panel.h" |
| 15 #include "chrome/browser/ui/panels/panel_strip.h" |
15 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" | 16 #include "chrome/browser/ui/panels/panel_mouse_watcher_observer.h" |
16 #include "ui/gfx/rect.h" | 17 #include "ui/gfx/rect.h" |
17 | 18 |
18 class Browser; | 19 class Browser; |
19 class PanelManager; | 20 class PanelManager; |
20 | 21 |
21 // This class manages a group of panels displayed in a horizontal strip, | 22 // This class manages a group of panels displayed in a horizontal strip, |
22 // positioning the panels and controlling how they are displayed. | 23 // positioning the panels and controlling how they are displayed. |
23 // Panels in the strip appear minimized, showing title-only or expanded. | 24 // Panels in the strip appear minimized, showing title-only or expanded. |
24 // All panels in the strip are contained within the bounds of the strip. | 25 // All panels in the strip are contained within the bounds of the strip. |
25 class DockedPanelStrip : public PanelMouseWatcherObserver { | 26 class DockedPanelStrip : public PanelStrip, |
| 27 public PanelMouseWatcherObserver { |
26 public: | 28 public: |
27 typedef std::vector<Panel*> Panels; | 29 typedef std::vector<Panel*> Panels; |
28 | 30 |
29 explicit DockedPanelStrip(PanelManager* panel_manager); | 31 explicit DockedPanelStrip(PanelManager* panel_manager); |
30 virtual ~DockedPanelStrip(); | 32 virtual ~DockedPanelStrip(); |
31 | 33 |
32 // Sets the bounds of the panel strip. | 34 // PanelStrip OVERRIDES: |
33 // |area| is in screen coordinates. | 35 virtual void SetDisplayArea(const gfx::Rect& display_area) OVERRIDE; |
34 void SetDisplayArea(const gfx::Rect& area); | 36 |
| 37 // Rearranges the positions of the panels in the strip. |
| 38 // Handles moving panels to/from overflow area as needed. |
| 39 // This is called when the display space has been changed, i.e. working |
| 40 // area being changed or a panel being closed. |
| 41 virtual void RefreshLayout() OVERRIDE; |
35 | 42 |
36 // Adds a panel to the strip. The panel may be a newly created panel or one | 43 // Adds a panel to the strip. The panel may be a newly created panel or one |
37 // that is transitioning from another grouping of panels. | 44 // that is transitioning from another grouping of panels. |
38 void AddPanel(Panel* panel); | 45 virtual void AddPanel(Panel* panel) OVERRIDE; |
39 | 46 |
40 // Returns |false| if the panel is not in the strip. | 47 // Returns |false| if the panel is not in the strip. |
41 bool Remove(Panel* panel); | 48 virtual bool RemovePanel(Panel* panel) OVERRIDE; |
42 void RemoveAll(); | 49 virtual void CloseAll() OVERRIDE; |
| 50 |
| 51 // Invoked when the window size of the given panel needs to be changed. |
| 52 virtual void ResizePanelWindow( |
| 53 Panel* panel, |
| 54 const gfx::Size& preferred_window_size) OVERRIDE; |
| 55 |
| 56 // Invoked when a panel's attention state changes. |
| 57 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; |
43 | 58 |
44 // Drags the given panel. | 59 // Drags the given panel. |
45 void StartDragging(Panel* panel); | 60 void StartDragging(Panel* panel); |
46 void Drag(int delta_x); | 61 void Drag(int delta_x); |
47 void EndDragging(bool cancelled); | 62 void EndDragging(bool cancelled); |
48 | 63 |
49 // Invoked when a panel's expansion state changes. | 64 // Invoked when a panel's expansion state changes. |
50 void OnPanelExpansionStateChanged(Panel* panel); | 65 void OnPanelExpansionStateChanged(Panel* panel); |
51 | 66 |
52 // Invoked when a panel's attention state changes. | |
53 void OnPanelAttentionStateChanged(Panel* panel); | |
54 | |
55 // Invoked when the window size of the given panel is changed. | |
56 void OnWindowSizeChanged( | |
57 Panel* panel, const gfx::Size& preferred_window_size); | |
58 | |
59 // Returns true if we should bring up the titlebars, given the current mouse | 67 // Returns true if we should bring up the titlebars, given the current mouse |
60 // point. | 68 // point. |
61 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 69 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
62 | 70 |
63 // Brings up or down the titlebars for all minimized panels. | 71 // Brings up or down the titlebars for all minimized panels. |
64 void BringUpOrDownTitlebars(bool bring_up); | 72 void BringUpOrDownTitlebars(bool bring_up); |
65 | 73 |
66 // Returns the bottom position for the panel per its expansion state. If auto- | 74 // Returns the bottom position for the panel per its expansion state. If auto- |
67 // hide bottom bar is present, we want to move the minimized panel to the | 75 // hide bottom bar is present, we want to move the minimized panel to the |
68 // bottom of the screen, not the bottom of the work area. | 76 // bottom of the screen, not the bottom of the work area. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void DecrementMinimizedPanels(); | 116 void DecrementMinimizedPanels(); |
109 | 117 |
110 // Handles all the panels that're delayed to be removed. | 118 // Handles all the panels that're delayed to be removed. |
111 void DelayedRemove(); | 119 void DelayedRemove(); |
112 | 120 |
113 // Does the actual remove. Caller is responsible for rearranging | 121 // Does the actual remove. Caller is responsible for rearranging |
114 // the panel strip if necessary. | 122 // the panel strip if necessary. |
115 // Returns |false| if panel is not in the strip. | 123 // Returns |false| if panel is not in the strip. |
116 bool DoRemove(Panel* panel); | 124 bool DoRemove(Panel* panel); |
117 | 125 |
118 // Rearranges the positions of the panels in the strip. | |
119 // Handles moving panels to/from overflow area as needed. | |
120 // This is called when the display space has been changed, i.e. working | |
121 // area being changed or a panel being closed. | |
122 void Rearrange(); | |
123 | |
124 // Help functions to drag the given panel. | 126 // Help functions to drag the given panel. |
125 void DragLeft(); | 127 void DragLeft(); |
126 void DragRight(); | 128 void DragRight(); |
127 | 129 |
128 // Does the real job of bringing up or down the titlebars. | 130 // Does the real job of bringing up or down the titlebars. |
129 void DoBringUpOrDownTitlebars(bool bring_up); | 131 void DoBringUpOrDownTitlebars(bool bring_up); |
130 // The callback for a delyed task, checks if it still need to perform | 132 // The callback for a delyed task, checks if it still need to perform |
131 // the delayed action. | 133 // the delayed action. |
132 void DelayedBringUpOrDownTitlebarsCheck(); | 134 void DelayedBringUpOrDownTitlebarsCheck(); |
133 | 135 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // Absolute minimum width and height for panels, including non-client area. | 184 // Absolute minimum width and height for panels, including non-client area. |
183 // Should only be big enough to accomodate a close button on the reasonably | 185 // Should only be big enough to accomodate a close button on the reasonably |
184 // recognisable titlebar. | 186 // recognisable titlebar. |
185 static const int kPanelMinWidth; | 187 static const int kPanelMinWidth; |
186 static const int kPanelMinHeight; | 188 static const int kPanelMinHeight; |
187 | 189 |
188 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); | 190 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); |
189 }; | 191 }; |
190 | 192 |
191 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ | 193 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
OLD | NEW |