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

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

Issue 9403035: Refactor intra-strip panel drags by introducing PanelDragController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix per feedback Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/panels/panel_drag_controller.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/ui/panels/panel.h"
9 #include "chrome/browser/ui/panels/panel_strip.h"
10
11 PanelDragController::PanelDragController()
12 : dragging_panel_(NULL) {
13 }
14
15 PanelDragController::~PanelDragController() {
16 DCHECK(panels_pending_to_remove_.empty());
17 }
18
19 void PanelDragController::StartDragging(Panel* panel) {
20 DCHECK(!dragging_panel_);
jennb 2012/02/17 21:28:45 Also DCHECK panel->panel_strip()->CanDragPanel(pan
jianli 2012/02/17 23:52:56 Done.
21
22 dragging_panel_ = panel;
23 dragging_panel_->panel_strip()->StartDraggingPanel(panel);
24 }
25
26 void PanelDragController::Drag(int delta_x, int delta_y) {
27 DCHECK(dragging_panel_);
28
29 dragging_panel_->panel_strip()->DragPanel(delta_x, delta_y);
30 }
31
32 void PanelDragController::EndDragging(bool cancelled) {
33 DCHECK(dragging_panel_);
34
35 dragging_panel_->panel_strip()->EndDraggingPanel(cancelled);
36 dragging_panel_ = NULL;
37
38 DelayedRemove();
39 }
40
41 bool PanelDragController::CanRemovePanel(Panel* panel) {
42 if (!dragging_panel_)
43 return true;
44
45 // The following panels can't be removed immediately:
46 // 1) The dragging panel no matter which strip it is in.
47 // 2) All docked panels.
48 bool can_remove = (panel != dragging_panel_) &&
jennb 2012/02/17 21:28:45 if (panel == dragging_panel_ || is_a_docked_panel)
jianli 2012/02/17 23:52:56 Done.
49 (panel->panel_strip()->type() != PanelStrip::DOCKED);
50 if (!can_remove)
51 panels_pending_to_remove_.insert(panel);
52
53 return can_remove;
54 }
55
56 void PanelDragController::DelayedRemove() {
57 for (std::set<Panel*>::const_iterator iter =
58 panels_pending_to_remove_.begin();
59 iter != panels_pending_to_remove_.end(); ++iter) {
60 (*iter)->Close();
jennb 2012/02/17 21:28:45 The existing logic allows Close() while dragging.
jianli 2012/02/17 23:52:56 Per discussion, I remove it from this patch.
61 }
62
63 panels_pending_to_remove_.clear();
64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698