| Index: ash/wm/workspace/workspace_window_resizer.cc
|
| diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
|
| index a16178cf6c68fdac09e2f5f11cc7801bd770df74..699617fe82ecc3fb21a93df0936de08772d4225b 100644
|
| --- a/ash/wm/workspace/workspace_window_resizer.cc
|
| +++ b/ash/wm/workspace/workspace_window_resizer.cc
|
| @@ -7,7 +7,11 @@
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_delegate.h"
|
| #include "ui/aura/window_property.h"
|
| +#include "ui/base/hit_test.h"
|
| +#include "ui/gfx/compositor/scoped_layer_animation_settings.h"
|
| +#include "ui/gfx/compositor/layer.h"
|
| #include "ui/gfx/screen.h"
|
| +#include "ui/gfx/transform.h"
|
|
|
| DECLARE_WINDOW_PROPERTY_TYPE(int)
|
|
|
| @@ -22,21 +26,78 @@ const aura::WindowProperty<int>* const kHeightBeforeObscuredKey =
|
|
|
| } // namespace
|
|
|
| +// static
|
| +bool WorkspaceWindowResizer::scale_windows_ = true;
|
| +
|
| WorkspaceWindowResizer::WorkspaceWindowResizer(aura::Window* window,
|
| const gfx::Point& location,
|
| int window_component,
|
| int grid_size)
|
| - : WindowResizer(window, location, window_component, grid_size) {
|
| + : WindowResizer(window, location, window_component, grid_size),
|
| + scale_window_(scale_windows_ && is_resizable() &&
|
| + window_component == HTCAPTION) {
|
| if (is_resizable() && GetHeightBeforeObscured(window) &&
|
| (!WindowTouchesBottomOfScreen() ||
|
| bounds_change() != kBoundsChange_Repositions)) {
|
| ClearHeightBeforeObscured(window);
|
| }
|
| + if (scale_window_) {
|
| + // When dragging the caption scale slightly from the center.
|
| + float scale = 1.01f;
|
| + float x_offset =
|
| + static_cast<float>(window->bounds().width()) * (scale - 1) / 2.0f;
|
| + float y_offset =
|
| + (static_cast<float>(window->bounds().width()) * (scale - 1) / 2.0f);
|
| + ui::Transform transform;
|
| + transform.SetTranslate(-x_offset, -y_offset);
|
| + transform.SetScaleX(scale);
|
| + transform.SetScaleY(scale);
|
| + window->layer()->SetTransform(transform);
|
| + }
|
| }
|
|
|
| WorkspaceWindowResizer::~WorkspaceWindowResizer() {
|
| }
|
|
|
| +// static
|
| +void WorkspaceWindowResizer::SetScaleWindowsForTest(bool value) {
|
| + scale_windows_ = value;
|
| +}
|
| +
|
| +void WorkspaceWindowResizer::CompleteDrag() {
|
| + if (!did_move_or_resize() || grid_size() <= 1) {
|
| + if (scale_window_) {
|
| + ui::ScopedLayerAnimationSettings scoped_setter(
|
| + window()->layer()->GetAnimator());
|
| + window()->layer()->SetTransform(ui::Transform());
|
| + }
|
| + return;
|
| + }
|
| +
|
| + gfx::Rect new_bounds(GetFinalBounds());
|
| + if (new_bounds.size() != window()->bounds().size()) {
|
| + // Don't attempt to animate a size change.
|
| + window()->SetBounds(new_bounds);
|
| + if (scale_window_)
|
| + window()->layer()->SetTransform(ui::Transform());
|
| + return;
|
| + }
|
| +
|
| + ui::ScopedLayerAnimationSettings scoped_setter(
|
| + window()->layer()->GetAnimator());
|
| + // Use a small duration since the grid is small.
|
| + scoped_setter.SetTransitionDuration(base::TimeDelta::FromMilliseconds(100));
|
| + window()->SetBounds(new_bounds);
|
| + if (scale_window_)
|
| + window()->layer()->SetTransform(ui::Transform());
|
| +}
|
| +
|
| +void WorkspaceWindowResizer::RevertDrag() {
|
| + if (scale_window_)
|
| + window()->layer()->SetTransform(ui::Transform());
|
| + WindowResizer::RevertDrag();
|
| +}
|
| +
|
| gfx::Rect WorkspaceWindowResizer::GetBoundsForDrag(const gfx::Point& location) {
|
| if (!is_resizable())
|
| return WindowResizer::GetBoundsForDrag(location);
|
|
|