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 <list> | 9 #include <list> |
10 #include <set> | 10 #include <set> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 virtual void AddPanel(Panel* panel) OVERRIDE; | 46 virtual void AddPanel(Panel* panel) OVERRIDE; |
47 virtual bool RemovePanel(Panel* panel) OVERRIDE; | 47 virtual bool RemovePanel(Panel* panel) OVERRIDE; |
48 virtual void CloseAll() OVERRIDE; | 48 virtual void CloseAll() OVERRIDE; |
49 virtual void ResizePanelWindow( | 49 virtual void ResizePanelWindow( |
50 Panel* panel, | 50 Panel* panel, |
51 const gfx::Size& preferred_window_size) OVERRIDE; | 51 const gfx::Size& preferred_window_size) OVERRIDE; |
52 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; | 52 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; |
53 virtual void ActivatePanel(Panel* panel) OVERRIDE; | 53 virtual void ActivatePanel(Panel* panel) OVERRIDE; |
54 virtual void MinimizePanel(Panel* panel) OVERRIDE; | 54 virtual void MinimizePanel(Panel* panel) OVERRIDE; |
55 virtual void RestorePanel(Panel* panel) OVERRIDE; | 55 virtual void RestorePanel(Panel* panel) OVERRIDE; |
56 | 56 virtual bool CanDragPanel(Panel* panel) const OVERRIDE; |
57 // Drags the given panel. | 57 virtual void StartDraggingPanel(Panel* panel) OVERRIDE; |
58 void StartDragging(Panel* panel); | 58 virtual void DragPanel(int delta_x, int delta_y) OVERRIDE; |
59 void Drag(int delta_x); | 59 virtual void EndDraggingPanel(bool cancelled) OVERRIDE; |
60 void EndDragging(bool cancelled); | |
61 | 60 |
62 // Invoked when a panel's expansion state changes. | 61 // Invoked when a panel's expansion state changes. |
63 void OnPanelExpansionStateChanged(Panel* panel); | 62 void OnPanelExpansionStateChanged(Panel* panel); |
64 | 63 |
65 // Returns true if we should bring up the titlebars, given the current mouse | 64 // Returns true if we should bring up the titlebars, given the current mouse |
66 // point. | 65 // point. |
67 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; | 66 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; |
68 | 67 |
69 // Brings up or down the titlebars for all minimized panels. | 68 // Brings up or down the titlebars for all minimized panels. |
70 void BringUpOrDownTitlebars(bool bring_up); | 69 void BringUpOrDownTitlebars(bool bring_up); |
71 | 70 |
72 // Returns the bottom position for the panel per its expansion state. If auto- | 71 // Returns the bottom position for the panel per its expansion state. If auto- |
73 // hide bottom bar is present, we want to move the minimized panel to the | 72 // hide bottom bar is present, we want to move the minimized panel to the |
74 // bottom of the screen, not the bottom of the work area. | 73 // bottom of the screen, not the bottom of the work area. |
75 int GetBottomPositionForExpansionState( | 74 int GetBottomPositionForExpansionState( |
76 Panel::ExpansionState expansion_state) const; | 75 Panel::ExpansionState expansion_state) const; |
77 | 76 |
78 // num_panels() and panels() only includes panels in the panel strip that | 77 // num_panels() and panels() only includes panels in the panel strip that |
79 // do NOT have a temporary layout. | 78 // do NOT have a temporary layout. |
80 int num_panels() const { return panels_.size(); } | 79 int num_panels() const { return panels_.size(); } |
81 const Panels& panels() const { return panels_; } | 80 const Panels& panels() const { return panels_; } |
82 | 81 |
83 bool is_dragging_panel() const; | |
84 gfx::Rect display_area() const { return display_area_; } | 82 gfx::Rect display_area() const { return display_area_; } |
85 | 83 |
86 int GetMaxPanelWidth() const; | 84 int GetMaxPanelWidth() const; |
87 int GetMaxPanelHeight() const; | 85 int GetMaxPanelHeight() const; |
88 int StartingRightPosition() const; | 86 int StartingRightPosition() const; |
89 | 87 |
90 void OnAutoHidingDesktopBarVisibilityChanged( | 88 void OnAutoHidingDesktopBarVisibilityChanged( |
91 AutoHidingDesktopBar::Alignment alignment, | 89 AutoHidingDesktopBar::Alignment alignment, |
92 AutoHidingDesktopBar::Visibility visibility); | 90 AutoHidingDesktopBar::Visibility visibility); |
93 | 91 |
(...skipping 12 matching lines...) Expand all Loading... |
106 BRING_DOWN | 104 BRING_DOWN |
107 }; | 105 }; |
108 | 106 |
109 // Overridden from PanelMouseWatcherObserver: | 107 // Overridden from PanelMouseWatcherObserver: |
110 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; | 108 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; |
111 | 109 |
112 // Keep track of the minimized panels to control mouse watching. | 110 // Keep track of the minimized panels to control mouse watching. |
113 void IncrementMinimizedPanels(); | 111 void IncrementMinimizedPanels(); |
114 void DecrementMinimizedPanels(); | 112 void DecrementMinimizedPanels(); |
115 | 113 |
116 // Handles all the panels that're delayed to be removed. | |
117 void DelayedRemove(); | |
118 | |
119 // Does the actual remove. Caller is responsible for rearranging | |
120 // the panel strip if necessary. | |
121 // Returns |false| if panel is not in the strip. | |
122 bool DoRemove(Panel* panel); | |
123 | |
124 // Help functions to drag the given panel. | 114 // Help functions to drag the given panel. |
125 void DragLeft(); | 115 void DragLeft(Panel* dragging_panel); |
126 void DragRight(); | 116 void DragRight(Panel* dragging_panel); |
127 | 117 |
128 // Does the real job of bringing up or down the titlebars. | 118 // Does the real job of bringing up or down the titlebars. |
129 void DoBringUpOrDownTitlebars(bool bring_up); | 119 void DoBringUpOrDownTitlebars(bool bring_up); |
130 // The callback for a delyed task, checks if it still need to perform | 120 // The callback for a delyed task, checks if it still need to perform |
131 // the delayed action. | 121 // the delayed action. |
132 void DelayedBringUpOrDownTitlebarsCheck(); | 122 void DelayedBringUpOrDownTitlebarsCheck(); |
133 | 123 |
134 int GetRightMostAvailablePosition() const; | 124 int GetRightMostAvailablePosition() const; |
135 | 125 |
136 // Called by AddPanel() after a delay to move a newly created panel from | 126 // Called by AddPanel() after a delay to move a newly created panel from |
137 // the panel strip to overflow because the panel could not fit | 127 // the panel strip to overflow because the panel could not fit |
138 // within the bounds of the panel strip. New panels are first displayed | 128 // within the bounds of the panel strip. New panels are first displayed |
139 // in the panel strip, then moved to overflow so that all created | 129 // in the panel strip, then moved to overflow so that all created |
140 // panels are (at least briefly) visible before entering overflow. | 130 // panels are (at least briefly) visible before entering overflow. |
141 void DelayedMovePanelToOverflow(Panel* panel); | 131 void DelayedMovePanelToOverflow(Panel* panel); |
142 | 132 |
143 PanelManager* panel_manager_; // Weak, owns us. | 133 PanelManager* panel_manager_; // Weak, owns us. |
144 | 134 |
145 // All panels in the panel strip must fit within this area. | 135 // All panels in the panel strip must fit within this area. |
146 gfx::Rect display_area_; | 136 gfx::Rect display_area_; |
147 | 137 |
148 Panels panels_; | 138 Panels panels_; |
149 | 139 |
150 // Stores the panels that are pending to remove. We want to delay the removal | |
151 // when we're in the process of the dragging. | |
152 std::vector<Panel*> panels_pending_to_remove_; | |
153 | |
154 // Stores newly created panels that have a temporary layout until they | 140 // Stores newly created panels that have a temporary layout until they |
155 // are moved to overflow after a delay. | 141 // are moved to overflow after a delay. |
156 std::set<Panel*> panels_in_temporary_layout_; | 142 std::set<Panel*> panels_in_temporary_layout_; |
157 | 143 |
158 int minimized_panel_count_; | 144 int minimized_panel_count_; |
159 bool are_titlebars_up_; | 145 bool are_titlebars_up_; |
160 | 146 |
161 // |True| to temporarily prevent refreshing panel layout, e.g. while | 147 // |True| to temporarily prevent refreshing panel layout, e.g. while |
162 // moving panels to overflow area to make room for a panel in this strip. | 148 // moving panels to overflow area to make room for a panel in this strip. |
163 bool disable_layout_refresh_; | 149 bool disable_layout_refresh_; |
164 | 150 |
165 // Panel to drag. | 151 // Iterator of panel being dragged. |
166 Panel* dragging_panel_; | |
167 Panels::iterator dragging_panel_iterator_; | 152 Panels::iterator dragging_panel_iterator_; |
168 | 153 |
169 // Original x coordinate of the panel to drag. This is used to get back to | 154 // Original x coordinate of the panel to drag. This is used to get back to |
170 // the original position when we cancel the dragging. | 155 // the original position when we cancel the dragging. |
171 int dragging_panel_original_x_; | 156 int dragging_panel_original_x_; |
172 | 157 |
173 // Bounds of the panel to drag. It is first set to the original bounds when | 158 // Bounds of the panel to drag. It is first set to the original bounds when |
174 // the dragging happens. Then it is updated to the position that will be set | 159 // the dragging happens. Then it is updated to the position that will be set |
175 // to when the dragging ends. | 160 // to when the dragging ends. |
176 gfx::Rect dragging_panel_bounds_; | 161 gfx::Rect dragging_panel_bounds_; |
(...skipping 10 matching lines...) Expand all Loading... |
187 // Absolute minimum width and height for panels, including non-client area. | 172 // Absolute minimum width and height for panels, including non-client area. |
188 // Should only be big enough to accomodate a close button on the reasonably | 173 // Should only be big enough to accomodate a close button on the reasonably |
189 // recognisable titlebar. | 174 // recognisable titlebar. |
190 static const int kPanelMinWidth; | 175 static const int kPanelMinWidth; |
191 static const int kPanelMinHeight; | 176 static const int kPanelMinHeight; |
192 | 177 |
193 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); | 178 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); |
194 }; | 179 }; |
195 | 180 |
196 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ | 181 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
OLD | NEW |