Index: ui/app_list/views/app_list_folder_view.cc |
diff --git a/ui/app_list/views/app_list_folder_view.cc b/ui/app_list/views/app_list_folder_view.cc |
index 10171ffa8b44950d7a06df2b33f552989d5d7605..24c3fcbca87b4642978b2af06da11375eea3dc51 100644 |
--- a/ui/app_list/views/app_list_folder_view.cc |
+++ b/ui/app_list/views/app_list_folder_view.cc |
@@ -10,11 +10,13 @@ |
#include "ui/app_list/app_list_folder_item.h" |
#include "ui/app_list/app_list_model.h" |
#include "ui/app_list/pagination_model.h" |
+#include "ui/app_list/views/app_list_item_view.h" |
#include "ui/app_list/views/app_list_main_view.h" |
#include "ui/app_list/views/apps_container_view.h" |
#include "ui/app_list/views/apps_grid_view.h" |
#include "ui/app_list/views/contents_view.h" |
#include "ui/app_list/views/folder_header_view.h" |
+#include "ui/compositor/scoped_layer_animation_settings.h" |
#include "ui/events/event.h" |
#include "ui/views/view_model.h" |
#include "ui/views/view_model_utils.h" |
@@ -37,7 +39,8 @@ AppListFolderView::AppListFolderView(AppsContainerView* container_view, |
folder_header_view_(new FolderHeaderView(this)), |
view_model_(new views::ViewModel), |
folder_item_(NULL), |
- pagination_model_(new PaginationModel) { |
+ pagination_model_(new PaginationModel), |
+ animate_to_show_(false) { |
AddChildView(folder_header_view_); |
view_model_->Add(folder_header_view_, kIndexFolderHeader); |
@@ -50,6 +53,11 @@ AppListFolderView::AppListFolderView(AppsContainerView* container_view, |
items_grid_view_->SetModel(model); |
AddChildView(items_grid_view_); |
view_model_->Add(items_grid_view_, kIndexChildItems); |
+ |
+#if defined(USE_AURA) |
+ SetPaintToLayer(true); |
+ SetFillsBoundsOpaquely(false); |
+#endif |
} |
AppListFolderView::~AppListFolderView() { |
@@ -63,6 +71,29 @@ void AppListFolderView::SetAppListFolderItem(AppListFolderItem* folder) { |
folder_header_view_->SetFolderItem(folder_item_); |
} |
+void AppListFolderView::ScheduleAnimationToShow(bool show) { |
+ // Stop any previous animation. |
+ layer()->GetAnimator()->StopAnimating(); |
+ |
+ animate_to_show_ = show; |
+ |
+ // Hide the top items temporarily if showing the view for opening the folder. |
+ if (show) |
+ items_grid_view_->ShowTopItemViews(false); |
+ |
+ // Set initial state. |
+ SetVisible(true); |
+ layer()->SetOpacity(show ? 0.0f : 1.0f); |
+ |
+ ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator()); |
+ animation.SetTweenType(gfx::Tween::EASE_IN_2); |
+ animation.AddObserver(this); |
+ animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
+ show ? kFolderTransitionInDurationMs : kFolderTransitionOutDurationMs)); |
+ |
+ layer()->SetOpacity(show ? 1.0f : 0.0f); |
+} |
+ |
gfx::Size AppListFolderView::GetPreferredSize() { |
const gfx::Size header_size = folder_header_view_->GetPreferredSize(); |
const gfx::Size grid_size = items_grid_view_->GetPreferredSize(); |
@@ -80,6 +111,16 @@ bool AppListFolderView::OnKeyPressed(const ui::KeyEvent& event) { |
return items_grid_view_->OnKeyPressed(event); |
} |
+void AppListFolderView::OnImplicitAnimationsCompleted() { |
+ // Show the top items when the opening folder animation is done. |
+ if (animate_to_show_) { |
xiyuan
2014/01/16 01:46:48
Can we check layer()->opacity to find it out? If s
jennyz
2014/01/16 17:49:52
Done.
|
+ items_grid_view_->ShowTopItemViews(true); |
+ } |
+ |
+ if (!animate_to_show_) |
+ SetVisible(false); |
+} |
+ |
void AppListFolderView::CalculateIdealBounds() { |
gfx::Rect rect(GetContentsBounds()); |
if (rect.IsEmpty()) |
@@ -95,9 +136,24 @@ void AppListFolderView::CalculateIdealBounds() { |
view_model_->set_ideal_bounds(kIndexChildItems, grid_frame); |
} |
+gfx::Rect AppListFolderView::GetItemIconBoundsAt(int index) { |
+ AppListItemView* item_view = items_grid_view_->GetItemViewAt(index); |
+ // Icon bounds relative to AppListItemView. |
+ const gfx::Rect icon_bounds = item_view->GetIconBounds(); |
+ gfx::Rect to_apps_grid_view = item_view->ConvertRectToParent(icon_bounds); |
+ gfx::Rect to_folder = |
+ items_grid_view_->ConvertRectToParent(to_apps_grid_view); |
+ |
+ // Get the icon image's bound. |
+ to_folder.ClampToCenteredSize( |
+ gfx::Size(kPreferredIconDimension, kPreferredIconDimension)); |
+ |
+ return to_folder; |
+} |
+ |
void AppListFolderView::NavigateBack(AppListFolderItem* item, |
const ui::Event& event_flags) { |
- container_view_->ShowApps(); |
+ container_view_->ShowApps(item); |
} |
} // namespace app_list |