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

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

Issue 11669018: Support dragging panels to stack and snap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 7 years, 11 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_STACKED_PANEL_COLLECTION_H_ 5 #ifndef CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
6 #define CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ 6 #define CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
7 7
8 #include <list> 8 #include <list>
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "chrome/browser/ui/panels/panel_collection.h" 11 #include "chrome/browser/ui/panels/panel_collection.h"
12 #include "chrome/browser/ui/panels/panel_constants.h"
13 #include "ui/gfx/native_widget_types.h"
dcheng 2013/01/10 22:39:03 Do we still need this #include?
jianli 2013/01/10 23:23:23 Removed.
12 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
13 15
16 class NativePanelStack;
14 class PanelManager; 17 class PanelManager;
18 namespace gfx {
19 class Vector2d;
20 }
15 21
16 class StackedPanelCollection : public PanelCollection { 22 class StackedPanelCollection : public PanelCollection {
17 public: 23 public:
18 typedef std::list<Panel*> Panels; 24 typedef std::list<Panel*> Panels;
19 25
20 explicit StackedPanelCollection(PanelManager* panel_manager); 26 explicit StackedPanelCollection(PanelManager* panel_manager);
21 virtual ~StackedPanelCollection(); 27 virtual ~StackedPanelCollection();
22 28
23 // PanelCollection OVERRIDES: 29 // PanelCollection OVERRIDES:
24 virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE; 30 virtual void OnDisplayAreaChanged(const gfx::Rect& old_display_area) OVERRIDE;
(...skipping 21 matching lines...) Expand all
46 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE; 52 virtual bool IsPanelMinimized(const Panel* panel) const OVERRIDE;
47 virtual void SavePanelPlacement(Panel* panel) OVERRIDE; 53 virtual void SavePanelPlacement(Panel* panel) OVERRIDE;
48 virtual void RestorePanelToSavedPlacement() OVERRIDE; 54 virtual void RestorePanelToSavedPlacement() OVERRIDE;
49 virtual void DiscardSavedPanelPlacement() OVERRIDE; 55 virtual void DiscardSavedPanelPlacement() OVERRIDE;
50 virtual void UpdatePanelOnCollectionChange(Panel* panel) OVERRIDE; 56 virtual void UpdatePanelOnCollectionChange(Panel* panel) OVERRIDE;
51 virtual void OnPanelActiveStateChanged(Panel* panel) OVERRIDE; 57 virtual void OnPanelActiveStateChanged(Panel* panel) OVERRIDE;
52 58
53 Panel* GetPanelAbove(Panel* panel) const; 59 Panel* GetPanelAbove(Panel* panel) const;
54 bool HasPanel(Panel* panel) const; 60 bool HasPanel(Panel* panel) const;
55 61
56 bool empty() const { return panels_.empty(); } 62 void MoveAllDraggingPanelsInstantly(const gfx::Vector2d& delta_origin);
63
64 NativePanelStack* native_stack() const { return native_stack_; }
57 int num_panels() const { return panels_.size(); } 65 int num_panels() const { return panels_.size(); }
58 const Panels& panels() const { return panels_; } 66 const Panels& panels() const { return panels_; }
59 Panel* top_panel() const { return panels_.front(); } 67 Panel* top_panel() const { return panels_.empty() ? NULL : panels_.front(); }
60 Panel* bottom_panel() const { return panels_.back(); } 68 Panel* bottom_panel() const {
69 return panels_.empty() ? NULL : panels_.back();
70 }
61 71
62 private: 72 private:
63 PanelManager* panel_manager_; // Weak, owns us. 73 struct PanelPlacement {
74 Panel* panel;
75 gfx::Point position;
76 // Used to remember the top panel, if different from |panel|, for use when
77 // restoring it. When there're only 2 panels in the stack and the bottom
78 // panel is being dragged out of the stack, both panels will be moved to
79 // the detached collection. We need to track the top panel in order to
80 // put it back to the same stack of the dragging panel.
81 Panel* top_panel;
82
83 PanelPlacement() : panel(NULL), top_panel(NULL) { }
84 };
85
86 PanelManager* panel_manager_;
87
88 NativePanelStack* native_stack_; // Weak, owns us.
64 89
65 Panels panels_; // The top panel is in the front of the list. 90 Panels panels_; // The top panel is in the front of the list.
66 91
92 // Used to save the placement information for a panel.
93 PanelPlacement saved_panel_placement_;
94
67 DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection); 95 DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection);
68 }; 96 };
69 97
70 #endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ 98 #endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698