| Index: athena/wm/window_overview_mode.cc
|
| diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc
|
| index 83f700392a7a233f91d9e743889cd6646bb18430..4cb5d2c87fe1b11f164bb1fc3b9e527bcb3f3569 100644
|
| --- a/athena/wm/window_overview_mode.cc
|
| +++ b/athena/wm/window_overview_mode.cc
|
| @@ -9,6 +9,7 @@
|
| #include <vector>
|
|
|
| #include "athena/common/closure_animation_observer.h"
|
| +#include "athena/wm/public/window_list_provider.h"
|
| #include "base/bind.h"
|
| #include "base/macros.h"
|
| #include "ui/aura/scoped_window_targeter.h"
|
| @@ -52,10 +53,6 @@ namespace athena {
|
|
|
| namespace {
|
|
|
| -bool ShouldShowWindowInOverviewMode(aura::Window* window) {
|
| - return window->type() == ui::wm::WINDOW_TYPE_NORMAL;
|
| -}
|
| -
|
| // Gets the transform for the window in its current state.
|
| gfx::Transform GetTransformForState(WindowOverviewState* state) {
|
| return gfx::Tween::TransformValueBetween(state->progress,
|
| @@ -109,8 +106,10 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| public ui::CompositorAnimationObserver {
|
| public:
|
| WindowOverviewModeImpl(aura::Window* container,
|
| + const WindowListProvider* window_list_provider,
|
| WindowOverviewModeDelegate* delegate)
|
| : container_(container),
|
| + window_list_provider_(window_list_provider),
|
| delegate_(delegate),
|
| scoped_targeter_(new aura::ScopedWindowTargeter(
|
| container,
|
| @@ -128,13 +127,10 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| virtual ~WindowOverviewModeImpl() {
|
| container_->set_target_handler(container_->delegate());
|
| RemoveAnimationObserver();
|
| - const aura::Window::Windows& windows = container_->children();
|
| - for (aura::Window::Windows::const_iterator iter = windows.begin();
|
| - iter != windows.end();
|
| - ++iter) {
|
| - if ((*iter)->GetProperty(kWindowOverviewState))
|
| - RestoreWindowState(*iter);
|
| - }
|
| + aura::Window::Windows windows = window_list_provider_->GetWindowList();
|
| + if (windows.empty())
|
| + return;
|
| + std::for_each(windows.begin(), windows.end(), &RestoreWindowState);
|
| }
|
|
|
| private:
|
| @@ -142,10 +138,8 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| // positions. The transforms are set in the |kWindowOverviewState| property of
|
| // the windows.
|
| void ComputeTerminalStatesForAllWindows() {
|
| - const aura::Window::Windows& windows = container_->children();
|
| - size_t window_count = std::count_if(windows.begin(), windows.end(),
|
| - ShouldShowWindowInOverviewMode);
|
| -
|
| + aura::Window::Windows windows = window_list_provider_->GetWindowList();
|
| + size_t window_count = windows.size();
|
| size_t index = 0;
|
| const gfx::Size container_size = container_->bounds().size();
|
|
|
| @@ -154,10 +148,8 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
|
|
| for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
|
| iter != windows.rend();
|
| - ++iter) {
|
| + ++iter, ++index) {
|
| aura::Window* window = (*iter);
|
| - if (!ShouldShowWindowInOverviewMode(window))
|
| - continue;
|
|
|
| gfx::Transform top_transform;
|
| int top = (window_count - index - 1) * kGapBetweenWindowsTop;
|
| @@ -177,27 +169,20 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| state->progress = 0.f;
|
| state->shadow = CreateShadowForWindow(window);
|
| window->SetProperty(kWindowOverviewState, state);
|
| -
|
| - index++;
|
| }
|
| }
|
|
|
| // Sets the initial position for the windows for the overview mode.
|
| void SetInitialWindowStates() {
|
| + aura::Window::Windows windows = window_list_provider_->GetWindowList();
|
| + size_t window_count = windows.size();
|
| // The initial overview state of the topmost three windows.
|
| const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f };
|
| - size_t index = 0;
|
| - const aura::Window::Windows& windows = container_->children();
|
| - for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
|
| - iter != windows.rend();
|
| - ++iter) {
|
| - aura::Window* window = (*iter);
|
| - if (!window->GetProperty(kWindowOverviewState))
|
| - continue;
|
| -
|
| + for (size_t i = 0; i < window_count; ++i) {
|
| float progress = 0.f;
|
| - if (index < arraysize(kInitialProgress))
|
| - progress = kInitialProgress[index];
|
| + aura::Window* window = windows[window_count - 1 - i];
|
| + if (i < arraysize(kInitialProgress))
|
| + progress = kInitialProgress[i];
|
|
|
| scoped_refptr<ui::LayerAnimator> animator =
|
| window->layer()->GetAnimator();
|
| @@ -218,14 +203,13 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250));
|
| SetWindowProgress(window, progress);
|
| }
|
| - index++;
|
| }
|
| }
|
|
|
| scoped_ptr<wm::Shadow> CreateShadowForWindow(aura::Window* window) {
|
| scoped_ptr<wm::Shadow> shadow(new wm::Shadow());
|
| shadow->Init(wm::Shadow::STYLE_ACTIVE);
|
| - shadow->SetContentBounds(gfx::Rect(window->bounds().size()));
|
| + shadow->SetContentBounds(gfx::Rect(container_->bounds().size()));
|
| shadow->layer()->SetVisible(true);
|
| window->layer()->Add(shadow->layer());
|
| return shadow.Pass();
|
| @@ -254,7 +238,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| void DoScroll(float delta_y) {
|
| const float kEpsilon = 1e-3f;
|
| float delta_y_p = std::abs(delta_y) / GetScrollableHeight();
|
| - const aura::Window::Windows& windows = container_->children();
|
| + aura::Window::Windows windows = window_list_provider_->GetWindowList();
|
| if (delta_y < 0) {
|
| // Scroll up. Start with the top-most (i.e. behind-most in terms of
|
| // z-index) window, and try to scroll them up.
|
| @@ -263,8 +247,6 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| ++iter) {
|
| aura::Window* window = (*iter);
|
| WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
|
| - if (!state)
|
| - continue;
|
| if (state->progress > kEpsilon) {
|
| // It is possible to scroll |window| up. Scroll it up, and update
|
| // |delta_y_p| for the next window.
|
| @@ -276,14 +258,12 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| } else {
|
| // Scroll down. Start with the bottom-most (i.e. front-most in terms of
|
| // z-index) window, and try to scroll them down.
|
| - for (aura::Window::Windows::const_reverse_iterator iter =
|
| - windows.rbegin();
|
| + aura::Window::Windows::const_reverse_iterator iter;
|
| + for (iter = windows.rbegin();
|
| delta_y_p > kEpsilon && iter != windows.rend();
|
| ++iter) {
|
| aura::Window* window = (*iter);
|
| WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
|
| - if (!state)
|
| - continue;
|
| if (1.f - state->progress > kEpsilon) {
|
| // It is possible to scroll |window| down. Scroll it down, and update
|
| // |delta_y_p| for the next window.
|
| @@ -499,6 +479,8 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| const float kMinOpacity = 0.2f;
|
|
|
| aura::Window* container_;
|
| + // Provider of the stack of windows to show in the overview mode. Not owned.
|
| + const WindowListProvider* window_list_provider_;
|
| WindowOverviewModeDelegate* delegate_;
|
| scoped_ptr<aura::ScopedWindowTargeter> scoped_targeter_;
|
| scoped_ptr<ui::FlingCurve> fling_;
|
| @@ -514,9 +496,10 @@ class WindowOverviewModeImpl : public WindowOverviewMode,
|
| // static
|
| scoped_ptr<WindowOverviewMode> WindowOverviewMode::Create(
|
| aura::Window* container,
|
| + const WindowListProvider* window_list_provider,
|
| WindowOverviewModeDelegate* delegate) {
|
| return scoped_ptr<WindowOverviewMode>(
|
| - new WindowOverviewModeImpl(container, delegate));
|
| + new WindowOverviewModeImpl(container, window_list_provider, delegate));
|
| }
|
|
|
| } // namespace athena
|
|
|