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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 // Rearranges the positions of the panels in the strip. | 37 // Rearranges the positions of the panels in the strip. |
38 // Handles moving panels to/from overflow area as needed. | 38 // Handles moving panels to/from overflow area as needed. |
39 // This is called when the display space has been changed, i.e. working | 39 // This is called when the display space has been changed, i.e. working |
40 // area being changed or a panel being closed. | 40 // area being changed or a panel being closed. |
41 virtual void RefreshLayout() OVERRIDE; | 41 virtual void RefreshLayout() OVERRIDE; |
42 | 42 |
43 // 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 |
44 // that is transitioning from another grouping of panels. | 44 // that is transitioning from another grouping of panels. |
45 virtual void AddPanel(Panel* panel) OVERRIDE; | 45 virtual void AddPanel(Panel* panel) OVERRIDE; |
46 virtual bool RemovePanel(Panel* panel) OVERRIDE; | 46 virtual void RemovePanel(Panel* panel) OVERRIDE; |
47 virtual void CloseAll() OVERRIDE; | 47 virtual void CloseAll() OVERRIDE; |
48 virtual void ResizePanelWindow( | 48 virtual void ResizePanelWindow( |
49 Panel* panel, | 49 Panel* panel, |
50 const gfx::Size& preferred_window_size) OVERRIDE; | 50 const gfx::Size& preferred_window_size) OVERRIDE; |
51 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; | 51 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; |
52 virtual void ActivatePanel(Panel* panel) OVERRIDE; | 52 virtual void ActivatePanel(Panel* panel) OVERRIDE; |
53 virtual void MinimizePanel(Panel* panel) OVERRIDE; | 53 virtual void MinimizePanel(Panel* panel) OVERRIDE; |
54 virtual void RestorePanel(Panel* panel) OVERRIDE; | 54 virtual void RestorePanel(Panel* panel) OVERRIDE; |
| 55 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; |
55 virtual bool CanShowPanelAsActive(const Panel* panel) const OVERRIDE; | 56 virtual bool CanShowPanelAsActive(const Panel* panel) const OVERRIDE; |
56 virtual bool CanDragPanel(const Panel* panel) const OVERRIDE; | 57 virtual bool CanDragPanel(const Panel* panel) const OVERRIDE; |
57 virtual void StartDraggingPanel(Panel* panel) OVERRIDE; | 58 virtual void StartDraggingPanel(Panel* panel) OVERRIDE; |
58 virtual void DragPanel(Panel* panel, int delta_x, int delta_y) OVERRIDE; | 59 virtual void DragPanel(Panel* panel, int delta_x, int delta_y) OVERRIDE; |
59 virtual void EndDraggingPanel(Panel* panel, bool cancelled) OVERRIDE; | 60 virtual void EndDraggingPanel(Panel* panel, bool cancelled) OVERRIDE; |
60 | 61 |
61 // Invoked when a panel's expansion state changes. | 62 // Invoked when a panel's expansion state changes. |
62 void OnPanelExpansionStateChanged(Panel* panel); | 63 void OnPanelExpansionStateChanged(Panel* panel); |
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 // 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 // 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 // bottom of the screen, not the bottom of the work area. |
74 int GetBottomPositionForExpansionState( | 75 int GetBottomPositionForExpansionState( |
75 Panel::ExpansionState expansion_state) const; | 76 Panel::ExpansionState expansion_state) const; |
76 | 77 |
77 // num_panels() and panels() only includes panels in the panel strip that | 78 // num_panels() and panels() only includes panels in the panel strip that |
78 // do NOT have a temporary layout. | 79 // do NOT have a temporary layout. |
79 int num_panels() const { return panels_.size(); } | 80 int num_panels() const { return panels_.size(); } |
80 const Panels& panels() const { return panels_; } | 81 const Panels& panels() const { return panels_; } |
| 82 Panel* last_panel() const { return panels_.empty() ? NULL : panels_.back(); } |
81 | 83 |
82 gfx::Rect display_area() const { return display_area_; } | 84 gfx::Rect display_area() const { return display_area_; } |
83 | 85 |
84 int GetMaxPanelWidth() const; | 86 int GetMaxPanelWidth() const; |
85 int GetMaxPanelHeight() const; | 87 int GetMaxPanelHeight() const; |
86 int StartingRightPosition() const; | 88 int StartingRightPosition() const; |
87 | 89 |
88 void OnAutoHidingDesktopBarVisibilityChanged( | 90 void OnAutoHidingDesktopBarVisibilityChanged( |
89 AutoHidingDesktopBar::Alignment alignment, | 91 AutoHidingDesktopBar::Alignment alignment, |
90 AutoHidingDesktopBar::Visibility visibility); | 92 AutoHidingDesktopBar::Visibility visibility); |
91 | 93 |
92 void OnFullScreenModeChanged(bool is_full_screen); | 94 void OnFullScreenModeChanged(bool is_full_screen); |
93 | 95 |
| 96 // Returns |true| if panel can fit in the dock strip. |
| 97 bool CanFitPanel(const Panel* panel) const; |
| 98 |
| 99 // Used to temporarily disable/re-enable layout refreshes while manipulating |
| 100 // multiple panels at a time. |
| 101 void enable_layout_refresh(bool enable) { layout_refresh_enabled_ = enable; } |
| 102 |
94 #ifdef UNIT_TEST | 103 #ifdef UNIT_TEST |
95 int num_temporary_layout_panels() const { | 104 int num_temporary_layout_panels() const { |
96 return panels_in_temporary_layout_.size(); | 105 return panels_in_temporary_layout_.size(); |
97 } | 106 } |
98 #endif | 107 #endif |
99 | 108 |
100 private: | 109 private: |
101 enum TitlebarAction { | 110 enum TitlebarAction { |
102 NO_ACTION, | 111 NO_ACTION, |
103 BRING_UP, | 112 BRING_UP, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 148 |
140 Panels panels_; | 149 Panels panels_; |
141 | 150 |
142 // Stores newly created panels that have a temporary layout until they | 151 // Stores newly created panels that have a temporary layout until they |
143 // are moved to overflow after a delay. | 152 // are moved to overflow after a delay. |
144 std::set<Panel*> panels_in_temporary_layout_; | 153 std::set<Panel*> panels_in_temporary_layout_; |
145 | 154 |
146 int minimized_panel_count_; | 155 int minimized_panel_count_; |
147 bool are_titlebars_up_; | 156 bool are_titlebars_up_; |
148 | 157 |
149 // |True| to temporarily prevent refreshing panel layout, e.g. while | 158 // |False| to temporarily prevent refreshing panel layout, e.g. while |
150 // moving panels to overflow area to make room for a panel in this strip. | 159 // moving panels to overflow area to make room for a panel in this strip. |
151 bool disable_layout_refresh_; | 160 bool layout_refresh_enabled_; |
152 | 161 |
153 // Referring to current position in |panels_| where the dragging panel | 162 // Referring to current position in |panels_| where the dragging panel |
154 // resides. | 163 // resides. |
155 Panels::iterator dragging_panel_current_iterator_; | 164 Panels::iterator dragging_panel_current_iterator_; |
156 | 165 |
157 // Referring to original position in |panels_| where the dragging panel | 166 // Referring to original position in |panels_| where the dragging panel |
158 // resides. | 167 // resides. |
159 Panels::iterator dragging_panel_original_iterator_; | 168 Panels::iterator dragging_panel_original_iterator_; |
160 | 169 |
161 // Delayed transitions support. Sometimes transitions between minimized and | 170 // Delayed transitions support. Sometimes transitions between minimized and |
162 // title-only states are delayed, for better usability with Taskbars/Docks. | 171 // title-only states are delayed, for better usability with Taskbars/Docks. |
163 TitlebarAction delayed_titlebar_action_; | 172 TitlebarAction delayed_titlebar_action_; |
164 | 173 |
165 // Owned by MessageLoop after posting. | 174 // Owned by MessageLoop after posting. |
166 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_; | 175 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_; |
167 | 176 |
168 static const int kPanelsHorizontalSpacing = 4; | 177 static const int kPanelsHorizontalSpacing = 4; |
169 | 178 |
170 // Absolute minimum width and height for panels, including non-client area. | 179 // Absolute minimum width and height for panels, including non-client area. |
171 // Should only be big enough to accomodate a close button on the reasonably | 180 // Should only be big enough to accomodate a close button on the reasonably |
172 // recognisable titlebar. | 181 // recognisable titlebar. |
173 static const int kPanelMinWidth; | 182 static const int kPanelMinWidth; |
174 static const int kPanelMinHeight; | 183 static const int kPanelMinHeight; |
175 | 184 |
176 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); | 185 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); |
177 }; | 186 }; |
178 | 187 |
179 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ | 188 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ |
OLD | NEW |