| 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/wm/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "ui/aura/root_window.h" | 10 #include "ui/aura/root_window.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 max_height_(-1), | 36 max_height_(-1), |
| 37 launcher_(launcher), | 37 launcher_(launcher), |
| 38 status_(status) { | 38 status_(status) { |
| 39 gfx::Rect launcher_bounds = launcher->GetWindowScreenBounds(); | 39 gfx::Rect launcher_bounds = launcher->GetWindowScreenBounds(); |
| 40 gfx::Rect status_bounds = status->GetWindowScreenBounds(); | 40 gfx::Rect status_bounds = status->GetWindowScreenBounds(); |
| 41 max_height_ = std::max(launcher_bounds.height(), status_bounds.height()); | 41 max_height_ = std::max(launcher_bounds.height(), status_bounds.height()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ShelfLayoutManager::~ShelfLayoutManager() { | 44 ShelfLayoutManager::~ShelfLayoutManager() { |
| 45 // Without a shelf we don't need special insets anymore. | 45 // Without a shelf we don't need special insets anymore. |
| 46 Shell::GetRootWindow()->screen()->set_work_area_insets(gfx::Insets()); | 46 Shell::GetRootWindow()->SetScreenWorkAreaInsets(gfx::Insets()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ShelfLayoutManager::LayoutShelf() { | 49 void ShelfLayoutManager::LayoutShelf() { |
| 50 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 50 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 51 StopAnimating(); | 51 StopAnimating(); |
| 52 TargetBounds target_bounds; | 52 TargetBounds target_bounds; |
| 53 float target_opacity = visible_ ? 1.0f : 0.0f; | 53 float target_opacity = visible_ ? 1.0f : 0.0f; |
| 54 CalculateTargetBounds(visible_, &target_bounds); | 54 CalculateTargetBounds(visible_, &target_bounds); |
| 55 GetLayer(launcher_)->SetOpacity(target_opacity); | 55 GetLayer(launcher_)->SetOpacity(target_opacity); |
| 56 GetLayer(status_)->SetOpacity(target_opacity); | 56 GetLayer(status_)->SetOpacity(target_opacity); |
| 57 launcher_->SetBounds(target_bounds.launcher_bounds); | 57 launcher_->SetBounds(target_bounds.launcher_bounds); |
| 58 status_->SetBounds(target_bounds.status_bounds); | 58 status_->SetBounds(target_bounds.status_bounds); |
| 59 Shell::GetInstance()->launcher()->SetStatusWidth( | 59 Shell::GetInstance()->launcher()->SetStatusWidth( |
| 60 target_bounds.status_bounds.width()); | 60 target_bounds.status_bounds.width()); |
| 61 Shell::GetRootWindow()->screen()->set_work_area_insets( | 61 Shell::GetRootWindow()->SetScreenWorkAreaInsets( |
| 62 target_bounds.work_area_insets); | 62 target_bounds.work_area_insets); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ShelfLayoutManager::SetVisible(bool visible) { | 65 void ShelfLayoutManager::SetVisible(bool visible) { |
| 66 ui::Layer* launcher_layer = GetLayer(launcher_); | 66 ui::Layer* launcher_layer = GetLayer(launcher_); |
| 67 ui::Layer* status_layer = GetLayer(status_); | 67 ui::Layer* status_layer = GetLayer(status_); |
| 68 | 68 |
| 69 // TODO(vollick): once visibility is animatable, use GetTargetVisibility. | 69 // TODO(vollick): once visibility is animatable, use GetTargetVisibility. |
| 70 bool current_visibility = visible_ && | 70 bool current_visibility = visible_ && |
| 71 launcher_layer->GetTargetOpacity() > 0.0f && | 71 launcher_layer->GetTargetOpacity() > 0.0f && |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, | 142 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, |
| 143 available_bounds.width(), | 143 available_bounds.width(), |
| 144 launcher_bounds.height()); | 144 launcher_bounds.height()); |
| 145 if (visible) | 145 if (visible) |
| 146 target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0); | 146 target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void ShelfLayoutManager::OnImplicitAnimationsCompleted() { | 149 void ShelfLayoutManager::OnImplicitAnimationsCompleted() { |
| 150 TargetBounds target_bounds; | 150 TargetBounds target_bounds; |
| 151 CalculateTargetBounds(visible_, &target_bounds); | 151 CalculateTargetBounds(visible_, &target_bounds); |
| 152 Shell::GetRootWindow()->screen()->set_work_area_insets( | 152 Shell::GetRootWindow()->SetScreenWorkAreaInsets( |
| 153 target_bounds.work_area_insets); | 153 target_bounds.work_area_insets); |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace internal | 156 } // namespace internal |
| 157 } // namespace ash | 157 } // namespace ash |
| OLD | NEW |