Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 15 matching lines...) Expand all Loading... | |
| 26 if (panels_.empty()) | 26 if (panels_.empty()) |
| 27 return; | 27 return; |
| 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 PositioningMask positioning_mask) { | |
| 38 // positioning_mask is ignored since the detached panel is free-floating. | |
| 37 DCHECK_NE(this, panel->panel_strip()); | 39 DCHECK_NE(this, panel->panel_strip()); |
| 38 panel->set_panel_strip(this); | 40 panel->set_panel_strip(this); |
| 39 panels_.insert(panel); | 41 panels_.insert(panel); |
| 42 | |
| 43 panel->SetAlwaysOnTop(false); | |
| 40 } | 44 } |
| 41 | 45 |
| 42 void DetachedPanelStrip::RemovePanel(Panel* panel) { | 46 void DetachedPanelStrip::RemovePanel(Panel* panel) { |
| 43 DCHECK_EQ(this, panel->panel_strip()); | 47 DCHECK_EQ(this, panel->panel_strip()); |
| 44 panel->set_panel_strip(NULL); | 48 panel->set_panel_strip(NULL); |
| 45 panels_.erase(panel); | 49 panels_.erase(panel); |
| 46 } | 50 } |
| 47 | 51 |
| 48 void DetachedPanelStrip::CloseAll() { | 52 void DetachedPanelStrip::CloseAll() { |
| 49 // Make a copy as closing panels can modify the iterator. | 53 // Make a copy as closing panels can modify the iterator. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 DCHECK_EQ(this, panel->panel_strip()); | 88 DCHECK_EQ(this, panel->panel_strip()); |
| 85 NOTIMPLEMENTED(); | 89 NOTIMPLEMENTED(); |
| 86 return false; | 90 return false; |
| 87 } | 91 } |
| 88 | 92 |
| 89 bool DetachedPanelStrip::CanShowPanelAsActive(const Panel* panel) const { | 93 bool DetachedPanelStrip::CanShowPanelAsActive(const Panel* panel) const { |
| 90 // All detached panels can be shown as active. | 94 // All detached panels can be shown as active. |
| 91 return true; | 95 return true; |
| 92 } | 96 } |
| 93 | 97 |
| 98 void DetachedPanelStrip::SavePanelPlacement(Panel* panel) { | |
| 99 DCHECK(!saved_panel_placement_.panel); | |
| 100 saved_panel_placement_.panel = panel; | |
| 101 saved_panel_placement_.position = panel->GetBounds().origin(); | |
| 102 } | |
| 103 | |
| 104 void DetachedPanelStrip::RestorePanelToSavedPlacement() { | |
| 105 DCHECK(saved_panel_placement_.panel); | |
| 106 | |
| 107 gfx::Rect new_bounds(saved_panel_placement_.panel->GetBounds()); | |
| 108 new_bounds.set_origin(saved_panel_placement_.position); | |
| 109 saved_panel_placement_.panel->SetPanelBounds(new_bounds); | |
| 110 | |
| 111 DiscardSavedPanelPlacement(); | |
| 112 } | |
| 113 | |
| 114 void DetachedPanelStrip::DiscardSavedPanelPlacement() { | |
| 115 DCHECK(saved_panel_placement_.panel); | |
| 116 saved_panel_placement_.panel = NULL; | |
| 117 } | |
| 118 | |
| 94 bool DetachedPanelStrip::CanDragPanel(const Panel* panel) const { | 119 bool DetachedPanelStrip::CanDragPanel(const Panel* panel) const { |
| 95 // All detached panels are draggable. | 120 // All detached panels are draggable. |
| 96 return true; | 121 return true; |
| 97 } | 122 } |
| 98 | 123 |
| 99 void DetachedPanelStrip::StartDraggingPanel(Panel* panel) { | 124 void DetachedPanelStrip::StartDraggingPanelWithinStrip(Panel* panel) { |
| 125 DCHECK(HasPanel(panel)); | |
| 100 } | 126 } |
| 101 | 127 |
| 102 void DetachedPanelStrip::DragPanel(Panel* panel, int delta_x, int delta_y) { | 128 void DetachedPanelStrip::DragPanelWithinStrip(Panel* panel, |
| 129 int delta_x, | |
| 130 int delta_y) { | |
| 103 gfx::Rect new_bounds(panel->GetBounds()); | 131 gfx::Rect new_bounds(panel->GetBounds()); |
| 104 new_bounds.Offset(delta_x, delta_y); | 132 new_bounds.Offset(delta_x, delta_y); |
| 105 panel->SetPanelBounds(new_bounds); | 133 panel->SetPanelBoundsInstantly(new_bounds); |
|
jennb
2012/03/12 22:43:00
Why no animation?
jianli
2012/03/13 00:21:40
When we're dragging a panel via mouse moving, the
| |
| 106 } | 134 } |
| 107 | 135 |
| 108 void DetachedPanelStrip::EndDraggingPanel(Panel* panel, bool cancelled) { | 136 void DetachedPanelStrip::EndDraggingPanelWithinStrip(Panel* panel, |
| 109 if (cancelled) { | 137 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 } | 138 } |
| 116 | 139 |
| 117 bool DetachedPanelStrip::HasPanel(Panel* panel) const { | 140 bool DetachedPanelStrip::HasPanel(Panel* panel) const { |
| 118 return panels_.find(panel) != panels_.end(); | 141 return panels_.find(panel) != panels_.end(); |
| 119 } | 142 } |
| OLD | NEW |