summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 00:51:19 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-21 00:51:19 +0000
commit01c480c19d6ccfbdf57311a1e4cd218526b47ffd (patch)
tree0c7d04a0fbd5230fad3ba12927369c7aeb0dcd9c /ash
parent7d649d32bff855e2a7f9ab562f867b08a8e8546d (diff)
downloadchromium_src-01c480c19d6ccfbdf57311a1e4cd218526b47ffd.zip
chromium_src-01c480c19d6ccfbdf57311a1e4cd218526b47ffd.tar.gz
chromium_src-01c480c19d6ccfbdf57311a1e4cd218526b47ffd.tar.bz2
app_list/ash: Update show/hide animation.
- Animation duraiont 0.2s. Fade + moving away/towards shelf 8px. - Minor clean up to remove unused member and const; BUG=132179 TEST=Verify app list showing/hiding animation has 8px sliding away/towards launcher bar and has fading in/out. Review URL: https://chromiumcodereview.appspot.com/10580040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@143314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/wm/app_list_controller.cc44
-rw-r--r--ash/wm/app_list_controller.h4
2 files changed, 37 insertions, 11 deletions
diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_controller.cc
index 5fa32d6..45cf34f 100644
--- a/ash/wm/app_list_controller.cc
+++ b/ash/wm/app_list_controller.cc
@@ -27,10 +27,11 @@ namespace internal {
namespace {
-const float kContainerAnimationScaleFactor = 1.05f;
-
// Duration for show/hide animation in milliseconds.
-const int kAnimationDurationMs = 150;
+const int kAnimationDurationMs = 200;
+
+// Offset in pixels to animation away/towards the launcher.
+const int kAnimationOffset = 8;
ui::Layer* GetLayer(views::Widget* widget) {
return widget->GetNativeView()->layer();
@@ -39,8 +40,7 @@ ui::Layer* GetLayer(views::Widget* widget) {
// Gets arrow location based on shelf alignment.
views::BubbleBorder::ArrowLocation GetBubbleArrowLocation() {
DCHECK(Shell::HasInstance());
- ash::ShelfAlignment shelf_alignment =
- Shell::GetInstance()->shelf()->alignment();
+ ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment();
switch (shelf_alignment) {
case ash::SHELF_ALIGNMENT_BOTTOM:
return views::BubbleBorder::BOTTOM_RIGHT;
@@ -54,6 +54,29 @@ views::BubbleBorder::ArrowLocation GetBubbleArrowLocation() {
}
}
+// Offset given |rect| towards shelf.
+gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect) {
+ DCHECK(Shell::HasInstance());
+ ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment();
+ gfx::Rect offseted(rect);
+ switch(shelf_alignment) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ offseted.Offset(0, kAnimationOffset);
+ break;
+ case SHELF_ALIGNMENT_LEFT:
+ offseted.Offset(-kAnimationOffset, 0);
+ break;
+ case SHELF_ALIGNMENT_RIGHT:
+ offseted.Offset(kAnimationOffset, 0);
+ break;
+ default:
+ NOTREACHED() << "Unknown shelf alignment " << shelf_alignment;
+ break;
+ }
+
+ return offseted;
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -150,20 +173,27 @@ void AppListController::ResetView() {
}
void AppListController::ScheduleAnimation() {
- second_animation_timer_.Stop();
-
// Stop observing previous animation.
StopObservingImplicitAnimations();
ui::Layer* layer = GetLayer(view_->GetWidget());
layer->GetAnimator()->StopAnimating();
+ gfx::Rect target_bounds;
+ if (is_visible_) {
+ target_bounds = layer->bounds();
+ layer->SetBounds(OffsetTowardsShelf(layer->bounds()));
+ } else {
+ target_bounds = OffsetTowardsShelf(layer->bounds());
+ }
+
ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
animation.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(kAnimationDurationMs));
animation.AddObserver(this);
layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
+ layer->SetBounds(target_bounds);
}
void AppListController::ProcessLocatedEvent(const aura::LocatedEvent& event) {
diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h
index dd0ffb7..b9e1e18 100644
--- a/ash/wm/app_list_controller.h
+++ b/ash/wm/app_list_controller.h
@@ -111,10 +111,6 @@ class AppListController : public aura::EventFilter,
// The AppListView this class manages, owned by its widget.
app_list::AppListView* view_;
- // Timer to schedule the 2nd step animation, started when the first step
- // animation is scheduled in ScheduleAnimation.
- base::OneShotTimer<AppListController> second_animation_timer_;
-
DISALLOW_COPY_AND_ASSIGN(AppListController);
};