Commit def06165 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

desks: Shift desks items when swiping to close overview.

Test: manual
Bug: 1005354
Change-Id: I5674ed65831e640ddb17012ac41eb7e694f975f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1818716
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699537}
parent 11d7f93d
...@@ -1186,14 +1186,25 @@ OverviewGrid::UpdateYPositionAndOpacity( ...@@ -1186,14 +1186,25 @@ OverviewGrid::UpdateYPositionAndOpacity(
int new_y, int new_y,
float opacity, float opacity,
OverviewSession::UpdateAnimationSettingsCallback callback) { OverviewSession::UpdateAnimationSettingsCallback callback) {
DCHECK(!window_list_.empty());
// Translate the window items to |new_y| with the opacity. Observe the
// animation of the first window.
std::unique_ptr<ui::ScopedLayerAnimationSettings> settings_to_observe; std::unique_ptr<ui::ScopedLayerAnimationSettings> settings_to_observe;
if (desks_widget_) {
aura::Window* window = desks_widget_->GetNativeWindow();
ui::Layer* layer = window->layer();
if (!callback.is_null()) {
settings_to_observe = std::make_unique<ui::ScopedLayerAnimationSettings>(
layer->GetAnimator());
callback.Run(settings_to_observe.get());
}
window->SetTransform(gfx::Transform(1.f, 0.f, 0.f, 1.f, 0.f, -new_y));
layer->SetOpacity(opacity);
}
// Translate the window items to |new_y| with the opacity. Observe the
// animation of the last item, if any.
for (const auto& window_item : window_list_) { for (const auto& window_item : window_list_) {
auto new_settings = auto new_settings =
window_item->UpdateYPositionAndOpacity(new_y, opacity, callback); window_item->UpdateYPositionAndOpacity(new_y, opacity, callback);
if (!settings_to_observe && new_settings) if (new_settings)
settings_to_observe = std::move(new_settings); settings_to_observe = std::move(new_settings);
} }
return settings_to_observe; return settings_to_observe;
......
...@@ -227,6 +227,7 @@ class ASH_EXPORT OverviewGrid : public ScreenRotationAnimatorObserver, ...@@ -227,6 +227,7 @@ class ASH_EXPORT OverviewGrid : public ScreenRotationAnimatorObserver,
// transformation and opacity change should be animated. The animation // transformation and opacity change should be animated. The animation
// settings will be set by the caller via |callback|. Returns the settings of // settings will be set by the caller via |callback|. Returns the settings of
// the first window we are animating; the caller will observe this animation. // the first window we are animating; the caller will observe this animation.
// The returned object may be nullptr.
std::unique_ptr<ui::ScopedLayerAnimationSettings> UpdateYPositionAndOpacity( std::unique_ptr<ui::ScopedLayerAnimationSettings> UpdateYPositionAndOpacity(
int new_y, int new_y,
float opacity, float opacity,
......
...@@ -315,12 +315,10 @@ OverviewItem::UpdateYPositionAndOpacity( ...@@ -315,12 +315,10 @@ OverviewItem::UpdateYPositionAndOpacity(
// Alter the y-translation. Offset by the window location relative to the // Alter the y-translation. Offset by the window location relative to the
// grid. // grid.
gfx::Transform transform = layer->transform(); gfx::Transform transform = layer->transform();
transform.matrix().setFloat(1, 3, transform.matrix().setFloat(1, 3, initial_y - new_grid_y);
static_cast<float>(initial_y - new_grid_y));
layer->SetTransform(transform); layer->SetTransform(transform);
// Return the first layer for the caller to observe. if (settings)
if (!settings_to_observe)
settings_to_observe = std::move(settings); settings_to_observe = std::move(settings);
} }
......
...@@ -617,23 +617,25 @@ OverviewSession::UpdateGridAtLocationYPositionAndOpacity( ...@@ -617,23 +617,25 @@ OverviewSession::UpdateGridAtLocationYPositionAndOpacity(
if (!grid) if (!grid)
return nullptr; return nullptr;
std::unique_ptr<ui::ScopedLayerAnimationSettings> settings =
grid->UpdateYPositionAndOpacity(new_y, opacity, callback);
if (no_windows_widget_) { if (no_windows_widget_) {
// Translate and fade |no_windows_widget_| if it is visible.
DCHECK(grid->empty()); DCHECK(grid->empty());
// Translate and fade |no_windows_widget_| if it is visible. Overwrite
// |settings| to observe |no_windows_widget| if necessary.
aura::Window* window = no_windows_widget_->GetNativeWindow(); aura::Window* window = no_windows_widget_->GetNativeWindow();
std::unique_ptr<ui::ScopedLayerAnimationSettings> settings; ui::Layer* layer = window->layer();
if (!callback.is_null()) { if (!callback.is_null()) {
settings = std::make_unique<ui::ScopedLayerAnimationSettings>( settings = std::make_unique<ui::ScopedLayerAnimationSettings>(
window->layer()->GetAnimator()); layer->GetAnimator());
callback.Run(settings.get()); callback.Run(settings.get());
} }
window->SetTransform( window->SetTransform(gfx::Transform(1.f, 0.f, 0.f, 1.f, 0.f, -new_y));
gfx::Transform(1.f, 0.f, 0.f, 1.f, 0.f, static_cast<float>(-new_y))); layer->SetOpacity(opacity);
window->layer()->SetOpacity(opacity);
return settings;
} }
return grid->UpdateYPositionAndOpacity(new_y, opacity, callback); return settings;
} }
void OverviewSession::UpdateRoundedCornersAndShadow() { void OverviewSession::UpdateRoundedCornersAndShadow() {
......
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