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/window_animations.h" | 5 #include "ash/wm/window_animations.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <vector> | 10 #include <vector> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 const float kWindowAnimation_ShowBrightnessGrayscale = 0.f; | 55 const float kWindowAnimation_ShowBrightnessGrayscale = 0.f; |
56 | 56 |
57 const float kWindowAnimation_HideOpacity = 0.f; | 57 const float kWindowAnimation_HideOpacity = 0.f; |
58 const float kWindowAnimation_ShowOpacity = 1.f; | 58 const float kWindowAnimation_ShowOpacity = 1.f; |
59 // TODO(sky): if we end up sticking with 0, nuke the code doing the rotation. | 59 // TODO(sky): if we end up sticking with 0, nuke the code doing the rotation. |
60 const float kWindowAnimation_MinimizeRotate = 0.f; | 60 const float kWindowAnimation_MinimizeRotate = 0.f; |
61 | 61 |
62 // Tween type when cross fading a workspace window. | 62 // Tween type when cross fading a workspace window. |
63 const ui::Tween::Type kCrossFadeTweenType = ui::Tween::EASE_IN_OUT; | 63 const ui::Tween::Type kCrossFadeTweenType = ui::Tween::EASE_IN_OUT; |
64 | 64 |
| 65 // Scales for AshWindow above/below current workspace. |
| 66 const float kLayerScaleAboveSize = 1.1f; |
| 67 const float kLayerScaleBelowSize = .9f; |
| 68 |
65 int64 Round64(float f) { | 69 int64 Round64(float f) { |
66 return static_cast<int64>(f + 0.5f); | 70 return static_cast<int64>(f + 0.5f); |
67 } | 71 } |
68 | 72 |
69 } | 73 } |
70 | 74 |
71 gfx::Rect GetMinimizeRectForWindow(aura::Window* window) { | 75 gfx::Rect GetMinimizeRectForWindow(aura::Window* window) { |
72 Launcher* launcher = Launcher::ForWindow(window); | 76 Launcher* launcher = Launcher::ForWindow(window); |
73 // Launcher is created lazily and can be NULL. | 77 // Launcher is created lazily and can be NULL. |
74 if (!launcher) | 78 if (!launcher) |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 217 } |
214 | 218 |
215 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { | 219 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { |
216 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); | 220 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); |
217 } | 221 } |
218 | 222 |
219 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { | 223 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { |
220 AnimateShowHideWindowCommon_BrightnessGrayscale(window, false); | 224 AnimateShowHideWindowCommon_BrightnessGrayscale(window, false); |
221 } | 225 } |
222 | 226 |
223 | |
224 | |
225 bool AnimateShowWindow(aura::Window* window) { | 227 bool AnimateShowWindow(aura::Window* window) { |
226 if (!views::corewm::HasWindowVisibilityAnimationTransition( | 228 if (!views::corewm::HasWindowVisibilityAnimationTransition( |
227 window, views::corewm::ANIMATE_SHOW)) { | 229 window, views::corewm::ANIMATE_SHOW)) { |
228 return false; | 230 return false; |
229 } | 231 } |
230 | 232 |
231 switch (views::corewm::GetWindowVisibilityAnimationType(window)) { | 233 switch (views::corewm::GetWindowVisibilityAnimationType(window)) { |
232 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: | 234 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: |
233 AnimateShowWindow_Minimize(window); | 235 AnimateShowWindow_Minimize(window); |
234 return true; | 236 return true; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 grayscale_element->set_tween_type(animation_type); | 496 grayscale_element->set_tween_type(animation_type); |
495 grayscale_sequence->AddElement(grayscale_element.release()); | 497 grayscale_sequence->AddElement(grayscale_element.release()); |
496 | 498 |
497 std::vector<ui::LayerAnimationSequence*> animations; | 499 std::vector<ui::LayerAnimationSequence*> animations; |
498 animations.push_back(brightness_sequence.release()); | 500 animations.push_back(brightness_sequence.release()); |
499 animations.push_back(grayscale_sequence.release()); | 501 animations.push_back(grayscale_sequence.release()); |
500 | 502 |
501 return animations; | 503 return animations; |
502 } | 504 } |
503 | 505 |
| 506 // Returns scale related to the specified AshWindowScaleType. |
| 507 void SetTransformForScaleAnimation(ui::Layer* layer, |
| 508 LayerScaleAnimationDirection type) { |
| 509 const float scale = |
| 510 type == LAYER_SCALE_ANIMATION_ABOVE ? kLayerScaleAboveSize : |
| 511 kLayerScaleBelowSize; |
| 512 gfx::Transform transform; |
| 513 transform.Translate(-layer->bounds().width() * (scale - 1.0f) / 2, |
| 514 -layer->bounds().height() * (scale - 1.0f) / 2); |
| 515 transform.Scale(scale, scale); |
| 516 layer->SetTransform(transform); |
| 517 } |
| 518 |
504 } // namespace ash | 519 } // namespace ash |
OLD | NEW |