Commit f4167f1f authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Fix weird movement when folder is created or distroyed

When the folder is created, the folder item view's origin is initiated
with (0, 0). So after dragging the folder item view will be animated to
where it is supposed to be, which cause the weird movement.

The same thing happens when the last item is moved outside the folder.

Changes:
Use the original view's bounds to set the newly created view's bounds
before the deletion of the original view.

BUG=819664

Change-Id: Id0066b27a0bd30f04e5b62c6b782178fbf84d48c
Reviewed-on: https://chromium-review.googlesource.com/953204Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541620}
parent 9b0885d0
...@@ -2085,10 +2085,14 @@ bool AppsGridView::ReparentItemToAnotherFolder(AppListItemView* item_view, ...@@ -2085,10 +2085,14 @@ bool AppsGridView::ReparentItemToAnotherFolder(AppListItemView* item_view,
const std::string& new_folder_id = reparent_item->folder_id(); const std::string& new_folder_id = reparent_item->folder_id();
size_t new_folder_index; size_t new_folder_index;
if (item_list_->FindItemIndex(new_folder_id, &new_folder_index)) { if (item_list_->FindItemIndex(new_folder_id, &new_folder_index)) {
// Save the target view's bounds before deletion, which will be used as
// new folder view's bounds.
gfx::Rect target_rect = target_view->bounds();
int target_view_index = view_model_.GetIndexOfView(target_view); int target_view_index = view_model_.GetIndexOfView(target_view);
DeleteItemViewAtIndex(target_view_index); DeleteItemViewAtIndex(target_view_index);
AppListItemView* new_folder_view = AppListItemView* new_folder_view =
CreateViewForItemAtIndex(new_folder_index); CreateViewForItemAtIndex(new_folder_index);
new_folder_view->SetBoundsRect(target_rect);
view_model_.Add(new_folder_view, target_view_index); view_model_.Add(new_folder_view, target_view_index);
AddChildViewAt(new_folder_view, AddChildViewAt(new_folder_view,
GetAppListItemViewIndexOffset() + new_folder_index); GetAppListItemViewIndexOffset() + new_folder_index);
...@@ -2125,6 +2129,9 @@ void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary( ...@@ -2125,6 +2129,9 @@ void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary(
if (!source_folder || source_folder->ChildItemCount() != 1u) if (!source_folder || source_folder->ChildItemCount() != 1u)
return; return;
// Save the folder item view's bounds before deletion, which will be used as
// last item view's bounds.
gfx::Rect folder_rect = activated_folder_item_view()->bounds();
// Delete view associated with the folder item to be removed. // Delete view associated with the folder item to be removed.
DeleteItemViewAtIndex( DeleteItemViewAtIndex(
view_model_.GetIndexOfView(activated_folder_item_view())); view_model_.GetIndexOfView(activated_folder_item_view()));
...@@ -2141,6 +2148,7 @@ void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary( ...@@ -2141,6 +2148,7 @@ void AppsGridView::RemoveLastItemFromReparentItemFolderIfNecessary(
return; return;
} }
AppListItemView* last_item_view = CreateViewForItemAtIndex(last_item_index); AppListItemView* last_item_view = CreateViewForItemAtIndex(last_item_index);
last_item_view->SetBoundsRect(folder_rect);
view_model_.Add(last_item_view, last_item_index); view_model_.Add(last_item_view, last_item_index);
AddChildViewAt(last_item_view, AddChildViewAt(last_item_view,
GetAppListItemViewIndexOffset() + last_item_index); GetAppListItemViewIndexOffset() + last_item_index);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment