Commit 303fd058 authored by Toni Barzic's avatar Toni Barzic Committed by Commit Bot

Animate exapand arrow position during app list view state change

BUG=1026343

Change-Id: Ibb517db781ceffd26e7f4fa9e00d087d9b814af3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2004053Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Toni Baržić <tbarzic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732518}
parent 28f9f5c9
......@@ -849,7 +849,7 @@ void ContentsView::AnimateToViewState(AppListViewState target_view_state,
// |layer| - The layer to transform.
// |y_offset| - The initial vertical offset - the layer's vertical offset will
// be animated to 0.
auto animate_transform = [](base::TimeDelta duration, int y_offset,
auto animate_transform = [](base::TimeDelta duration, float y_offset,
views::View* view) {
ui::Layer* layer = view->layer();
gfx::Transform transform;
......@@ -941,6 +941,10 @@ void ContentsView::AnimateToViewState(AppListViewState target_view_state,
// Schedule expand arrow repaint to ensure the view picks up the new target
// state.
expand_arrow_view()->SchedulePaint();
animate_transform(
duration,
expand_arrow_view()->CalculateOffsetFromCurrentAppListProgress(progress),
expand_arrow_view());
}
void ContentsView::SetExpandArrowViewVisibility(bool show) {
......
......@@ -85,6 +85,25 @@ constexpr int kFocusRingWidth = 2;
constexpr int kTapTargetWidth = 156;
constexpr int kTapTargetHeight = 72;
float GetCircleCenterYForAppListProgress(float progress) {
if (progress <= 1) {
return gfx::Tween::FloatValueBetween(progress, kCircleCenterClosedY,
kCircleCenterPeekingY);
}
return gfx::Tween::FloatValueBetween(std::min(1.0f, progress - 1),
kCircleCenterPeekingY,
kCircleCenterFullscreenY);
}
float GetArrowYForAppListProgress(float progress) {
if (progress <= 1) {
return gfx::Tween::FloatValueBetween(progress, kArrowClosedY,
kArrowPeekingY);
}
return gfx::Tween::FloatValueBetween(std::min(1.0f, progress - 1),
kArrowPeekingY, kArrowFullscreenY);
}
} // namespace
ExpandArrowView::ExpandArrowView(ContentsView* contents_view,
......@@ -122,23 +141,13 @@ void ExpandArrowView::PaintButtonContents(gfx::Canvas* canvas) {
SkColor circle_color = kBackgroundColor;
const float progress = app_list_view_->GetAppListTransitionProgress(
AppListView::kProgressFlagNone);
if (progress <= 1) {
// Currently transition progress is between closed and peeking state.
// Change the y positions of arrow and circle.
circle_center.set_y(gfx::Tween::FloatValueBetween(
progress, kCircleCenterClosedY, kCircleCenterPeekingY));
arrow_origin.set_y(
gfx::Tween::FloatValueBetween(progress, kArrowClosedY, kArrowPeekingY));
} else {
circle_center.set_y(GetCircleCenterYForAppListProgress(progress));
arrow_origin.set_y(GetArrowYForAppListProgress(progress));
// If transition progress is between peeking and fullscreen state, change the
// shape of the arrow and the opacity of the circle in addition to changing
// the circle and arrow position.
if (progress > 1) {
const float peeking_to_full_progress = progress - 1;
// Currently transition progress is between peeking and fullscreen state.
// Change the y positions of arrow and circle. Also change the shape of
// the arrow and the opacity of the circle.
circle_center.set_y(gfx::Tween::FloatValueBetween(
peeking_to_full_progress, kCircleCenterPeekingY,
kCircleCenterFullscreenY));
arrow_origin.set_y(gfx::Tween::FloatValueBetween(
peeking_to_full_progress, kArrowPeekingY, kArrowFullscreenY));
for (size_t i = 0; i < kPointCount; ++i) {
arrow_points[i].set_y(gfx::Tween::FloatValueBetween(
peeking_to_full_progress, kPeekingPoints[i].y(),
......@@ -374,6 +383,14 @@ void ExpandArrowView::MaybeEnableHintingAnimation(bool enabled) {
}
}
float ExpandArrowView::CalculateOffsetFromCurrentAppListProgress(
double progress) const {
const float current_progress = app_list_view_->GetAppListTransitionProgress(
AppListView::kProgressFlagNone);
return GetCircleCenterYForAppListProgress(progress) -
GetCircleCenterYForAppListProgress(current_progress);
}
void ExpandArrowView::ScheduleHintingAnimation(bool is_first_time) {
int delay_in_sec = kAnimationIntervalInSec;
if (is_first_time)
......
......@@ -54,6 +54,11 @@ class APP_LIST_EXPORT ExpandArrowView : public views::Button,
std::unique_ptr<views::InkDropMask> CreateInkDropMask() const override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
// Calculates vertical offset between expand arrow circle's positions with app
// list view drag progress |progress| and the current app list progress
// (calculated without taking app list animation state into account).
float CalculateOffsetFromCurrentAppListProgress(double progress) const;
void MaybeEnableHintingAnimation(bool enabled);
bool IsHintingAnimationRunningForTest() {
......
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