| 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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 // change once a regrouping animation is performed. | 626 // change once a regrouping animation is performed. |
| 627 pre_drag_and_drop_size_ = drag_and_drop_view->size(); | 627 pre_drag_and_drop_size_ = drag_and_drop_view->size(); |
| 628 drag_and_drop_view->SetSize(gfx::Size()); | 628 drag_and_drop_view->SetSize(gfx::Size()); |
| 629 | 629 |
| 630 // First we have to center the mouse cursor over the item. | 630 // First we have to center the mouse cursor over the item. |
| 631 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); | 631 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); |
| 632 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); | 632 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 633 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, | 633 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, |
| 634 pt, location_in_screen_coordinates, 0); | 634 pt, location_in_screen_coordinates, 0); |
| 635 PointerPressedOnButton( | 635 PointerPressedOnButton( |
| 636 drag_and_drop_view, LauncherButtonHost::DRAG_AND_DROP, event); | 636 drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, event); |
| 637 | 637 |
| 638 // Drag the item where it really belongs. | 638 // Drag the item where it really belongs. |
| 639 Drag(location_in_screen_coordinates); | 639 Drag(location_in_screen_coordinates); |
| 640 return true; | 640 return true; |
| 641 } | 641 } |
| 642 | 642 |
| 643 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { | 643 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { |
| 644 if (!drag_and_drop_launcher_id_ || | 644 if (!drag_and_drop_launcher_id_ || |
| 645 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) | 645 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) |
| 646 return false; | 646 return false; |
| 647 | 647 |
| 648 gfx::Point pt = location_in_screen_coordinates; | 648 gfx::Point pt = location_in_screen_coordinates; |
| 649 views::View* drag_and_drop_view = view_model_->view_at( | 649 views::View* drag_and_drop_view = view_model_->view_at( |
| 650 model_->ItemIndexByID(drag_and_drop_launcher_id_)); | 650 model_->ItemIndexByID(drag_and_drop_launcher_id_)); |
| 651 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); | 651 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 652 | 652 |
| 653 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, gfx::Point(), 0); | 653 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, gfx::Point(), 0); |
| 654 PointerDraggedOnButton( | 654 PointerDraggedOnButton( |
| 655 drag_and_drop_view, LauncherButtonHost::DRAG_AND_DROP, event); | 655 drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, event); |
| 656 return true; | 656 return true; |
| 657 } | 657 } |
| 658 | 658 |
| 659 void ShelfView::EndDrag(bool cancel) { | 659 void ShelfView::EndDrag(bool cancel) { |
| 660 if (!drag_and_drop_launcher_id_) | 660 if (!drag_and_drop_launcher_id_) |
| 661 return; | 661 return; |
| 662 | 662 |
| 663 views::View* drag_and_drop_view = view_model_->view_at( | 663 views::View* drag_and_drop_view = view_model_->view_at( |
| 664 model_->ItemIndexByID(drag_and_drop_launcher_id_)); | 664 model_->ItemIndexByID(drag_and_drop_launcher_id_)); |
| 665 PointerReleasedOnButton( | 665 PointerReleasedOnButton( |
| 666 drag_and_drop_view, LauncherButtonHost::DRAG_AND_DROP, cancel); | 666 drag_and_drop_view, ShelfButtonHost::DRAG_AND_DROP, cancel); |
| 667 | 667 |
| 668 // Either destroy the temporarily created item - or - make the item visible. | 668 // Either destroy the temporarily created item - or - make the item visible. |
| 669 if (drag_and_drop_item_pinned_ && cancel) | 669 if (drag_and_drop_item_pinned_ && cancel) |
| 670 delegate_->UnpinAppWithID(drag_and_drop_app_id_); | 670 delegate_->UnpinAppWithID(drag_and_drop_app_id_); |
| 671 else if (drag_and_drop_view) { | 671 else if (drag_and_drop_view) { |
| 672 if (cancel) { | 672 if (cancel) { |
| 673 // When a hosted drag gets canceled, the item can remain in the same slot | 673 // When a hosted drag gets canceled, the item can remain in the same slot |
| 674 // and it might have moved within the bounds. In that case the item need | 674 // and it might have moved within the bounds. In that case the item need |
| 675 // to animate back to its correct location. | 675 // to animate back to its correct location. |
| 676 AnimateToIdealBounds(); | 676 AnimateToIdealBounds(); |
| (...skipping 1223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 break; | 1900 break; |
| 1901 case ash::SHELF_ALIGNMENT_TOP: | 1901 case ash::SHELF_ALIGNMENT_TOP: |
| 1902 distance = coordinate.y() - bounds.bottom(); | 1902 distance = coordinate.y() - bounds.bottom(); |
| 1903 break; | 1903 break; |
| 1904 } | 1904 } |
| 1905 return distance > 0 ? distance : 0; | 1905 return distance > 0 ? distance : 0; |
| 1906 } | 1906 } |
| 1907 | 1907 |
| 1908 } // namespace internal | 1908 } // namespace internal |
| 1909 } // namespace ash | 1909 } // namespace ash |
| OLD | NEW |