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

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

Issue 196063002: Move wm/core to wm namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 const float kLayerScaleAboveSize = 1.1f; 62 const float kLayerScaleAboveSize = 1.1f;
63 const float kLayerScaleBelowSize = .9f; 63 const float kLayerScaleBelowSize = .9f;
64 64
65 int64 Round64(float f) { 65 int64 Round64(float f) {
66 return static_cast<int64>(f + 0.5f); 66 return static_cast<int64>(f + 0.5f);
67 } 67 }
68 68
69 base::TimeDelta GetCrossFadeDuration(aura::Window* window, 69 base::TimeDelta GetCrossFadeDuration(aura::Window* window,
70 const gfx::Rect& old_bounds, 70 const gfx::Rect& old_bounds,
71 const gfx::Rect& new_bounds) { 71 const gfx::Rect& new_bounds) {
72 if (views::corewm::WindowAnimationsDisabled(window)) 72 if (::wm::WindowAnimationsDisabled(window))
73 return base::TimeDelta(); 73 return base::TimeDelta();
74 74
75 int old_area = old_bounds.width() * old_bounds.height(); 75 int old_area = old_bounds.width() * old_bounds.height();
76 int new_area = new_bounds.width() * new_bounds.height(); 76 int new_area = new_bounds.width() * new_bounds.height();
77 int max_area = std::max(old_area, new_area); 77 int max_area = std::max(old_area, new_area);
78 // Avoid divide by zero. 78 // Avoid divide by zero.
79 if (max_area == 0) 79 if (max_area == 0)
80 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS); 80 return base::TimeDelta::FromMilliseconds(kCrossFadeDurationMS);
81 81
82 int delta_area = std::abs(old_area - new_area); 82 int delta_area = std::abs(old_area - new_area);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 window->layer()->set_delegate(window); 158 window->layer()->set_delegate(window);
159 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 159 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
160 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 160 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
161 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 161 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
162 kLayerAnimationsForMinimizeDurationMS); 162 kLayerAnimationsForMinimizeDurationMS);
163 settings.SetTransitionDuration(duration); 163 settings.SetTransitionDuration(duration);
164 AddLayerAnimationsForMinimize(window, true); 164 AddLayerAnimationsForMinimize(window, true);
165 165
166 // Now that the window has been restored, we need to clear its animation style 166 // Now that the window has been restored, we need to clear its animation style
167 // to default so that normal animation applies. 167 // to default so that normal animation applies.
168 views::corewm::SetWindowVisibilityAnimationType( 168 ::wm::SetWindowVisibilityAnimationType(
169 window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); 169 window, ::wm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT);
170 } 170 }
171 171
172 void AnimateHideWindow_Minimize(aura::Window* window) { 172 void AnimateHideWindow_Minimize(aura::Window* window) {
173 window->layer()->set_delegate(NULL); 173 window->layer()->set_delegate(NULL);
174 174
175 // Property sets within this scope will be implicitly animated. 175 // Property sets within this scope will be implicitly animated.
176 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 176 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( 177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(
178 kLayerAnimationsForMinimizeDurationMS); 178 kLayerAnimationsForMinimizeDurationMS);
179 settings.SetTransitionDuration(duration); 179 settings.SetTransitionDuration(duration);
180 settings.AddObserver( 180 settings.AddObserver(
181 views::corewm::CreateHidingWindowAnimationObserver(window)); 181 ::wm::CreateHidingWindowAnimationObserver(window));
182 window->layer()->SetVisible(false); 182 window->layer()->SetVisible(false);
183 183
184 AddLayerAnimationsForMinimize(window, false); 184 AddLayerAnimationsForMinimize(window, false);
185 } 185 }
186 186
187 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, 187 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window,
188 bool show) { 188 bool show) {
189 window->layer()->set_delegate(window); 189 window->layer()->set_delegate(window);
190 190
191 float start_value, end_value; 191 float start_value, end_value;
(...skipping 12 matching lines...) Expand all
204 window->layer()->SetVisible(true); 204 window->layer()->SetVisible(true);
205 } 205 }
206 206
207 base::TimeDelta duration = 207 base::TimeDelta duration =
208 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); 208 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs);
209 209
210 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); 210 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator());
211 settings.SetTransitionDuration(duration); 211 settings.SetTransitionDuration(duration);
212 if (!show) { 212 if (!show) {
213 settings.AddObserver( 213 settings.AddObserver(
214 views::corewm::CreateHidingWindowAnimationObserver(window)); 214 ::wm::CreateHidingWindowAnimationObserver(window));
215 } 215 }
216 216
217 window->layer()->GetAnimator()-> 217 window->layer()->GetAnimator()->
218 ScheduleTogether( 218 ScheduleTogether(
219 CreateBrightnessGrayscaleAnimationSequence(end_value, duration)); 219 CreateBrightnessGrayscaleAnimationSequence(end_value, duration));
220 if (!show) { 220 if (!show) {
221 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); 221 window->layer()->SetOpacity(kWindowAnimation_HideOpacity);
222 window->layer()->SetVisible(false); 222 window->layer()->SetVisible(false);
223 } 223 }
224 } 224 }
225 225
226 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { 226 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) {
227 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); 227 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true);
228 } 228 }
229 229
230 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { 230 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) {
231 AnimateShowHideWindowCommon_BrightnessGrayscale(window, false); 231 AnimateShowHideWindowCommon_BrightnessGrayscale(window, false);
232 } 232 }
233 233
234 bool AnimateShowWindow(aura::Window* window) { 234 bool AnimateShowWindow(aura::Window* window) {
235 if (!views::corewm::HasWindowVisibilityAnimationTransition( 235 if (!::wm::HasWindowVisibilityAnimationTransition(
236 window, views::corewm::ANIMATE_SHOW)) { 236 window, ::wm::ANIMATE_SHOW)) {
237 return false; 237 return false;
238 } 238 }
239 239
240 switch (views::corewm::GetWindowVisibilityAnimationType(window)) { 240 switch (::wm::GetWindowVisibilityAnimationType(window)) {
241 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: 241 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
242 AnimateShowWindow_Minimize(window); 242 AnimateShowWindow_Minimize(window);
243 return true; 243 return true;
244 case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE: 244 case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
245 AnimateShowWindow_BrightnessGrayscale(window); 245 AnimateShowWindow_BrightnessGrayscale(window);
246 return true; 246 return true;
247 default: 247 default:
248 NOTREACHED(); 248 NOTREACHED();
249 return false; 249 return false;
250 } 250 }
251 } 251 }
252 252
253 bool AnimateHideWindow(aura::Window* window) { 253 bool AnimateHideWindow(aura::Window* window) {
254 if (!views::corewm::HasWindowVisibilityAnimationTransition( 254 if (!::wm::HasWindowVisibilityAnimationTransition(
255 window, views::corewm::ANIMATE_HIDE)) { 255 window, ::wm::ANIMATE_HIDE)) {
256 return false; 256 return false;
257 } 257 }
258 258
259 switch (views::corewm::GetWindowVisibilityAnimationType(window)) { 259 switch (::wm::GetWindowVisibilityAnimationType(window)) {
260 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE: 260 case WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE:
261 AnimateHideWindow_Minimize(window); 261 AnimateHideWindow_Minimize(window);
262 return true; 262 return true;
263 case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE: 263 case WINDOW_VISIBILITY_ANIMATION_TYPE_BRIGHTNESS_GRAYSCALE:
264 AnimateHideWindow_BrightnessGrayscale(window); 264 AnimateHideWindow_BrightnessGrayscale(window);
265 return true; 265 return true;
266 default: 266 default:
267 NOTREACHED(); 267 NOTREACHED();
268 return false; 268 return false;
269 } 269 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 window->layer()->SetTransform(gfx::Transform()); 394 window->layer()->SetTransform(gfx::Transform());
395 if (!old_on_top) { 395 if (!old_on_top) {
396 // New layer is on top, fade it in. 396 // New layer is on top, fade it in.
397 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); 397 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity);
398 } 398 }
399 } 399 }
400 return duration; 400 return duration;
401 } 401 }
402 402
403 bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) { 403 bool AnimateOnChildWindowVisibilityChanged(aura::Window* window, bool visible) {
404 if (views::corewm::WindowAnimationsDisabled(window)) 404 if (::wm::WindowAnimationsDisabled(window))
405 return false; 405 return false;
406 406
407 // Attempt to run CoreWm supplied animation types. 407 // Attempt to run CoreWm supplied animation types.
408 if (views::corewm::AnimateOnChildWindowVisibilityChanged(window, visible)) 408 if (::wm::AnimateOnChildWindowVisibilityChanged(window, visible))
409 return true; 409 return true;
410 410
411 // Otherwise try to run an Ash-specific animation. 411 // Otherwise try to run an Ash-specific animation.
412 if (visible) 412 if (visible)
413 return AnimateShowWindow(window); 413 return AnimateShowWindow(window);
414 // Don't start hiding the window again if it's already being hidden. 414 // Don't start hiding the window again if it's already being hidden.
415 return window->layer()->GetTargetOpacity() != 0.0f && 415 return window->layer()->GetTargetOpacity() != 0.0f &&
416 AnimateHideWindow(window); 416 AnimateHideWindow(window);
417 } 417 }
418 418
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 } 498 }
499 499
500 // Assume the shelf is overflowed, zoom off to the bottom right of the 500 // Assume the shelf is overflowed, zoom off to the bottom right of the
501 // work area. 501 // work area.
502 gfx::Rect work_area = 502 gfx::Rect work_area =
503 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); 503 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
504 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); 504 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0);
505 } 505 }
506 506
507 } // namespace ash 507 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_animations.h ('k') | ash/wm/window_animations_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698