| Index: ash/wm/overview/scoped_transform_overview_window.cc
|
| diff --git a/ash/wm/overview/window_selector_window.cc b/ash/wm/overview/scoped_transform_overview_window.cc
|
| similarity index 82%
|
| copy from ash/wm/overview/window_selector_window.cc
|
| copy to ash/wm/overview/scoped_transform_overview_window.cc
|
| index 226c782462273c8d71e05f3ce55544006683cd3f..40c57e3516096b0721c367778a85f18f75576ae4 100644
|
| --- a/ash/wm/overview/window_selector_window.cc
|
| +++ b/ash/wm/overview/scoped_transform_overview_window.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "ash/wm/overview/window_selector_window.h"
|
| +#include "ash/wm/overview/scoped_transform_overview_window.h"
|
|
|
| #include "ash/shell.h"
|
| #include "ui/aura/client/aura_constants.h"
|
| @@ -23,8 +23,6 @@ namespace ash {
|
|
|
| namespace {
|
|
|
| -const int kOverviewWindowTransitionMilliseconds = 100;
|
| -
|
| // Creates a copy of |window| with |recreated_layer| in the |target_root|.
|
| views::Widget* CreateCopyOfWindow(aura::RootWindow* target_root,
|
| aura::Window* src_window,
|
| @@ -137,7 +135,7 @@ class WindowSelectorAnimationSettings
|
| SetPreemptionStrategy(
|
| ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
|
| SetTransitionDuration(base::TimeDelta::FromMilliseconds(
|
| - kOverviewWindowTransitionMilliseconds));
|
| + ScopedTransformOverviewWindow::kTransitionMilliseconds));
|
| }
|
|
|
| virtual ~WindowSelectorAnimationSettings() {
|
| @@ -146,16 +144,20 @@ class WindowSelectorAnimationSettings
|
|
|
| } // namespace
|
|
|
| -WindowSelectorWindow::WindowSelectorWindow(aura::Window* window)
|
| +const int ScopedTransformOverviewWindow::kTransitionMilliseconds = 100;
|
| +
|
| +ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(
|
| + aura::Window* window)
|
| : window_(window),
|
| window_copy_(NULL),
|
| layer_(NULL),
|
| minimized_(window->GetProperty(aura::client::kShowStateKey) ==
|
| ui::SHOW_STATE_MINIMIZED),
|
| + overview_started_(false),
|
| original_transform_(window->layer()->GetTargetTransform()) {
|
| }
|
|
|
| -WindowSelectorWindow::~WindowSelectorWindow() {
|
| +ScopedTransformOverviewWindow::~ScopedTransformOverviewWindow() {
|
| if (window_) {
|
| WindowSelectorAnimationSettings animation_settings(window_);
|
| gfx::Transform transform;
|
| @@ -166,7 +168,7 @@ WindowSelectorWindow::~WindowSelectorWindow() {
|
| // to SHOW_STATE_MINIMIZED will not animate the window from its original
|
| // bounds to the minimized position.
|
| window_->layer()->SetOpacity(0);
|
| - window_->layer()->SetVisible(false);
|
| + window_->Hide();
|
| window_->SetProperty(aura::client::kShowStateKey,
|
| ui::SHOW_STATE_MINIMIZED);
|
| }
|
| @@ -191,40 +193,56 @@ WindowSelectorWindow::~WindowSelectorWindow() {
|
| }
|
| }
|
|
|
| -bool WindowSelectorWindow::Contains(const aura::Window* window) const {
|
| +bool ScopedTransformOverviewWindow::Contains(const aura::Window* window) const {
|
| if (window_copy_ && window_copy_->GetNativeWindow()->Contains(window))
|
| return true;
|
| return window_->Contains(window);
|
| }
|
|
|
| -void WindowSelectorWindow::RestoreWindowOnExit() {
|
| +void ScopedTransformOverviewWindow::RestoreWindow() {
|
| + if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) ==
|
| + ui::SHOW_STATE_MINIMIZED) {
|
| + window_->Show();
|
| + }
|
| +}
|
| +
|
| +void ScopedTransformOverviewWindow::RestoreWindowOnExit() {
|
| minimized_ = false;
|
| original_transform_ = gfx::Transform();
|
| }
|
|
|
| -void WindowSelectorWindow::OnWindowDestroyed() {
|
| +void ScopedTransformOverviewWindow::OnWindowDestroyed() {
|
| window_ = NULL;
|
| }
|
|
|
| -void WindowSelectorWindow::TransformToFitBounds(
|
| - aura::RootWindow* root_window,
|
| - const gfx::Rect& target_bounds) {
|
| - if (minimized_ && window_->GetProperty(aura::client::kShowStateKey) ==
|
| - ui::SHOW_STATE_MINIMIZED) {
|
| - window_->Show();
|
| - }
|
| - fit_bounds_ = target_bounds;
|
| - const gfx::Rect bounds = window_->GetBoundsInScreen();
|
| +gfx::Transform ScopedTransformOverviewWindow::
|
| + GetTransformForRectPreservingAspectRatio(const gfx::Rect& rect,
|
| + const gfx::Rect& bounds) {
|
| + DCHECK(!rect.IsEmpty());
|
| + DCHECK(!bounds.IsEmpty());
|
| float scale = std::min(1.0f,
|
| - std::min(static_cast<float>(target_bounds.width()) / bounds.width(),
|
| - static_cast<float>(target_bounds.height()) / bounds.height()));
|
| + std::min(static_cast<float>(bounds.width()) / rect.width(),
|
| + static_cast<float>(bounds.height()) / rect.height()));
|
| gfx::Transform transform;
|
| gfx::Vector2d offset(
|
| - 0.5 * (target_bounds.width() - scale * bounds.width()),
|
| - 0.5 * (target_bounds.height() - scale * bounds.height()));
|
| - transform.Translate(target_bounds.x() - bounds.x() + offset.x(),
|
| - target_bounds.y() - bounds.y() + offset.y());
|
| + 0.5 * (bounds.width() - scale * rect.width()),
|
| + 0.5 * (bounds.height() - scale * rect.height()));
|
| + transform.Translate(bounds.x() - rect.x() + offset.x(),
|
| + bounds.y() - rect.y() + offset.y());
|
| transform.Scale(scale, scale);
|
| + return transform;
|
| +}
|
| +
|
| +void ScopedTransformOverviewWindow::SetTransform(
|
| + aura::RootWindow* root_window,
|
| + const gfx::Transform& transform) {
|
| + // If this is the first transform, perform one-time window modifications
|
| + // necessary for overview mode.
|
| + if (!overview_started_) {
|
| + OnOverviewStarted();
|
| + overview_started_ = true;
|
| + }
|
| +
|
| if (root_window != window_->GetRootWindow()) {
|
| if (!window_copy_) {
|
| DCHECK(!layer_);
|
| @@ -239,4 +257,8 @@ void WindowSelectorWindow::TransformToFitBounds(
|
| window_->SetTransform(transform);
|
| }
|
|
|
| +void ScopedTransformOverviewWindow::OnOverviewStarted() {
|
| + RestoreWindow();
|
| +}
|
| +
|
| } // namespace ash
|
|
|