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

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"
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 gfx::NativeWindow GetNativeWindow() const;
Dmitry Titov 2013/01/10 00:16:24 lets get native_stack() accessor and then call Get
jianli 2013/01/10 02:05:37 Done.
63
64 void MoveAllDraggingPanelsInstantly(const gfx::Vector2d& delta_origin);
65
57 int num_panels() const { return panels_.size(); } 66 int num_panels() const { return panels_.size(); }
58 const Panels& panels() const { return panels_; } 67 const Panels& panels() const { return panels_; }
59 Panel* top_panel() const { return panels_.front(); } 68 Panel* top_panel() const { return panels_.empty() ? NULL : panels_.front(); }
60 Panel* bottom_panel() const { return panels_.back(); } 69 Panel* bottom_panel() const {
70 return panels_.empty() ? NULL : panels_.back();
71 }
61 72
62 private: 73 private:
63 PanelManager* panel_manager_; // Weak, owns us. 74 struct PanelPlacement {
75 Panel* panel;
76 gfx::Point position;
77 // Used to remember the top panel, if different from |panel|, for use when
78 // restoring it. When there're only 2 panels in the stack and the bottom
79 // panel is being dragged out of the stack, both panels will be moved to
80 // the detached collection. We need to track the top panel in order to
81 // put it back to the same stack of the dragging panel.
82 Panel* top_panel;
83
84 PanelPlacement() : panel(NULL), top_panel(NULL) { }
85 };
86
87 PanelManager* panel_manager_;
88
89 NativePanelStack* native_stack_; // Weak, own us.
Dmitry Titov 2013/01/10 00:16:24 own -> owns
jianli 2013/01/10 02:05:37 Done.
64 90
65 Panels panels_; // The top panel is in the front of the list. 91 Panels panels_; // The top panel is in the front of the list.
66 92
93 // Used to save the placement information for a panel.
94 PanelPlacement saved_panel_placement_;
95
67 DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection); 96 DISALLOW_COPY_AND_ASSIGN(StackedPanelCollection);
68 }; 97 };
69 98
70 #endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_ 99 #endif // CHROME_BROWSER_UI_PANELS_STACKED_PANEL_COLLECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698