Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: athena/wm/window_overview_mode.cc

Issue 480293003: Adding functions to the window_list_provider for accessing the activities window list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the other functions as well Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "athena/wm/window_overview_mode.h" 5 #include "athena/wm/window_overview_mode.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 // Prepare the desired transforms for all the windows, and set the initial 174 // Prepare the desired transforms for all the windows, and set the initial
175 // state on the windows. 175 // state on the windows.
176 ComputeTerminalStatesForAllWindows(); 176 ComputeTerminalStatesForAllWindows();
177 SetInitialWindowStates(); 177 SetInitialWindowStates();
178 } 178 }
179 179
180 virtual ~WindowOverviewModeImpl() { 180 virtual ~WindowOverviewModeImpl() {
181 container_->set_target_handler(container_->delegate()); 181 container_->set_target_handler(container_->delegate());
182 RemoveAnimationObserver(); 182 RemoveAnimationObserver();
183 aura::Window::Windows windows = window_list_provider_->GetWindowList(); 183 aura::Window::Windows windows =
184 window_list_provider_->GetCurrentWindowList();
184 if (windows.empty()) 185 if (windows.empty())
185 return; 186 return;
186 std::for_each(windows.begin(), windows.end(), 187 std::for_each(windows.begin(), windows.end(),
187 std::bind2nd(std::ptr_fun(&RestoreWindowState), 188 std::bind2nd(std::ptr_fun(&RestoreWindowState),
188 split_view_controller_)); 189 split_view_controller_));
189 } 190 }
190 191
191 private: 192 private:
192 // Computes the transforms for all windows in both the topmost and bottom-most 193 // Computes the transforms for all windows in both the topmost and bottom-most
193 // positions. The transforms are set in the |kWindowOverviewState| property of 194 // positions. The transforms are set in the |kWindowOverviewState| property of
194 // the windows. 195 // the windows.
195 void ComputeTerminalStatesForAllWindows() { 196 void ComputeTerminalStatesForAllWindows() {
196 aura::Window::Windows windows = window_list_provider_->GetWindowList(); 197 aura::Window::Windows windows =
198 window_list_provider_->GetCurrentWindowList();
197 size_t index = 0; 199 size_t index = 0;
198 200
199 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); 201 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
200 iter != windows.rend(); 202 iter != windows.rend();
201 ++iter, ++index) { 203 ++iter, ++index) {
202 aura::Window* window = (*iter); 204 aura::Window* window = (*iter);
203 wm::SetShadowType(window, wm::SHADOW_TYPE_RECTANGULAR_ALWAYS_ACTIVE); 205 wm::SetShadowType(window, wm::SHADOW_TYPE_RECTANGULAR_ALWAYS_ACTIVE);
204 206
205 WindowOverviewState* state = new WindowOverviewState; 207 WindowOverviewState* state = new WindowOverviewState;
206 window->SetProperty(kWindowOverviewState, state); 208 window->SetProperty(kWindowOverviewState, state);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 247
246 WindowOverviewState* state = window->GetProperty(kWindowOverviewState); 248 WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
247 CHECK(state); 249 CHECK(state);
248 state->top = top_transform; 250 state->top = top_transform;
249 state->bottom = bottom_transform; 251 state->bottom = bottom_transform;
250 state->progress = 0.f; 252 state->progress = 0.f;
251 } 253 }
252 254
253 // Sets the initial position for the windows for the overview mode. 255 // Sets the initial position for the windows for the overview mode.
254 void SetInitialWindowStates() { 256 void SetInitialWindowStates() {
255 aura::Window::Windows windows = window_list_provider_->GetWindowList(); 257 aura::Window::Windows windows =
258 window_list_provider_->GetCurrentWindowList();
256 // The initial overview state of the topmost three windows. 259 // The initial overview state of the topmost three windows.
257 const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f }; 260 const float kInitialProgress[] = { 0.5f, 0.05f, 0.01f };
258 size_t index = 0; 261 size_t index = 0;
259 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin(); 262 for (aura::Window::Windows::const_reverse_iterator iter = windows.rbegin();
260 iter != windows.rend(); 263 iter != windows.rend();
261 ++iter) { 264 ++iter) {
262 float progress = 0.f; 265 float progress = 0.f;
263 aura::Window* window = *iter; 266 aura::Window* window = *iter;
264 if (split_view_controller_->IsSplitViewModeActive() && 267 if (split_view_controller_->IsSplitViewModeActive() &&
265 (window == split_view_controller_->left_window() || 268 (window == split_view_controller_->left_window() ||
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 while (target && target->parent() != container_) 308 while (target && target->parent() != container_)
306 target = target->parent(); 309 target = target->parent();
307 return target; 310 return target;
308 } 311 }
309 312
310 // Scroll the window list by |delta_y| amount. |delta_y| is negative when 313 // Scroll the window list by |delta_y| amount. |delta_y| is negative when
311 // scrolling up; and positive when scrolling down. 314 // scrolling up; and positive when scrolling down.
312 void DoScroll(float delta_y) { 315 void DoScroll(float delta_y) {
313 const float kEpsilon = 1e-3f; 316 const float kEpsilon = 1e-3f;
314 float delta_y_p = std::abs(delta_y) / GetScrollableHeight(); 317 float delta_y_p = std::abs(delta_y) / GetScrollableHeight();
315 aura::Window::Windows windows = window_list_provider_->GetWindowList(); 318 aura::Window::Windows windows =
319 window_list_provider_->GetCurrentWindowList();
316 if (delta_y < 0) { 320 if (delta_y < 0) {
317 // Scroll up. Start with the top-most (i.e. behind-most in terms of 321 // Scroll up. Start with the top-most (i.e. behind-most in terms of
318 // z-index) window, and try to scroll them up. 322 // z-index) window, and try to scroll them up.
319 for (aura::Window::Windows::const_iterator iter = windows.begin(); 323 for (aura::Window::Windows::const_iterator iter = windows.begin();
320 delta_y_p > kEpsilon && iter != windows.end(); 324 delta_y_p > kEpsilon && iter != windows.end();
321 ++iter) { 325 ++iter) {
322 aura::Window* window = (*iter); 326 aura::Window* window = (*iter);
323 WindowOverviewState* state = window->GetProperty(kWindowOverviewState); 327 WindowOverviewState* state = window->GetProperty(kWindowOverviewState);
324 if (state->progress > kEpsilon) { 328 if (state->progress > kEpsilon) {
325 // It is possible to scroll |window| up. Scroll it up, and update 329 // It is possible to scroll |window| up. Scroll it up, and update
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 transform_x = container_->bounds().right() - transformed_bounds.x(); 502 transform_x = container_->bounds().right() - transformed_bounds.x();
499 else 503 else
500 transform_x = -(transformed_bounds.x() + transformed_bounds.width()); 504 transform_x = -(transformed_bounds.x() + transformed_bounds.width());
501 float scale = gfx::Tween::FloatValueBetween( 505 float scale = gfx::Tween::FloatValueBetween(
502 dragged_state->progress, kMinScale, kMaxScale); 506 dragged_state->progress, kMinScale, kMaxScale);
503 transform.Translate(transform_x / scale, 0); 507 transform.Translate(transform_x / scale, 0);
504 dragged_window_->SetTransform(transform); 508 dragged_window_->SetTransform(transform);
505 dragged_window_->layer()->SetOpacity(kMinOpacity); 509 dragged_window_->layer()->SetOpacity(kMinOpacity);
506 } 510 }
507 511
508 const aura::Window::Windows list = window_list_provider_->GetWindowList(); 512 const aura::Window::Windows list =
513 window_list_provider_->GetCurrentWindowList();
509 CHECK(!list.empty()); 514 CHECK(!list.empty());
510 if (list.front() == dragged_window_) { 515 if (list.front() == dragged_window_) {
511 // There's no window behind |dragged_window_|. So move the windows in 516 // There's no window behind |dragged_window_|. So move the windows in
512 // front take a step back. 517 // front take a step back.
513 for (aura::Window::Windows::const_reverse_iterator iter = list.rbegin(); 518 for (aura::Window::Windows::const_reverse_iterator iter = list.rbegin();
514 iter != list.rend() && *iter != dragged_window_; 519 iter != list.rend() && *iter != dragged_window_;
515 ++iter) { 520 ++iter) {
516 aura::Window* window = *iter; 521 aura::Window* window = *iter;
517 ui::ScopedLayerAnimationSettings settings( 522 ui::ScopedLayerAnimationSettings settings(
518 window->layer()->GetAnimator()); 523 window->layer()->GetAnimator());
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 aura::Window* container, 739 aura::Window* container,
735 const WindowListProvider* window_list_provider, 740 const WindowListProvider* window_list_provider,
736 SplitViewController* split_view_controller, 741 SplitViewController* split_view_controller,
737 WindowOverviewModeDelegate* delegate) { 742 WindowOverviewModeDelegate* delegate) {
738 return scoped_ptr<WindowOverviewMode>( 743 return scoped_ptr<WindowOverviewMode>(
739 new WindowOverviewModeImpl(container, window_list_provider, 744 new WindowOverviewModeImpl(container, window_list_provider,
740 split_view_controller, delegate)); 745 split_view_controller, delegate));
741 } 746 }
742 747
743 } // namespace athena 748 } // namespace athena
OLDNEW
« athena/wm/window_list_provider_impl.cc ('K') | « athena/wm/window_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698