Chromium Code Reviews| Index: athena/wm/window_overview_mode.cc |
| diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc |
| index 7b3c73e0fc77156a093cf49fe34945a4f3cc8441..ef15e0e456b04321d8c7f7d3ddb2ec1186969d6d 100644 |
| --- a/athena/wm/window_overview_mode.cc |
| +++ b/athena/wm/window_overview_mode.cc |
| @@ -32,16 +32,17 @@ |
| namespace { |
| -struct WindowOverviewState { |
| - // The transform for when the window is at the topmost position. |
| - gfx::Transform top; |
| - |
| - // The transform for when the window is at the bottom-most position. |
| - gfx::Transform bottom; |
| +const float kOverviewDefaultScale = 0.75f; |
| +struct WindowOverviewState { |
| // The current overview state of the window. 0.f means the window is at the |
| // topmost position. 1.f means the window is at the bottom-most position. |
| float progress; |
| + |
| + float max_y; |
| + float min_y; |
|
oshima
2014/09/10 00:19:42
please document them.
sadrul
2014/09/10 04:38:40
Done.
|
| + |
| + bool split; |
| }; |
| } // namespace |
| @@ -54,18 +55,50 @@ namespace athena { |
| namespace { |
| +gfx::Transform GetTransformForSplitWindow(aura::Window* window, float scale) { |
| + int x_translate = window->bounds().width() * (1 - scale) / 2; |
| + gfx::Transform transform; |
| + transform.Translate(x_translate, window->bounds().height() * 0.65); |
|
oshima
2014/09/10 00:19:42
define const for 0.65
sadrul
2014/09/10 04:38:40
Done.
|
| + transform.Scale(scale, scale); |
| + return transform; |
| +} |
| + |
| // Gets the transform for the window in its current state. |
| -gfx::Transform GetTransformForState(WindowOverviewState* state) { |
| - return gfx::Tween::TransformValueBetween(state->progress, |
| - state->top, |
| - state->bottom); |
| +gfx::Transform GetTransformForState(aura::Window* window, |
| + WindowOverviewState* state) { |
| + if (state->split) |
| + return GetTransformForSplitWindow(window, kOverviewDefaultScale); |
| + |
| + const float kStartShrinking = 0.07; |
|
oshima
2014/09/10 00:19:42
kProgressToStartShrinking ?
sadrul
2014/09/10 04:38:40
Done.
|
| + const float kOverviewScale = 0.75f; |
| + float scale = kOverviewScale; |
| + if (state->progress < kStartShrinking) { |
| + const float kShrunkScale = 0.7f; |
|
oshima
2014/09/10 00:19:42
kShrunkMinimumScale ?
sadrul
2014/09/10 04:38:40
Done.
|
| + scale = gfx::Tween::FloatValueBetween(state->progress / kStartShrinking, |
| + kShrunkScale, |
| + kOverviewScale); |
| + } |
| + int container_width = window->parent()->bounds().width(); |
| + int window_width = window->bounds().width(); |
| + int window_x = window->bounds().x(); |
| + float x_translate = |
| + (container_width - (window_width * scale)) / 2 - window_x; |
| + float y_translate = gfx::Tween::FloatValueBetween(state->progress, |
| + state->min_y, |
| + state->max_y); |
| + gfx::Transform transform; |
| + transform.Translate(x_translate, y_translate); |
| + transform.Scale(scale, scale); |
| + return transform; |
| } |
| // Sets the progress-state for the window in the overview mode. |
| void SetWindowProgress(aura::Window* window, float progress) { |
| WindowOverviewState* state = window->GetProperty(kWindowOverviewState); |
| state->progress = progress; |
| - window->SetTransform(GetTransformForState(state)); |
| + |
| + gfx::Transform transform = GetTransformForState(window, state); |
| + window->SetTransform(transform); |
| } |
| void HideWindowIfNotVisible(aura::Window* window, |
| @@ -112,14 +145,6 @@ gfx::RectF GetTransformedBounds(aura::Window* window) { |
| return bounds; |
| } |
| -gfx::Transform GetTransformForSplitWindow(aura::Window* window, float scale) { |
| - int x_translate = window->bounds().width() * (1 - scale) / 2; |
| - gfx::Transform transform; |
| - transform.Translate(x_translate, window->bounds().height() * 0.65); |
| - transform.Scale(scale, scale); |
| - return transform; |
| -} |
| - |
| void TransformSplitWindowScale(aura::Window* window, float scale) { |
| gfx::Transform transform = window->layer()->GetTargetTransform(); |
| if (transform.Scale2d() == gfx::Vector2dF(scale, scale)) |
| @@ -208,11 +233,14 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| (window == split_view_controller_->left_window() || |
| window == split_view_controller_->right_window())) { |
| // Do not let the left/right windows be scrolled. |
| - state->top = GetTransformForSplitWindow(window, kMaxScale); |
| - state->bottom = state->top; |
| + gfx::Transform transform = |
| + GetTransformForSplitWindow(window, kOverviewDefaultScale); |
| + state->max_y = state->min_y = transform.To2dTranslation().y(); |
| + state->split = true; |
| --index; |
| continue; |
| } |
| + state->split = false; |
| UpdateTerminalStateForWindowAtIndex(window, index, windows.size()); |
| } |
| } |
| @@ -227,26 +255,15 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| const int kGapBetweenWindowsBottom = 10; |
| const int kGapBetweenWindowsTop = 5; |
| - const int container_width = container_->bounds().width(); |
| - const int window_width = window->bounds().width(); |
| - const int window_x = window->bounds().x(); |
| - gfx::Transform top_transform; |
| int top = (window_count - index - 1) * kGapBetweenWindowsTop; |
| - float x_translate = |
| - (container_width - (window_width * kMinScale)) / 2 - window_x; |
| - top_transform.Translate(x_translate, top); |
| - top_transform.Scale(kMinScale, kMinScale); |
| - |
| - gfx::Transform bottom_transform; |
| int bottom = GetScrollableHeight() - (index * kGapBetweenWindowsBottom); |
| - x_translate = (container_width - (window_width * kMaxScale)) / 2 - window_x; |
| - bottom_transform.Translate(x_translate, bottom - window->bounds().y()); |
| - bottom_transform.Scale(kMaxScale, kMaxScale); |
| WindowOverviewState* state = window->GetProperty(kWindowOverviewState); |
| CHECK(state); |
| - state->top = top_transform; |
| - state->bottom = bottom_transform; |
| + if (state->split) |
| + return; |
| + state->min_y = top; |
| + state->max_y = bottom - window->bounds().y(); |
| state->progress = 0.f; |
| } |
| @@ -349,7 +366,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| } |
| int GetScrollableHeight() const { |
| - const float kScrollableFraction = 0.65f; |
| + const float kScrollableFraction = 0.85f; |
| const float kScrollableFractionInSplit = 0.5f; |
| const float fraction = split_view_controller_->IsSplitViewModeActive() |
| ? kScrollableFractionInSplit |
| @@ -399,7 +416,8 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| WindowOverviewState* dragged_state = |
| dragged_window_->GetProperty(kWindowOverviewState); |
| CHECK(dragged_state); |
| - gfx::Transform transform = GetTransformForState(dragged_state); |
| + gfx::Transform transform = GetTransformForState(dragged_window_, |
| + dragged_state); |
| transform.Translate(-dragged_distance.x(), 0); |
| dragged_window_->SetTransform(transform); |
| @@ -451,12 +469,12 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| } |
| if (split_view_controller_->IsSplitViewModeActive()) { |
| - float scale = kMaxScale; |
| + float scale = kOverviewDefaultScale; |
| if (split_drop == split_view_controller_->left_window()) |
| scale = kMaxScaleForSplitTarget; |
| TransformSplitWindowScale(split_view_controller_->left_window(), scale); |
| - scale = kMaxScale; |
| + scale = kOverviewDefaultScale; |
| if (split_drop == split_view_controller_->right_window()) |
| scale = kMaxScaleForSplitTarget; |
| TransformSplitWindowScale(split_view_controller_->right_window(), scale); |
| @@ -498,9 +516,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| transform_x = container_->bounds().right() - transformed_bounds.x(); |
| else |
| transform_x = -(transformed_bounds.x() + transformed_bounds.width()); |
| - float scale = gfx::Tween::FloatValueBetween( |
| - dragged_state->progress, kMinScale, kMaxScale); |
| - transform.Translate(transform_x / scale, 0); |
| + transform.Translate(transform_x / kOverviewDefaultScale, 0); |
| dragged_window_->SetTransform(transform); |
| dragged_window_->layer()->SetOpacity(kMinOpacity); |
| } |
| @@ -560,7 +576,8 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| dragged_window_->layer()->GetAnimator()); |
| settings.SetPreemptionStrategy( |
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| - dragged_window_->SetTransform(GetTransformForState(dragged_state)); |
| + dragged_window_->SetTransform(GetTransformForState(dragged_window_, |
| + dragged_state)); |
| dragged_window_->layer()->SetOpacity(1.f); |
| dragged_window_ = NULL; |
| } |
| @@ -705,8 +722,6 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| } |
| const int kMinDistanceForDismissal = 300; |
| - const float kMinScale = 0.6f; |
| - const float kMaxScale = 0.75f; |
| const float kMaxOpacity = 1.0f; |
| const float kMinOpacity = 0.2f; |
| const float kMaxScaleForSplitTarget = 0.9f; |