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_manager.h" | 10 #include "chrome/browser/ui/panels/panel_manager.h" |
10 | 11 |
11 DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager) | 12 DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager) |
12 : PanelStrip(PanelStrip::DETACHED), | 13 : PanelStrip(PanelStrip::DETACHED), |
13 panel_manager_(panel_manager) { | 14 panel_manager_(panel_manager) { |
14 } | 15 } |
15 | 16 |
16 DetachedPanelStrip::~DetachedPanelStrip() { | 17 DetachedPanelStrip::~DetachedPanelStrip() { |
17 DCHECK(panels_.empty()); | 18 DCHECK(panels_.empty()); |
18 } | 19 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 void DetachedPanelStrip::MinimizePanel(Panel* panel) { | 73 void DetachedPanelStrip::MinimizePanel(Panel* panel) { |
73 DCHECK_EQ(this, panel->panel_strip()); | 74 DCHECK_EQ(this, panel->panel_strip()); |
74 NOTIMPLEMENTED(); | 75 NOTIMPLEMENTED(); |
75 } | 76 } |
76 | 77 |
77 void DetachedPanelStrip::RestorePanel(Panel* panel) { | 78 void DetachedPanelStrip::RestorePanel(Panel* panel) { |
78 DCHECK_EQ(this, panel->panel_strip()); | 79 DCHECK_EQ(this, panel->panel_strip()); |
79 NOTIMPLEMENTED(); | 80 NOTIMPLEMENTED(); |
80 } | 81 } |
81 | 82 |
83 bool DetachedPanelStrip::CanDragPanel(Panel* panel) const { | |
84 // All detached panels are draggable. | |
85 return true; | |
86 } | |
87 | |
88 void DetachedPanelStrip::StartDraggingPanel(Panel* panel) { | |
89 dragging_panel_original_position_ = panel->GetBounds().origin(); | |
90 } | |
91 | |
92 void DetachedPanelStrip::DragPanel(int delta_x, int delta_y) { | |
jennb
2012/02/17 21:28:45
Maybe we should pass the dragging_panel into this
jianli
2012/02/17 23:52:56
Done.
| |
93 Panel* dragging_panel = panel_manager_->drag_controller()->dragging_panel(); | |
94 DCHECK(dragging_panel); | |
95 | |
96 gfx::Rect new_bounds(dragging_panel->GetBounds()); | |
97 new_bounds.Offset(delta_x, delta_y); | |
jennb
2012/02/17 21:28:45
Do we need to adjust the deltas to keep the panel
jianli
2012/02/17 23:52:56
The detached panel should be allowed at any positi
| |
98 dragging_panel->SetPanelBounds(new_bounds); | |
99 } | |
100 | |
101 void DetachedPanelStrip::EndDraggingPanel(bool cancelled) { | |
102 Panel* dragging_panel = panel_manager_->drag_controller()->dragging_panel(); | |
103 DCHECK(dragging_panel); | |
104 | |
105 if (cancelled) { | |
106 gfx::Rect new_bounds(dragging_panel->GetBounds()); | |
107 new_bounds.set_origin(dragging_panel_original_position_); | |
108 dragging_panel->SetPanelBounds(new_bounds); | |
109 } | |
110 } | |
OLD | NEW |