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

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

Issue 2237613002: mash: Migrate some misc ShelfLayoutManager deps to ash common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move ShelfBezelEventHandler to WmShelfAura. 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 const gfx::RectF& old_bounds, 71 const gfx::RectF& old_bounds,
72 const gfx::Rect& new_bounds) { 72 const gfx::Rect& new_bounds) {
73 if (::wm::WindowAnimationsDisabled(window)) 73 if (::wm::WindowAnimationsDisabled(window))
74 return base::TimeDelta(); 74 return base::TimeDelta();
75 75
76 int old_area = static_cast<int>(old_bounds.width() * old_bounds.height()); 76 int old_area = static_cast<int>(old_bounds.width() * old_bounds.height());
77 int new_area = new_bounds.width() * new_bounds.height(); 77 int new_area = new_bounds.width() * new_bounds.height();
78 int max_area = std::max(old_area, new_area); 78 int max_area = std::max(old_area, new_area);
79 // Avoid divide by zero. 79 // Avoid divide by zero.
80 if (max_area == 0) 80 if (max_area == 0)
81 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS); 81 return base::TimeDelta::FromMilliseconds(wm::kCrossFadeDurationMS);
82 82
83 int delta_area = std::abs(old_area - new_area); 83 int delta_area = std::abs(old_area - new_area);
84 // If the area didn't change, the animation is instantaneous. 84 // If the area didn't change, the animation is instantaneous.
85 if (delta_area == 0) 85 if (delta_area == 0)
86 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS); 86 return base::TimeDelta::FromMilliseconds(wm::kCrossFadeDurationMS);
87 87
88 float factor = static_cast<float>(delta_area) / static_cast<float>(max_area); 88 float factor = static_cast<float>(delta_area) / static_cast<float>(max_area);
89 const float kRange = kCrossFadeDurationMaxMs - kCrossFadeDurationMinMs; 89 const float kRange = kCrossFadeDurationMaxMs - kCrossFadeDurationMinMs;
90 return base::TimeDelta::FromMilliseconds( 90 return base::TimeDelta::FromMilliseconds(
91 Round64(kCrossFadeDurationMinMs + (factor * kRange))); 91 Round64(kCrossFadeDurationMinMs + (factor * kRange)));
92 } 92 }
93 93
94 } // namespace 94 } // namespace
95 95
96 const int kCrossFadeDurationMS = 200;
97
98 void AddLayerAnimationsForMinimize(aura::Window* window, bool show) { 96 void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
99 // Recalculate the transform at restore time since the launcher item may have 97 // Recalculate the transform at restore time since the launcher item may have
100 // moved while the window was minimized. 98 // moved while the window was minimized.
101 gfx::Rect bounds = window->bounds(); 99 gfx::Rect bounds = window->bounds();
102 gfx::Rect target_bounds = GetMinimizeAnimationTargetBoundsInScreen(window); 100 gfx::Rect target_bounds = GetMinimizeAnimationTargetBoundsInScreen(window);
103 target_bounds = 101 target_bounds =
104 ScreenUtil::ConvertRectFromScreen(window->parent(), target_bounds); 102 ScreenUtil::ConvertRectFromScreen(window->parent(), target_bounds);
105 103
106 float scale_x = static_cast<float>(target_bounds.width()) / bounds.width(); 104 float scale_x = static_cast<float>(target_bounds.width()) / bounds.width();
107 float scale_y = static_cast<float>(target_bounds.height()) / bounds.height(); 105 float scale_y = static_cast<float>(target_bounds.height()) / bounds.height();
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 case SHELF_ALIGNMENT_LEFT: 487 case SHELF_ALIGNMENT_LEFT:
490 return gfx::Rect(work_area.x(), work_area.y(), 0, 0); 488 return gfx::Rect(work_area.x(), work_area.y(), 0, 0);
491 case SHELF_ALIGNMENT_RIGHT: 489 case SHELF_ALIGNMENT_RIGHT:
492 return gfx::Rect(work_area.right(), work_area.y(), 0, 0); 490 return gfx::Rect(work_area.right(), work_area.y(), 0, 0);
493 } 491 }
494 NOTREACHED(); 492 NOTREACHED();
495 return gfx::Rect(); 493 return gfx::Rect();
496 } 494 }
497 495
498 } // namespace ash 496 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698