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

Side by Side Diff: chrome/views/root_view_drop_target.cc

Issue 7317: Change all ConvertPointTo* methods to use gfx::Point instead of CPoint.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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
« no previous file with comments | « chrome/views/root_view_drop_target.h ('k') | chrome/views/tooltip_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/views/root_view_drop_target.h" 5 #include "chrome/views/root_view_drop_target.h"
6 6
7 #include "base/gfx/point.h"
7 #include "base/logging.h" 8 #include "base/logging.h"
8 #include "chrome/common/drag_drop_types.h" 9 #include "chrome/common/drag_drop_types.h"
9 #include "chrome/views/root_view.h" 10 #include "chrome/views/root_view.h"
10 #include "chrome/views/view_container.h" 11 #include "chrome/views/view_container.h"
11 12
12 namespace ChromeViews { 13 namespace ChromeViews {
13 14
14 RootViewDropTarget::RootViewDropTarget(RootView* root_view) 15 RootViewDropTarget::RootViewDropTarget(RootView* root_view)
15 : BaseDropTarget(root_view->GetViewContainer()->GetHWND()), 16 : BaseDropTarget(root_view->GetViewContainer()->GetHWND()),
16 root_view_(root_view), 17 root_view_(root_view),
17 target_view_(NULL), 18 target_view_(NULL),
18 deepest_view_(NULL) { 19 deepest_view_(NULL) {
19 } 20 }
20 21
21 RootViewDropTarget::~RootViewDropTarget() { 22 RootViewDropTarget::~RootViewDropTarget() {
22 } 23 }
23 24
24 void RootViewDropTarget::ResetTargetViewIfEquals(View* view) { 25 void RootViewDropTarget::ResetTargetViewIfEquals(View* view) {
25 if (target_view_ == view) 26 if (target_view_ == view)
26 target_view_ = NULL; 27 target_view_ = NULL;
27 if (deepest_view_ == view) 28 if (deepest_view_ == view)
28 deepest_view_ = NULL; 29 deepest_view_ = NULL;
29 } 30 }
30 31
31 DWORD RootViewDropTarget::OnDragOver(IDataObject* data_object, 32 DWORD RootViewDropTarget::OnDragOver(IDataObject* data_object,
32 DWORD key_state, 33 DWORD key_state,
33 POINT cursor_position, 34 POINT cursor_position,
34 DWORD effect) { 35 DWORD effect) {
35 const OSExchangeData data(data_object); 36 const OSExchangeData data(data_object);
36 CPoint root_view_location(cursor_position.x, cursor_position.y); 37 gfx::Point root_view_location(cursor_position.x, cursor_position.y);
37 View::ConvertPointToView(NULL, root_view_, &root_view_location); 38 View::ConvertPointToView(NULL, root_view_, &root_view_location);
38 View* view = CalculateTargetView(root_view_location, data); 39 View* view = CalculateTargetView(root_view_location, data);
39 40
40 if (view != target_view_) { 41 if (view != target_view_) {
41 // Target changed notify old drag exited, then new drag entered. 42 // Target changed notify old drag exited, then new drag entered.
42 if (target_view_) 43 if (target_view_)
43 target_view_->OnDragExited(); 44 target_view_->OnDragExited();
44 target_view_ = view; 45 target_view_ = view;
45 if (target_view_) { 46 if (target_view_) {
46 CPoint target_view_location(root_view_location.x, root_view_location.y); 47 gfx::Point target_view_location(root_view_location);
47 View::ConvertPointToView(root_view_, target_view_, &target_view_location); 48 View::ConvertPointToView(root_view_, target_view_, &target_view_location);
48 DropTargetEvent enter_event(data, 49 DropTargetEvent enter_event(data,
49 target_view_location.x, 50 target_view_location.x(),
50 target_view_location.y, 51 target_view_location.y(),
51 DragDropTypes::DropEffectToDragOperation(effect)); 52 DragDropTypes::DropEffectToDragOperation(effect));
52 target_view_->OnDragEntered(enter_event); 53 target_view_->OnDragEntered(enter_event);
53 } 54 }
54 } 55 }
55 56
56 if (target_view_) { 57 if (target_view_) {
57 CPoint target_view_location(root_view_location.x, root_view_location.y); 58 gfx::Point target_view_location(root_view_location);
58 View::ConvertPointToView(root_view_, target_view_, &target_view_location); 59 View::ConvertPointToView(root_view_, target_view_, &target_view_location);
59 DropTargetEvent enter_event(data, 60 DropTargetEvent enter_event(data,
60 target_view_location.x, 61 target_view_location.x(),
61 target_view_location.y, 62 target_view_location.y(),
62 DragDropTypes::DropEffectToDragOperation(effect)); 63 DragDropTypes::DropEffectToDragOperation(effect));
63 int result_operation = target_view_->OnDragUpdated(enter_event); 64 int result_operation = target_view_->OnDragUpdated(enter_event);
64 return DragDropTypes::DragOperationToDropEffect(result_operation); 65 return DragDropTypes::DragOperationToDropEffect(result_operation);
65 } else { 66 } else {
66 return DROPEFFECT_NONE; 67 return DROPEFFECT_NONE;
67 } 68 }
68 } 69 }
69 70
70 void RootViewDropTarget::OnDragLeave(IDataObject* data_object) { 71 void RootViewDropTarget::OnDragLeave(IDataObject* data_object) {
71 if (target_view_) 72 if (target_view_)
72 target_view_->OnDragExited(); 73 target_view_->OnDragExited();
73 deepest_view_ = target_view_ = NULL; 74 deepest_view_ = target_view_ = NULL;
74 } 75 }
75 76
76 DWORD RootViewDropTarget::OnDrop(IDataObject* data_object, 77 DWORD RootViewDropTarget::OnDrop(IDataObject* data_object,
77 DWORD key_state, 78 DWORD key_state,
78 POINT cursor_position, 79 POINT cursor_position,
79 DWORD effect) { 80 DWORD effect) {
80 const OSExchangeData data(data_object); 81 const OSExchangeData data(data_object);
81 DWORD drop_effect = OnDragOver(data_object, key_state, cursor_position, 82 DWORD drop_effect = OnDragOver(data_object, key_state, cursor_position,
82 effect); 83 effect);
83 View* drop_view = target_view_; 84 View* drop_view = target_view_;
84 deepest_view_ = target_view_ = NULL; 85 deepest_view_ = target_view_ = NULL;
85 if (drop_effect != DROPEFFECT_NONE) { 86 if (drop_effect != DROPEFFECT_NONE) {
86 CPoint view_location(cursor_position.x, cursor_position.y); 87 gfx::Point view_location(cursor_position.x, cursor_position.y);
87 View::ConvertPointToView(NULL, drop_view, &view_location); 88 View::ConvertPointToView(NULL, drop_view, &view_location);
88 DropTargetEvent drop_event(data, view_location.x, view_location.y, 89 DropTargetEvent drop_event(data, view_location.x(), view_location.y(),
89 DragDropTypes::DropEffectToDragOperation(effect)); 90 DragDropTypes::DropEffectToDragOperation(effect));
90 return DragDropTypes::DragOperationToDropEffect( 91 return DragDropTypes::DragOperationToDropEffect(
91 drop_view->OnPerformDrop(drop_event)); 92 drop_view->OnPerformDrop(drop_event));
92 } else { 93 } else {
93 if (drop_view) 94 if (drop_view)
94 drop_view->OnDragExited(); 95 drop_view->OnDragExited();
95 return DROPEFFECT_NONE; 96 return DROPEFFECT_NONE;
96 } 97 }
97 } 98 }
98 99
99 View* RootViewDropTarget::CalculateTargetView( 100 View* RootViewDropTarget::CalculateTargetView(
100 const CPoint& root_view_location, 101 const gfx::Point& root_view_location,
101 const OSExchangeData& data) { 102 const OSExchangeData& data) {
102 View* view = root_view_->GetViewForPoint(root_view_location); 103 View* view = root_view_->GetViewForPoint(root_view_location.ToPOINT());
103 if (view == deepest_view_) { 104 if (view == deepest_view_) {
104 // The view the mouse is over hasn't changed; reuse the target. 105 // The view the mouse is over hasn't changed; reuse the target.
105 return target_view_; 106 return target_view_;
106 } 107 }
107 // View under mouse changed, which means a new view may want the drop. 108 // View under mouse changed, which means a new view may want the drop.
108 // Walk the tree, stopping at target_view_ as we know it'll accept the 109 // Walk the tree, stopping at target_view_ as we know it'll accept the
109 // drop. 110 // drop.
110 deepest_view_ = view; 111 deepest_view_ = view;
111 while (view && view != target_view_ && 112 while (view && view != target_view_ &&
112 (!view->IsEnabled() || !view->CanDrop(data))) { 113 (!view->IsEnabled() || !view->CanDrop(data))) {
113 view = view->GetParent(); 114 view = view->GetParent();
114 } 115 }
115 return view; 116 return view;
116 } 117 }
117 118
118 } // namespace 119 } // namespace
119 120
OLDNEW
« no previous file with comments | « chrome/views/root_view_drop_target.h ('k') | chrome/views/tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698