| 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/screen_ash.h" | 8 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.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::GetInstance()->SetScreenWorkAreaInsets(gfx::Insets()); | 46 Shell::GetInstance()->SetMonitorWorkAreaInsets( |
| 47 Shell::GetRootWindow(), gfx::Insets()); |
| 47 } | 48 } |
| 48 | 49 |
| 49 void ShelfLayoutManager::LayoutShelf() { | 50 void ShelfLayoutManager::LayoutShelf() { |
| 50 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 51 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 51 StopAnimating(); | 52 StopAnimating(); |
| 52 TargetBounds target_bounds; | 53 TargetBounds target_bounds; |
| 53 float target_opacity = visible_ ? 1.0f : 0.0f; | 54 float target_opacity = visible_ ? 1.0f : 0.0f; |
| 54 CalculateTargetBounds(visible_, &target_bounds); | 55 CalculateTargetBounds(visible_, &target_bounds); |
| 55 GetLayer(launcher_)->SetOpacity(target_opacity); | 56 GetLayer(launcher_)->SetOpacity(target_opacity); |
| 56 GetLayer(status_)->SetOpacity(target_opacity); | 57 GetLayer(status_)->SetOpacity(target_opacity); |
| 57 launcher_->SetBounds(target_bounds.launcher_bounds); | 58 launcher_->SetBounds(target_bounds.launcher_bounds); |
| 58 status_->SetBounds(target_bounds.status_bounds); | 59 status_->SetBounds(target_bounds.status_bounds); |
| 59 Shell::GetInstance()->launcher()->SetStatusWidth( | 60 Shell::GetInstance()->launcher()->SetStatusWidth( |
| 60 target_bounds.status_bounds.width()); | 61 target_bounds.status_bounds.width()); |
| 61 Shell::GetInstance()->SetScreenWorkAreaInsets( | 62 Shell::GetInstance()->SetMonitorWorkAreaInsets( |
| 63 Shell::GetRootWindow(), |
| 62 target_bounds.work_area_insets); | 64 target_bounds.work_area_insets); |
| 63 } | 65 } |
| 64 | 66 |
| 65 void ShelfLayoutManager::SetVisible(bool visible) { | 67 void ShelfLayoutManager::SetVisible(bool visible) { |
| 66 ui::Layer* launcher_layer = GetLayer(launcher_); | 68 ui::Layer* launcher_layer = GetLayer(launcher_); |
| 67 ui::Layer* status_layer = GetLayer(status_); | 69 ui::Layer* status_layer = GetLayer(status_); |
| 68 | 70 |
| 69 // TODO(vollick): once visibility is animatable, use GetTargetVisibility. | 71 // TODO(vollick): once visibility is animatable, use GetTargetVisibility. |
| 70 bool current_visibility = visible_ && | 72 bool current_visibility = visible_ && |
| 71 launcher_layer->GetTargetOpacity() > 0.0f && | 73 launcher_layer->GetTargetOpacity() > 0.0f && |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, | 145 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, |
| 144 available_bounds.width(), | 146 available_bounds.width(), |
| 145 launcher_bounds.height()); | 147 launcher_bounds.height()); |
| 146 if (visible) | 148 if (visible) |
| 147 target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0); | 149 target_bounds->work_area_insets = gfx::Insets(0, 0, max_height_, 0); |
| 148 } | 150 } |
| 149 | 151 |
| 150 void ShelfLayoutManager::OnImplicitAnimationsCompleted() { | 152 void ShelfLayoutManager::OnImplicitAnimationsCompleted() { |
| 151 TargetBounds target_bounds; | 153 TargetBounds target_bounds; |
| 152 CalculateTargetBounds(visible_, &target_bounds); | 154 CalculateTargetBounds(visible_, &target_bounds); |
| 153 Shell::GetInstance()->SetScreenWorkAreaInsets( | 155 Shell::GetInstance()->SetMonitorWorkAreaInsets( |
| 156 Shell::GetRootWindow(), |
| 154 target_bounds.work_area_insets); | 157 target_bounds.work_area_insets); |
| 155 } | 158 } |
| 156 | 159 |
| 157 } // namespace internal | 160 } // namespace internal |
| 158 } // namespace ash | 161 } // namespace ash |
| OLD | NEW |