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/views/tabs/tab_drag_controller.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 // If the user presses ESC during a drag, we need to abort and revert things | 652 // If the user presses ESC during a drag, we need to abort and revert things |
653 // to the way they were. This is the most reliable way to do this since no | 653 // to the way they were. This is the most reliable way to do this since no |
654 // single view or window reliably receives events throughout all the various | 654 // single view or window reliably receives events throughout all the various |
655 // kinds of tab dragging. | 655 // kinds of tab dragging. |
656 if (ui::EventTypeFromNative(event) == ui::ET_KEY_PRESSED && | 656 if (ui::EventTypeFromNative(event) == ui::ET_KEY_PRESSED && |
657 ui::KeyboardCodeFromNative(event) == ui::VKEY_ESCAPE) { | 657 ui::KeyboardCodeFromNative(event) == ui::VKEY_ESCAPE) { |
658 EndDrag(END_DRAG_CANCEL); | 658 EndDrag(END_DRAG_CANCEL); |
659 } | 659 } |
660 } | 660 } |
661 | 661 |
662 void TabDragController::OnWidgetBoundsChanged(views::Widget* widget, | 662 void TabDragController::OnWidgetMoved(views::Widget* widget) { |
663 const gfx::Rect& new_bounds) { | |
664 Drag(GetCursorScreenPoint()); | 663 Drag(GetCursorScreenPoint()); |
665 } | 664 } |
666 | 665 |
667 void TabDragController::TabStripEmpty() { | 666 void TabDragController::TabStripEmpty() { |
668 DCHECK(detach_into_browser_); | 667 DCHECK(detach_into_browser_); |
669 GetModel(source_tabstrip_)->RemoveObserver(this); | 668 GetModel(source_tabstrip_)->RemoveObserver(this); |
670 // NULL out source_tabstrip_ so that we don't attempt to add back to it (in | 669 // NULL out source_tabstrip_ so that we don't attempt to add back to it (in |
671 // the case of a revert). | 670 // the case of a revert). |
672 source_tabstrip_ = NULL; | 671 source_tabstrip_ = NULL; |
673 } | 672 } |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 gfx::Vector2d TabDragController::GetWindowOffset( | 2041 gfx::Vector2d TabDragController::GetWindowOffset( |
2043 const gfx::Point& point_in_screen) { | 2042 const gfx::Point& point_in_screen) { |
2044 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? | 2043 TabStrip* owning_tabstrip = (attached_tabstrip_ && detach_into_browser_) ? |
2045 attached_tabstrip_ : source_tabstrip_; | 2044 attached_tabstrip_ : source_tabstrip_; |
2046 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); | 2045 views::View* toplevel_view = owning_tabstrip->GetWidget()->GetContentsView(); |
2047 | 2046 |
2048 gfx::Point point = point_in_screen; | 2047 gfx::Point point = point_in_screen; |
2049 views::View::ConvertPointFromScreen(toplevel_view, &point); | 2048 views::View::ConvertPointFromScreen(toplevel_view, &point); |
2050 return point.OffsetFromOrigin(); | 2049 return point.OffsetFromOrigin(); |
2051 } | 2050 } |
OLD | NEW |