| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/common/wm/maximize_mode/workspace_backdrop_delegate.h" | 5 #include "ash/common/wm/maximize_mode/workspace_backdrop_delegate.h" |
| 6 | 6 |
| 7 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" | 7 #include "ash/common/wm/workspace/workspace_layout_manager_backdrop_delegate.h" |
| 8 #include "ash/common/wm_lookup.h" | 8 #include "ash/common/wm_lookup.h" |
| 9 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 10 #include "ash/common/wm_window_observer.h" | |
| 11 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 12 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
| 13 #include "base/auto_reset.h" | 12 #include "base/auto_reset.h" |
| 13 #include "ui/aura/window_observer.h" |
| 14 #include "ui/compositor/layer.h" | 14 #include "ui/compositor/layer.h" |
| 15 #include "ui/compositor/scoped_layer_animation_settings.h" | 15 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 16 #include "ui/views/background.h" | 16 #include "ui/views/background.h" |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 #include "ui/wm/core/window_animations.h" | 18 #include "ui/wm/core/window_animations.h" |
| 19 #include "ui/wm/core/window_util.h" | 19 #include "ui/wm/core/window_util.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // The opacity of the backdrop. | 24 // The opacity of the backdrop. |
| 25 const float kBackdropOpacity = 0.5f; | 25 const float kBackdropOpacity = 0.5f; |
| 26 | 26 |
| 27 } // namespace | 27 } // namespace |
| 28 | 28 |
| 29 class WorkspaceBackdropDelegate::WindowObserverImpl : public WmWindowObserver { | 29 class WorkspaceBackdropDelegate::WindowObserverImpl |
| 30 : public aura::WindowObserver { |
| 30 public: | 31 public: |
| 31 explicit WindowObserverImpl(WorkspaceBackdropDelegate* delegate) | 32 explicit WindowObserverImpl(WorkspaceBackdropDelegate* delegate) |
| 32 : delegate_(delegate) {} | 33 : delegate_(delegate) {} |
| 33 ~WindowObserverImpl() override {} | 34 ~WindowObserverImpl() override {} |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 // WmWindowObserver overrides: | 37 // aura::WindowObserver overrides: |
| 37 void OnWindowBoundsChanged(WmWindow* window, | 38 void OnWindowBoundsChanged(aura::Window* window, |
| 38 const gfx::Rect& old_bounds, | 39 const gfx::Rect& old_bounds, |
| 39 const gfx::Rect& new_bounds) override { | 40 const gfx::Rect& new_bounds) override { |
| 40 // The container size has changed and the layer needs to be adapt to it. | 41 // The container size has changed and the layer needs to be adapt to it. |
| 41 delegate_->AdjustToContainerBounds(); | 42 delegate_->AdjustToContainerBounds(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 WorkspaceBackdropDelegate* delegate_; | 45 WorkspaceBackdropDelegate* delegate_; |
| 45 | 46 |
| 46 DISALLOW_COPY_AND_ASSIGN(WindowObserverImpl); | 47 DISALLOW_COPY_AND_ASSIGN(WindowObserverImpl); |
| 47 }; | 48 }; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 background_window_ = WmLookup::Get()->GetWindowForWidget(background_); | 67 background_window_ = WmLookup::Get()->GetWindowForWidget(background_); |
| 67 // Do not use the animation system. We don't want the bounds animation and | 68 // Do not use the animation system. We don't want the bounds animation and |
| 68 // opacity needs to get set to |kBackdropOpacity|. | 69 // opacity needs to get set to |kBackdropOpacity|. |
| 69 background_window_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 70 background_window_->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
| 70 background_window_->GetLayer()->SetColor(SK_ColorBLACK); | 71 background_window_->GetLayer()->SetColor(SK_ColorBLACK); |
| 71 // Make sure that the layer covers visibly everything - including the shelf. | 72 // Make sure that the layer covers visibly everything - including the shelf. |
| 72 background_window_->GetLayer()->SetBounds(params.bounds); | 73 background_window_->GetLayer()->SetBounds(params.bounds); |
| 73 DCHECK(background_window_->GetBounds() == params.bounds); | 74 DCHECK(background_window_->GetBounds() == params.bounds); |
| 74 Show(); | 75 Show(); |
| 75 RestackBackdrop(); | 76 RestackBackdrop(); |
| 76 container_->AddObserver(container_observer_.get()); | 77 container_->aura_window()->AddObserver(container_observer_.get()); |
| 77 } | 78 } |
| 78 | 79 |
| 79 WorkspaceBackdropDelegate::~WorkspaceBackdropDelegate() { | 80 WorkspaceBackdropDelegate::~WorkspaceBackdropDelegate() { |
| 80 container_->RemoveObserver(container_observer_.get()); | 81 container_->aura_window()->RemoveObserver(container_observer_.get()); |
| 81 // TODO: animations won't work right with mus: http://crbug.com/548396. | 82 // TODO: animations won't work right with mus: http://crbug.com/548396. |
| 82 ::wm::ScopedHidingAnimationSettings hiding_settings( | 83 ::wm::ScopedHidingAnimationSettings hiding_settings( |
| 83 background_->GetNativeView()); | 84 background_->GetNativeView()); |
| 84 background_->Close(); | 85 background_->Close(); |
| 85 background_window_->GetLayer()->SetOpacity(0.0f); | 86 background_window_->GetLayer()->SetOpacity(0.0f); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void WorkspaceBackdropDelegate::OnWindowAddedToLayout(WmWindow* child) { | 89 void WorkspaceBackdropDelegate::OnWindowAddedToLayout(WmWindow* child) { |
| 89 RestackBackdrop(); | 90 RestackBackdrop(); |
| 90 } | 91 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 169 |
| 169 void WorkspaceBackdropDelegate::Show() { | 170 void WorkspaceBackdropDelegate::Show() { |
| 170 background_window_->GetLayer()->SetOpacity(0.0f); | 171 background_window_->GetLayer()->SetOpacity(0.0f); |
| 171 background_->Show(); | 172 background_->Show(); |
| 172 ui::ScopedLayerAnimationSettings settings( | 173 ui::ScopedLayerAnimationSettings settings( |
| 173 background_window_->GetLayer()->GetAnimator()); | 174 background_window_->GetLayer()->GetAnimator()); |
| 174 background_window_->GetLayer()->SetOpacity(kBackdropOpacity); | 175 background_window_->GetLayer()->SetOpacity(kBackdropOpacity); |
| 175 } | 176 } |
| 176 | 177 |
| 177 } // namespace ash | 178 } // namespace ash |
| OLD | NEW |