Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8926)

Unified Diff: athena/wm/window_overview_mode.cc

Issue 556043002: athena: Change the scrolling behaviour of the windows in overview mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fbab9979c7298634d691ee963f8abab9cb492c91 100644
--- a/athena/wm/window_overview_mode.cc
+++ b/athena/wm/window_overview_mode.cc
@@ -32,16 +32,21 @@
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;
+
+ // The top-most and bottom-most vertical position of the window in overview
+ // mode.
+ float max_y;
+ float min_y;
+
+ // |split| is set if this window is one of the two split windows in split-view
+ // mode.
+ bool split;
};
} // namespace
@@ -54,18 +59,51 @@ namespace athena {
namespace {
+gfx::Transform GetTransformForSplitWindow(aura::Window* window, float scale) {
+ const float kScrollWindowPositionInOverview = 0.65f;
+ int x_translate = window->bounds().width() * (1 - scale) / 2;
+ gfx::Transform transform;
+ transform.Translate(
+ x_translate, window->bounds().height() * kScrollWindowPositionInOverview);
+ 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 kProgressToStartShrinking = 0.07;
+ const float kOverviewScale = 0.75f;
+ float scale = kOverviewScale;
+ if (state->progress < kProgressToStartShrinking) {
+ const float kShrunkMinimumScale = 0.7f;
+ scale = gfx::Tween::FloatValueBetween(
+ state->progress / kProgressToStartShrinking,
+ kShrunkMinimumScale,
+ 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 +150,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 +238,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 +260,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 +371,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 +421,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 +474,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 +521,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 +581,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 +727,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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698