Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: ui/app_list/views/apps_grid_view.cc

Issue 140203003: Implement animation UI for opening/closing an app list folder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address code review comments. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 096ea70802192126420f1f25ceebe14cda7b2707..0782bd3ce58de4463f3f31991d0bce5f698b969b 100644
--- a/ui/app_list/views/apps_grid_view.cc
+++ b/ui/app_list/views/apps_grid_view.cc
@@ -16,6 +16,7 @@
#include "ui/app_list/app_list_switches.h"
#include "ui/app_list/pagination_model.h"
#include "ui/app_list/views/app_list_drag_and_drop_host.h"
+#include "ui/app_list/views/app_list_folder_view.h"
#include "ui/app_list/views/app_list_item_view.h"
#include "ui/app_list/views/apps_grid_view_delegate.h"
#include "ui/app_list/views/page_switcher.h"
@@ -347,7 +348,11 @@ AppsGridView::AppsGridView(AppsGridViewDelegate* delegate,
page_flip_target_(-1),
page_flip_delay_in_ms_(kPageFlipDelayInMs),
bounds_animator_(this),
- is_root_level_(true) {
+ is_root_level_(true),
+ activated_item_view_(NULL) {
+ SetPaintToLayer(true);
+ SetFillsBoundsOpaquely(false);
+
pagination_model_->AddObserver(this);
AddChildView(page_switcher_view_);
@@ -658,6 +663,35 @@ void AppsGridView::StopPageFlipTimer() {
page_flip_target_ = -1;
}
+AppListItemView* AppsGridView::GetItemViewAt(int index) const {
+ DCHECK(index >= 0 && index < view_model_.view_size());
+ return static_cast<AppListItemView*>(view_model_.view_at(index));
+}
+
+void AppsGridView::SetTopItemViewsVisible(bool visible) {
+ int top_item_count = std::min(static_cast<int>(kNumFolderTopItems),
+ view_model_.view_size());
+ for (int i = 0; i < top_item_count; ++i)
+ GetItemViewAt(i)->SetVisible(visible);
+}
+
+void AppsGridView::ScheduleShowHideAnimation(bool show) {
+ // Stop any previous animation.
+ layer()->GetAnimator()->StopAnimating();
+
+ // Set initial state.
+ SetVisible(true);
+ layer()->SetOpacity(show ? 0.0f : 1.0f);
+
+ ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator());
+ animation.AddObserver(this);
+ animation.SetTweenType(gfx::Tween::EASE_IN_2);
+ animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds(
+ show ? kFolderTransitionInDurationMs : kFolderTransitionOutDurationMs));
+
+ layer()->SetOpacity(show ? 1.0f : 0.0f);
+}
+
bool AppsGridView::IsDraggedView(const views::View* view) const {
return drag_view_ == view;
}
@@ -1401,6 +1435,7 @@ void AppsGridView::ButtonPressed(views::Button* sender,
return;
if (delegate_) {
+ activated_item_view_ = static_cast<AppListItemView*>(sender);
delegate_->ActivateApp(static_cast<AppListItemView*>(sender)->item(),
event.flags());
}
@@ -1508,6 +1543,11 @@ void AppsGridView::SetViewHidden(views::View* view, bool hide, bool immediate) {
#endif
}
+void AppsGridView::OnImplicitAnimationsCompleted() {
+ if (layer()->opacity() == 0.0f)
+ SetVisible(false);
+}
+
bool AppsGridView::EnableFolderDragDropUI() {
// Enable drag and drop folder UI only if it is at the app list root level
// and the switch is on and the target folder can still accept new items.
« no previous file with comments | « ui/app_list/views/apps_grid_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698