OLD | NEW |
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 <math.h> | 5 #include <math.h> |
6 | 6 |
7 #include "chrome/browser/views/tabs/dragged_tab_controller.h" | 7 #include "chrome/browser/views/tabs/dragged_tab_controller.h" |
8 | 8 |
9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
10 #include "chrome/browser/frame_util.h" | 10 #include "chrome/browser/frame_util.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 | 64 |
65 POINT screen_point_; | 65 POINT screen_point_; |
66 HWND ignore1_; | 66 HWND ignore1_; |
67 HWND result_; | 67 HWND result_; |
68 | 68 |
69 DISALLOW_EVIL_CONSTRUCTORS(WindowFinder); | 69 DISALLOW_EVIL_CONSTRUCTORS(WindowFinder); |
70 }; | 70 }; |
71 | 71 |
72 gfx::Point ConvertScreenPointToTabStripPoint(TabStrip* tabstrip, | 72 gfx::Point ConvertScreenPointToTabStripPoint(TabStrip* tabstrip, |
73 const gfx::Point& screen_point) { | 73 const gfx::Point& screen_point) { |
74 CPoint tabstrip_topleft(0, 0); | 74 gfx::Point tabstrip_topleft; |
75 ChromeViews::View::ConvertPointToScreen(tabstrip, &tabstrip_topleft); | 75 ChromeViews::View::ConvertPointToScreen(tabstrip, &tabstrip_topleft); |
76 return gfx::Point(screen_point.x() - tabstrip_topleft.x, | 76 return gfx::Point(screen_point.x() - tabstrip_topleft.x(), |
77 screen_point.y() - tabstrip_topleft.y); | 77 screen_point.y() - tabstrip_topleft.y()); |
78 } | 78 } |
79 | 79 |
80 } | 80 } |
81 | 81 |
82 /////////////////////////////////////////////////////////////////////////////// | 82 /////////////////////////////////////////////////////////////////////////////// |
83 // DraggedTabController, public: | 83 // DraggedTabController, public: |
84 | 84 |
85 DraggedTabController::DraggedTabController(Tab* source_tab, | 85 DraggedTabController::DraggedTabController(Tab* source_tab, |
86 TabStrip* source_tabstrip) | 86 TabStrip* source_tabstrip) |
87 : dragged_contents_(NULL), | 87 : dragged_contents_(NULL), |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // single view or window reliably receives events throughout all the various | 264 // single view or window reliably receives events throughout all the various |
265 // kinds of tab dragging. | 265 // kinds of tab dragging. |
266 if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) | 266 if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) |
267 EndDrag(true); | 267 EndDrag(true); |
268 } | 268 } |
269 | 269 |
270 /////////////////////////////////////////////////////////////////////////////// | 270 /////////////////////////////////////////////////////////////////////////////// |
271 // DraggedTabController, private: | 271 // DraggedTabController, private: |
272 | 272 |
273 void DraggedTabController::InitWindowCreatePoint() { | 273 void DraggedTabController::InitWindowCreatePoint() { |
274 CPoint mouse_offset_cpoint(mouse_offset_.x(), mouse_offset_.y()); | 274 window_create_point_.SetPoint(mouse_offset_.x(), mouse_offset_.y()); |
275 Tab* first_tab = attached_tabstrip_->GetTabAt(0); | 275 Tab* first_tab = attached_tabstrip_->GetTabAt(0); |
276 ChromeViews::View::ConvertPointToViewContainer(first_tab, | 276 ChromeViews::View::ConvertPointToViewContainer(first_tab, |
277 &mouse_offset_cpoint); | 277 &window_create_point_); |
278 window_create_point_.SetPoint(mouse_offset_cpoint.x, mouse_offset_cpoint.y); | |
279 } | 278 } |
280 | 279 |
281 gfx::Point DraggedTabController::GetWindowCreatePoint() const { | 280 gfx::Point DraggedTabController::GetWindowCreatePoint() const { |
282 POINT pt; | 281 POINT pt; |
283 GetCursorPos(&pt); | 282 GetCursorPos(&pt); |
284 return gfx::Point(pt.x - window_create_point_.x(), | 283 return gfx::Point(pt.x - window_create_point_.x(), |
285 pt.y - window_create_point_.y()); | 284 pt.y - window_create_point_.y()); |
286 } | 285 } |
287 | 286 |
288 void DraggedTabController::ChangeDraggedContents(TabContents* new_contents) { | 287 void DraggedTabController::ChangeDraggedContents(TabContents* new_contents) { |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 } | 719 } |
721 | 720 |
722 gfx::Point DraggedTabController::GetCursorScreenPoint() const { | 721 gfx::Point DraggedTabController::GetCursorScreenPoint() const { |
723 POINT pt; | 722 POINT pt; |
724 GetCursorPos(&pt); | 723 GetCursorPos(&pt); |
725 return gfx::Point(pt); | 724 return gfx::Point(pt); |
726 } | 725 } |
727 | 726 |
728 gfx::Rect DraggedTabController::GetViewScreenBounds( | 727 gfx::Rect DraggedTabController::GetViewScreenBounds( |
729 ChromeViews::View* view) const { | 728 ChromeViews::View* view) const { |
730 CPoint view_topleft(0, 0); | 729 gfx::Point view_topleft; |
731 ChromeViews::View::ConvertPointToScreen(view, &view_topleft); | 730 ChromeViews::View::ConvertPointToScreen(view, &view_topleft); |
732 CRect view_screen_bounds; | 731 CRect view_screen_bounds; |
733 view->GetLocalBounds(&view_screen_bounds, true); | 732 view->GetLocalBounds(&view_screen_bounds, true); |
734 view_screen_bounds.OffsetRect(view_topleft); | 733 view_screen_bounds.OffsetRect(view_topleft.ToPOINT()); |
735 return gfx::Rect(view_screen_bounds); | 734 return gfx::Rect(view_screen_bounds); |
736 } | 735 } |
737 | 736 |
738 int DraggedTabController::NormalizeIndexToAttachedTabStrip(int index) const { | 737 int DraggedTabController::NormalizeIndexToAttachedTabStrip(int index) const { |
739 DCHECK(attached_tabstrip_) << "Can only be called when attached!"; | 738 DCHECK(attached_tabstrip_) << "Can only be called when attached!"; |
740 TabStripModel* attached_model = attached_tabstrip_->model(); | 739 TabStripModel* attached_model = attached_tabstrip_->model(); |
741 if (index >= attached_model->count()) | 740 if (index >= attached_model->count()) |
742 return attached_model->count() - 1; | 741 return attached_model->count() - 1; |
743 if (index == TabStripModel::kNoTab) | 742 if (index == TabStripModel::kNoTab) |
744 return 0; | 743 return 0; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 Tab* tab = GetTabMatchingDraggedContents(attached_tabstrip_); | 782 Tab* tab = GetTabMatchingDraggedContents(attached_tabstrip_); |
784 if (tab) | 783 if (tab) |
785 tab->SetVisible(true); | 784 tab->SetVisible(true); |
786 } | 785 } |
787 CleanUpHiddenFrame(); | 786 CleanUpHiddenFrame(); |
788 | 787 |
789 if (!in_destructor_) | 788 if (!in_destructor_) |
790 source_tabstrip_->DestroyDragController(); | 789 source_tabstrip_->DestroyDragController(); |
791 } | 790 } |
792 | 791 |
OLD | NEW |