Chromium Code Reviews| Index: ui/app_list/views/apps_grid_view.cc |
| diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc |
| index dd145ca2d97536bded59c1657b1dcb958a1e1db5..216becb4dcbad6940138c3a9fe8cc05954f4d816 100644 |
| --- a/ui/app_list/views/apps_grid_view.cc |
| +++ b/ui/app_list/views/apps_grid_view.cc |
| @@ -201,14 +201,19 @@ void AppsGridView::InitiateDrag(AppListItemView* view, |
| // Note: This code has very likely to be changed for Windows (non metro mode) |
| // when a |drag_and_drop_host_| gets implemented. |
| if (drag_and_drop_host_) { |
| + // Determine the mouse offset to the center of the icon so that the drag and |
| + // drop host follows this layer. |
| + gfx::Vector2d delta = event.root_location() - |
| + drag_view_->GetBoundsInScreen().CenterPoint(); |
| + delta.set_y(delta.y() + drag_view_->title()->size().height() / 2); |
| // We have to hide the original item since the drag and drop host will do |
| // the OS dependent code to "lift off the dragged item". |
| - // Note that we cannot use SetVisible since it would remove the mouse input. |
| - drag_view_->SetSize(gfx::Size()); |
| drag_and_drop_host_->CreateDragIconProxy(event.root_location(), |
| view->model()->icon(), |
| drag_view_, |
| + delta, |
| kDragAndDropProxyScale); |
| + HideView(drag_view_, true); |
| } |
| drag_start_ = event.location(); |
| } |
| @@ -244,10 +249,8 @@ void AppsGridView::UpdateDrag(AppListItemView* view, |
| if (last_drop_target != drop_target_) |
| AnimateToIdealBounds(); |
| - if (drag_and_drop_host_) { |
| + if (drag_and_drop_host_) |
| drag_and_drop_host_->UpdateDragIconProxy(event.root_location()); |
| - return; |
| - } |
| drag_view_->SetPosition( |
| gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_)); |
| @@ -263,14 +266,11 @@ void AppsGridView::EndDrag(bool cancel) { |
| MoveItemInModel(drag_view_, drop_target_); |
| } |
| - // In case we had a drag and drop proxy icon, we delete it and make the real |
| - // item visible again. |
| if (drag_and_drop_host_) { |
| + // If we had a drag and drop proxy icon, we delete it and make the real |
| + // item visible again. |
| drag_and_drop_host_->DestroyDragIconProxy(); |
| - // To avoid an incorrect animation on re-group, |drag_view_| gets positioned |
| - // at its last known drag location. |
| - drag_view_->SetPosition( |
| - gfx::PointAtOffsetFromOrigin(last_drag_point_ - drag_start_)); |
| + HideView(drag_view_, false); |
| } |
| drag_pointer_ = NONE; |
| @@ -919,4 +919,14 @@ void AppsGridView::OnAppListModelStatusChanged() { |
| SchedulePaint(); |
| } |
| +void AppsGridView::HideView(views::View* view, bool hide) { |
| + ui::LayerAnimator* animator = view->layer()->GetAnimator(); |
| + ui::LayerAnimator::PreemptionStrategy strategy = |
|
James Cook
2013/05/31 22:33:11
Use ui::ScopedLayerAnimationSettings here
Mr4D (OOO till 08-26)
2013/05/31 22:51:24
Done.
|
| + animator->preemption_strategy(); |
| + animator->set_preemption_strategy( |
| + ui::LayerAnimator::IMMEDIATELY_SET_NEW_TARGET); |
| + view->layer()->SetOpacity(hide ? 0 : 1); |
| + animator->set_preemption_strategy(strategy); |
| +} |
| + |
| } // namespace app_list |