Chromium Code Reviews| Index: athena/wm/window_overview_mode.cc |
| diff --git a/athena/wm/window_overview_mode.cc b/athena/wm/window_overview_mode.cc |
| index b37339e3cf7cca7b76aad83cc3e4ae66a5508c24..3c2cef59ff4effc73e123d72154f92240ac264d4 100644 |
| --- a/athena/wm/window_overview_mode.cc |
| +++ b/athena/wm/window_overview_mode.cc |
| @@ -110,10 +110,13 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| virtual ~WindowOverviewModeImpl() { |
| container_->set_target_handler(container_->delegate()); |
| - aura::Window::Windows windows = container_->children(); |
| - if (windows.empty()) |
| - return; |
| - std::for_each(windows.begin(), windows.end(), &RestoreWindowState); |
| + for (aura::Window::Windows::const_iterator iter = |
| + container_->children().begin(); |
| + iter != container_->children().end(); |
| + ++iter) { |
| + if ((*iter)->GetProperty(kWindowOverviewState)) |
| + RestoreWindowState(*iter); |
| + } |
| } |
| private: |
| @@ -121,8 +124,17 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| // positions. The transforms are set in the |kWindowOverviewState| property of |
| // the windows. |
| void ComputeTerminalStatesForAllWindows() { |
| - aura::Window::Windows windows = container_->children(); |
| - size_t window_count = windows.size(); |
| + size_t window_count = 0; |
| + for (aura::Window::Windows::const_iterator iter = |
| + container_->children().begin(); |
| + iter != container_->children().end(); |
| + ++iter) { |
| + if ((*iter)->type() == ui::wm::WINDOW_TYPE_NORMAL) { |
| + window_count++; |
| + (*iter)->SetProperty(kWindowOverviewState, new WindowOverviewState()); |
| + } |
| + } |
| + |
| size_t index = 0; |
| const gfx::Size container_size = container_->bounds().size(); |
| @@ -131,10 +143,14 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| const float kMinScale = 0.6f; |
| const float kMaxScale = 0.95f; |
| - for (aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
| - iter != windows.rend(); |
| - ++iter, ++index) { |
| + for (aura::Window::Windows::const_reverse_iterator iter = |
| + container_->children().rbegin(); |
| + iter != container_->children().rend(); |
| + ++iter) { |
| aura::Window* window = (*iter); |
| + WindowOverviewState* state = window->GetProperty(kWindowOverviewState); |
| + if (!state) |
| + continue; |
|
oshima
2014/08/01 22:27:46
Check the type here and skip or create a property.
mohsen
2014/08/01 23:03:18
I just wanted to check type only in one place and
|
| gfx::Transform top_transform; |
| int top = (window_count - index - 1) * kGapBetweenWindowsTop; |
| @@ -148,26 +164,30 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| bottom_transform.Translate(x_translate, bottom - window->bounds().y()); |
| bottom_transform.Scale(kMaxScale, kMaxScale); |
| - WindowOverviewState* state = new WindowOverviewState; |
| state->top = top_transform; |
| state->bottom = bottom_transform; |
| 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 = container_->children(); |
| - size_t window_count = windows.size(); |
| // The initial overview state of the topmost three windows. |
| const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f }; |
| - for (size_t i = 0; i < window_count; ++i) { |
| + size_t index = 0; |
| + for (aura::Window::Windows::const_reverse_iterator iter = |
| + container_->children().rbegin(); |
| + iter != container_->children().rend(); |
| + ++iter) { |
| + aura::Window* window = (*iter); |
| + if (!window->GetProperty(kWindowOverviewState)) |
|
oshima
2014/08/01 22:27:46
HasProperty
mohsen
2014/08/01 23:03:18
Is there a HasProperty function? Can't find it!
oshima
2014/08/01 23:10:08
Oops sorry. it's my mistkae.
|
| + continue; |
| + |
| float progress = 0.f; |
| - aura::Window* window = windows[window_count - 1 - i]; |
| - if (i < arraysize(kInitialProgress)) |
| - progress = kInitialProgress[i]; |
| + if (index < arraysize(kInitialProgress)) |
| + progress = kInitialProgress[index]; |
| scoped_refptr<ui::LayerAnimator> animator = |
| window->layer()->GetAnimator(); |
| @@ -188,6 +208,7 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds(250)); |
| SetWindowProgress(window, progress); |
| } |
| + index++; |
| } |
| } |
| @@ -222,16 +243,18 @@ class WindowOverviewModeImpl : public WindowOverviewMode, |
| // scrolling up; and positive when scrolling down. |
| void DoScroll(float delta_y) { |
| const float kEpsilon = 1e-3f; |
| - aura::Window::Windows windows = container_->children(); |
|
oshima
2014/08/01 22:27:46
const aura::Window::Windows& and you may use windo
mohsen
2014/08/01 23:03:19
Done. Here and other places like this.
|
| float delta_y_p = std::abs(delta_y) / GetScrollableHeight(); |
| 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. |
| - for (aura::Window::Windows::iterator iter = windows.begin(); |
| - delta_y_p > kEpsilon && iter != windows.end(); |
| + for (aura::Window::Windows::const_iterator iter = |
| + container_->children().begin(); |
| + delta_y_p > kEpsilon && iter != container_->children().end(); |
| ++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. |
| @@ -243,11 +266,14 @@ 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::reverse_iterator iter = windows.rbegin(); |
| - delta_y_p > kEpsilon && iter != windows.rend(); |
| + for (aura::Window::Windows::const_reverse_iterator iter = |
| + container_->children().rbegin(); |
| + delta_y_p > kEpsilon && iter != container_->children().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. |