| OLD | NEW |
| 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/split_view_controller.h" | 5 #include "athena/wm/split_view_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "athena/wm/public/window_list_provider.h" | 9 #include "athena/wm/public/window_list_provider.h" |
| 10 #include "athena/wm/public/window_manager.h" | 10 #include "athena/wm/public/window_manager.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 WindowManager* window_manager) | 49 WindowManager* window_manager) |
| 50 : state_(INACTIVE), | 50 : state_(INACTIVE), |
| 51 container_(container), | 51 container_(container), |
| 52 window_manager_(window_manager), | 52 window_manager_(window_manager), |
| 53 window_list_provider_(window_list_provider), | 53 window_list_provider_(window_list_provider), |
| 54 current_activity_window_(NULL), | 54 current_activity_window_(NULL), |
| 55 left_window_(NULL), | 55 left_window_(NULL), |
| 56 right_window_(NULL), | 56 right_window_(NULL), |
| 57 separator_position_(0), | 57 separator_position_(0), |
| 58 weak_factory_(this) { | 58 weak_factory_(this) { |
| 59 window_manager->AddObserver(this); | 59 if (window_manager_) |
| 60 window_manager_->AddObserver(this); |
| 60 } | 61 } |
| 61 | 62 |
| 62 SplitViewController::~SplitViewController() { | 63 SplitViewController::~SplitViewController() { |
| 63 window_manager_->RemoveObserver(this); | 64 if (window_manager_) |
| 65 window_manager_->RemoveObserver(this); |
| 64 } | 66 } |
| 65 | 67 |
| 66 bool SplitViewController::IsSplitViewModeActive() const { | 68 bool SplitViewController::IsSplitViewModeActive() const { |
| 67 return state_ == ACTIVE; | 69 return state_ == ACTIVE; |
| 68 } | 70 } |
| 69 | 71 |
| 70 void SplitViewController::ActivateSplitMode(aura::Window* left, | 72 void SplitViewController::ActivateSplitMode(aura::Window* left, |
| 71 aura::Window* right) { | 73 aura::Window* right) { |
| 72 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 74 aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
| 73 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); | 75 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
| 74 if (state_ == ACTIVE) { | 76 if (state_ == ACTIVE) { |
| 77 if (left_window_ == right) |
| 78 left_window_ = left; |
| 79 if (right_window_ == left) |
| 80 right_window_ = right; |
| 81 |
| 75 if (!left) | 82 if (!left) |
| 76 left = left_window_; | 83 left = left_window_; |
| 77 if (!right) | 84 if (!right) |
| 78 right = right_window_; | 85 right = right_window_; |
| 79 } | 86 } |
| 80 | 87 |
| 81 if (!left && iter != windows.rend()) { | 88 if (!left && iter != windows.rend()) { |
| 82 left = *iter; | 89 left = *iter; |
| 83 iter++; | 90 iter++; |
| 84 if (left == right && iter != windows.rend()) { | 91 if (left == right && iter != windows.rend()) { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 280 |
| 274 void SplitViewController::ScrollUpdate(float delta) { | 281 void SplitViewController::ScrollUpdate(float delta) { |
| 275 if (state_ != SCROLLING) | 282 if (state_ != SCROLLING) |
| 276 return; | 283 return; |
| 277 UpdateSeparatorPositionFromScrollDelta(delta); | 284 UpdateSeparatorPositionFromScrollDelta(delta); |
| 278 UpdateLayout(false); | 285 UpdateLayout(false); |
| 279 } | 286 } |
| 280 | 287 |
| 281 bool SplitViewController::CanScroll() { | 288 bool SplitViewController::CanScroll() { |
| 282 // TODO(mfomitchev): return false in vertical orientation, in full screen. | 289 // TODO(mfomitchev): return false in vertical orientation, in full screen. |
| 283 bool result = (!window_manager_->IsOverviewModeActive() && | 290 bool result = (window_manager_ && !window_manager_->IsOverviewModeActive() && |
| 284 !IsSplitViewModeActive() && | 291 !IsSplitViewModeActive() && |
| 285 window_list_provider_->GetWindowList().size() >= 2); | 292 window_list_provider_->GetWindowList().size() >= 2); |
| 286 return result; | 293 return result; |
| 287 } | 294 } |
| 288 | 295 |
| 289 /////////////////////////////////////////////////////////////////////////////// | 296 /////////////////////////////////////////////////////////////////////////////// |
| 290 // WindowManagerObserver overrides | 297 // WindowManagerObserver overrides |
| 291 void SplitViewController::OnOverviewModeEnter() { | 298 void SplitViewController::OnOverviewModeEnter() { |
| 292 if (state_ == ACTIVE) { | 299 if (state_ == ACTIVE) { |
| 293 CHECK(left_window_); | 300 CHECK(left_window_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 304 state_ = INACTIVE; | 311 state_ = INACTIVE; |
| 305 left_window_ = NULL; | 312 left_window_ = NULL; |
| 306 right_window_ = NULL; | 313 right_window_ = NULL; |
| 307 current_activity_window_ = NULL; | 314 current_activity_window_ = NULL; |
| 308 } | 315 } |
| 309 | 316 |
| 310 void SplitViewController::OnOverviewModeExit() { | 317 void SplitViewController::OnOverviewModeExit() { |
| 311 } | 318 } |
| 312 | 319 |
| 313 } // namespace athena | 320 } // namespace athena |
| OLD | NEW |