Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: ash/wm/window_animations.cc

Issue 2243513004: mash: Partially migrate WorkspaceController to ash common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <algorithm> 8 #include <algorithm>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 19 matching lines...) Expand all
30 #include "ui/compositor/layer.h" 30 #include "ui/compositor/layer.h"
31 #include "ui/compositor/layer_animation_observer.h" 31 #include "ui/compositor/layer_animation_observer.h"
32 #include "ui/compositor/layer_animation_sequence.h" 32 #include "ui/compositor/layer_animation_sequence.h"
33 #include "ui/compositor/layer_animator.h" 33 #include "ui/compositor/layer_animator.h"
34 #include "ui/compositor/layer_tree_owner.h" 34 #include "ui/compositor/layer_tree_owner.h"
35 #include "ui/compositor/scoped_layer_animation_settings.h" 35 #include "ui/compositor/scoped_layer_animation_settings.h"
36 #include "ui/display/display.h" 36 #include "ui/display/display.h"
37 #include "ui/display/screen.h" 37 #include "ui/display/screen.h"
38 #include "ui/gfx/geometry/vector3d_f.h" 38 #include "ui/gfx/geometry/vector3d_f.h"
39 #include "ui/gfx/interpolated_transform.h" 39 #include "ui/gfx/interpolated_transform.h"
40 #include "ui/gfx/transform.h"
40 #include "ui/views/view.h" 41 #include "ui/views/view.h"
41 #include "ui/views/widget/widget.h" 42 #include "ui/views/widget/widget.h"
42 #include "ui/wm/core/window_util.h" 43 #include "ui/wm/core/window_util.h"
43 44
44 namespace ash { 45 namespace ash {
45 namespace { 46 namespace {
47
46 const int kLayerAnimationsForMinimizeDurationMS = 200; 48 const int kLayerAnimationsForMinimizeDurationMS = 200;
47 49
48 // Durations for the cross-fade animation, in milliseconds. 50 // Durations for the cross-fade animation, in milliseconds.
49 const float kCrossFadeDurationMinMs = 200.f; 51 const float kCrossFadeDurationMinMs = 200.f;
50 const float kCrossFadeDurationMaxMs = 400.f; 52 const float kCrossFadeDurationMaxMs = 400.f;
51 53
52 // Durations for the brightness/grayscale fade animation, in milliseconds. 54 // Durations for the brightness/grayscale fade animation, in milliseconds.
53 const int kBrightnessGrayscaleFadeDurationMs = 1000; 55 const int kBrightnessGrayscaleFadeDurationMs = 1000;
54 56
55 // Brightness/grayscale values for hide/show window animations. 57 // Brightness/grayscale values for hide/show window animations.
56 const float kWindowAnimation_HideBrightnessGrayscale = 1.f; 58 const float kWindowAnimation_HideBrightnessGrayscale = 1.f;
57 const float kWindowAnimation_ShowBrightnessGrayscale = 0.f; 59 const float kWindowAnimation_ShowBrightnessGrayscale = 0.f;
58 60
59 const float kWindowAnimation_HideOpacity = 0.f; 61 const float kWindowAnimation_HideOpacity = 0.f;
60 const float kWindowAnimation_ShowOpacity = 1.f; 62 const float kWindowAnimation_ShowOpacity = 1.f;
61 63
62 // Scales for AshWindow above/below current workspace.
63 const float kLayerScaleAboveSize = 1.1f;
64 const float kLayerScaleBelowSize = .9f;
65
66 int64_t Round64(float f) { 64 int64_t Round64(float f) {
67 return static_cast<int64_t>(f + 0.5f); 65 return static_cast<int64_t>(f + 0.5f);
68 } 66 }
69 67
70 base::TimeDelta GetCrossFadeDuration(aura::Window* window, 68 base::TimeDelta GetCrossFadeDuration(aura::Window* window,
71 const gfx::RectF& old_bounds, 69 const gfx::RectF& old_bounds,
72 const gfx::Rect& new_bounds) { 70 const gfx::Rect& new_bounds) {
73 if (::wm::WindowAnimationsDisabled(window)) 71 if (::wm::WindowAnimationsDisabled(window))
74 return base::TimeDelta(); 72 return base::TimeDelta();
75 73
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 grayscale_element->set_tween_type(animation_type); 425 grayscale_element->set_tween_type(animation_type);
428 grayscale_sequence->AddElement(grayscale_element.release()); 426 grayscale_sequence->AddElement(grayscale_element.release());
429 427
430 std::vector<ui::LayerAnimationSequence*> animations; 428 std::vector<ui::LayerAnimationSequence*> animations;
431 animations.push_back(brightness_sequence.release()); 429 animations.push_back(brightness_sequence.release());
432 animations.push_back(grayscale_sequence.release()); 430 animations.push_back(grayscale_sequence.release());
433 431
434 return animations; 432 return animations;
435 } 433 }
436 434
437 // Returns scale related to the specified AshWindowScaleType.
438 void SetTransformForScaleAnimation(ui::Layer* layer,
439 LayerScaleAnimationDirection type) {
440 const float scale = type == LAYER_SCALE_ANIMATION_ABOVE
441 ? kLayerScaleAboveSize
442 : kLayerScaleBelowSize;
443 gfx::Transform transform;
444 transform.Translate(-layer->bounds().width() * (scale - 1.0f) / 2,
445 -layer->bounds().height() * (scale - 1.0f) / 2);
446 transform.Scale(scale, scale);
447 layer->SetTransform(transform);
448 }
449
450 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) { 435 gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
451 Shelf* shelf = Shelf::ForWindow(window); 436 Shelf* shelf = Shelf::ForWindow(window);
452 // Shelf is created lazily and can be NULL. 437 // Shelf is created lazily and can be NULL.
453 if (!shelf) 438 if (!shelf)
454 return gfx::Rect(); 439 return gfx::Rect();
455 gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(window); 440 gfx::Rect item_rect = shelf->GetScreenBoundsOfItemIconForWindow(window);
456 441
457 // The launcher item is visible and has an icon. 442 // The launcher item is visible and has an icon.
458 if (!item_rect.IsEmpty()) 443 if (!item_rect.IsEmpty())
459 return item_rect; 444 return item_rect;
(...skipping 29 matching lines...) Expand all
489 case SHELF_ALIGNMENT_LEFT: 474 case SHELF_ALIGNMENT_LEFT:
490 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); 475 return gfx::Rect(work_area.x(), work_area.y(), 0, 0);
491 case SHELF_ALIGNMENT_RIGHT: 476 case SHELF_ALIGNMENT_RIGHT:
492 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); 477 return gfx::Rect(work_area.right(), work_area.y(), 0, 0);
493 } 478 }
494 NOTREACHED(); 479 NOTREACHED();
495 return gfx::Rect(); 480 return gfx::Rect();
496 } 481 }
497 482
498 } // namespace ash 483 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698