| OLD | NEW |
| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Shelf we're in. NULL if deleted before we're deleted. | 190 // Shelf we're in. NULL if deleted before we're deleted. |
| 191 ShelfLayoutManager* shelf_; | 191 ShelfLayoutManager* shelf_; |
| 192 | 192 |
| 193 DISALLOW_COPY_AND_ASSIGN(UpdateShelfObserver); | 193 DISALLOW_COPY_AND_ASSIGN(UpdateShelfObserver); |
| 194 }; | 194 }; |
| 195 | 195 |
| 196 // ShelfLayoutManager ---------------------------------------------------------- | 196 // ShelfLayoutManager ---------------------------------------------------------- |
| 197 | 197 |
| 198 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) | 198 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) |
| 199 : root_window_(shelf->GetNativeView()->GetRootWindow()), | 199 : root_window_(shelf->GetNativeView()->GetRootWindow()), |
| 200 in_layout_(false), | 200 updating_bounds_(false), |
| 201 auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER), | 201 auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER), |
| 202 alignment_(SHELF_ALIGNMENT_BOTTOM), | 202 alignment_(SHELF_ALIGNMENT_BOTTOM), |
| 203 shelf_(shelf), | 203 shelf_(shelf), |
| 204 workspace_controller_(NULL), | 204 workspace_controller_(NULL), |
| 205 window_overlaps_shelf_(false), | 205 window_overlaps_shelf_(false), |
| 206 mouse_over_shelf_when_auto_hide_timer_started_(false), | 206 mouse_over_shelf_when_auto_hide_timer_started_(false), |
| 207 bezel_event_filter_(new ShelfBezelEventFilter(this)), | 207 bezel_event_filter_(new ShelfBezelEventFilter(this)), |
| 208 gesture_drag_status_(GESTURE_DRAG_NONE), | 208 gesture_drag_status_(GESTURE_DRAG_NONE), |
| 209 gesture_drag_amount_(0.f), | 209 gesture_drag_amount_(0.f), |
| 210 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), | 210 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 int width = 0, height = 0; | 265 int width = 0, height = 0; |
| 266 GetShelfSize(&width, &height); | 266 GetShelfSize(&width, &height); |
| 267 return SelectValueForShelfAlignment( | 267 return SelectValueForShelfAlignment( |
| 268 gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height), | 268 gfx::Rect(bounds.x(), bounds.bottom() - height, bounds.width(), height), |
| 269 gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()), | 269 gfx::Rect(bounds.x(), bounds.y(), width, bounds.height()), |
| 270 gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()), | 270 gfx::Rect(bounds.right() - width, bounds.y(), width, bounds.height()), |
| 271 gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height)); | 271 gfx::Rect(bounds.x(), bounds.y(), bounds.width(), height)); |
| 272 } | 272 } |
| 273 | 273 |
| 274 void ShelfLayoutManager::LayoutShelf() { | 274 void ShelfLayoutManager::LayoutShelf() { |
| 275 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | |
| 276 StopAnimating(); | |
| 277 TargetBounds target_bounds; | 275 TargetBounds target_bounds; |
| 278 CalculateTargetBounds(state_, &target_bounds); | 276 CalculateTargetBounds(state_, &target_bounds); |
| 279 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); | 277 UpdateBoundsAndOpacity(target_bounds, false, NULL); |
| 280 shelf_->SetWidgetBounds( | 278 |
| 281 ScreenAsh::ConvertRectToScreen( | 279 if (shelf_->launcher()) { |
| 282 shelf_->GetNativeView()->parent(), | 280 // This is not part of UpdateBoundsAndOpacity() because |
| 283 target_bounds.shelf_bounds_in_root)); | 281 // SetLauncherViewBounds() sets the bounds immediately and does not animate. |
| 284 if (shelf_->launcher()) | 282 // The height of the LauncherView for a horizontal shelf and the width of |
| 283 // the LauncherView for a vertical shelf are set when |shelf_|'s bounds |
| 284 // are changed via UpdateBoundsAndOpacity(). This sets the origin and the |
| 285 // dimension in the other direction. |
| 285 shelf_->launcher()->SetLauncherViewBounds( | 286 shelf_->launcher()->SetLauncherViewBounds( |
| 286 target_bounds.launcher_bounds_in_shelf); | 287 target_bounds.launcher_bounds_in_shelf); |
| 287 GetLayer(shelf_->status_area_widget())->SetOpacity( | 288 } |
| 288 target_bounds.status_opacity); | |
| 289 // TODO(harrym): Once status area widget is a child view of shelf | |
| 290 // this can be simplified. | |
| 291 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; | |
| 292 status_bounds.set_x(status_bounds.x() + | |
| 293 target_bounds.shelf_bounds_in_root.x()); | |
| 294 status_bounds.set_y(status_bounds.y() + | |
| 295 target_bounds.shelf_bounds_in_root.y()); | |
| 296 shelf_->status_area_widget()->SetBounds( | |
| 297 ScreenAsh::ConvertRectToScreen( | |
| 298 shelf_->status_area_widget()->GetNativeView()->parent(), | |
| 299 status_bounds)); | |
| 300 Shell::GetInstance()->SetDisplayWorkAreaInsets( | |
| 301 root_window_, target_bounds.work_area_insets); | |
| 302 UpdateHitTestBounds(); | |
| 303 } | 289 } |
| 304 | 290 |
| 305 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { | 291 ShelfVisibilityState ShelfLayoutManager::CalculateShelfVisibility() { |
| 306 switch(auto_hide_behavior_) { | 292 switch(auto_hide_behavior_) { |
| 307 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: | 293 case SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS: |
| 308 return SHELF_AUTO_HIDE; | 294 return SHELF_AUTO_HIDE; |
| 309 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: | 295 case SHELF_AUTO_HIDE_BEHAVIOR_NEVER: |
| 310 return SHELF_VISIBLE; | 296 return SHELF_VISIBLE; |
| 311 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: | 297 case SHELF_AUTO_HIDE_ALWAYS_HIDDEN: |
| 312 return SHELF_HIDDEN; | 298 return SHELF_HIDDEN; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 // In fullscreen with minimal chrome, the auto hide behavior affects neither | 460 // In fullscreen with minimal chrome, the auto hide behavior affects neither |
| 475 // the visibility state nor the auto hide state. Set |gesture_drag_status_| | 461 // the visibility state nor the auto hide state. Set |gesture_drag_status_| |
| 476 // to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto hide state to | 462 // to GESTURE_DRAG_COMPLETE_IN_PROGRESS to set the auto hide state to |
| 477 // |gesture_drag_auto_hide_state_|. | 463 // |gesture_drag_auto_hide_state_|. |
| 478 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; | 464 gesture_drag_status_ = GESTURE_DRAG_COMPLETE_IN_PROGRESS; |
| 479 if (auto_hide_behavior_ != new_auto_hide_behavior) | 465 if (auto_hide_behavior_ != new_auto_hide_behavior) |
| 480 SetAutoHideBehavior(new_auto_hide_behavior); | 466 SetAutoHideBehavior(new_auto_hide_behavior); |
| 481 else | 467 else |
| 482 UpdateVisibilityState(); | 468 UpdateVisibilityState(); |
| 483 gesture_drag_status_ = GESTURE_DRAG_NONE; | 469 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 484 LayoutShelf(); | |
| 485 } | 470 } |
| 486 | 471 |
| 487 void ShelfLayoutManager::CancelGestureDrag() { | 472 void ShelfLayoutManager::CancelGestureDrag() { |
| 473 gesture_drag_status_ = GESTURE_DRAG_CANCEL_IN_PROGRESS; |
| 474 UpdateVisibilityState(); |
| 488 gesture_drag_status_ = GESTURE_DRAG_NONE; | 475 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 489 ui::ScopedLayerAnimationSettings | |
| 490 launcher_settings(GetLayer(shelf_)->GetAnimator()), | |
| 491 status_settings(GetLayer(shelf_->status_area_widget())->GetAnimator()); | |
| 492 LayoutShelf(); | |
| 493 UpdateVisibilityState(); | |
| 494 UpdateShelfBackground(BackgroundAnimator::CHANGE_ANIMATE); | |
| 495 } | 476 } |
| 496 | 477 |
| 497 //////////////////////////////////////////////////////////////////////////////// | 478 //////////////////////////////////////////////////////////////////////////////// |
| 498 // ShelfLayoutManager, aura::LayoutManager implementation: | 479 // ShelfLayoutManager, aura::LayoutManager implementation: |
| 499 | 480 |
| 500 void ShelfLayoutManager::OnWindowResized() { | 481 void ShelfLayoutManager::OnWindowResized() { |
| 501 LayoutShelf(); | 482 LayoutShelf(); |
| 502 } | 483 } |
| 503 | 484 |
| 504 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { | 485 void ShelfLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| 505 } | 486 } |
| 506 | 487 |
| 507 void ShelfLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { | 488 void ShelfLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { |
| 508 } | 489 } |
| 509 | 490 |
| 510 void ShelfLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { | 491 void ShelfLayoutManager::OnWindowRemovedFromLayout(aura::Window* child) { |
| 511 } | 492 } |
| 512 | 493 |
| 513 void ShelfLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, | 494 void ShelfLayoutManager::OnChildWindowVisibilityChanged(aura::Window* child, |
| 514 bool visible) { | 495 bool visible) { |
| 515 } | 496 } |
| 516 | 497 |
| 517 void ShelfLayoutManager::SetChildBounds(aura::Window* child, | 498 void ShelfLayoutManager::SetChildBounds(aura::Window* child, |
| 518 const gfx::Rect& requested_bounds) { | 499 const gfx::Rect& requested_bounds) { |
| 519 SetChildBoundsDirect(child, requested_bounds); | 500 SetChildBoundsDirect(child, requested_bounds); |
| 520 // We may contain other widgets (such as frame maximize bubble) but they don't | 501 // We may contain other widgets (such as frame maximize bubble) but they don't |
| 521 // effect the layout in anyway. | 502 // effect the layout in anyway. |
| 522 if (!in_layout_ && | 503 if (!updating_bounds_ && |
| 523 ((shelf_->GetNativeView() == child) || | 504 ((shelf_->GetNativeView() == child) || |
| 524 (shelf_->status_area_widget()->GetNativeView() == child))) { | 505 (shelf_->status_area_widget()->GetNativeView() == child))) { |
| 525 LayoutShelf(); | 506 LayoutShelf(); |
| 526 } | 507 } |
| 527 } | 508 } |
| 528 | 509 |
| 529 void ShelfLayoutManager::OnLockStateChanged(bool locked) { | 510 void ShelfLayoutManager::OnLockStateChanged(bool locked) { |
| 530 UpdateVisibilityState(); | 511 UpdateVisibilityState(); |
| 531 } | 512 } |
| 532 | 513 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 return; | 550 return; |
| 570 | 551 |
| 571 State state; | 552 State state; |
| 572 state.visibility_state = visibility_state; | 553 state.visibility_state = visibility_state; |
| 573 state.auto_hide_state = CalculateAutoHideState(visibility_state); | 554 state.auto_hide_state = CalculateAutoHideState(visibility_state); |
| 574 state.is_screen_locked = | 555 state.is_screen_locked = |
| 575 Shell::GetInstance()->session_state_delegate()->IsScreenLocked(); | 556 Shell::GetInstance()->session_state_delegate()->IsScreenLocked(); |
| 576 state.window_state = workspace_controller_ ? | 557 state.window_state = workspace_controller_ ? |
| 577 workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT; | 558 workspace_controller_->GetWindowState() : WORKSPACE_WINDOW_STATE_DEFAULT; |
| 578 | 559 |
| 579 if (state_.Equals(state)) | 560 // Force an update because gesture drags affect the shelf bounds and we |
| 561 // should animate back to the normal bounds at the end of a gesture. |
| 562 bool force_update = |
| 563 (gesture_drag_status_ == GESTURE_DRAG_CANCEL_IN_PROGRESS || |
| 564 gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS); |
| 565 |
| 566 if (!force_update && state_.Equals(state)) |
| 580 return; // Nothing changed. | 567 return; // Nothing changed. |
| 581 | 568 |
| 582 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 569 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 583 WillChangeVisibilityState(visibility_state)); | 570 WillChangeVisibilityState(visibility_state)); |
| 584 | 571 |
| 585 if (state.visibility_state == SHELF_AUTO_HIDE) { | 572 if (state.visibility_state == SHELF_AUTO_HIDE) { |
| 586 // When state is SHELF_AUTO_HIDE we need to track when the mouse is over the | 573 // When state is SHELF_AUTO_HIDE we need to track when the mouse is over the |
| 587 // launcher to unhide the shelf. AutoHideEventFilter does that for us. | 574 // launcher to unhide the shelf. AutoHideEventFilter does that for us. |
| 588 if (!auto_hide_event_filter_) | 575 if (!auto_hide_event_filter_) |
| 589 auto_hide_event_filter_.reset(new AutoHideEventFilter(this)); | 576 auto_hide_event_filter_.reset(new AutoHideEventFilter(this)); |
| 590 } else { | 577 } else { |
| 591 auto_hide_event_filter_.reset(NULL); | 578 auto_hide_event_filter_.reset(NULL); |
| 592 } | 579 } |
| 593 | 580 |
| 594 StopAutoHideTimer(); | 581 StopAutoHideTimer(); |
| 595 | 582 |
| 596 State old_state = state_; | 583 State old_state = state_; |
| 597 state_ = state; | 584 state_ = state; |
| 598 TargetBounds target_bounds; | |
| 599 CalculateTargetBounds(state_, &target_bounds); | |
| 600 | |
| 601 ui::ScopedLayerAnimationSettings launcher_animation_setter( | |
| 602 GetLayer(shelf_)->GetAnimator()); | |
| 603 launcher_animation_setter.SetTransitionDuration( | |
| 604 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | |
| 605 launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); | |
| 606 launcher_animation_setter.SetPreemptionStrategy( | |
| 607 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 608 GetLayer(shelf_)->SetBounds( | |
| 609 target_bounds.shelf_bounds_in_root); | |
| 610 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); | |
| 611 ui::ScopedLayerAnimationSettings status_animation_setter( | |
| 612 GetLayer(shelf_->status_area_widget())->GetAnimator()); | |
| 613 status_animation_setter.SetTransitionDuration( | |
| 614 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); | |
| 615 status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); | |
| 616 status_animation_setter.SetPreemptionStrategy( | |
| 617 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | |
| 618 | 585 |
| 619 BackgroundAnimator::ChangeType change_type = | 586 BackgroundAnimator::ChangeType change_type = |
| 620 BackgroundAnimator::CHANGE_ANIMATE; | 587 BackgroundAnimator::CHANGE_ANIMATE; |
| 621 bool delay_background_change = false; | 588 bool delay_background_change = false; |
| 622 | 589 |
| 623 // Do not animate the background when: | 590 // Do not animate the background when: |
| 624 // - Going from a hidden / auto hidden shelf in fullscreen to a visible shelf | 591 // - Going from a hidden / auto hidden shelf in fullscreen to a visible shelf |
| 625 // in maximized mode. | 592 // in maximized mode. |
| 626 // - Going from an auto hidden shelf in maximized mode to a visible shelf in | 593 // - Going from an auto hidden shelf in maximized mode to a visible shelf in |
| 627 // maximized mode. | 594 // maximized mode. |
| 628 if (state.visibility_state == SHELF_VISIBLE && | 595 if (state.visibility_state == SHELF_VISIBLE && |
| 629 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED && | 596 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED && |
| 630 old_state.visibility_state != SHELF_VISIBLE) { | 597 old_state.visibility_state != SHELF_VISIBLE) { |
| 631 change_type = BackgroundAnimator::CHANGE_IMMEDIATE; | 598 change_type = BackgroundAnimator::CHANGE_IMMEDIATE; |
| 632 } else { | 599 } else { |
| 633 // Delay the animation when the shelf was hidden, and has just been made | 600 // Delay the animation when the shelf was hidden, and has just been made |
| 634 // visible (e.g. using a gesture-drag). | 601 // visible (e.g. using a gesture-drag). |
| 635 if (state.visibility_state == SHELF_VISIBLE && | 602 if (state.visibility_state == SHELF_VISIBLE && |
| 636 old_state.visibility_state == SHELF_AUTO_HIDE && | 603 old_state.visibility_state == SHELF_AUTO_HIDE && |
| 637 old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { | 604 old_state.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
| 638 delay_background_change = true; | 605 delay_background_change = true; |
| 639 } | 606 } |
| 640 } | 607 } |
| 641 | 608 |
| 642 if (delay_background_change) { | 609 if (delay_background_change) { |
| 643 if (update_shelf_observer_) | 610 if (update_shelf_observer_) |
| 644 update_shelf_observer_->Detach(); | 611 update_shelf_observer_->Detach(); |
| 645 // UpdateShelfBackground deletes itself when the animation is done. | 612 // UpdateShelfBackground deletes itself when the animation is done. |
| 646 update_shelf_observer_ = new UpdateShelfObserver(this); | 613 update_shelf_observer_ = new UpdateShelfObserver(this); |
| 647 status_animation_setter.AddObserver(update_shelf_observer_); | |
| 648 } else { | 614 } else { |
| 649 UpdateShelfBackground(change_type); | 615 UpdateShelfBackground(change_type); |
| 650 } | 616 } |
| 651 | 617 |
| 652 shelf_->SetDimsShelf( | 618 shelf_->SetDimsShelf( |
| 653 state.visibility_state == SHELF_VISIBLE && | 619 state.visibility_state == SHELF_VISIBLE && |
| 654 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED); | 620 state.window_state == WORKSPACE_WINDOW_STATE_MAXIMIZED); |
| 655 | 621 |
| 656 ui::Layer* layer = GetLayer(shelf_->status_area_widget()); | 622 TargetBounds target_bounds; |
| 657 // TODO(harrym): Remove when status_area is view (crbug.com/180422). | 623 CalculateTargetBounds(state_, &target_bounds); |
| 658 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; | 624 UpdateBoundsAndOpacity(target_bounds, true, |
| 659 status_bounds.set_x(status_bounds.x() + | 625 delay_background_change ? update_shelf_observer_ : NULL); |
| 660 target_bounds.shelf_bounds_in_root.x()); | |
| 661 status_bounds.set_y(status_bounds.y() + | |
| 662 target_bounds.shelf_bounds_in_root.y()); | |
| 663 layer->SetBounds(status_bounds); | |
| 664 layer->SetOpacity(target_bounds.status_opacity); | |
| 665 Shell::GetInstance()->SetDisplayWorkAreaInsets( | |
| 666 root_window_, target_bounds.work_area_insets); | |
| 667 UpdateHitTestBounds(); | |
| 668 | 626 |
| 669 // OnAutoHideStateChanged Should be emitted when: | 627 // OnAutoHideStateChanged Should be emitted when: |
| 670 // - firstly state changed to auto-hide from other state | 628 // - firstly state changed to auto-hide from other state |
| 671 // - or, auto_hide_state has changed | 629 // - or, auto_hide_state has changed |
| 672 if ((old_state.visibility_state != state_.visibility_state && | 630 if ((old_state.visibility_state != state_.visibility_state && |
| 673 state_.visibility_state == SHELF_AUTO_HIDE) || | 631 state_.visibility_state == SHELF_AUTO_HIDE) || |
| 674 old_state.auto_hide_state != state_.auto_hide_state) { | 632 old_state.auto_hide_state != state_.auto_hide_state) { |
| 675 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 633 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 676 OnAutoHideStateChanged(state_.auto_hide_state)); | 634 OnAutoHideStateChanged(state_.auto_hide_state)); |
| 677 } | 635 } |
| 678 } | 636 } |
| 679 | 637 |
| 638 void ShelfLayoutManager::UpdateBoundsAndOpacity( |
| 639 const TargetBounds& target_bounds, |
| 640 bool animate, |
| 641 ui::ImplicitAnimationObserver* observer) { |
| 642 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); |
| 643 |
| 644 ui::ScopedLayerAnimationSettings launcher_animation_setter( |
| 645 GetLayer(shelf_)->GetAnimator()); |
| 646 ui::ScopedLayerAnimationSettings status_animation_setter( |
| 647 GetLayer(shelf_->status_area_widget())->GetAnimator()); |
| 648 if (animate) { |
| 649 launcher_animation_setter.SetTransitionDuration( |
| 650 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
| 651 launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); |
| 652 launcher_animation_setter.SetPreemptionStrategy( |
| 653 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 654 status_animation_setter.SetTransitionDuration( |
| 655 base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS)); |
| 656 status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); |
| 657 status_animation_setter.SetPreemptionStrategy( |
| 658 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 659 } else { |
| 660 StopAnimating(); |
| 661 launcher_animation_setter.SetTransitionDuration(base::TimeDelta()); |
| 662 status_animation_setter.SetTransitionDuration(base::TimeDelta()); |
| 663 } |
| 664 if (observer) |
| 665 status_animation_setter.AddObserver(observer); |
| 666 |
| 667 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); |
| 668 shelf_->SetBounds(ScreenAsh::ConvertRectToScreen( |
| 669 shelf_->GetNativeView()->parent(), |
| 670 target_bounds.shelf_bounds_in_root)); |
| 671 |
| 672 GetLayer(shelf_->status_area_widget())->SetOpacity( |
| 673 target_bounds.status_opacity); |
| 674 // TODO(harrym): Once status area widget is a child view of shelf |
| 675 // this can be simplified. |
| 676 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; |
| 677 status_bounds.set_x(status_bounds.x() + |
| 678 target_bounds.shelf_bounds_in_root.x()); |
| 679 status_bounds.set_y(status_bounds.y() + |
| 680 target_bounds.shelf_bounds_in_root.y()); |
| 681 shelf_->status_area_widget()->SetBounds( |
| 682 ScreenAsh::ConvertRectToScreen( |
| 683 shelf_->status_area_widget()->GetNativeView()->parent(), |
| 684 status_bounds)); |
| 685 Shell::GetInstance()->SetDisplayWorkAreaInsets( |
| 686 root_window_, target_bounds.work_area_insets); |
| 687 UpdateHitTestBounds(); |
| 688 } |
| 689 |
| 680 void ShelfLayoutManager::StopAnimating() { | 690 void ShelfLayoutManager::StopAnimating() { |
| 681 GetLayer(shelf_)->GetAnimator()->StopAnimating(); | 691 GetLayer(shelf_)->GetAnimator()->StopAnimating(); |
| 682 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); | 692 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); |
| 683 } | 693 } |
| 684 | 694 |
| 685 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { | 695 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { |
| 686 *width = *height = 0; | 696 *width = *height = 0; |
| 687 gfx::Size status_size( | 697 gfx::Size status_size( |
| 688 shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); | 698 shelf_->status_area_widget()->GetWindowBoundsInScreen().size()); |
| 689 if (IsHorizontalAlignment()) | 699 if (IsHorizontalAlignment()) |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1111 return gfx::Insets(0, distance, 0, 0); | 1121 return gfx::Insets(0, distance, 0, 0); |
| 1112 case SHELF_ALIGNMENT_TOP: | 1122 case SHELF_ALIGNMENT_TOP: |
| 1113 return gfx::Insets(0, 0, distance, 0); | 1123 return gfx::Insets(0, 0, distance, 0); |
| 1114 } | 1124 } |
| 1115 NOTREACHED(); | 1125 NOTREACHED(); |
| 1116 return gfx::Insets(); | 1126 return gfx::Insets(); |
| 1117 } | 1127 } |
| 1118 | 1128 |
| 1119 } // namespace internal | 1129 } // namespace internal |
| 1120 } // namespace ash | 1130 } // namespace ash |
| OLD | NEW |