| 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/common/workspace/phantom_window_controller.h" | 5 #include "ash/wm/common/workspace/phantom_window_controller.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "ash/wm/common/root_window_finder.h" | 9 #include "ash/wm/common/root_window_finder.h" |
| 10 #include "ash/wm/common/wm_lookup.h" |
| 10 #include "ash/wm/common/wm_root_window_controller.h" | 11 #include "ash/wm/common/wm_root_window_controller.h" |
| 11 #include "ash/wm/common/wm_shell_window_ids.h" | 12 #include "ash/wm/common/wm_shell_window_ids.h" |
| 12 #include "ash/wm/common/wm_window.h" | 13 #include "ash/wm/common/wm_window.h" |
| 13 #include "grit/ash_resources.h" | 14 #include "grit/ash_resources.h" |
| 14 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
| 15 #include "ui/compositor/scoped_layer_animation_settings.h" | 16 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 16 #include "ui/views/background.h" | 17 #include "ui/views/background.h" |
| 17 #include "ui/views/painter.h" | 18 #include "ui/views/painter.h" |
| 18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 54 } |
| 54 | 55 |
| 55 // Starts an animation of |widget| to |new_bounds_in_screen|. No-op if |widget| | 56 // Starts an animation of |widget| to |new_bounds_in_screen|. No-op if |widget| |
| 56 // is NULL. | 57 // is NULL. |
| 57 void AnimateToBounds(views::Widget* widget, | 58 void AnimateToBounds(views::Widget* widget, |
| 58 const gfx::Rect& new_bounds_in_screen) { | 59 const gfx::Rect& new_bounds_in_screen) { |
| 59 if (!widget) | 60 if (!widget) |
| 60 return; | 61 return; |
| 61 | 62 |
| 62 ui::ScopedLayerAnimationSettings scoped_setter( | 63 ui::ScopedLayerAnimationSettings scoped_setter( |
| 63 wm::WmWindow::Get(widget)->GetLayer()->GetAnimator()); | 64 wm::WmLookup::Get() |
| 65 ->GetWindowForWidget(widget) |
| 66 ->GetLayer() |
| 67 ->GetAnimator()); |
| 64 scoped_setter.SetTweenType(gfx::Tween::EASE_IN); | 68 scoped_setter.SetTweenType(gfx::Tween::EASE_IN); |
| 65 scoped_setter.SetPreemptionStrategy( | 69 scoped_setter.SetPreemptionStrategy( |
| 66 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 70 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 67 scoped_setter.SetTransitionDuration( | 71 scoped_setter.SetTransitionDuration( |
| 68 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 72 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
| 69 widget->SetBounds(new_bounds_in_screen); | 73 widget->SetBounds(new_bounds_in_screen); |
| 70 } | 74 } |
| 71 | 75 |
| 72 } // namespace | 76 } // namespace |
| 73 | 77 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // launcher button. Put the phantom in the same window as the launcher so that | 115 // launcher button. Put the phantom in the same window as the launcher so that |
| 112 // the phantom is visible. | 116 // the phantom is visible. |
| 113 params.keep_on_top = true; | 117 params.keep_on_top = true; |
| 114 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 118 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 115 params.name = "PhantomWindow"; | 119 params.name = "PhantomWindow"; |
| 116 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | 120 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( |
| 117 phantom_widget.get(), kShellWindowId_ShelfContainer, ¶ms); | 121 phantom_widget.get(), kShellWindowId_ShelfContainer, ¶ms); |
| 118 phantom_widget->set_focus_on_creation(false); | 122 phantom_widget->set_focus_on_creation(false); |
| 119 phantom_widget->Init(params); | 123 phantom_widget->Init(params); |
| 120 phantom_widget->SetVisibilityChangedAnimationsEnabled(false); | 124 phantom_widget->SetVisibilityChangedAnimationsEnabled(false); |
| 121 wm::WmWindow* phantom_widget_window = wm::WmWindow::Get(phantom_widget.get()); | 125 wm::WmWindow* phantom_widget_window = |
| 126 wm::WmLookup::Get()->GetWindowForWidget(phantom_widget.get()); |
| 122 phantom_widget_window->SetShellWindowId(kShellWindowId_PhantomWindow); | 127 phantom_widget_window->SetShellWindowId(kShellWindowId_PhantomWindow); |
| 123 phantom_widget->SetBounds(bounds_in_screen); | 128 phantom_widget->SetBounds(bounds_in_screen); |
| 124 // TODO(sky): I suspect this is never true, verify that. | 129 // TODO(sky): I suspect this is never true, verify that. |
| 125 if (phantom_widget_window->GetParent() == window_->GetParent()) { | 130 if (phantom_widget_window->GetParent() == window_->GetParent()) { |
| 126 phantom_widget_window->GetParent()->StackChildAbove(phantom_widget_window, | 131 phantom_widget_window->GetParent()->StackChildAbove(phantom_widget_window, |
| 127 window_); | 132 window_); |
| 128 } | 133 } |
| 129 | 134 |
| 130 const int kImages[] = IMAGE_GRID(IDR_AURA_PHANTOM_WINDOW); | 135 const int kImages[] = IMAGE_GRID(IDR_AURA_PHANTOM_WINDOW); |
| 131 views::Painter* background_painter = | 136 views::Painter* background_painter = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 143 widget_layer->SetOpacity(0); | 148 widget_layer->SetOpacity(0); |
| 144 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator()); | 149 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator()); |
| 145 scoped_setter.SetTransitionDuration( | 150 scoped_setter.SetTransitionDuration( |
| 146 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); | 151 base::TimeDelta::FromMilliseconds(kAnimationDurationMs)); |
| 147 widget_layer->SetOpacity(1); | 152 widget_layer->SetOpacity(1); |
| 148 | 153 |
| 149 return phantom_widget; | 154 return phantom_widget; |
| 150 } | 155 } |
| 151 | 156 |
| 152 } // namespace ash | 157 } // namespace ash |
| OLD | NEW |