Chromium Code Reviews| Index: ash/wm/app_list_shower_delegate.cc |
| diff --git a/ash/wm/app_list_controller.cc b/ash/wm/app_list_shower_delegate.cc |
| similarity index 42% |
| copy from ash/wm/app_list_controller.cc |
| copy to ash/wm/app_list_shower_delegate.cc |
| index 823c32733048335204dc830fcdede1d47742357e..75658c4a9898a09caf9055ef3948ffbc2f1eacb8 100644 |
| --- a/ash/wm/app_list_controller.cc |
| +++ b/ash/wm/app_list_shower_delegate.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "ash/wm/app_list_controller.h" |
| +#include "ash/wm/app_list_shower_delegate.h" |
| #include "ash/ash_switches.h" |
| #include "ash/root_window_controller.h" |
| @@ -12,34 +12,24 @@ |
| #include "ash/shell.h" |
| #include "ash/shell_delegate.h" |
| #include "ash/shell_window_ids.h" |
| +#include "ash/wm/app_list_view_delegate_factory.h" |
| #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| #include "base/command_line.h" |
| #include "ui/app_list/app_list_constants.h" |
| #include "ui/app_list/app_list_switches.h" |
| -#include "ui/app_list/pagination_model.h" |
| +#include "ui/app_list/shower/app_list_shower.h" |
| #include "ui/app_list/views/app_list_view.h" |
| -#include "ui/aura/client/focus_client.h" |
| #include "ui/aura/window.h" |
| -#include "ui/aura/window_event_dispatcher.h" |
| -#include "ui/compositor/layer.h" |
| -#include "ui/compositor/scoped_layer_animation_settings.h" |
| #include "ui/events/event.h" |
| -#include "ui/gfx/transform_util.h" |
| #include "ui/keyboard/keyboard_controller.h" |
| #include "ui/views/widget/widget.h" |
| namespace ash { |
| namespace { |
| -// Duration for show/hide animation in milliseconds. |
| -const int kAnimationDurationMs = 200; |
| - |
| // Offset in pixels to animation away/towards the shelf. |
| const int kAnimationOffset = 8; |
| -// The maximum shift in pixels when over-scroll happens. |
| -const int kMaxOverScrollShift = 48; |
| - |
| // The minimal anchor position offset to make sure that the bubble is still on |
| // the screen with 8 pixels spacing on the left / right. This constant is a |
| // result of minimal bubble arrow sizes and offsets. |
| @@ -48,10 +38,6 @@ const int kMinimalAnchorPositionOffset = 57; |
| // The minimal margin (in pixels) around the app list when in centered mode. |
| const int kMinimalCenteredAppListMargin = 10; |
| -ui::Layer* GetLayer(views::Widget* widget) { |
| - return widget->GetNativeView()->layer(); |
| -} |
| - |
| // Gets arrow location based on shelf alignment. |
| views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { |
| DCHECK(Shell::HasInstance()); |
| @@ -60,27 +46,6 @@ views::BubbleBorder::Arrow GetBubbleArrow(aura::Window* window) { |
| views::BubbleBorder::RIGHT_CENTER); |
| } |
| -// Offset given |rect| towards shelf. |
| -gfx::Rect OffsetTowardsShelf(const gfx::Rect& rect, views::Widget* widget) { |
| - DCHECK(Shell::HasInstance()); |
| - ShelfAlignment shelf_alignment = Shell::GetInstance()->GetShelfAlignment( |
| - widget->GetNativeView()->GetRootWindow()); |
| - 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; |
| - } |
| - |
| - return offseted; |
| -} |
| - |
| // Using |button_bounds|, determine the anchor offset so that the bubble gets |
| // shown above the shelf (used for the alternate shelf theme). |
| gfx::Vector2d GetAnchorPositionOffsetToShelf( |
| @@ -154,106 +119,106 @@ bool IsFullscreenAppListEnabled() { |
| } // namespace |
| //////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, public: |
| - |
| -AppListController::AppListController() |
| - : is_visible_(false), |
| - is_centered_(false), |
| - view_(NULL), |
| - current_apps_page_(-1), |
| - should_snap_back_(false) { |
| +// AppListShowerDelegate, public: |
| + |
| +AppListShowerDelegate::AppListShowerDelegate( |
| + app_list::AppListShower* shower, |
| + AppListViewDelegateFactory* view_delegate_factory) |
| + : shower_(shower), view_delegate_factory_(view_delegate_factory) { |
| Shell::GetInstance()->AddShellObserver(this); |
| } |
| -AppListController::~AppListController() { |
| - // Ensures app list view goes before the controller since pagination model |
| - // lives in the controller and app list view would access it on destruction. |
| - if (view_) { |
| - view_->GetAppsPaginationModel()->RemoveObserver(this); |
| - if (view_->GetWidget()) |
| - view_->GetWidget()->CloseNow(); |
| - } |
| - |
| +AppListShowerDelegate::~AppListShowerDelegate() { |
| + DCHECK(view_); |
| + keyboard::KeyboardController* keyboard_controller = |
| + keyboard::KeyboardController::GetInstance(); |
| + if (keyboard_controller) |
| + keyboard_controller->RemoveObserver(this); |
| + views::Widget* widget = view_->GetWidget(); |
| + Shell::GetInstance()->RemovePreTargetHandler(this); |
| + Shelf::ForWindow(widget->GetNativeWindow())->RemoveIconObserver(this); |
| Shell::GetInstance()->RemoveShellObserver(this); |
| } |
| -void AppListController::Show(aura::Window* window) { |
| - if (is_visible_) |
| - return; |
| - |
| - is_visible_ = true; |
| +app_list::AppListViewDelegate* AppListShowerDelegate::GetViewDelegate() { |
| + return view_delegate_factory_->GetDelegate(); |
| +} |
| +void AppListShowerDelegate::Init(app_list::AppListView* view, |
| + aura::Window* root_window, |
| + int current_apps_page) { |
| // App list needs to know the new shelf layout in order to calculate its |
| // UI layout when AppListView visibility changes. |
| - Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()-> |
| - UpdateAutoHideState(); |
| - |
| - if (view_) { |
| - ScheduleAnimation(); |
| + ash::Shell::GetPrimaryRootWindowController() |
| + ->GetShelfLayoutManager() |
| + ->UpdateAutoHideState(); |
| + view_ = view; |
| + aura::Window* container = GetRootWindowController(root_window) |
| + ->GetContainer(kShellWindowId_AppListContainer); |
| + views::View* applist_button = |
| + Shelf::ForWindow(container)->GetAppListButtonView(); |
| + is_centered_ = view->ShouldCenterWindow(); |
| + bool is_fullscreen = IsFullscreenAppListEnabled() && |
| + Shell::GetInstance() |
| + ->maximize_mode_controller() |
| + ->IsMaximizeModeWindowManagerEnabled(); |
| + if (is_fullscreen) { |
| + view->InitAsFramelessWindow( |
| + container, current_apps_page, |
| + ScreenUtil::GetDisplayWorkAreaBoundsInParent(container)); |
| + } else if (is_centered_) { |
| + // Note: We can't center the app list until we have its dimensions, so we |
| + // init at (0, 0) and then reset its anchor point. |
| + view->InitAsBubbleAtFixedLocation(container, |
| + current_apps_page, |
| + gfx::Point(), |
| + views::BubbleBorder::FLOAT, |
| + true /* border_accepts_events */); |
| + // The experimental app list is centered over the display of the app list |
| + // button that was pressed (if triggered via keyboard, this is the display |
| + // with the currently focused window). |
| + view->SetAnchorPoint(GetCenterOfDisplayForView( |
| + applist_button, GetMinimumBoundsHeightForAppList(view))); |
| } else { |
| - // Note the AppListViewDelegate outlives the AppListView. For Ash, the view |
| - // is destroyed when dismissed. |
| - app_list::AppListView* view = new app_list::AppListView( |
| - Shell::GetInstance()->delegate()->GetAppListViewDelegate()); |
| - aura::Window* root_window = window->GetRootWindow(); |
| - aura::Window* container = GetRootWindowController(root_window)-> |
| - GetContainer(kShellWindowId_AppListContainer); |
| - views::View* applist_button = |
| - Shelf::ForWindow(container)->GetAppListButtonView(); |
| - is_centered_ = view->ShouldCenterWindow(); |
| - bool is_fullscreen = IsFullscreenAppListEnabled() && |
| - Shell::GetInstance() |
| - ->maximize_mode_controller() |
| - ->IsMaximizeModeWindowManagerEnabled(); |
| - if (is_fullscreen) { |
| - view->InitAsFramelessWindow( |
| - container, current_apps_page_, |
| - ScreenUtil::GetDisplayWorkAreaBoundsInParent(container)); |
| - } else if (is_centered_) { |
| - // Note: We can't center the app list until we have its dimensions, so we |
| - // init at (0, 0) and then reset its anchor point. |
| - view->InitAsBubbleAtFixedLocation(container, |
| - current_apps_page_, |
| - gfx::Point(), |
| - views::BubbleBorder::FLOAT, |
| - true /* border_accepts_events */); |
| - // The experimental app list is centered over the display of the app list |
| - // button that was pressed (if triggered via keyboard, this is the display |
| - // with the currently focused window). |
| - view->SetAnchorPoint(GetCenterOfDisplayForView( |
| - applist_button, GetMinimumBoundsHeightForAppList(view))); |
| - } else { |
| - gfx::Rect applist_button_bounds = applist_button->GetBoundsInScreen(); |
| - // We need the location of the button within the local screen. |
| - applist_button_bounds = ScreenUtil::ConvertRectFromScreen( |
| - root_window, |
| - applist_button_bounds); |
| - view->InitAsBubbleAttachedToAnchor( |
| - container, |
| - current_apps_page_, |
| - Shelf::ForWindow(container)->GetAppListButtonView(), |
| - GetAnchorPositionOffsetToShelf( |
| - applist_button_bounds, |
| - Shelf::ForWindow(container)->GetAppListButtonView()->GetWidget()), |
| - GetBubbleArrow(container), |
| - true /* border_accepts_events */); |
| - view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| - } |
| - SetView(view); |
| - // By setting us as DnD recipient, the app list knows that we can |
| - // handle items. |
| - SetDragAndDropHostOfCurrentAppList( |
| - Shelf::ForWindow(window)->GetDragAndDropHostForAppList()); |
| + gfx::Rect applist_button_bounds = applist_button->GetBoundsInScreen(); |
| + // We need the location of the button within the local screen. |
| + applist_button_bounds = ScreenUtil::ConvertRectFromScreen( |
| + root_window, |
| + applist_button_bounds); |
| + view->InitAsBubbleAttachedToAnchor( |
| + container, |
| + current_apps_page, |
| + Shelf::ForWindow(container)->GetAppListButtonView(), |
| + GetAnchorPositionOffsetToShelf( |
| + applist_button_bounds, |
| + Shelf::ForWindow(container)->GetAppListButtonView()->GetWidget()), |
| + GetBubbleArrow(container), |
| + true /* border_accepts_events */); |
| + view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
| } |
| - // Update applist button status when app list visibility is changed. |
| - Shelf::ForWindow(window)->GetAppListButtonView()->SchedulePaint(); |
| + |
| + keyboard::KeyboardController* keyboard_controller = |
| + keyboard::KeyboardController::GetInstance(); |
| + if (keyboard_controller) |
| + keyboard_controller->AddObserver(this); |
| + Shell::GetInstance()->AddPreTargetHandler(this); |
| + views::Widget* widget = view->GetWidget(); |
| + Shelf::ForWindow(widget->GetNativeWindow())->AddIconObserver(this); |
| + |
| + // By setting us as DnD recipient, the app list knows that we can |
| + // handle items. |
| + view->SetDragAndDropHostOfCurrentAppList( |
| + Shelf::ForWindow(root_window)->GetDragAndDropHostForAppList()); |
| } |
| -void AppListController::Dismiss() { |
| - if (!is_visible_) |
| - return; |
| +void AppListShowerDelegate::OnShown(aura::Window* root_window) { |
| + is_visible_ = true; |
| + // Update applist button status when app list visibility is changed. |
| + Shelf::ForWindow(root_window)->GetAppListButtonView()->SchedulePaint(); |
| +} |
| - // If the app list is currently visible, there should be an existing view. |
| +void AppListShowerDelegate::OnDismissed() { |
| + DCHECK(is_visible_); |
| DCHECK(view_); |
| is_visible_ = false; |
| @@ -264,107 +229,51 @@ void AppListController::Dismiss() { |
| ->GetShelfLayoutManager() |
| ->UpdateAutoHideState(); |
| - // Our widget is currently active. When the animation completes we'll hide |
| - // the widget, changing activation. If a menu is shown before the animation |
| - // completes then the activation change triggers the menu to close. By |
| - // deactivating now we ensure there is no activation change when the |
| - // animation completes and any menus stay open. |
| - view_->GetWidget()->Deactivate(); |
| - ScheduleAnimation(); |
| - |
| // Update applist button status when app list visibility is changed. |
| Shelf::ForWindow(view_->GetWidget()->GetNativeView()) |
| ->GetAppListButtonView() |
| ->SchedulePaint(); |
| } |
| -bool AppListController::IsVisible() const { |
| - return view_ && view_->GetWidget()->IsVisible(); |
| -} |
| - |
| -aura::Window* AppListController::GetWindow() { |
| - return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL; |
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, private: |
| - |
| -void AppListController::SetDragAndDropHostOfCurrentAppList( |
| - app_list::ApplicationDragAndDropHost* drag_and_drop_host) { |
| - if (view_ && is_visible_) |
| - view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); |
| -} |
| - |
| -void AppListController::SetView(app_list::AppListView* view) { |
| - DCHECK(view_ == NULL); |
| - DCHECK(is_visible_); |
| - |
| - view_ = view; |
| - views::Widget* widget = view_->GetWidget(); |
| - widget->AddObserver(this); |
| - keyboard::KeyboardController* keyboard_controller = |
| - keyboard::KeyboardController::GetInstance(); |
| - if (keyboard_controller) |
| - keyboard_controller->AddObserver(this); |
| - Shell::GetInstance()->AddPreTargetHandler(this); |
| - Shelf::ForWindow(widget->GetNativeWindow())->AddIconObserver(this); |
| - widget->GetNativeView()->GetRootWindow()->AddObserver(this); |
| - aura::client::GetFocusClient(widget->GetNativeView())->AddObserver(this); |
| - |
| - view_->GetAppsPaginationModel()->AddObserver(this); |
| - |
| - view_->ShowWhenReady(); |
| -} |
| - |
| -void AppListController::ResetView() { |
| - if (!view_) |
| +void AppListShowerDelegate::UpdateBounds() { |
| + if (!view_ || !is_visible_) |
| return; |
| - views::Widget* widget = view_->GetWidget(); |
| - widget->RemoveObserver(this); |
| - GetLayer(widget)->GetAnimator()->RemoveObserver(this); |
| - keyboard::KeyboardController* keyboard_controller = |
| - keyboard::KeyboardController::GetInstance(); |
| - if (keyboard_controller) |
| - keyboard_controller->RemoveObserver(this); |
| - Shell::GetInstance()->RemovePreTargetHandler(this); |
| - Shelf::ForWindow(widget->GetNativeWindow())->RemoveIconObserver(this); |
| - widget->GetNativeView()->GetRootWindow()->RemoveObserver(this); |
| - aura::client::GetFocusClient(widget->GetNativeView())->RemoveObserver(this); |
| - |
| - view_->GetAppsPaginationModel()->RemoveObserver(this); |
| + view_->UpdateBounds(); |
| - view_ = NULL; |
| + if (is_centered_) |
| + view_->SetAnchorPoint(GetCenterOfDisplayForView( |
|
xiyuan
2016/04/07 18:13:22
nit: wrap with {}
mfomitchev
2016/04/07 19:23:27
Done.
|
| + view_, GetMinimumBoundsHeightForAppList(view_))); |
| } |
| -void AppListController::ScheduleAnimation() { |
| - // Stop observing previous animation. |
| - StopObservingImplicitAnimations(); |
| +gfx::Vector2d AppListShowerDelegate::GetVisibilityAnimationOffset( |
| + aura::Window* root_window) { |
| + DCHECK(Shell::HasInstance()); |
| - views::Widget* widget = view_->GetWidget(); |
| - ui::Layer* layer = GetLayer(widget); |
| - layer->GetAnimator()->StopAnimating(); |
| + // App list needs to know the new shelf layout in order to calculate its |
| + // UI layout when AppListView visibility changes. |
| + Shell::GetPrimaryRootWindowController() |
| + ->GetShelfLayoutManager() |
| + ->UpdateAutoHideState(); |
| - gfx::Rect target_bounds; |
| - if (is_visible_) { |
| - target_bounds = widget->GetWindowBoundsInScreen(); |
| - widget->SetBounds(OffsetTowardsShelf(target_bounds, widget)); |
| - } else { |
| - target_bounds = OffsetTowardsShelf(widget->GetWindowBoundsInScreen(), |
| - widget); |
| + ShelfAlignment shelf_alignment = |
| + Shell::GetInstance()->GetShelfAlignment(root_window); |
| + switch (shelf_alignment) { |
| + case SHELF_ALIGNMENT_BOTTOM: |
| + return gfx::Vector2d(0, kAnimationOffset); |
| + case SHELF_ALIGNMENT_LEFT: |
| + return gfx::Vector2d(-kAnimationOffset, 0); |
| + case SHELF_ALIGNMENT_RIGHT: |
| + return gfx::Vector2d(kAnimationOffset, 0); |
| } |
| - |
| - ui::ScopedLayerAnimationSettings animation(layer->GetAnimator()); |
| - animation.SetTransitionDuration( |
| - base::TimeDelta::FromMilliseconds( |
| - is_visible_ ? 0 : kAnimationDurationMs)); |
| - animation.AddObserver(this); |
| - |
| - layer->SetOpacity(is_visible_ ? 1.0 : 0.0); |
| - widget->SetBounds(target_bounds); |
| + NOTREACHED(); |
| + return gfx::Vector2d(); |
| } |
| -void AppListController::ProcessLocatedEvent(ui::LocatedEvent* event) { |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// AppListShowerDelegate, private: |
| + |
| +void AppListShowerDelegate::ProcessLocatedEvent(ui::LocatedEvent* event) { |
| if (!view_ || !is_visible_) |
| return; |
| @@ -389,169 +298,59 @@ void AppListController::ProcessLocatedEvent(ui::LocatedEvent* event) { |
| aura::Window* window = view_->GetWidget()->GetNativeView()->parent(); |
| if (!window->Contains(target) && |
| !app_list::switches::ShouldNotDismissOnBlur()) { |
| - Dismiss(); |
| + shower_->Dismiss(); |
| } |
| } |
| -void AppListController::UpdateBounds() { |
| - if (!view_ || !is_visible_) |
| - return; |
| - |
| - view_->UpdateBounds(); |
| - |
| - if (is_centered_) |
| - view_->SetAnchorPoint(GetCenterOfDisplayForView( |
| - view_, GetMinimumBoundsHeightForAppList(view_))); |
| -} |
| - |
| //////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, aura::EventFilter implementation: |
| +// AppListShowerDelegate, aura::EventFilter implementation: |
| -void AppListController::OnMouseEvent(ui::MouseEvent* event) { |
| +void AppListShowerDelegate::OnMouseEvent(ui::MouseEvent* event) { |
| if (event->type() == ui::ET_MOUSE_PRESSED) |
| ProcessLocatedEvent(event); |
| } |
| -void AppListController::OnGestureEvent(ui::GestureEvent* event) { |
| +void AppListShowerDelegate::OnGestureEvent(ui::GestureEvent* event) { |
| if (event->type() == ui::ET_GESTURE_TAP_DOWN) |
| ProcessLocatedEvent(event); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, aura::FocusObserver implementation: |
| - |
| -void AppListController::OnWindowFocused(aura::Window* gained_focus, |
| - aura::Window* lost_focus) { |
| - if (view_ && is_visible_) { |
| - aura::Window* applist_window = view_->GetWidget()->GetNativeView(); |
| - aura::Window* applist_container = applist_window->parent(); |
| - |
| - if (applist_container->Contains(lost_focus) && |
| - (!gained_focus || !applist_container->Contains(gained_focus)) && |
| - !app_list::switches::ShouldNotDismissOnBlur()) { |
| - Dismiss(); |
| - } |
| - } |
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, aura::WindowObserver implementation: |
| -void AppListController::OnWindowBoundsChanged(aura::Window* root, |
| - const gfx::Rect& old_bounds, |
| - const gfx::Rect& new_bounds) { |
| - UpdateBounds(); |
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, ui::ImplicitAnimationObserver implementation: |
| - |
| -void AppListController::OnImplicitAnimationsCompleted() { |
| - if (is_visible_ ) |
| - view_->GetWidget()->Activate(); |
| - else |
| - view_->GetWidget()->Close(); |
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, views::WidgetObserver implementation: |
| - |
| -void AppListController::OnWidgetDestroying(views::Widget* widget) { |
| - DCHECK(view_->GetWidget() == widget); |
| - if (is_visible_) |
| - Dismiss(); |
| - ResetView(); |
| -} |
| - |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, keyboard::KeyboardControllerObserver implementation: |
| +// AppListShowerDelegate, keyboard::KeyboardControllerObserver implementation: |
| -void AppListController::OnKeyboardBoundsChanging(const gfx::Rect& new_bounds) { |
| +void AppListShowerDelegate::OnKeyboardBoundsChanging( |
| + const gfx::Rect& new_bounds) { |
| UpdateBounds(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, ShellObserver implementation: |
| -void AppListController::OnShelfAlignmentChanged(aura::Window* root_window) { |
| +// AppListShowerDelegate, ShellObserver implementation: |
| +void AppListShowerDelegate::OnShelfAlignmentChanged(aura::Window* root_window) { |
| if (view_) |
| view_->SetBubbleArrow(GetBubbleArrow(view_->GetWidget()->GetNativeView())); |
| } |
| -void AppListController::OnMaximizeModeStarted() { |
| +void AppListShowerDelegate::OnMaximizeModeStarted() { |
| // The "fullscreen" app-list is initialized as in a different type of window, |
| // therefore we can't switch between the fullscreen status and the normal |
| // app-list bubble. App-list should be dismissed for the transition between |
| // maximize mode (touch-view mode) and non-maximize mode, otherwise the app |
| // list tries to behave as a bubble which leads to a crash. crbug.com/510062 |
| if (IsFullscreenAppListEnabled() && is_visible_) |
| - Dismiss(); |
| + shower_->Dismiss(); |
| } |
| -void AppListController::OnMaximizeModeEnded() { |
| +void AppListShowerDelegate::OnMaximizeModeEnded() { |
| // See the comments of OnMaximizeModeStarted(). |
| if (IsFullscreenAppListEnabled() && is_visible_) |
| - Dismiss(); |
| + shower_->Dismiss(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, ShelfIconObserver implementation: |
| +// AppListShowerDelegate, ShelfIconObserver implementation: |
| -void AppListController::OnShelfIconPositionsChanged() { |
| +void AppListShowerDelegate::OnShelfIconPositionsChanged() { |
| UpdateBounds(); |
| } |
| -//////////////////////////////////////////////////////////////////////////////// |
| -// AppListController, PaginationModelObserver implementation: |
| - |
| -void AppListController::TotalPagesChanged() { |
| -} |
| - |
| -void AppListController::SelectedPageChanged(int old_selected, |
| - int new_selected) { |
| - current_apps_page_ = new_selected; |
| -} |
| - |
| -void AppListController::TransitionStarted() { |
| -} |
| - |
| -void AppListController::TransitionChanged() { |
| - // |view_| could be NULL when app list is closed with a running transition. |
| - if (!view_) |
| - return; |
| - |
| - app_list::PaginationModel* pagination_model = view_->GetAppsPaginationModel(); |
| - |
| - const app_list::PaginationModel::Transition& transition = |
| - pagination_model->transition(); |
| - if (pagination_model->is_valid_page(transition.target_page)) |
| - return; |
| - |
| - views::Widget* widget = view_->GetWidget(); |
| - ui::LayerAnimator* widget_animator = GetLayer(widget)->GetAnimator(); |
| - if (!pagination_model->IsRevertingCurrentTransition()) { |
| - // Update cached |view_bounds_| if it is the first over-scroll move and |
| - // widget does not have running animations. |
| - if (!should_snap_back_ && !widget_animator->is_animating()) |
| - view_bounds_ = widget->GetWindowBoundsInScreen(); |
| - |
| - const int current_page = pagination_model->selected_page(); |
| - const int dir = transition.target_page > current_page ? -1 : 1; |
| - |
| - const double progress = 1.0 - pow(1.0 - transition.progress, 4); |
| - const int shift = kMaxOverScrollShift * progress * dir; |
| - |
| - gfx::Rect shifted(view_bounds_); |
| - shifted.set_x(shifted.x() + shift); |
| - |
| - widget->SetBounds(shifted); |
| - |
| - should_snap_back_ = true; |
| - } else if (should_snap_back_) { |
| - should_snap_back_ = false; |
| - ui::ScopedLayerAnimationSettings animation(widget_animator); |
| - animation.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| - app_list::kOverscrollPageTransitionDurationMs)); |
| - widget->SetBounds(view_bounds_); |
| - } |
| -} |
| - |
| } // namespace ash |