Commit a7037544 authored by Jun Mukai's avatar Jun Mukai Committed by Commit Bot

Use AnimationDelegateViews for PaginationModel page transition

The page transition in ash::PaginationModel is used to provide
the animation effect on several views in ash, but currently
this is the default gfx::Animation which runs independently from
the compositor.

It would be plausible to run with the compositor by using
AnimationDelegateViews. The use of UnifiedSystemTralModel is
still TODO, so the use of the compositor is still optional.

Bug: 980722
Test: ash_unittests
Change-Id: I34a1cb2f8b179354a99bf5bcaad07249ca252fda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1692976
Commit-Queue: Jun Mukai <mukai@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676255}
parent 4c10fa6b
...@@ -681,7 +681,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -681,7 +681,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// This can be NULL. Only grid views inside folders have a folder delegate. // This can be NULL. Only grid views inside folders have a folder delegate.
AppsGridViewFolderDelegate* folder_delegate_ = nullptr; AppsGridViewFolderDelegate* folder_delegate_ = nullptr;
ash::PaginationModel pagination_model_; ash::PaginationModel pagination_model_{this};
// Must appear after |pagination_model_|. // Must appear after |pagination_model_|.
std::unique_ptr<ash::PaginationController> pagination_controller_; std::unique_ptr<ash::PaginationController> pagination_controller_;
......
...@@ -308,7 +308,7 @@ class APP_LIST_EXPORT ContentsView : public views::View, ...@@ -308,7 +308,7 @@ class APP_LIST_EXPORT ContentsView : public views::View,
int page_before_assistant_ = 0; int page_before_assistant_ = 0;
// Manages the pagination for the launcher pages. // Manages the pagination for the launcher pages.
ash::PaginationModel pagination_model_; ash::PaginationModel pagination_model_{this};
// If true, SetActiveState immediately. // If true, SetActiveState immediately.
bool set_active_state_without_animation_ = false; bool set_active_state_without_animation_ = false;
......
...@@ -77,7 +77,7 @@ class APP_LIST_EXPORT HorizontalPageContainer ...@@ -77,7 +77,7 @@ class APP_LIST_EXPORT HorizontalPageContainer
gfx::Vector2d GetOffsetForPageIndex(int index) const; gfx::Vector2d GetOffsetForPageIndex(int index) const;
// Manages the pagination for the horizontal pages. // Manages the pagination for the horizontal pages.
ash::PaginationModel pagination_model_; ash::PaginationModel pagination_model_{this};
// Must appear after |pagination_model_|. // Must appear after |pagination_model_|.
std::unique_ptr<ash::PaginationController> pagination_controller_; std::unique_ptr<ash::PaginationController> pagination_controller_;
......
...@@ -308,6 +308,7 @@ source_set("unit_tests") { ...@@ -308,6 +308,7 @@ source_set("unit_tests") {
"//testing/gtest", "//testing/gtest",
"//ui/aura:test_support", "//ui/aura:test_support",
"//ui/gfx:test_support", "//ui/gfx:test_support",
"//ui/views:test_support",
] ]
} }
......
...@@ -16,8 +16,9 @@ namespace { ...@@ -16,8 +16,9 @@ namespace {
constexpr int kPageTransitionDurationDampening = 3; constexpr int kPageTransitionDurationDampening = 3;
} // namespace } // namespace
PaginationModel::PaginationModel() PaginationModel::PaginationModel(views::View* view)
: total_pages_(-1), : views::AnimationDelegateViews(view),
total_pages_(-1),
selected_page_(-1), selected_page_(-1),
transition_(-1, 0), transition_(-1, 0),
pending_selected_page_(-1), pending_selected_page_(-1),
......
...@@ -12,18 +12,19 @@ ...@@ -12,18 +12,19 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "ui/gfx/animation/animation_delegate.h" #include "ui/views/animation/animation_delegate_views.h"
namespace gfx { namespace gfx {
class SlideAnimation; class SlideAnimation;
} }
namespace ash { namespace ash {
class PaginationModelObserver; class PaginationModelObserver;
// A simple pagination model that consists of two numbers: the total pages and // A simple pagination model that consists of two numbers: the total pages and
// the currently selected page. The model is a single selection model that at // the currently selected page. The model is a single selection model that at
// the most one page can become selected at any time. // the most one page can become selected at any time.
class ASH_PUBLIC_EXPORT PaginationModel : public gfx::AnimationDelegate { class ASH_PUBLIC_EXPORT PaginationModel : public views::AnimationDelegateViews {
public: public:
// Holds info for transition animation and touch scroll. // Holds info for transition animation and touch scroll.
struct Transition { struct Transition {
...@@ -45,7 +46,7 @@ class ASH_PUBLIC_EXPORT PaginationModel : public gfx::AnimationDelegate { ...@@ -45,7 +46,7 @@ class ASH_PUBLIC_EXPORT PaginationModel : public gfx::AnimationDelegate {
double progress; double progress;
}; };
PaginationModel(); explicit PaginationModel(views::View* owner_view);
~PaginationModel() override; ~PaginationModel() override;
void SetTotalPages(int total_pages); void SetTotalPages(int total_pages);
......
...@@ -74,7 +74,7 @@ void UnifiedSystemTrayModel::DBusObserver::KeyboardBrightnessChanged( ...@@ -74,7 +74,7 @@ void UnifiedSystemTrayModel::DBusObserver::KeyboardBrightnessChanged(
UnifiedSystemTrayModel::UnifiedSystemTrayModel() UnifiedSystemTrayModel::UnifiedSystemTrayModel()
: dbus_observer_(std::make_unique<DBusObserver>(this)), : dbus_observer_(std::make_unique<DBusObserver>(this)),
pagination_model_(std::make_unique<PaginationModel>()) {} pagination_model_(std::make_unique<PaginationModel>(nullptr)) {}
UnifiedSystemTrayModel::~UnifiedSystemTrayModel() = default; UnifiedSystemTrayModel::~UnifiedSystemTrayModel() = default;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace views { namespace views {
AnimationDelegateViews::AnimationDelegateViews(View* view) : view_(view) { AnimationDelegateViews::AnimationDelegateViews(View* view) : view_(view) {
if (view)
scoped_observer_.Add(view); scoped_observer_.Add(view);
} }
......
...@@ -18,7 +18,7 @@ namespace views { ...@@ -18,7 +18,7 @@ namespace views {
class View; class View;
// Provides default implementaton to adapt CompositorAnimationRunner for // Provides default implementaton to adapt CompositorAnimationRunner for
// Animation. // Animation. Falls back to the default animation runner when |view| is nullptr.
class VIEWS_EXPORT AnimationDelegateViews class VIEWS_EXPORT AnimationDelegateViews
: public gfx::AnimationDelegate, : public gfx::AnimationDelegate,
public ViewObserver, public ViewObserver,
......
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