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

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: More 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 19 matching lines...) Expand all
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_NE(this, panel->panel_strip()); 37 DCHECK_NE(this, panel->panel_strip());
38 panel->set_panel_strip(this); 38 panel->set_panel_strip(this);
39 panels_.insert(panel); 39 panels_.insert(panel);
40
41 panel->SetAlwaysOnTop(false);
40 } 42 }
41 43
42 void DetachedPanelStrip::RemovePanel(Panel* panel) { 44 void DetachedPanelStrip::RemovePanel(Panel* panel) {
43 DCHECK_EQ(this, panel->panel_strip()); 45 DCHECK_EQ(this, panel->panel_strip());
44 panel->set_panel_strip(NULL); 46 panel->set_panel_strip(NULL);
45 panels_.erase(panel); 47 panels_.erase(panel);
46 } 48 }
47 49
48 void DetachedPanelStrip::CloseAll() { 50 void DetachedPanelStrip::CloseAll() {
49 // Make a copy as closing panels can modify the iterator. 51 // Make a copy as closing panels can modify the iterator.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DCHECK_EQ(this, panel->panel_strip()); 86 DCHECK_EQ(this, panel->panel_strip());
85 NOTIMPLEMENTED(); 87 NOTIMPLEMENTED();
86 return false; 88 return false;
87 } 89 }
88 90
89 bool DetachedPanelStrip::CanShowPanelAsActive(const Panel* panel) const { 91 bool DetachedPanelStrip::CanShowPanelAsActive(const Panel* panel) const {
90 // All detached panels can be shown as active. 92 // All detached panels can be shown as active.
91 return true; 93 return true;
92 } 94 }
93 95
96 void DetachedPanelStrip::SavePanelPlacement(Panel* panel) {
97 DCHECK(!saved_panel_placement_.panel);
98 saved_panel_placement_.panel = panel;
99 saved_panel_placement_.position = panel->GetBounds().origin();
100 }
101
102 void DetachedPanelStrip::RestorePanelToSavedPlacement() {
103 DCHECK(saved_panel_placement_.panel);
104
105 gfx::Rect new_bounds(saved_panel_placement_.panel->GetBounds());
106 new_bounds.set_origin(saved_panel_placement_.position);
107 saved_panel_placement_.panel->SetPanelBounds(new_bounds);
108
109 DiscardSavedPanelPlacement();
110 }
111
112 void DetachedPanelStrip::DiscardSavedPanelPlacement() {
113 DCHECK(saved_panel_placement_.panel);
114 saved_panel_placement_.panel = NULL;
115 }
116
94 bool DetachedPanelStrip::CanDragPanel(const Panel* panel) const { 117 bool DetachedPanelStrip::CanDragPanel(const Panel* panel) const {
95 // All detached panels are draggable. 118 // All detached panels are draggable.
96 return true; 119 return true;
97 } 120 }
98 121
99 void DetachedPanelStrip::StartDraggingPanel(Panel* panel) { 122 void DetachedPanelStrip::StartDraggingPanelWithinStrip(Panel* panel) {
100 } 123 }
101 124
102 void DetachedPanelStrip::DragPanel(Panel* panel, int delta_x, int delta_y) { 125 void DetachedPanelStrip::DragPanelWithinStrip(Panel* panel,
126 int delta_x,
127 int delta_y) {
103 gfx::Rect new_bounds(panel->GetBounds()); 128 gfx::Rect new_bounds(panel->GetBounds());
104 new_bounds.Offset(delta_x, delta_y); 129 new_bounds.Offset(delta_x, delta_y);
105 panel->SetPanelBounds(new_bounds); 130 panel->SetPanelBounds(new_bounds);
106 } 131 }
107 132
108 void DetachedPanelStrip::EndDraggingPanel(Panel* panel, bool cancelled) { 133 void DetachedPanelStrip::EndDraggingPanelWithinStrip(Panel* panel,
109 if (cancelled) { 134 bool aborted) {
110 gfx::Rect new_bounds(panel->GetBounds());
111 new_bounds.set_origin(
112 panel_manager_->drag_controller()->dragging_panel_original_position());
113 panel->SetPanelBounds(new_bounds);
114 }
115 } 135 }
116 136
117 bool DetachedPanelStrip::HasPanel(Panel* panel) const { 137 bool DetachedPanelStrip::HasPanel(Panel* panel) const {
118 return panels_.find(panel) != panels_.end(); 138 return panels_.find(panel) != panels_.end();
119 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698