| 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" |
| 11 #include "ui/aura/screen_aura.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 { |
| 22 | 22 |
| 23 const int kSystemTrayPadding = 10; |
| 24 |
| 23 ui::Layer* GetLayer(views::Widget* widget) { | 25 ui::Layer* GetLayer(views::Widget* widget) { |
| 24 return widget->GetNativeView()->layer(); | 26 return widget->GetNativeView()->layer(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 } // namespace | 29 } // namespace |
| 28 | 30 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 31 //////////////////////////////////////////////////////////////////////////////// |
| 30 // ShelfLayoutManager, public: | 32 // ShelfLayoutManager, public: |
| 31 | 33 |
| 32 ShelfLayoutManager::ShelfLayoutManager(views::Widget* launcher, | 34 ShelfLayoutManager::ShelfLayoutManager(views::Widget* launcher, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 GetLayer(launcher_)->GetAnimator()->StopAnimating(); | 129 GetLayer(launcher_)->GetAnimator()->StopAnimating(); |
| 128 GetLayer(status_)->GetAnimator()->StopAnimating(); | 130 GetLayer(status_)->GetAnimator()->StopAnimating(); |
| 129 } | 131 } |
| 130 | 132 |
| 131 void ShelfLayoutManager::CalculateTargetBounds(bool visible, | 133 void ShelfLayoutManager::CalculateTargetBounds(bool visible, |
| 132 TargetBounds* target_bounds) { | 134 TargetBounds* target_bounds) { |
| 133 const gfx::Rect& available_bounds(Shell::GetRootWindow()->bounds()); | 135 const gfx::Rect& available_bounds(Shell::GetRootWindow()->bounds()); |
| 134 int y = available_bounds.bottom() - (visible ? max_height_ : 0); | 136 int y = available_bounds.bottom() - (visible ? max_height_ : 0); |
| 135 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); | 137 gfx::Rect status_bounds(status_->GetWindowScreenBounds()); |
| 136 target_bounds->status_bounds = gfx::Rect( | 138 target_bounds->status_bounds = gfx::Rect( |
| 137 available_bounds.right() - status_bounds.width(), | 139 available_bounds.right() - status_bounds.width() - kSystemTrayPadding, |
| 138 y + (max_height_ - status_bounds.height()) / 2, | 140 y + (max_height_ - status_bounds.height()) / 2, |
| 139 status_bounds.width(), status_bounds.height()); | 141 status_bounds.width(), status_bounds.height()); |
| 140 gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds()); | 142 gfx::Rect launcher_bounds(launcher_->GetWindowScreenBounds()); |
| 141 target_bounds->launcher_bounds = gfx::Rect( | 143 target_bounds->launcher_bounds = gfx::Rect( |
| 142 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, | 144 available_bounds.x(), y + (max_height_ - launcher_bounds.height()) / 2, |
| 143 available_bounds.width(), | 145 available_bounds.width(), |
| 144 launcher_bounds.height()); | 146 launcher_bounds.height()); |
| 145 if (visible) | 147 if (visible) |
| 146 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); |
| 147 } | 149 } |
| 148 | 150 |
| 149 void ShelfLayoutManager::OnImplicitAnimationsCompleted() { | 151 void ShelfLayoutManager::OnImplicitAnimationsCompleted() { |
| 150 TargetBounds target_bounds; | 152 TargetBounds target_bounds; |
| 151 CalculateTargetBounds(visible_, &target_bounds); | 153 CalculateTargetBounds(visible_, &target_bounds); |
| 152 Shell::GetRootWindow()->SetScreenWorkAreaInsets( | 154 Shell::GetRootWindow()->SetScreenWorkAreaInsets( |
| 153 target_bounds.work_area_insets); | 155 target_bounds.work_area_insets); |
| 154 } | 156 } |
| 155 | 157 |
| 156 } // namespace internal | 158 } // namespace internal |
| 157 } // namespace ash | 159 } // namespace ash |
| OLD | NEW |