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_manager.h" | 9 #include "chrome/browser/ui/panels/panel_manager.h" |
10 | 10 |
11 DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager) | 11 DetachedPanelStrip::DetachedPanelStrip(PanelManager* panel_manager) |
12 : PanelStrip(PanelStrip::DETACHED), | 12 : PanelStrip(PanelStrip::DETACHED), |
13 panel_manager_(panel_manager) { | 13 panel_manager_(panel_manager), |
14 dragging_panel_(NULL) { | |
14 } | 15 } |
15 | 16 |
16 DetachedPanelStrip::~DetachedPanelStrip() { | 17 DetachedPanelStrip::~DetachedPanelStrip() { |
17 DCHECK(panels_.empty()); | 18 DCHECK(panels_.empty()); |
18 } | 19 } |
19 | 20 |
20 void DetachedPanelStrip::SetDisplayArea(const gfx::Rect& display_area) { | 21 void DetachedPanelStrip::SetDisplayArea(const gfx::Rect& display_area) { |
21 if (display_area_ == display_area) | 22 if (display_area_ == display_area) |
22 return; | 23 return; |
23 display_area_ = display_area; | 24 display_area_ = display_area; |
(...skipping 48 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 DCHECK(!dragging_panel_); | |
90 | |
91 dragging_panel_ = panel; | |
92 dragging_panel_original_position_ = panel->GetBounds().origin(); | |
93 } | |
94 | |
95 void DetachedPanelStrip::DragPanel(int delta_x, int delta_y) { | |
96 DCHECK(dragging_panel_); | |
97 | |
98 gfx::Rect new_bounds(dragging_panel_->GetBounds()); | |
99 new_bounds.Offset(delta_x, delta_y); | |
100 dragging_panel_->SetPanelBounds(new_bounds); | |
101 } | |
102 | |
103 void DetachedPanelStrip::EndDraggingPanel(bool cancelled) { | |
104 DCHECK(dragging_panel_); | |
105 | |
106 if (cancelled) { | |
107 gfx::Rect new_bounds(dragging_panel_->GetBounds()); | |
108 new_bounds.set_origin(dragging_panel_original_position_); | |
109 dragging_panel_->SetPanelBounds(new_bounds); | |
110 } | |
Andrei
2012/02/17 00:08:18
It looks like cancelling the drag will happen very
jianli
2012/02/17 00:15:13
Yes. Inter-strip drags are not included in this pa
| |
111 | |
112 dragging_panel_ = NULL; | |
113 } | |
OLD | NEW |