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/workspace/phantom_window_controller.h" | 5 #include "ash/wm/workspace/phantom_window_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/wm/coordinate_conversion.h" | 9 #include "ash/wm/coordinate_conversion.h" |
10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/base/animation/slide_animation.h" | |
14 #include "ui/compositor/layer.h" | 13 #include "ui/compositor/layer.h" |
15 #include "ui/compositor/scoped_layer_animation_settings.h" | 14 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 15 #include "ui/gfx/animation/slide_animation.h" |
16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
17 #include "ui/gfx/skia_util.h" | 17 #include "ui/gfx/skia_util.h" |
18 #include "ui/views/painter.h" | 18 #include "ui/views/painter.h" |
19 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
20 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
21 | 21 |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
24 namespace internal { | 24 namespace internal { |
25 | 25 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 if (phantom_widget_start_ && | 136 if (phantom_widget_start_ && |
137 (phantom_widget_start_->GetNativeWindow()->GetRootWindow() != start_root | 137 (phantom_widget_start_->GetNativeWindow()->GetRootWindow() != start_root |
138 || start_root == target_root)) { | 138 || start_root == target_root)) { |
139 phantom_widget_start_->Close(); | 139 phantom_widget_start_->Close(); |
140 phantom_widget_start_ = NULL; | 140 phantom_widget_start_ = NULL; |
141 } | 141 } |
142 if (!phantom_widget_start_ && start_root != target_root) | 142 if (!phantom_widget_start_ && start_root != target_root) |
143 phantom_widget_start_ = CreatePhantomWidget(start_root, start_bounds_); | 143 phantom_widget_start_ = CreatePhantomWidget(start_root, start_bounds_); |
144 | 144 |
145 animation_.reset(new ui::SlideAnimation(this)); | 145 animation_.reset(new gfx::SlideAnimation(this)); |
146 animation_->SetTweenType(ui::Tween::EASE_IN); | 146 animation_->SetTweenType(gfx::Tween::EASE_IN); |
147 const int kAnimationDurationMS = 200; | 147 const int kAnimationDurationMS = 200; |
148 animation_->SetSlideDuration(kAnimationDurationMS); | 148 animation_->SetSlideDuration(kAnimationDurationMS); |
149 animation_->Show(); | 149 animation_->Show(); |
150 } | 150 } |
151 | 151 |
152 void PhantomWindowController::Hide() { | 152 void PhantomWindowController::Hide() { |
153 if (phantom_widget_) | 153 if (phantom_widget_) |
154 phantom_widget_->Close(); | 154 phantom_widget_->Close(); |
155 phantom_widget_ = NULL; | 155 phantom_widget_ = NULL; |
156 if (phantom_widget_start_) | 156 if (phantom_widget_start_) |
157 phantom_widget_start_->Close(); | 157 phantom_widget_start_->Close(); |
158 phantom_widget_start_ = NULL; | 158 phantom_widget_start_ = NULL; |
159 } | 159 } |
160 | 160 |
161 bool PhantomWindowController::IsShowing() const { | 161 bool PhantomWindowController::IsShowing() const { |
162 return phantom_widget_ != NULL; | 162 return phantom_widget_ != NULL; |
163 } | 163 } |
164 | 164 |
165 void PhantomWindowController::AnimationProgressed( | 165 void PhantomWindowController::AnimationProgressed( |
166 const ui::Animation* animation) { | 166 const gfx::Animation* animation) { |
167 const gfx::Rect current_bounds = | 167 const gfx::Rect current_bounds = |
168 animation->CurrentValueBetween(start_bounds_, bounds_in_screen_); | 168 animation->CurrentValueBetween(start_bounds_, bounds_in_screen_); |
169 if (phantom_widget_start_) | 169 if (phantom_widget_start_) |
170 phantom_widget_start_->SetBounds(current_bounds); | 170 phantom_widget_start_->SetBounds(current_bounds); |
171 phantom_widget_->SetBounds(current_bounds); | 171 phantom_widget_->SetBounds(current_bounds); |
172 } | 172 } |
173 | 173 |
174 views::Widget* PhantomWindowController::CreatePhantomWidget( | 174 views::Widget* PhantomWindowController::CreatePhantomWidget( |
175 aura::RootWindow* root_window, | 175 aura::RootWindow* root_window, |
176 const gfx::Rect& bounds_in_screen) { | 176 const gfx::Rect& bounds_in_screen) { |
(...skipping 28 matching lines...) Expand all Loading... |
205 // Fade the window in. | 205 // Fade the window in. |
206 ui::Layer* widget_layer = phantom_widget->GetNativeWindow()->layer(); | 206 ui::Layer* widget_layer = phantom_widget->GetNativeWindow()->layer(); |
207 widget_layer->SetOpacity(0); | 207 widget_layer->SetOpacity(0); |
208 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator()); | 208 ui::ScopedLayerAnimationSettings scoped_setter(widget_layer->GetAnimator()); |
209 widget_layer->SetOpacity(1); | 209 widget_layer->SetOpacity(1); |
210 return phantom_widget; | 210 return phantom_widget; |
211 } | 211 } |
212 | 212 |
213 } // namespace internal | 213 } // namespace internal |
214 } // namespace ash | 214 } // namespace ash |
OLD | NEW |