| 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 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "ash/ash_constants.h" | 10 #include "ash/ash_constants.h" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 555 |
| 556 // Since there is already an icon presented by the caller, we hide this item | 556 // Since there is already an icon presented by the caller, we hide this item |
| 557 // for now. That has to be done by reducing the size since the visibility will | 557 // for now. That has to be done by reducing the size since the visibility will |
| 558 // change once a regrouping animation is performed. | 558 // change once a regrouping animation is performed. |
| 559 pre_drag_and_drop_size_ = drag_and_drop_view->size(); | 559 pre_drag_and_drop_size_ = drag_and_drop_view->size(); |
| 560 drag_and_drop_view->SetSize(gfx::Size()); | 560 drag_and_drop_view->SetSize(gfx::Size()); |
| 561 | 561 |
| 562 // First we have to center the mouse cursor over the item. | 562 // First we have to center the mouse cursor over the item. |
| 563 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); | 563 gfx::Point pt = drag_and_drop_view->GetBoundsInScreen().CenterPoint(); |
| 564 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); | 564 views::View::ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 565 gfx::Point point_in_root = | 565 gfx::Point point_in_root = location_in_screen_coordinates; |
| 566 wm::GetRootWindowAt(location_in_screen_coordinates) | 566 ::wm::ConvertPointFromScreen( |
| 567 ->ConvertPointFromScreen(location_in_screen_coordinates); | 567 wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); |
| 568 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, | 568 ui::MouseEvent event(ui::ET_MOUSE_PRESSED, pt, point_in_root, |
| 569 ui::EventTimeForNow(), 0, 0); | 569 ui::EventTimeForNow(), 0, 0); |
| 570 PointerPressedOnButton(drag_and_drop_view, DRAG_AND_DROP, event); | 570 PointerPressedOnButton(drag_and_drop_view, DRAG_AND_DROP, event); |
| 571 | 571 |
| 572 // Drag the item where it really belongs. | 572 // Drag the item where it really belongs. |
| 573 Drag(location_in_screen_coordinates); | 573 Drag(location_in_screen_coordinates); |
| 574 return true; | 574 return true; |
| 575 } | 575 } |
| 576 | 576 |
| 577 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { | 577 bool ShelfView::Drag(const gfx::Point& location_in_screen_coordinates) { |
| 578 if (drag_and_drop_shelf_id_.IsNull() || | 578 if (drag_and_drop_shelf_id_.IsNull() || |
| 579 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) | 579 !GetBoundsInScreen().Contains(location_in_screen_coordinates)) |
| 580 return false; | 580 return false; |
| 581 | 581 |
| 582 gfx::Point pt = location_in_screen_coordinates; | 582 gfx::Point pt = location_in_screen_coordinates; |
| 583 views::View* drag_and_drop_view = | 583 views::View* drag_and_drop_view = |
| 584 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); | 584 view_model_->view_at(model_->ItemIndexByID(drag_and_drop_shelf_id_)); |
| 585 ConvertPointFromScreen(drag_and_drop_view, &pt); | 585 ConvertPointFromScreen(drag_and_drop_view, &pt); |
| 586 gfx::Point point_in_root = | 586 gfx::Point point_in_root = location_in_screen_coordinates; |
| 587 wm::GetRootWindowAt(location_in_screen_coordinates) | 587 ::wm::ConvertPointFromScreen( |
| 588 ->ConvertPointFromScreen(location_in_screen_coordinates); | 588 wm::GetRootWindowAt(location_in_screen_coordinates), &point_in_root); |
| 589 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, | 589 ui::MouseEvent event(ui::ET_MOUSE_DRAGGED, pt, point_in_root, |
| 590 ui::EventTimeForNow(), 0, 0); | 590 ui::EventTimeForNow(), 0, 0); |
| 591 PointerDraggedOnButton(drag_and_drop_view, DRAG_AND_DROP, event); | 591 PointerDraggedOnButton(drag_and_drop_view, DRAG_AND_DROP, event); |
| 592 return true; | 592 return true; |
| 593 } | 593 } |
| 594 | 594 |
| 595 void ShelfView::EndDrag(bool cancel) { | 595 void ShelfView::EndDrag(bool cancel) { |
| 596 if (drag_and_drop_shelf_id_.IsNull()) | 596 if (drag_and_drop_shelf_id_.IsNull()) |
| 597 return; | 597 return; |
| 598 | 598 |
| (...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1826 if (pointer == TOUCH && | 1826 if (pointer == TOUCH && |
| 1827 (base::TimeTicks::Now() - touch_press_time_) < | 1827 (base::TimeTicks::Now() - touch_press_time_) < |
| 1828 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { | 1828 base::TimeDelta::FromMilliseconds(kTouchDragTimeThresholdMs)) { |
| 1829 return false; | 1829 return false; |
| 1830 } | 1830 } |
| 1831 | 1831 |
| 1832 return true; | 1832 return true; |
| 1833 } | 1833 } |
| 1834 | 1834 |
| 1835 } // namespace ash | 1835 } // namespace ash |
| OLD | NEW |