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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 1901773002: Removes most of aura dependencies from DefaultState (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wm_window_positioner
Patch Set: comment Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // Bail out early when there is no |workspace_controller_|, which happens 271 // Bail out early when there is no |workspace_controller_|, which happens
272 // during shutdown after PrepareForShutdown. Also bail before a shelf exists. 272 // during shutdown after PrepareForShutdown. Also bail before a shelf exists.
273 if (!workspace_controller_ || !shelf_->shelf()) 273 if (!workspace_controller_ || !shelf_->shelf())
274 return; 274 return;
275 275
276 if (state_.is_screen_locked || state_.is_adding_user_screen) { 276 if (state_.is_screen_locked || state_.is_adding_user_screen) {
277 SetState(SHELF_VISIBLE); 277 SetState(SHELF_VISIBLE);
278 } else { 278 } else {
279 // TODO(zelidrag): Verify shelf drag animation still shows on the device 279 // TODO(zelidrag): Verify shelf drag animation still shows on the device
280 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN. 280 // when we are in SHELF_AUTO_HIDE_ALWAYS_HIDDEN.
281 WorkspaceWindowState window_state(workspace_controller_->GetWindowState()); 281 wm::WorkspaceWindowState window_state(
282 workspace_controller_->GetWindowState());
282 switch (window_state) { 283 switch (window_state) {
283 case WORKSPACE_WINDOW_STATE_FULL_SCREEN: { 284 case wm::WORKSPACE_WINDOW_STATE_FULL_SCREEN: {
284 const aura::Window* fullscreen_window = GetRootWindowController( 285 const aura::Window* fullscreen_window = GetRootWindowController(
285 root_window_)->GetWindowForFullscreenMode(); 286 root_window_)->GetWindowForFullscreenMode();
286 if (fullscreen_window && wm::GetWindowState(fullscreen_window)-> 287 if (fullscreen_window && wm::GetWindowState(fullscreen_window)->
287 hide_shelf_when_fullscreen()) { 288 hide_shelf_when_fullscreen()) {
288 SetState(SHELF_HIDDEN); 289 SetState(SHELF_HIDDEN);
289 } else { 290 } else {
290 // The shelf is sometimes not hidden when in immersive fullscreen. 291 // The shelf is sometimes not hidden when in immersive fullscreen.
291 // Force the shelf to be auto hidden in this case. 292 // Force the shelf to be auto hidden in this case.
292 SetState(SHELF_AUTO_HIDE); 293 SetState(SHELF_AUTO_HIDE);
293 } 294 }
294 break; 295 break;
295 } 296 }
296 297
297 case WORKSPACE_WINDOW_STATE_MAXIMIZED: 298 case wm::WORKSPACE_WINDOW_STATE_MAXIMIZED:
298 SetState(CalculateShelfVisibility()); 299 SetState(CalculateShelfVisibility());
299 break; 300 break;
300 301
301 case WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF: 302 case wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF:
302 case WORKSPACE_WINDOW_STATE_DEFAULT: 303 case wm::WORKSPACE_WINDOW_STATE_DEFAULT:
303 SetState(CalculateShelfVisibility()); 304 SetState(CalculateShelfVisibility());
304 SetWindowOverlapsShelf(window_state == 305 SetWindowOverlapsShelf(
305 WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF); 306 window_state == wm::WORKSPACE_WINDOW_STATE_WINDOW_OVERLAPS_SHELF);
306 break; 307 break;
307 } 308 }
308 } 309 }
309 } 310 }
310 311
311 void ShelfLayoutManager::UpdateAutoHideState() { 312 void ShelfLayoutManager::UpdateAutoHideState() {
312 ShelfAutoHideState auto_hide_state = 313 ShelfAutoHideState auto_hide_state =
313 CalculateAutoHideState(state_.visibility_state); 314 CalculateAutoHideState(state_.visibility_state);
314 if (auto_hide_state != state_.auto_hide_state) { 315 if (auto_hide_state != state_.auto_hide_state) {
315 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { 316 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 527
527 ShelfLayoutManager::TargetBounds::~TargetBounds() {} 528 ShelfLayoutManager::TargetBounds::~TargetBounds() {}
528 529
529 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) { 530 void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
530 if (!shelf_->GetNativeView()) 531 if (!shelf_->GetNativeView())
531 return; 532 return;
532 533
533 State state; 534 State state;
534 state.visibility_state = visibility_state; 535 state.visibility_state = visibility_state;
535 state.auto_hide_state = CalculateAutoHideState(visibility_state); 536 state.auto_hide_state = CalculateAutoHideState(visibility_state);
536 state.window_state = workspace_controller_ ? 537 state.window_state = workspace_controller_
537 workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT; 538 ? workspace_controller_->GetWindowState()
539 : wm::WORKSPACE_WINDOW_STATE_DEFAULT;
538 // Preserve the log in screen states. 540 // Preserve the log in screen states.
539 state.is_adding_user_screen = state_.is_adding_user_screen; 541 state.is_adding_user_screen = state_.is_adding_user_screen;
540 state.is_screen_locked = state_.is_screen_locked; 542 state.is_screen_locked = state_.is_screen_locked;
541 543
542 // Force an update because gesture drags affect the shelf bounds and we 544 // Force an update because gesture drags affect the shelf bounds and we
543 // should animate back to the normal bounds at the end of a gesture. 545 // should animate back to the normal bounds at the end of a gesture.
544 bool force_update = 546 bool force_update =
545 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS || 547 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS ||
546 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS); 548 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS);
547 549
(...skipping 19 matching lines...) Expand all
567 569
568 BackgroundAnimatorChangeType change_type = BACKGROUND_CHANGE_ANIMATE; 570 BackgroundAnimatorChangeType change_type = BACKGROUND_CHANGE_ANIMATE;
569 bool delay_background_change = false; 571 bool delay_background_change = false;
570 572
571 // Do not animate the background when: 573 // Do not animate the background when:
572 // - Going from a hidden / auto hidden shelf in fullscreen to a visible shelf 574 // - Going from a hidden / auto hidden shelf in fullscreen to a visible shelf
573 // in maximized mode. 575 // in maximized mode.
574 // - Going from an auto hidden shelf in maximized mode to a visible shelf in 576 // - Going from an auto hidden shelf in maximized mode to a visible shelf in
575 // maximized mode. 577 // maximized mode.
576 if (state.visibility_state == SHELF_VISIBLE && 578 if (state.visibility_state == SHELF_VISIBLE &&
577 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED && 579 state.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED &&
578 old_state.visibility_state != SHELF_VISIBLE) { 580 old_state.visibility_state != SHELF_VISIBLE) {
579 change_type = BACKGROUND_CHANGE_IMMEDIATE; 581 change_type = BACKGROUND_CHANGE_IMMEDIATE;
580 } else { 582 } else {
581 // Delay the animation when the shelf was hidden, and has just been made 583 // Delay the animation when the shelf was hidden, and has just been made
582 // visible (e.g. using a gesture-drag). 584 // visible (e.g. using a gesture-drag).
583 if (state.visibility_state == SHELF_VISIBLE && 585 if (state.visibility_state == SHELF_VISIBLE &&
584 old_state.visibility_state == SHELF_AUTO_HIDE && 586 old_state.visibility_state == SHELF_AUTO_HIDE &&
585 old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { 587 old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) {
586 delay_background_change = true; 588 delay_background_change = true;
587 } 589 }
588 } 590 }
589 591
590 if (delay_background_change) { 592 if (delay_background_change) {
591 if (update_shelf_observer_) 593 if (update_shelf_observer_)
592 update_shelf_observer_->Detach(); 594 update_shelf_observer_->Detach();
593 // UpdateShelfBackground deletes itself when the animation is done. 595 // UpdateShelfBackground deletes itself when the animation is done.
594 update_shelf_observer_ = new UpdateShelfObserver(this); 596 update_shelf_observer_ = new UpdateShelfObserver(this);
595 } else { 597 } else {
596 UpdateShelfBackground(change_type); 598 UpdateShelfBackground(change_type);
597 } 599 }
598 600
599 shelf_->SetDimsShelf( 601 shelf_->SetDimsShelf(state.visibility_state == SHELF_VISIBLE &&
600 state.visibility_state == SHELF_VISIBLE && 602 state.window_state ==
601 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED); 603 wm::WORKSPACE_WINDOW_STATE_MAXIMIZED);
602 604
603 TargetBounds target_bounds; 605 TargetBounds target_bounds;
604 CalculateTargetBounds(state_, &target_bounds); 606 CalculateTargetBounds(state_, &target_bounds);
605 UpdateBoundsAndOpacity(target_bounds, true, 607 UpdateBoundsAndOpacity(target_bounds, true,
606 delay_background_change ? update_shelf_observer_ : NULL); 608 delay_background_change ? update_shelf_observer_ : NULL);
607 609
608 // OnAutoHideStateChanged Should be emitted when: 610 // OnAutoHideStateChanged Should be emitted when:
609 // - firstly state changed to auto-hide from other state 611 // - firstly state changed to auto-hide from other state
610 // - or, auto_hide_state has changed 612 // - or, auto_hide_state has changed
611 if ((old_state.visibility_state != state_.visibility_state && 613 if ((old_state.visibility_state != state_.visibility_state &&
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 void ShelfLayoutManager::UpdateShelfBackground( 887 void ShelfLayoutManager::UpdateShelfBackground(
886 BackgroundAnimatorChangeType type) { 888 BackgroundAnimatorChangeType type) {
887 const ShelfBackgroundType background_type(GetShelfBackgroundType()); 889 const ShelfBackgroundType background_type(GetShelfBackgroundType());
888 shelf_->SetPaintsBackground(background_type, type); 890 shelf_->SetPaintsBackground(background_type, type);
889 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 891 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
890 OnBackgroundUpdated(background_type, type)); 892 OnBackgroundUpdated(background_type, type));
891 } 893 }
892 894
893 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const { 895 ShelfBackgroundType ShelfLayoutManager::GetShelfBackgroundType() const {
894 if (state_.visibility_state != SHELF_AUTO_HIDE && 896 if (state_.visibility_state != SHELF_AUTO_HIDE &&
895 state_.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED) { 897 state_.window_state == wm::WORKSPACE_WINDOW_STATE_MAXIMIZED) {
896 return SHELF_BACKGROUND_MAXIMIZED; 898 return SHELF_BACKGROUND_MAXIMIZED;
897 } 899 }
898 900
899 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS || 901 if (gesture_drag_status_ == GESTURE_DRAG_IN_PROGRESS ||
900 (!state_.is_screen_locked && !state_.is_adding_user_screen && 902 (!state_.is_screen_locked && !state_.is_adding_user_screen &&
901 window_overlaps_shelf_) || 903 window_overlaps_shelf_) ||
902 (state_.visibility_state == SHELF_AUTO_HIDE)) { 904 (state_.visibility_state == SHELF_AUTO_HIDE)) {
903 return SHELF_BACKGROUND_OVERLAP; 905 return SHELF_BACKGROUND_OVERLAP;
904 } 906 }
905 907
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1117 1119
1118 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { 1120 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() {
1119 UpdateVisibilityState(); 1121 UpdateVisibilityState();
1120 LayoutShelf(); 1122 LayoutShelf();
1121 // The shelf alignment may have changed when it was unlocked. 1123 // The shelf alignment may have changed when it was unlocked.
1122 Shell::GetInstance()->OnShelfAlignmentChanged( 1124 Shell::GetInstance()->OnShelfAlignmentChanged(
1123 shelf_->GetNativeWindow()->GetRootWindow()); 1125 shelf_->GetNativeWindow()->GetRootWindow());
1124 } 1126 }
1125 1127
1126 } // namespace ash 1128 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698