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

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

Issue 9560002: Cleanup to keep panel from manipulating its panel strip assignment directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more feedback changes Created 8 years, 9 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) 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
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
94 #ifdef UNIT_TEST 99 #ifdef UNIT_TEST
95 int num_temporary_layout_panels() const { 100 int num_temporary_layout_panels() const {
96 return panels_in_temporary_layout_.size(); 101 return panels_in_temporary_layout_.size();
97 } 102 }
98 #endif 103 #endif
99 104
100 private: 105 private:
101 enum TitlebarAction { 106 enum TitlebarAction {
102 NO_ACTION, 107 NO_ACTION,
103 BRING_UP, 108 BRING_UP,
(...skipping 12 matching lines...) Expand all
116 void DragRight(Panel* dragging_panel); 121 void DragRight(Panel* dragging_panel);
117 122
118 // Does the real job of bringing up or down the titlebars. 123 // Does the real job of bringing up or down the titlebars.
119 void DoBringUpOrDownTitlebars(bool bring_up); 124 void DoBringUpOrDownTitlebars(bool bring_up);
120 // The callback for a delyed task, checks if it still need to perform 125 // The callback for a delyed task, checks if it still need to perform
121 // the delayed action. 126 // the delayed action.
122 void DelayedBringUpOrDownTitlebarsCheck(); 127 void DelayedBringUpOrDownTitlebarsCheck();
123 128
124 int GetRightMostAvailablePosition() const; 129 int GetRightMostAvailablePosition() const;
125 130
131 // |width| of panel to be fitted into the dock strip.
jianli 2012/03/02 22:25:32 nit: better rephrase the comment to make it more l
jennb 2012/03/02 22:44:37 Done.
132 // Other panels in the strip may be moved to overflow to make room.
133 // Returns x position where a panel of |width| wide can fit.
134 int FitPanelInStrip(int width);
jianli 2012/03/02 22:25:32 nit: FitPanelWithWidth? so that the name is consi
jennb 2012/03/02 22:44:37 Done.
135
126 // Called by AddPanel() after a delay to move a newly created panel from 136 // Called by AddPanel() after a delay to move a newly created panel from
127 // the panel strip to overflow because the panel could not fit 137 // the panel strip to overflow because the panel could not fit
128 // within the bounds of the panel strip. New panels are first displayed 138 // within the bounds of the panel strip. New panels are first displayed
129 // in the panel strip, then moved to overflow so that all created 139 // in the panel strip, then moved to overflow so that all created
130 // panels are (at least briefly) visible before entering overflow. 140 // panels are (at least briefly) visible before entering overflow.
131 void DelayedMovePanelToOverflow(Panel* panel); 141 void DelayedMovePanelToOverflow(Panel* panel);
132 142
133 Panel* dragging_panel() const; 143 Panel* dragging_panel() const;
134 144
135 PanelManager* panel_manager_; // Weak, owns us. 145 PanelManager* panel_manager_; // Weak, owns us.
136 146
137 // All panels in the panel strip must fit within this area. 147 // All panels in the panel strip must fit within this area.
138 gfx::Rect display_area_; 148 gfx::Rect display_area_;
139 149
140 Panels panels_; 150 Panels panels_;
141 151
142 // Stores newly created panels that have a temporary layout until they 152 // Stores newly created panels that have a temporary layout until they
143 // are moved to overflow after a delay. 153 // are moved to overflow after a delay.
144 std::set<Panel*> panels_in_temporary_layout_; 154 std::set<Panel*> panels_in_temporary_layout_;
145 155
146 int minimized_panel_count_; 156 int minimized_panel_count_;
147 bool are_titlebars_up_; 157 bool are_titlebars_up_;
148 158
149 // |True| to temporarily prevent refreshing panel layout, e.g. while
150 // moving panels to overflow area to make room for a panel in this strip.
151 bool disable_layout_refresh_;
152
153 // Referring to current position in |panels_| where the dragging panel 159 // Referring to current position in |panels_| where the dragging panel
154 // resides. 160 // resides.
155 Panels::iterator dragging_panel_current_iterator_; 161 Panels::iterator dragging_panel_current_iterator_;
156 162
157 // Referring to original position in |panels_| where the dragging panel 163 // Referring to original position in |panels_| where the dragging panel
158 // resides. 164 // resides.
159 Panels::iterator dragging_panel_original_iterator_; 165 Panels::iterator dragging_panel_original_iterator_;
160 166
161 // Delayed transitions support. Sometimes transitions between minimized and 167 // Delayed transitions support. Sometimes transitions between minimized and
162 // title-only states are delayed, for better usability with Taskbars/Docks. 168 // title-only states are delayed, for better usability with Taskbars/Docks.
163 TitlebarAction delayed_titlebar_action_; 169 TitlebarAction delayed_titlebar_action_;
164 170
165 // Owned by MessageLoop after posting. 171 // Owned by MessageLoop after posting.
166 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_; 172 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_;
167 173
168 static const int kPanelsHorizontalSpacing = 4; 174 static const int kPanelsHorizontalSpacing = 4;
169 175
170 // Absolute minimum width and height for panels, including non-client area. 176 // 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 177 // Should only be big enough to accomodate a close button on the reasonably
172 // recognisable titlebar. 178 // recognisable titlebar.
173 static const int kPanelMinWidth; 179 static const int kPanelMinWidth;
174 static const int kPanelMinHeight; 180 static const int kPanelMinHeight;
175 181
176 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); 182 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip);
177 }; 183 };
178 184
179 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ 185 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698