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