| Index: ash/wm/overview/scoped_transform_overview_window.cc
|
| diff --git a/ash/wm/overview/scoped_transform_overview_window.cc b/ash/wm/overview/scoped_transform_overview_window.cc
|
| index 41205bf64ff8fa666af1e75383bee1332d400f6a..2c2ab62114ab212406c114542d303796b3aacda2 100644
|
| --- a/ash/wm/overview/scoped_transform_overview_window.cc
|
| +++ b/ash/wm/overview/scoped_transform_overview_window.cc
|
| @@ -8,9 +8,11 @@
|
| #include <vector>
|
|
|
| #include "ash/screen_util.h"
|
| +#include "ash/shell.h"
|
| #include "ash/shell_window_ids.h"
|
| #include "ash/wm/overview/scoped_overview_animation_settings.h"
|
| #include "ash/wm/overview/scoped_window_copy.h"
|
| +#include "ash/wm/overview/window_selector_controller.h"
|
| #include "ash/wm/overview/window_selector_item.h"
|
| #include "ash/wm/window_state.h"
|
| #include "ash/wm/window_util.h"
|
| @@ -32,12 +34,25 @@ namespace {
|
| // The opacity level that windows will be set to when they are restored.
|
| const float kRestoreWindowOpacity = 1.0f;
|
|
|
| +// The minimum opacity used during touch scroll gestures.
|
| +const float kMinimumOpacity = 0.2f;
|
| +
|
| +// The distance at which the minimum opacity should take effect.
|
| +const float kMinimumOpacityDistance = 200.0f;
|
| +
|
| aura::Window* GetTransientRoot(aura::Window* window) {
|
| while (::wm::GetTransientParent(window))
|
| window = ::wm::GetTransientParent(window);
|
| return window;
|
| }
|
|
|
| +// Calculates the window opacity from the given scroll |distance|.
|
| +float CalculateOpacityFromScrollDistance(int distance) {
|
| + float opacity =
|
| + 1.0 - static_cast<float>(abs(distance)) / kMinimumOpacityDistance;
|
| + return std::min(1.0f, std::max(kMinimumOpacity, opacity));
|
| +}
|
| +
|
| // An iterator class that traverses an aura::Window and all of it's transient
|
| // descendants.
|
| class TransientDescendantIterator {
|
| @@ -165,7 +180,7 @@ TransientDescendantIteratorRange GetTransientTreeIterator(
|
| } // namespace
|
|
|
| ScopedTransformOverviewWindow::ScopedTransformOverviewWindow(
|
| - aura::Window* window)
|
| + aura::Window* window)
|
| : window_(window),
|
| activate_button_(new TransparentActivateWindowButton(
|
| window_->GetRootWindow(), this)),
|
| @@ -302,6 +317,34 @@ void ScopedTransformOverviewWindow::SetOpacity(float opacity) {
|
| }
|
| }
|
|
|
| +void ScopedTransformOverviewWindow::Scroll(int delta_x) {
|
| + const float opacity = CalculateOpacityFromScrollDistance(delta_x);
|
| +
|
| + ScopedOverviewAnimationSettings animation_settings(
|
| + OverviewAnimationType::SELECTOR_ITEM_SCROLL,
|
| + window());
|
| + gfx::Transform new_transform;
|
| + new_transform.Translate(delta_x, 0);
|
| + new_transform.PreconcatTransform(get_overview_transform());
|
| + SetTransform(window()->GetRootWindow(), new_transform);
|
| +
|
| + SetOpacity(opacity);
|
| +}
|
| +
|
| +void ScopedTransformOverviewWindow::CancelScroll() {
|
| + ScopedOverviewAnimationSettings animation_settings(
|
| + OverviewAnimationType::SELECTOR_ITEM_SCROLL_CANCEL,
|
| + window());
|
| +
|
| + // The target opacity is set before the transform so that the
|
| + // WindowSelectorItem::OnWindowTransformed handler can properly
|
| + // update the opacity of the close button to the window's target
|
| + // opacity.
|
| + SetOpacity(1.0);
|
| + SetTransform(window()->GetRootWindow(),
|
| + get_overview_transform());
|
| +}
|
| +
|
| void ScopedTransformOverviewWindow::Select() {
|
| wm::GetWindowState(window_)->Activate();
|
| }
|
|
|