| 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/screen/public/screen_manager.h" | 9 #include "athena/screen/public/screen_manager.h" |
| 10 #include "athena/wm/public/window_list_provider.h" | 10 #include "athena/wm/public/window_list_provider.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 bool SplitViewController::IsSplitViewModeActive() const { | 59 bool SplitViewController::IsSplitViewModeActive() const { |
| 60 return state_ == ACTIVE; | 60 return state_ == ACTIVE; |
| 61 } | 61 } |
| 62 | 62 |
| 63 void SplitViewController::ActivateSplitMode(aura::Window* left, | 63 void SplitViewController::ActivateSplitMode(aura::Window* left, |
| 64 aura::Window* right) { | 64 aura::Window* right) { |
| 65 aura::Window::Windows windows = window_list_provider_->GetWindowList(); | 65 aura::Window::Windows windows = window_list_provider_->GetWindowList(); |
| 66 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); | 66 aura::Window::Windows::reverse_iterator iter = windows.rbegin(); |
| 67 if (state_ == ACTIVE) { | 67 if (state_ == ACTIVE) { |
| 68 if (left_window_ == right) | 68 if (!left && left_window_ != right) |
| 69 left_window_ = left; | |
| 70 if (right_window_ == left) | |
| 71 right_window_ = right; | |
| 72 | |
| 73 if (!left) | |
| 74 left = left_window_; | 69 left = left_window_; |
| 75 if (!right) | 70 if (!right && right_window_ != left) |
| 76 right = right_window_; | 71 right = right_window_; |
| 77 } | 72 } |
| 78 | 73 |
| 79 if (!left && iter != windows.rend()) { | 74 if (!left && iter != windows.rend()) { |
| 80 left = *iter; | 75 left = *iter; |
| 81 iter++; | 76 iter++; |
| 82 if (left == right && iter != windows.rend()) { | 77 if (left == right && iter != windows.rend()) { |
| 83 left = *iter; | 78 left = *iter; |
| 84 iter++; | 79 iter++; |
| 85 } | 80 } |
| 86 } | 81 } |
| 87 | 82 |
| 88 if (!right && iter != windows.rend()) { | 83 if (!right && iter != windows.rend()) { |
| 89 right = *iter; | 84 right = *iter; |
| 90 iter++; | 85 iter++; |
| 91 if (right == left && iter != windows.rend()) { | 86 if (right == left && iter != windows.rend()) { |
| 92 right = *iter; | 87 right = *iter; |
| 93 iter++; | 88 iter++; |
| 94 } | 89 } |
| 95 } | 90 } |
| 96 | 91 |
| 92 to_hide_.clear(); |
| 93 if (left_window_ && left_window_ != left && left_window_ != right) |
| 94 to_hide_.push_back(left_window_); |
| 95 if (right_window_ && right_window_ != left && right_window_ != right) |
| 96 to_hide_.push_back(right_window_); |
| 97 |
| 97 SetState(ACTIVE); | 98 SetState(ACTIVE); |
| 98 right_window_ = right; | 99 right_window_ = right; |
| 99 left_window_ = left; | 100 left_window_ = left; |
| 100 UpdateLayout(true); | 101 UpdateLayout(true); |
| 101 } | 102 } |
| 102 | 103 |
| 103 void SplitViewController::ReplaceWindow(aura::Window* window, | 104 void SplitViewController::ReplaceWindow(aura::Window* window, |
| 104 aura::Window* replace_with) { | 105 aura::Window* replace_with) { |
| 105 CHECK(IsSplitViewModeActive()); | 106 CHECK(IsSplitViewModeActive()); |
| 106 CHECK(replace_with); | 107 CHECK(replace_with); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 right_window_->SetTransform(right_transform); | 223 right_window_->SetTransform(right_transform); |
| 223 } | 224 } |
| 224 } | 225 } |
| 225 | 226 |
| 226 void SplitViewController::OnAnimationCompleted() { | 227 void SplitViewController::OnAnimationCompleted() { |
| 227 // Animation can be cancelled when deactivated. | 228 // Animation can be cancelled when deactivated. |
| 228 if (left_window_ == NULL) | 229 if (left_window_ == NULL) |
| 229 return; | 230 return; |
| 230 UpdateLayout(false); | 231 UpdateLayout(false); |
| 231 | 232 |
| 233 for (size_t i = 0; i < to_hide_.size(); ++i) |
| 234 to_hide_[i]->Hide(); |
| 235 to_hide_.clear(); |
| 236 |
| 232 if (state_ == INACTIVE) { | 237 if (state_ == INACTIVE) { |
| 233 left_window_ = NULL; | 238 left_window_ = NULL; |
| 234 right_window_ = NULL; | 239 right_window_ = NULL; |
| 235 } | 240 } |
| 236 } | 241 } |
| 237 | 242 |
| 238 void SplitViewController::UpdateSeparatorPositionFromScrollDelta(float delta) { | 243 void SplitViewController::UpdateSeparatorPositionFromScrollDelta(float delta) { |
| 239 gfx::Screen* screen = gfx::Screen::GetScreenFor(container_); | 244 gfx::Screen* screen = gfx::Screen::GetScreenFor(container_); |
| 240 const gfx::Rect& display_bounds = | 245 const gfx::Rect& display_bounds = |
| 241 screen->GetDisplayNearestWindow(container_).bounds(); | 246 screen->GetDisplayNearestWindow(container_).bounds(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 bool SplitViewController::CanScroll() { | 314 bool SplitViewController::CanScroll() { |
| 310 // TODO(mfomitchev): return false in full screen. | 315 // TODO(mfomitchev): return false in full screen. |
| 311 bool result = (!IsSplitViewModeActive() && | 316 bool result = (!IsSplitViewModeActive() && |
| 312 window_list_provider_->GetWindowList().size() >= 2 && | 317 window_list_provider_->GetWindowList().size() >= 2 && |
| 313 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> | 318 IsLandscapeOrientation(gfx::Screen::GetNativeScreen()-> |
| 314 GetDisplayNearestWindow(container_).rotation())); | 319 GetDisplayNearestWindow(container_).rotation())); |
| 315 return result; | 320 return result; |
| 316 } | 321 } |
| 317 | 322 |
| 318 } // namespace athena | 323 } // namespace athena |
| OLD | NEW |