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

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

Issue 9546001: Support detaching/attaching panels via inter-strip drags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land 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 24 matching lines...) Expand all
35 virtual void SetDisplayArea(const gfx::Rect& display_area) OVERRIDE; 35 virtual void SetDisplayArea(const gfx::Rect& display_area) OVERRIDE;
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,
46 PositioningMask positioning_mask) OVERRIDE;
46 virtual void RemovePanel(Panel* panel) OVERRIDE; 47 virtual void RemovePanel(Panel* panel) OVERRIDE;
47 virtual void CloseAll() OVERRIDE; 48 virtual void CloseAll() OVERRIDE;
48 virtual void ResizePanelWindow( 49 virtual void ResizePanelWindow(
49 Panel* panel, 50 Panel* panel,
50 const gfx::Size& preferred_window_size) OVERRIDE; 51 const gfx::Size& preferred_window_size) OVERRIDE;
51 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE; 52 virtual void OnPanelAttentionStateChanged(Panel* panel) OVERRIDE;
52 virtual void ActivatePanel(Panel* panel) OVERRIDE; 53 virtual void ActivatePanel(Panel* panel) OVERRIDE;
53 virtual void MinimizePanel(Panel* panel) OVERRIDE; 54 virtual void MinimizePanel(Panel* panel) OVERRIDE;
54 virtual void RestorePanel(Panel* panel) OVERRIDE; 55 virtual void RestorePanel(Panel* panel) OVERRIDE;
55 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; 56 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE;
56 virtual bool CanShowPanelAsActive(const Panel* panel) const OVERRIDE; 57 virtual bool CanShowPanelAsActive(const Panel* panel) const OVERRIDE;
58 virtual void SavePanelPlacement(Panel* panel) OVERRIDE;
59 virtual void RestorePanelToSavedPlacement() OVERRIDE;
60 virtual void DiscardSavedPanelPlacement() OVERRIDE;
57 virtual bool CanDragPanel(const Panel* panel) const OVERRIDE; 61 virtual bool CanDragPanel(const Panel* panel) const OVERRIDE;
58 virtual void StartDraggingPanel(Panel* panel) OVERRIDE; 62 virtual void StartDraggingPanelWithinStrip(Panel* panel) OVERRIDE;
59 virtual void DragPanel(Panel* panel, int delta_x, int delta_y) OVERRIDE; 63 virtual void DragPanelWithinStrip(Panel* panel,
60 virtual void EndDraggingPanel(Panel* panel, bool cancelled) OVERRIDE; 64 int delta_x,
65 int delta_y) OVERRIDE;
66 virtual void EndDraggingPanelWithinStrip(Panel* panel,
67 bool aborted) OVERRIDE;
61 68
62 // Invoked when a panel's expansion state changes. 69 // Invoked when a panel's expansion state changes.
63 void OnPanelExpansionStateChanged(Panel* panel); 70 void OnPanelExpansionStateChanged(Panel* panel);
64 71
65 // Returns true if we should bring up the titlebars, given the current mouse 72 // Returns true if we should bring up the titlebars, given the current mouse
66 // point. 73 // point.
67 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const; 74 bool ShouldBringUpTitlebars(int mouse_x, int mouse_y) const;
68 75
69 // Brings up or down the titlebars for all minimized panels. 76 // Brings up or down the titlebars for all minimized panels.
70 void BringUpOrDownTitlebars(bool bring_up); 77 void BringUpOrDownTitlebars(bool bring_up);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 109 }
103 #endif 110 #endif
104 111
105 private: 112 private:
106 enum TitlebarAction { 113 enum TitlebarAction {
107 NO_ACTION, 114 NO_ACTION,
108 BRING_UP, 115 BRING_UP,
109 BRING_DOWN 116 BRING_DOWN
110 }; 117 };
111 118
119 struct PanelPlacement {
120 Panel* panel;
121 // Used to remember the panel to the left of |panel|, if any, for use when
122 // restoring the position of |panel|. Will be updated if this panel is
123 // closed or moved out of the dock (e.g. to overflow)..
124 Panel* left_panel;
125
126 PanelPlacement() : panel(NULL) { }
127 };
128
112 // Overridden from PanelMouseWatcherObserver: 129 // Overridden from PanelMouseWatcherObserver:
113 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE; 130 virtual void OnMouseMove(const gfx::Point& mouse_position) OVERRIDE;
114 131
132 // Helper methods to put the panel to the collection.
133 void InsertNewlyCreatedPanel(Panel* panel);
134 void InsertExistingPanelAtKnownPosition(Panel* panel);
135 void InsertExistingPanelAtDefaultPosition(Panel* panel, bool refresh_bounds);
136
115 // Keep track of the minimized panels to control mouse watching. 137 // Keep track of the minimized panels to control mouse watching.
116 void IncrementMinimizedPanels(); 138 void IncrementMinimizedPanels();
117 void DecrementMinimizedPanels(); 139 void DecrementMinimizedPanels();
118 140
119 // Help functions to drag the given panel. 141 // Help functions to drag the given panel.
120 void DragLeft(Panel* dragging_panel); 142 void DragLeft(Panel* dragging_panel);
121 void DragRight(Panel* dragging_panel); 143 void DragRight(Panel* dragging_panel);
122 144
123 // Does the real job of bringing up or down the titlebars. 145 // Does the real job of bringing up or down the titlebars.
124 void DoBringUpOrDownTitlebars(bool bring_up); 146 void DoBringUpOrDownTitlebars(bool bring_up);
125 // The callback for a delyed task, checks if it still need to perform 147 // The callback for a delyed task, checks if it still need to perform
126 // the delayed action. 148 // the delayed action.
127 void DelayedBringUpOrDownTitlebarsCheck(); 149 void DelayedBringUpOrDownTitlebarsCheck();
128 150
129 int GetRightMostAvailablePosition() const; 151 int GetRightMostAvailablePosition() const;
130 152
131 // Determines position in strip where a panel of |width| will fit. 153 // Determines position in strip where a panel of |width| will fit.
132 // Other panels in the strip may be moved to overflow to make room. 154 // 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. 155 // Returns x position where a panel of |width| wide can fit.
134 // |width| is in screen coordinates. 156 // |width| is in screen coordinates.
135 int FitPanelWithWidth(int width); 157 int FitPanelWithWidth(int width);
136 158
137 // Called by AddPanel() after a delay to move a newly created panel from 159 // Called by AddPanel() after a delay to move a newly created panel from
138 // the panel strip to overflow because the panel could not fit 160 // the panel strip to overflow because the panel could not fit
139 // within the bounds of the panel strip. New panels are first displayed 161 // within the bounds of the panel strip. New panels are first displayed
140 // in the panel strip, then moved to overflow so that all created 162 // in the panel strip, then moved to overflow so that all created
141 // panels are (at least briefly) visible before entering overflow. 163 // panels are (at least briefly) visible before entering overflow.
142 void DelayedMovePanelToOverflow(Panel* panel); 164 void DelayedMovePanelToOverflow(Panel* panel);
143 165
144 Panel* dragging_panel() const;
145
146 PanelManager* panel_manager_; // Weak, owns us. 166 PanelManager* panel_manager_; // Weak, owns us.
147 167
148 // All panels in the panel strip must fit within this area. 168 // All panels in the panel strip must fit within this area.
149 gfx::Rect display_area_; 169 gfx::Rect display_area_;
150 170
151 Panels panels_; 171 Panels panels_;
152 172
153 // Stores newly created panels that have a temporary layout until they 173 // Stores newly created panels that have a temporary layout until they
154 // are moved to overflow after a delay. 174 // are moved to overflow after a delay.
155 std::set<Panel*> panels_in_temporary_layout_; 175 std::set<Panel*> panels_in_temporary_layout_;
156 176
157 int minimized_panel_count_; 177 int minimized_panel_count_;
158 bool are_titlebars_up_; 178 bool are_titlebars_up_;
159 179
160 // Referring to current position in |panels_| where the dragging panel 180 // Referring to current position in |panels_| where the dragging panel
161 // resides. 181 // resides.
162 Panels::iterator dragging_panel_current_iterator_; 182 Panels::iterator dragging_panel_current_iterator_;
163 183
164 // Referring to original position in |panels_| where the dragging panel
165 // resides.
166 Panels::iterator dragging_panel_original_iterator_;
167
168 // Delayed transitions support. Sometimes transitions between minimized and 184 // Delayed transitions support. Sometimes transitions between minimized and
169 // title-only states are delayed, for better usability with Taskbars/Docks. 185 // title-only states are delayed, for better usability with Taskbars/Docks.
170 TitlebarAction delayed_titlebar_action_; 186 TitlebarAction delayed_titlebar_action_;
171 187
172 // Owned by MessageLoop after posting. 188 // Owned by MessageLoop after posting.
173 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_; 189 base::WeakPtrFactory<DockedPanelStrip> titlebar_action_factory_;
174 190
191 // Used to save the placement information for a panel.
192 PanelPlacement saved_panel_placement_;
193
175 static const int kPanelsHorizontalSpacing = 4; 194 static const int kPanelsHorizontalSpacing = 4;
176 195
177 // Absolute minimum width and height for panels, including non-client area. 196 // Absolute minimum width and height for panels, including non-client area.
178 // Should only be big enough to accomodate a close button on the reasonably 197 // Should only be big enough to accomodate a close button on the reasonably
179 // recognisable titlebar. 198 // recognisable titlebar.
180 static const int kPanelMinWidth; 199 static const int kPanelMinWidth;
181 static const int kPanelMinHeight; 200 static const int kPanelMinHeight;
182 201
183 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip); 202 DISALLOW_COPY_AND_ASSIGN(DockedPanelStrip);
184 }; 203 };
185 204
186 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_ 205 #endif // CHROME_BROWSER_UI_PANELS_DOCKED_PANEL_STRIP_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/panels/detached_panel_strip.cc ('k') | chrome/browser/ui/panels/docked_panel_strip.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698