| 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 "ash/shelf/shelf_view.h" | 5 #include "ash/shelf/shelf_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/ash_constants.h" | 9 #include "ash/ash_constants.h" |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 // change once a regrouping animation is performed. | 616 // change once a regrouping animation is performed. |
| 617 pre_drag_and_drop_size_ = drag_and_drop_view->size(); | 617 pre_drag_and_drop_size_ = drag_and_drop_view->size(); |
| 618 drag_and_drop_view->SetSize(gfx::Size()); | 618 drag_and_drop_view->SetSize(gfx::Size()); |
| 619 | 619 |
| 620 // First we have to center the mouse cursor over the item. | 620 // First we have to center the mouse cursor over the item. |
| 621 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); | 621 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); |
| 622 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); | 622 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 623 gfx::Point point_in_root = location_in_screen_coordinates; | 623 gfx::Point point_in_root = location_in_screen_coordinates; |
| 624 ::wm::ConvertPointFromScreen( | 624 ::wm::ConvertPointFromScreen( |
| 625 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); | 625 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); |
| 626 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, | 626 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, gfx::PointF(pt), |
| 627 ui::EventTimeForNow(), 0, 0); | 627 gfx::PointF(point_in_root), ui::EventTimeForNow(), 0, 0); |
| 628 PointerPressedOnButton(drag_and_drop_view, | 628 PointerPressedOnButton(drag_and_drop_view, |
| 629 ShelfButtonHost::DRAG_AND_DROP, | 629 ShelfButtonHost::DRAG_AND_DROP, |
| 630 event); | 630 event); |
| 631 | 631 |
| 632 // Drag the item where it really belongs. | 632 // Drag the item where it really belongs. |
| 633 Drag(location_in_screen_coordinates); | 633 Drag(location_in_screen_coordinates); |
| 634 return true; | 634 return true; |
| 635 } | 635 } |
| 636 | 636 |
| 637 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { | 637 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { |
| 638 if (!drag_and_drop_shelf_id_ || | 638 if (!drag_and_drop_shelf_id_ || |
| 639 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) | 639 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) |
| 640 return false; | 640 return false; |
| 641 | 641 |
| 642 gfx::Point pt = location_in_screen_coordinates; | 642 gfx::Point pt = location_in_screen_coordinates; |
| 643 views::View* drag_and_drop_view = view_model_->view_at( | 643 views::View* drag_and_drop_view = view_model_->view_at( |
| 644 model_->ItemIndexByID(drag_and_drop_shelf_id_)); | 644 model_->ItemIndexByID(drag_and_drop_shelf_id_)); |
| 645 ConvertPointFromScreen(drag_and_drop_view, &pt); | 645 ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 646 gfx::Point point_in_root = location_in_screen_coordinates; | 646 gfx::Point point_in_root = location_in_screen_coordinates; |
| 647 ::wm::ConvertPointFromScreen( | 647 ::wm::ConvertPointFromScreen( |
| 648 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); | 648 ash::wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); |
| 649 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, | 649 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, gfx::PointF(pt), |
| 650 ui::EventTimeForNow(), 0, 0); | 650 gfx::PointF(point_in_root), ui::EventTimeForNow(), 0, 0); |
| 651 PointerDraggedOnButton(drag_and_drop_view, | 651 PointerDraggedOnButton(drag_and_drop_view, |
| 652 ShelfButtonHost::DRAG_AND_DROP, | 652 ShelfButtonHost::DRAG_AND_DROP, |
| 653 event); | 653 event); |
| 654 return true; | 654 return true; |
| 655 } | 655 } |
| 656 | 656 |
| 657 void ShelfView::EndDrag(bool cancel) { | 657 void ShelfView::EndDrag(bool cancel) { |
| 658 if (!drag_and_drop_shelf_id_) | 658 if (!drag_and_drop_shelf_id_) |
| 659 return; | 659 return; |
| 660 | 660 |
| (...skipping 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 distance = bounds.x() - coordinate.x(); | 1968 distance = bounds.x() - coordinate.x(); |
| 1969 break; | 1969 break; |
| 1970 case SHELF_ALIGNMENT_TOP: | 1970 case SHELF_ALIGNMENT_TOP: |
| 1971 distance = coordinate.y() - bounds.bottom(); | 1971 distance = coordinate.y() - bounds.bottom(); |
| 1972 break; | 1972 break; |
| 1973 } | 1973 } |
| 1974 return distance > 0 ? distance : 0; | 1974 return distance > 0 ? distance : 0; |
| 1975 } | 1975 } |
| 1976 | 1976 |
| 1977 } // namespace ash | 1977 } // namespace ash |
| OLD | NEW |