| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/aura_shell/shelf_layout_manager.h" | 5 #include "ui/aura_shell/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/root_window.h" |
| 9 #include "ui/aura/screen_aura.h" | 9 #include "ui/aura/screen_aura.h" |
| 10 #include "ui/gfx/compositor/layer.h" | 10 #include "ui/gfx/compositor/layer.h" |
| 11 #include "ui/gfx/compositor/layer_animator.h" | 11 #include "ui/gfx/compositor/layer_animator.h" |
| 12 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 13 | 13 |
| 14 namespace aura_shell { | 14 namespace aura_shell { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 48 void ShelfLayoutManager::LayoutShelf() { | 48 void ShelfLayoutManager::LayoutShelf() { |
| 49 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 49 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 50 StopAnimating(); | 50 StopAnimating(); |
| 51 TargetBounds target_bounds; | 51 TargetBounds target_bounds; |
| 52 float target_opacity = visible_ ? 1.0f : 0.0f; | 52 float target_opacity = visible_ ? 1.0f : 0.0f; |
| 53 CalculateTargetBounds(visible_, &target_bounds); | 53 CalculateTargetBounds(visible_, &target_bounds); |
| 54 GetLayer(launcher_)->SetOpacity(target_opacity); | 54 GetLayer(launcher_)->SetOpacity(target_opacity); |
| 55 GetLayer(status_)->SetOpacity(target_opacity); | 55 GetLayer(status_)->SetOpacity(target_opacity); |
| 56 launcher_->SetBounds(target_bounds.launcher_bounds); | 56 launcher_->SetBounds(target_bounds.launcher_bounds); |
| 57 status_->SetBounds(target_bounds.status_bounds); | 57 status_->SetBounds(target_bounds.status_bounds); |
| 58 aura::Desktop::GetInstance()->screen()->set_work_area_insets( | 58 aura::RootWindow::GetInstance()->screen()->set_work_area_insets( |
| 59 target_bounds.work_area_insets); | 59 target_bounds.work_area_insets); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ShelfLayoutManager::SetVisible(bool visible) { | 62 void ShelfLayoutManager::SetVisible(bool visible) { |
| 63 bool current_visibility = animating_ ? !visible_ : visible_; | 63 bool current_visibility = animating_ ? !visible_ : visible_; |
| 64 if (visible == current_visibility) | 64 if (visible == current_visibility) |
| 65 return; // Nothing changed. | 65 return; // Nothing changed. |
| 66 | 66 |
| 67 StopAnimating(); | 67 StopAnimating(); |
| 68 | 68 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void ShelfLayoutManager::StopAnimating() { | 105 void ShelfLayoutManager::StopAnimating() { |
| 106 if (animating_) { | 106 if (animating_) { |
| 107 animating_ = false; | 107 animating_ = false; |
| 108 visible_ = !visible_; | 108 visible_ = !visible_; |
| 109 } | 109 } |
| 110 GetLayer(launcher_)->GetAnimator()->StopAnimating(); | 110 GetLayer(launcher_)->GetAnimator()->StopAnimating(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ShelfLayoutManager::CalculateTargetBounds(bool visible, | 113 void ShelfLayoutManager::CalculateTargetBounds(bool visible, |
| 114 TargetBounds* target_bounds) { | 114 TargetBounds* target_bounds) { |
| 115 const gfx::Rect& available_bounds(aura::Desktop::GetInstance()->bounds()); | 115 const gfx::Rect& available_bounds(aura::RootWindow::GetInstance()->bounds()); |
| 116 int y = available_bounds.bottom() - (visible ? max_height_ : 0); | 116 int y = available_bounds.bottom() - (visible ? max_height_ : 0); |
| 117 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); | 117 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); |
| 118 target_bounds->status_bounds = gfx::Rect( | 118 target_bounds->status_bounds = gfx::Rect( |
| 119 available_bounds.right() - status_bounds.width(), | 119 available_bounds.right() - status_bounds.width(), |
| 120 y + (max_height_ - status_bounds.height()) / 2, | 120 y + (max_height_ - status_bounds.height()) / 2, |
| 121 status_bounds.width(), status_bounds.height()); | 121 status_bounds.width(), status_bounds.height()); |
| 122 gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds()); | 122 gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds()); |
| 123 target_bounds->launcher_bounds = gfx::Rect( | 123 target_bounds->launcher_bounds = gfx::Rect( |
| 124 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, | 124 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, |
| 125 available_bounds.width() - status_bounds.width(), | 125 available_bounds.width() - status_bounds.width(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 void ShelfLayoutManager::OnLayerAnimationEnded( | 140 void ShelfLayoutManager::OnLayerAnimationEnded( |
| 141 const ui::LayerAnimationSequence* sequence) { | 141 const ui::LayerAnimationSequence* sequence) { |
| 142 if (!animating_) | 142 if (!animating_) |
| 143 return; | 143 return; |
| 144 animating_ = false; | 144 animating_ = false; |
| 145 visible_ = !visible_; | 145 visible_ = !visible_; |
| 146 TargetBounds target_bounds; | 146 TargetBounds target_bounds; |
| 147 CalculateTargetBounds(visible_, &target_bounds); | 147 CalculateTargetBounds(visible_, &target_bounds); |
| 148 aura::Desktop::GetInstance()->screen()->set_work_area_insets( | 148 aura::RootWindow::GetInstance()->screen()->set_work_area_insets( |
| 149 target_bounds.work_area_insets); | 149 target_bounds.work_area_insets); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // internal | 152 } // internal |
| 153 } // aura_shell | 153 } // aura_shell |
| OLD | NEW |