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

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

Issue 653563004: NULL -> nullptr under athena/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « athena/wm/split_view_controller.h ('k') | athena/wm/split_view_controller_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return window_; 126 return window_;
127 } 127 }
128 128
129 return WindowTargeter::FindTargetForLocatedEvent(root, event); 129 return WindowTargeter::FindTargetForLocatedEvent(root, event);
130 } 130 }
131 131
132 // aura::WindowObserver: 132 // aura::WindowObserver:
133 virtual void OnWindowDestroying(aura::Window* window) override { 133 virtual void OnWindowDestroying(aura::Window* window) override {
134 DCHECK_EQ(window, window_); 134 DCHECK_EQ(window, window_);
135 window_->RemoveObserver(this); 135 window_->RemoveObserver(this);
136 window_ = NULL; 136 window_ = nullptr;
137 } 137 }
138 138
139 // Minimum dimension of a target to be comfortably touchable. 139 // Minimum dimension of a target to be comfortably touchable.
140 // The effective touch target area of |priority_window_| gets expanded so 140 // The effective touch target area of |priority_window_| gets expanded so
141 // that it's width and height is ayt least |kMinTouchDimension|. 141 // that it's width and height is ayt least |kMinTouchDimension|.
142 int const kMinTouchDimension = 26; 142 int const kMinTouchDimension = 26;
143 143
144 aura::Window* window_; 144 aura::Window* window_;
145 views::View* priority_view_; 145 views::View* priority_view_;
146 146
(...skipping 16 matching lines...) Expand all
163 } 163 }
164 164
165 } // namespace 165 } // namespace
166 166
167 SplitViewController::SplitViewController( 167 SplitViewController::SplitViewController(
168 aura::Window* container, 168 aura::Window* container,
169 WindowListProvider* window_list_provider) 169 WindowListProvider* window_list_provider)
170 : state_(INACTIVE), 170 : state_(INACTIVE),
171 container_(container), 171 container_(container),
172 window_list_provider_(window_list_provider), 172 window_list_provider_(window_list_provider),
173 left_window_(NULL), 173 left_window_(nullptr),
174 right_window_(NULL), 174 right_window_(nullptr),
175 divider_position_(0), 175 divider_position_(0),
176 divider_scroll_start_position_(0), 176 divider_scroll_start_position_(0),
177 divider_widget_(NULL), 177 divider_widget_(nullptr),
178 drag_handle_(NULL), 178 drag_handle_(nullptr),
179 weak_factory_(this) { 179 weak_factory_(this) {
180 } 180 }
181 181
182 SplitViewController::~SplitViewController() { 182 SplitViewController::~SplitViewController() {
183 } 183 }
184 184
185 bool SplitViewController::CanActivateSplitViewMode() const { 185 bool SplitViewController::CanActivateSplitViewMode() const {
186 // TODO(mfomitchev): return false in full screen. 186 // TODO(mfomitchev): return false in full screen.
187 return (!IsSplitViewModeActive() && 187 return (!IsSplitViewModeActive() &&
188 window_list_provider_->GetWindowList().size() >= 2 && 188 window_list_provider_->GetWindowList().size() >= 2 &&
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 void SplitViewController::ReplaceWindow(aura::Window* window, 259 void SplitViewController::ReplaceWindow(aura::Window* window,
260 aura::Window* replace_with) { 260 aura::Window* replace_with) {
261 CHECK(IsSplitViewModeActive()); 261 CHECK(IsSplitViewModeActive());
262 CHECK(replace_with); 262 CHECK(replace_with);
263 CHECK(window == left_window_ || window == right_window_); 263 CHECK(window == left_window_ || window == right_window_);
264 CHECK(replace_with != left_window_ && replace_with != right_window_); 264 CHECK(replace_with != left_window_ && replace_with != right_window_);
265 DCHECK(window_list_provider_->IsWindowInList(replace_with)); 265 DCHECK(window_list_provider_->IsWindowInList(replace_with));
266 266
267 aura::Window* not_replaced = NULL; 267 aura::Window* not_replaced = nullptr;
268 if (window == left_window_) { 268 if (window == left_window_) {
269 left_window_ = replace_with; 269 left_window_ = replace_with;
270 not_replaced = right_window_; 270 not_replaced = right_window_;
271 } else { 271 } else {
272 right_window_ = replace_with; 272 right_window_ = replace_with;
273 not_replaced = left_window_; 273 not_replaced = left_window_;
274 } 274 }
275 UpdateLayout(false); 275 UpdateLayout(false);
276 276
277 wm::ActivateWindow(replace_with); 277 wm::ActivateWindow(replace_with);
278 window_list_provider_->StackWindowBehindTo(not_replaced, replace_with); 278 window_list_provider_->StackWindowBehindTo(not_replaced, replace_with);
279 279
280 window->SetTransform(gfx::Transform()); 280 window->SetTransform(gfx::Transform());
281 window->Hide(); 281 window->Hide();
282 } 282 }
283 283
284 void SplitViewController::DeactivateSplitMode() { 284 void SplitViewController::DeactivateSplitMode() {
285 CHECK_EQ(ACTIVE, state_); 285 CHECK_EQ(ACTIVE, state_);
286 SetState(INACTIVE); 286 SetState(INACTIVE);
287 UpdateLayout(false); 287 UpdateLayout(false);
288 left_window_ = right_window_ = NULL; 288 left_window_ = right_window_ = nullptr;
289 } 289 }
290 290
291 void SplitViewController::InitializeDivider() { 291 void SplitViewController::InitializeDivider() {
292 CHECK(!divider_widget_); 292 CHECK(!divider_widget_);
293 CHECK(!drag_handle_); 293 CHECK(!drag_handle_);
294 294
295 drag_handle_ = CreateDragHandleView(DRAG_HANDLE_HORIZONTAL, 295 drag_handle_ = CreateDragHandleView(DRAG_HANDLE_HORIZONTAL,
296 this, 296 this,
297 kDragHandleWidth, 297 kDragHandleWidth,
298 kDragHandleHeight); 298 kDragHandleHeight);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 return gfx::Rect(divider_position_ + kDividerWidth / 2, 366 return gfx::Rect(divider_position_ + kDividerWidth / 2,
367 0, 367 0,
368 container_width - divider_position_ - kDividerWidth / 2, 368 container_width - divider_position_ - kDividerWidth / 2,
369 work_area.height()); 369 work_area.height());
370 } 370 }
371 371
372 void SplitViewController::SetState(SplitViewController::State state) { 372 void SplitViewController::SetState(SplitViewController::State state) {
373 if (state_ == state) 373 if (state_ == state)
374 return; 374 return;
375 375
376 if (divider_widget_ == NULL) 376 if (divider_widget_ == nullptr)
377 InitializeDivider(); 377 InitializeDivider();
378 378
379 state_ = state; 379 state_ = state;
380 380
381 ScreenManager::Get()->SetRotationLocked(state_ != INACTIVE); 381 ScreenManager::Get()->SetRotationLocked(state_ != INACTIVE);
382 if (state == INACTIVE) 382 if (state == INACTIVE)
383 HideDivider(); 383 HideDivider();
384 else 384 else
385 ShowDivider(); 385 ShowDivider();
386 } 386 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if (right_window_->bounds().width() >= right_area_bounds.width()) { 447 if (right_window_->bounds().width() >= right_area_bounds.width()) {
448 right_transform.Translate( 448 right_transform.Translate(
449 right_area_bounds.x() - right_window_->bounds().x(), 0); 449 right_area_bounds.x() - right_window_->bounds().x(), 0);
450 } else { 450 } else {
451 right_transform = 451 right_transform =
452 GetTransformForBounds(right_window_->bounds(), right_area_bounds); 452 GetTransformForBounds(right_window_->bounds(), right_area_bounds);
453 } 453 }
454 SetWindowTransforms( 454 SetWindowTransforms(
455 left_transform, right_transform, divider_transform, animate); 455 left_transform, right_transform, divider_transform, animate);
456 } 456 }
457 // Note: |left_window_| and |right_window_| may be NULL if calling 457 // Note: |left_window_| and |right_window_| may be nullptr if calling
458 // SetWindowTransforms(): 458 // SetWindowTransforms():
459 // - caused the in-progress animation to abort. 459 // - caused the in-progress animation to abort.
460 // - started a zero duration animation. 460 // - started a zero duration animation.
461 } 461 }
462 462
463 void SplitViewController::SetWindowTransforms( 463 void SplitViewController::SetWindowTransforms(
464 const gfx::Transform& left_transform, 464 const gfx::Transform& left_transform,
465 const gfx::Transform& right_transform, 465 const gfx::Transform& right_transform,
466 const gfx::Transform& divider_transform, 466 const gfx::Transform& divider_transform,
467 bool animate) { 467 bool animate) {
(...skipping 20 matching lines...) Expand all
488 right_window_->SetTransform(right_transform); 488 right_window_->SetTransform(right_transform);
489 } else { 489 } else {
490 left_window_->SetTransform(left_transform); 490 left_window_->SetTransform(left_transform);
491 divider_widget_->GetNativeWindow()->SetTransform(divider_transform); 491 divider_widget_->GetNativeWindow()->SetTransform(divider_transform);
492 right_window_->SetTransform(right_transform); 492 right_window_->SetTransform(right_transform);
493 } 493 }
494 } 494 }
495 495
496 void SplitViewController::OnAnimationCompleted() { 496 void SplitViewController::OnAnimationCompleted() {
497 // Animation can be cancelled when deactivated. 497 // Animation can be cancelled when deactivated.
498 if (left_window_ == NULL) 498 if (left_window_ == nullptr)
499 return; 499 return;
500 UpdateLayout(false); 500 UpdateLayout(false);
501 501
502 for (size_t i = 0; i < to_hide_.size(); ++i) 502 for (size_t i = 0; i < to_hide_.size(); ++i)
503 to_hide_[i]->Hide(); 503 to_hide_[i]->Hide();
504 to_hide_.clear(); 504 to_hide_.clear();
505 505
506 if (state_ == INACTIVE) { 506 if (state_ == INACTIVE) {
507 left_window_ = NULL; 507 left_window_ = nullptr;
508 right_window_ = NULL; 508 right_window_ = nullptr;
509 } 509 }
510 } 510 }
511 511
512 int SplitViewController::GetDefaultDividerPosition() { 512 int SplitViewController::GetDefaultDividerPosition() {
513 return container_->GetBoundsInScreen().width() / 2; 513 return container_->GetBoundsInScreen().width() / 2;
514 } 514 }
515 515
516 float SplitViewController::GetMaxDistanceFromMiddleForTest() const { 516 float SplitViewController::GetMaxDistanceFromMiddleForTest() const {
517 return kMaxDistanceFromMiddle; 517 return kMaxDistanceFromMiddle;
518 } 518 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 ShowDivider(); 634 ShowDivider();
635 } 635 }
636 636
637 void SplitViewController::OnSplitViewModeEnter() { 637 void SplitViewController::OnSplitViewModeEnter() {
638 } 638 }
639 639
640 void SplitViewController::OnSplitViewModeExit() { 640 void SplitViewController::OnSplitViewModeExit() {
641 } 641 }
642 642
643 } // namespace athena 643 } // namespace athena
OLDNEW
« no previous file with comments | « athena/wm/split_view_controller.h ('k') | athena/wm/split_view_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698