| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 views::corewm::SetWindowVisibilityAnimationType( |
| 169 window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); | 169 window, views::corewm::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 views::corewm::ScopedHidingAnimationSettings hiding_settings(window); |
| 177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( | 177 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( |
| 178 kLayerAnimationsForMinimizeDurationMS); | 178 kLayerAnimationsForMinimizeDurationMS); |
| 179 settings.SetTransitionDuration(duration); | 179 hiding_settings.layer_animation_settings()->SetTransitionDuration(duration); |
| 180 settings.AddObserver( | 180 hiding_settings.set_ensure_visible_after_focus_lost(true); |
| 181 views::corewm::CreateHidingWindowAnimationObserver(window)); | |
| 182 window->layer()->SetVisible(false); | 181 window->layer()->SetVisible(false); |
| 183 | 182 |
| 184 AddLayerAnimationsForMinimize(window, false); | 183 AddLayerAnimationsForMinimize(window, false); |
| 185 } | 184 } |
| 186 | 185 |
| 187 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, | 186 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, |
| 188 bool show) { | 187 bool show) { |
| 189 window->layer()->set_delegate(window); | 188 window->layer()->set_delegate(window); |
| 190 | 189 |
| 191 float start_value, end_value; | 190 float start_value, end_value; |
| 192 if (show) { | 191 if (show) { |
| 193 start_value = kWindowAnimation_HideBrightnessGrayscale; | 192 start_value = kWindowAnimation_HideBrightnessGrayscale; |
| 194 end_value = kWindowAnimation_ShowBrightnessGrayscale; | 193 end_value = kWindowAnimation_ShowBrightnessGrayscale; |
| 195 } else { | 194 } else { |
| 196 start_value = kWindowAnimation_ShowBrightnessGrayscale; | 195 start_value = kWindowAnimation_ShowBrightnessGrayscale; |
| 197 end_value = kWindowAnimation_HideBrightnessGrayscale; | 196 end_value = kWindowAnimation_HideBrightnessGrayscale; |
| 198 } | 197 } |
| 199 | 198 |
| 200 window->layer()->SetLayerBrightness(start_value); | 199 window->layer()->SetLayerBrightness(start_value); |
| 201 window->layer()->SetLayerGrayscale(start_value); | 200 window->layer()->SetLayerGrayscale(start_value); |
| 202 if (show) { | 201 if (show) { |
| 203 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); | 202 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); |
| 204 window->layer()->SetVisible(true); | 203 window->layer()->SetVisible(true); |
| 205 } | 204 } |
| 206 | 205 |
| 207 base::TimeDelta duration = | 206 base::TimeDelta duration = |
| 208 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); | 207 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); |
| 209 | 208 |
| 210 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 209 if (show) { |
| 211 settings.SetTransitionDuration(duration); | 210 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
| 212 if (!show) { | 211 window->layer()->GetAnimator()-> |
| 213 settings.AddObserver( | 212 ScheduleTogether( |
| 214 views::corewm::CreateHidingWindowAnimationObserver(window)); | 213 CreateBrightnessGrayscaleAnimationSequence(end_value, duration)); |
| 215 } | 214 } else { |
| 216 | 215 views::corewm::ScopedHidingAnimationSettings hiding_settings(window); |
| 217 window->layer()->GetAnimator()-> | 216 hiding_settings.set_ensure_visible_after_focus_lost(true); |
| 218 ScheduleTogether( | 217 window->layer()->GetAnimator()-> |
| 219 CreateBrightnessGrayscaleAnimationSequence(end_value, duration)); | 218 ScheduleTogether( |
| 220 if (!show) { | 219 CreateBrightnessGrayscaleAnimationSequence(end_value, duration)); |
| 221 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 220 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
| 222 window->layer()->SetVisible(false); | 221 window->layer()->SetVisible(false); |
| 223 } | 222 } |
| 224 } | 223 } |
| 225 | 224 |
| 226 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { | 225 void AnimateShowWindow_BrightnessGrayscale(aura::Window* window) { |
| 227 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); | 226 AnimateShowHideWindowCommon_BrightnessGrayscale(window, true); |
| 228 } | 227 } |
| 229 | 228 |
| 230 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { | 229 void AnimateHideWindow_BrightnessGrayscale(aura::Window* window) { |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 } | 497 } |
| 499 | 498 |
| 500 // Assume the shelf is overflowed, zoom off to the bottom right of the | 499 // Assume the shelf is overflowed, zoom off to the bottom right of the |
| 501 // work area. | 500 // work area. |
| 502 gfx::Rect work_area = | 501 gfx::Rect work_area = |
| 503 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 502 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
| 504 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); | 503 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); |
| 505 } | 504 } |
| 506 | 505 |
| 507 } // namespace ash | 506 } // namespace ash |
| OLD | NEW |