blob: 2a21cd28b7ffdf9af6b959ce845b07a30c172a51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/panels/panel_drag_controller.h"
#include "base/logging.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_strip.h"
PanelDragController::PanelDragController()
: dragging_panel_(NULL) {
}
PanelDragController::~PanelDragController() {
}
void PanelDragController::StartDragging(Panel* panel) {
DCHECK(!dragging_panel_);
DCHECK(panel->draggable());
dragging_panel_ = panel;
dragging_panel_original_position_ = panel->GetBounds().origin();
dragging_panel_->panel_strip()->StartDraggingPanel(panel);
}
void PanelDragController::Drag(int delta_x, int delta_y) {
DCHECK(dragging_panel_);
dragging_panel_->panel_strip()->DragPanel(dragging_panel_, delta_x, delta_y);
}
void PanelDragController::EndDragging(bool cancelled) {
DCHECK(dragging_panel_);
// The code in PanelStrip::EndDraggingPanel might call DragController to find
// out if the drag has ended. So we need to reset |dragging_panel_| to reflect
// this.
Panel* panel = dragging_panel_;
dragging_panel_ = NULL;
panel->panel_strip()->EndDraggingPanel(panel, cancelled);
}
void PanelDragController::OnPanelClosed(Panel* panel) {
if (!dragging_panel_)
return;
// If the dragging panel is closed, abort the drag.
if (dragging_panel_ == panel)
EndDragging(false);
}
|