| 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 "ash/shell_delegate.h" | 10 #include "ash/shell_delegate.h" |
| 11 #include "ash/shell_window_ids.h" | 11 #include "ash/shell_window_ids.h" |
| 12 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
| 13 #include "ash/wm/workspace/workspace_manager.h" | 13 #include "ash/wm/workspace/workspace_manager.h" |
| 14 #include "base/auto_reset.h" | 14 #include "base/auto_reset.h" |
| 15 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 16 #include "ui/aura/client/activation_client.h" | 16 #include "ui/aura/client/activation_client.h" |
| 17 #include "ui/aura/dip_util.h" | |
| 18 #include "ui/aura/event.h" | 17 #include "ui/aura/event.h" |
| 19 #include "ui/aura/event_filter.h" | 18 #include "ui/aura/event_filter.h" |
| 20 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
| 21 #include "ui/gfx/compositor/layer.h" | 20 #include "ui/gfx/compositor/layer.h" |
| 22 #include "ui/gfx/compositor/layer_animation_observer.h" | 21 #include "ui/gfx/compositor/layer_animation_observer.h" |
| 23 #include "ui/gfx/compositor/layer_animator.h" | 22 #include "ui/gfx/compositor/layer_animator.h" |
| 24 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/gfx/compositor/scoped_layer_animation_settings.h" |
| 25 #include "ui/gfx/screen.h" | 24 #include "ui/gfx/screen.h" |
| 26 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
| 27 | 26 |
| 28 namespace ash { | 27 namespace ash { |
| 29 namespace internal { | 28 namespace internal { |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| 33 // Delay before showing the launcher. This is after the mouse stops moving. | 32 // Delay before showing the launcher. This is after the mouse stops moving. |
| 34 const int kAutoHideDelayMS = 200; | 33 const int kAutoHideDelayMS = 200; |
| 35 | 34 |
| 36 ui::Layer* GetLayer(views::Widget* widget) { | 35 ui::Layer* GetLayer(views::Widget* widget) { |
| 37 return widget->GetNativeView()->layer(); | 36 return widget->GetNativeView()->layer(); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void SetLayerBounds(views::Widget* widget, const gfx::Rect& bounds) { | |
| 41 aura::Window* window = widget->GetNativeView(); | |
| 42 window->layer()->SetBounds(aura::ConvertRectToPixel(window, bounds)); | |
| 43 } | |
| 44 | |
| 45 } // namespace | 39 } // namespace |
| 46 | 40 |
| 47 // static | 41 // static |
| 48 const int ShelfLayoutManager::kWorkspaceAreaBottomInset = 2; | 42 const int ShelfLayoutManager::kWorkspaceAreaBottomInset = 2; |
| 49 | 43 |
| 50 // static | 44 // static |
| 51 const int ShelfLayoutManager::kAutoHideHeight = 2; | 45 const int ShelfLayoutManager::kAutoHideHeight = 2; |
| 52 | 46 |
| 53 // Notifies ShelfLayoutManager any time the mouse moves. | 47 // Notifies ShelfLayoutManager any time the mouse moves. |
| 54 class ShelfLayoutManager::AutoHideEventFilter : public aura::EventFilter { | 48 class ShelfLayoutManager::AutoHideEventFilter : public aura::EventFilter { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 LayoutShelf(); | 182 LayoutShelf(); |
| 189 } | 183 } |
| 190 | 184 |
| 191 void ShelfLayoutManager::LayoutShelf() { | 185 void ShelfLayoutManager::LayoutShelf() { |
| 192 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 186 AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 193 StopAnimating(); | 187 StopAnimating(); |
| 194 TargetBounds target_bounds; | 188 TargetBounds target_bounds; |
| 195 CalculateTargetBounds(state_, &target_bounds); | 189 CalculateTargetBounds(state_, &target_bounds); |
| 196 if (launcher_widget()) { | 190 if (launcher_widget()) { |
| 197 GetLayer(launcher_widget())->SetOpacity(target_bounds.opacity); | 191 GetLayer(launcher_widget())->SetOpacity(target_bounds.opacity); |
| 192 |
| 198 launcher_widget()->SetBounds(target_bounds.launcher_bounds); | 193 launcher_widget()->SetBounds(target_bounds.launcher_bounds); |
| 199 launcher_->SetStatusWidth( | 194 launcher_->SetStatusWidth( |
| 200 target_bounds.status_bounds.width()); | 195 target_bounds.status_bounds.width()); |
| 201 } | 196 } |
| 202 GetLayer(status_)->SetOpacity(target_bounds.opacity); | 197 GetLayer(status_)->SetOpacity(target_bounds.opacity); |
| 203 status_->SetBounds(target_bounds.status_bounds); | 198 status_->SetBounds(target_bounds.status_bounds); |
| 204 Shell::GetInstance()->SetMonitorWorkAreaInsets( | 199 Shell::GetInstance()->SetMonitorWorkAreaInsets( |
| 205 Shell::GetRootWindow(), | 200 Shell::GetRootWindow(), |
| 206 target_bounds.work_area_insets); | 201 target_bounds.work_area_insets); |
| 207 UpdateHitTestBounds(); | 202 UpdateHitTestBounds(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 StopAnimating(); | 322 StopAnimating(); |
| 328 state_ = state; | 323 state_ = state; |
| 329 TargetBounds target_bounds; | 324 TargetBounds target_bounds; |
| 330 CalculateTargetBounds(state_, &target_bounds); | 325 CalculateTargetBounds(state_, &target_bounds); |
| 331 if (launcher_widget()) { | 326 if (launcher_widget()) { |
| 332 ui::ScopedLayerAnimationSettings launcher_animation_setter( | 327 ui::ScopedLayerAnimationSettings launcher_animation_setter( |
| 333 GetLayer(launcher_widget())->GetAnimator()); | 328 GetLayer(launcher_widget())->GetAnimator()); |
| 334 launcher_animation_setter.SetTransitionDuration( | 329 launcher_animation_setter.SetTransitionDuration( |
| 335 base::TimeDelta::FromMilliseconds(130)); | 330 base::TimeDelta::FromMilliseconds(130)); |
| 336 launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); | 331 launcher_animation_setter.SetTweenType(ui::Tween::EASE_OUT); |
| 337 SetLayerBounds(launcher_widget(), target_bounds.launcher_bounds); | 332 GetLayer(launcher_widget())->SetBounds(target_bounds.launcher_bounds); |
| 338 GetLayer(launcher_widget())->SetOpacity(target_bounds.opacity); | 333 GetLayer(launcher_widget())->SetOpacity(target_bounds.opacity); |
| 339 } | 334 } |
| 340 ui::ScopedLayerAnimationSettings status_animation_setter( | 335 ui::ScopedLayerAnimationSettings status_animation_setter( |
| 341 GetLayer(status_)->GetAnimator()); | 336 GetLayer(status_)->GetAnimator()); |
| 342 status_animation_setter.SetTransitionDuration( | 337 status_animation_setter.SetTransitionDuration( |
| 343 base::TimeDelta::FromMilliseconds(130)); | 338 base::TimeDelta::FromMilliseconds(130)); |
| 344 status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); | 339 status_animation_setter.SetTweenType(ui::Tween::EASE_OUT); |
| 345 SetLayerBounds(status_, target_bounds.status_bounds); | 340 GetLayer(status_)->SetBounds(target_bounds.status_bounds); |
| 346 GetLayer(status_)->SetOpacity(target_bounds.opacity); | 341 GetLayer(status_)->SetOpacity(target_bounds.opacity); |
| 347 Shell::GetInstance()->SetMonitorWorkAreaInsets( | 342 Shell::GetInstance()->SetMonitorWorkAreaInsets( |
| 348 Shell::GetRootWindow(), | 343 Shell::GetRootWindow(), |
| 349 target_bounds.work_area_insets); | 344 target_bounds.work_area_insets); |
| 350 UpdateHitTestBounds(); | 345 UpdateHitTestBounds(); |
| 351 UpdateShelfBackground(change_type); | 346 UpdateShelfBackground(change_type); |
| 352 } | 347 } |
| 353 | 348 |
| 354 void ShelfLayoutManager::StopAnimating() { | 349 void ShelfLayoutManager::StopAnimating() { |
| 355 if (launcher_widget()) | 350 if (launcher_widget()) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) { | 462 bool ShelfLayoutManager::IsShelfWindow(aura::Window* window) { |
| 468 if (!window) | 463 if (!window) |
| 469 return false; | 464 return false; |
| 470 return (launcher_widget() && | 465 return (launcher_widget() && |
| 471 launcher_widget()->GetNativeWindow()->Contains(window)) || | 466 launcher_widget()->GetNativeWindow()->Contains(window)) || |
| 472 (status_ && status_->GetNativeWindow()->Contains(window)); | 467 (status_ && status_->GetNativeWindow()->Contains(window)); |
| 473 } | 468 } |
| 474 | 469 |
| 475 } // namespace internal | 470 } // namespace internal |
| 476 } // namespace ash | 471 } // namespace ash |
| OLD | NEW |