| 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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 pre_drag_and_drop_size_ = drag_and_drop_view->size(); | 609 pre_drag_and_drop_size_ = drag_and_drop_view->size(); |
| 610 drag_and_drop_view->SetSize(gfx::Size()); | 610 drag_and_drop_view->SetSize(gfx::Size()); |
| 611 | 611 |
| 612 // First we have to center the mouse cursor over the item. | 612 // First we have to center the mouse cursor over the item. |
| 613 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); | 613 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); |
| 614 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); | 614 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 615 gfx::Point point_in_root = location_in_screen_coordinates; | 615 gfx::Point point_in_root = location_in_screen_coordinates; |
| 616 ash::wm::ConvertPointFromScreen( | 616 ash::wm::ConvertPointFromScreen( |
| 617 ash::wm::GetRootWindowAt(location_in_screen_coordinates), | 617 ash::wm::GetRootWindowAt(location_in_screen_coordinates), |
| 618 &point_in_root); | 618 &point_in_root); |
| 619 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0); | 619 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, 0, 0); |
| 620 PointerPressedOnButton(drag_and_drop_view, | 620 PointerPressedOnButton(drag_and_drop_view, |
| 621 ShelfButtonHost::DRAG_AND_DROP, | 621 ShelfButtonHost::DRAG_AND_DROP, |
| 622 event); | 622 event); |
| 623 | 623 |
| 624 // Drag the item where it really belongs. | 624 // Drag the item where it really belongs. |
| 625 Drag(location_in_screen_coordinates); | 625 Drag(location_in_screen_coordinates); |
| 626 return true; | 626 return true; |
| 627 } | 627 } |
| 628 | 628 |
| 629 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { | 629 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { |
| 630 if (!drag_and_drop_launcher_id_ || | 630 if (!drag_and_drop_launcher_id_ || |
| 631 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) | 631 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) |
| 632 return false; | 632 return false; |
| 633 | 633 |
| 634 gfx::Point pt = location_in_screen_coordinates; | 634 gfx::Point pt = location_in_screen_coordinates; |
| 635 views::View* drag_and_drop_view = view_model_->view_at( | 635 views::View* drag_and_drop_view = view_model_->view_at( |
| 636 model_->ItemIndexByID(drag_and_drop_launcher_id_)); | 636 model_->ItemIndexByID(drag_and_drop_launcher_id_)); |
| 637 ConvertPointFromScreen(drag_and_drop_view, &pt); | 637 ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 638 gfx::Point point_in_root = location_in_screen_coordinates; | 638 gfx::Point point_in_root = location_in_screen_coordinates; |
| 639 ash::wm::ConvertPointFromScreen( | 639 ash::wm::ConvertPointFromScreen( |
| 640 ash::wm::GetRootWindowAt(location_in_screen_coordinates), | 640 ash::wm::GetRootWindowAt(location_in_screen_coordinates), |
| 641 &point_in_root); | 641 &point_in_root); |
| 642 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0); | 642 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, 0, 0); |
| 643 PointerDraggedOnButton(drag_and_drop_view, | 643 PointerDraggedOnButton(drag_and_drop_view, |
| 644 ShelfButtonHost::DRAG_AND_DROP, | 644 ShelfButtonHost::DRAG_AND_DROP, |
| 645 event); | 645 event); |
| 646 return true; | 646 return true; |
| 647 } | 647 } |
| 648 | 648 |
| 649 void ShelfView::EndDrag(bool cancel) { | 649 void ShelfView::EndDrag(bool cancel) { |
| 650 if (!drag_and_drop_launcher_id_) | 650 if (!drag_and_drop_launcher_id_) |
| 651 return; | 651 return; |
| 652 | 652 |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2022 break; | 2022 break; |
| 2023 case ash::SHELF_ALIGNMENT_TOP: | 2023 case ash::SHELF_ALIGNMENT_TOP: |
| 2024 distance = coordinate.y() - bounds.bottom(); | 2024 distance = coordinate.y() - bounds.bottom(); |
| 2025 break; | 2025 break; |
| 2026 } | 2026 } |
| 2027 return distance > 0 ? distance : 0; | 2027 return distance > 0 ? distance : 0; |
| 2028 } | 2028 } |
| 2029 | 2029 |
| 2030 } // namespace internal | 2030 } // namespace internal |
| 2031 } // namespace ash | 2031 } // namespace ash |
| OLD | NEW |