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

Side by Side Diff: chrome/browser/ui/panels/detached_panel_strip.cc

Issue 9546001: Support detaching/attaching panels via inter-strip drags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback 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 #include "chrome/browser/ui/panels/detached_panel_strip.h" 5 #include "chrome/browser/ui/panels/detached_panel_strip.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/ui/panels/panel_drag_controller.h" 9 #include "chrome/browser/ui/panels/panel_drag_controller.h"
10 #include "chrome/browser/ui/panels/panel_manager.h" 10 #include "chrome/browser/ui/panels/panel_manager.h"
(...skipping 17 matching lines...) Expand all
28 28
29 RefreshLayout(); 29 RefreshLayout();
30 } 30 }
31 31
32 void DetachedPanelStrip::RefreshLayout() { 32 void DetachedPanelStrip::RefreshLayout() {
33 NOTIMPLEMENTED(); 33 NOTIMPLEMENTED();
34 } 34 }
35 35
36 void DetachedPanelStrip::AddPanel(Panel* panel) { 36 void DetachedPanelStrip::AddPanel(Panel* panel) {
37 DCHECK_EQ(this, panel->panel_strip()); 37 DCHECK_EQ(this, panel->panel_strip());
38
39 panel->SetAlwaysOnTop(false);
38 panels_.insert(panel); 40 panels_.insert(panel);
39 } 41 }
40 42
41 bool DetachedPanelStrip::RemovePanel(Panel* panel) { 43 bool DetachedPanelStrip::RemovePanel(Panel* panel) {
42 return panels_.erase(panel) != 0; 44 return panels_.erase(panel) != 0;
43 } 45 }
44 46
45 void DetachedPanelStrip::CloseAll() { 47 void DetachedPanelStrip::CloseAll() {
46 // Make a copy as closing panels can modify the iterator. 48 // Make a copy as closing panels can modify the iterator.
47 Panels panels_copy = panels_; 49 Panels panels_copy = panels_;
(...skipping 26 matching lines...) Expand all
74 void DetachedPanelStrip::RestorePanel(Panel* panel) { 76 void DetachedPanelStrip::RestorePanel(Panel* panel) {
75 DCHECK_EQ(this, panel->panel_strip()); 77 DCHECK_EQ(this, panel->panel_strip());
76 NOTIMPLEMENTED(); 78 NOTIMPLEMENTED();
77 } 79 }
78 80
79 bool DetachedPanelStrip::CanShowPanelAsActive(const Panel* panel) const { 81 bool DetachedPanelStrip::CanShowPanelAsActive(const Panel* panel) const {
80 // All detached panels can be shown as active. 82 // All detached panels can be shown as active.
81 return true; 83 return true;
82 } 84 }
83 85
86 void DetachedPanelStrip::SavePanelPlacement(Panel* panel) {
87 DCHECK(!saved_panel_placement_.panel);
88 saved_panel_placement_.panel = panel;
89 saved_panel_placement_.position = panel->GetBounds().origin();
90 }
91
92 void DetachedPanelStrip::LoadSavedPanelPlacement() {
93 DCHECK(saved_panel_placement_.panel);
94
95 gfx::Rect new_bounds(saved_panel_placement_.panel->GetBounds());
96 new_bounds.set_origin(saved_panel_placement_.position);
97 saved_panel_placement_.panel->SetPanelBounds(new_bounds);
98
99 saved_panel_placement_.panel = NULL;
jennb 2012/03/03 02:19:33 Should this call DiscardSavedPanelPlacement() inst
jianli 2012/03/07 19:14:31 Done.
100 }
101
102 void DetachedPanelStrip::DiscardSavedPanelPlacement() {
103 DCHECK(saved_panel_placement_.panel);
104 saved_panel_placement_.panel = NULL;
105 }
106
84 bool DetachedPanelStrip::CanDragPanel(const Panel* panel) const { 107 bool DetachedPanelStrip::CanDragPanel(const Panel* panel) const {
85 // All detached panels are draggable. 108 // All detached panels are draggable.
86 return true; 109 return true;
87 } 110 }
88 111
89 void DetachedPanelStrip::StartDraggingPanel(Panel* panel) { 112 void DetachedPanelStrip::StartDraggingPanelLocally(Panel* panel) {
113 // Move the panel to this strip if needed.
114 if (!HasPanel(panel)) {
jennb 2012/03/03 02:19:33 Reminder that you meant to revert this change.
jianli 2012/03/07 19:14:31 Done.
115 // TODO(jianli): Remove this when set_panel_strip is part of AddPanel.
116 panel->set_panel_strip(this);
117 AddPanel(panel);
118 }
90 } 119 }
91 120
92 void DetachedPanelStrip::DragPanel(Panel* panel, int delta_x, int delta_y) { 121 void DetachedPanelStrip::DragPanelLocally(Panel* panel,
122 int delta_x,
123 int delta_y) {
93 gfx::Rect new_bounds(panel->GetBounds()); 124 gfx::Rect new_bounds(panel->GetBounds());
94 new_bounds.Offset(delta_x, delta_y); 125 new_bounds.Offset(delta_x, delta_y);
95 panel->SetPanelBounds(new_bounds); 126 panel->SetPanelBounds(new_bounds);
96 } 127 }
97 128
98 void DetachedPanelStrip::EndDraggingPanel(Panel* panel, bool cancelled) { 129 void DetachedPanelStrip::EndDraggingPanelLocally(Panel* panel, bool cancelled) {
99 if (cancelled) { 130 }
100 gfx::Rect new_bounds(panel->GetBounds()); 131
101 new_bounds.set_origin( 132 void DetachedPanelStrip::AddDraggingPanel(Panel* panel,
jennb 2012/03/03 02:19:33 As discussed, separate out moving panels between s
jianli 2012/03/07 19:14:31 Done.
102 panel_manager_->drag_controller()->dragging_panel_original_position()); 133 const gfx::Point& position) {
103 panel->SetPanelBounds(new_bounds); 134 // TODO(jianli): remove this when set_panel_strip is part of AddPanel.
104 } 135 panel->set_panel_strip(this);
136 AddPanel(panel);
137
138 gfx::Rect new_bounds(panel->GetBounds());
139 new_bounds.set_origin(position);
140 panel->SetPanelBounds(new_bounds);
105 } 141 }
106 142
107 bool DetachedPanelStrip::HasPanel(Panel* panel) const { 143 bool DetachedPanelStrip::HasPanel(Panel* panel) const {
108 return panels_.find(panel) != panels_.end(); 144 return panels_.find(panel) != panels_.end();
109 } 145 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698