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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 window->layer()->GetAnimator()->ScheduleAnimation( | 130 window->layer()->GetAnimator()->ScheduleAnimation( |
131 new ui::LayerAnimationSequence( | 131 new ui::LayerAnimationSequence( |
132 ui::LayerAnimationElement::CreateOpacityElement( | 132 ui::LayerAnimationElement::CreateOpacityElement( |
133 opacity, duration / 4))); | 133 opacity, duration / 4))); |
134 } | 134 } |
135 | 135 |
136 void AnimateShowWindow_Minimize(aura::Window* window) { | 136 void AnimateShowWindow_Minimize(aura::Window* window) { |
137 window->layer()->set_delegate(window); | 137 window->layer()->set_delegate(window); |
138 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); | 138 window->layer()->SetOpacity(kWindowAnimation_HideOpacity); |
139 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 139 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
140 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( | 140 base::TimeDelta duration = views::corewm::GetWindowShowAnimationDuration( |
141 kLayerAnimationsForMinimizeDurationMS); | 141 window, |
| 142 base::TimeDelta::FromMilliseconds(kLayerAnimationsForMinimizeDurationMS)); |
142 settings.SetTransitionDuration(duration); | 143 settings.SetTransitionDuration(duration); |
143 AddLayerAnimationsForMinimize(window, true); | 144 AddLayerAnimationsForMinimize(window, true); |
144 | 145 |
145 // Now that the window has been restored, we need to clear its animation style | 146 // Now that the window has been restored, we need to clear its animation style |
146 // to default so that normal animation applies. | 147 // to default so that normal animation applies. |
147 views::corewm::SetWindowVisibilityAnimationType( | 148 views::corewm::SetWindowVisibilityAnimationType( |
148 window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); | 149 window, views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_DEFAULT); |
149 } | 150 } |
150 | 151 |
151 void AnimateHideWindow_Minimize(aura::Window* window) { | 152 void AnimateHideWindow_Minimize(aura::Window* window) { |
152 window->layer()->set_delegate(NULL); | 153 window->layer()->set_delegate(NULL); |
153 | 154 |
154 // Property sets within this scope will be implicitly animated. | 155 // Property sets within this scope will be implicitly animated. |
155 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 156 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
156 base::TimeDelta duration = base::TimeDelta::FromMilliseconds( | 157 base::TimeDelta duration = views::corewm::GetWindowHideAnimationDuration( |
157 kLayerAnimationsForMinimizeDurationMS); | 158 window, |
| 159 base::TimeDelta::FromMilliseconds(kLayerAnimationsForMinimizeDurationMS)); |
158 settings.SetTransitionDuration(duration); | 160 settings.SetTransitionDuration(duration); |
159 settings.AddObserver( | 161 settings.AddObserver( |
160 views::corewm::CreateHidingWindowAnimationObserver(window)); | 162 views::corewm::CreateHidingWindowAnimationObserver(window)); |
161 window->layer()->SetVisible(false); | 163 window->layer()->SetVisible(false); |
162 | 164 |
163 AddLayerAnimationsForMinimize(window, false); | 165 AddLayerAnimationsForMinimize(window, false); |
164 } | 166 } |
165 | 167 |
166 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, | 168 void AnimateShowHideWindowCommon_BrightnessGrayscale(aura::Window* window, |
167 bool show) { | 169 bool show) { |
168 window->layer()->set_delegate(window); | 170 window->layer()->set_delegate(window); |
169 | 171 |
170 float start_value, end_value; | 172 float start_value, end_value; |
171 if (show) { | 173 if (show) { |
172 start_value = kWindowAnimation_HideBrightnessGrayscale; | 174 start_value = kWindowAnimation_HideBrightnessGrayscale; |
173 end_value = kWindowAnimation_ShowBrightnessGrayscale; | 175 end_value = kWindowAnimation_ShowBrightnessGrayscale; |
174 } else { | 176 } else { |
175 start_value = kWindowAnimation_ShowBrightnessGrayscale; | 177 start_value = kWindowAnimation_ShowBrightnessGrayscale; |
176 end_value = kWindowAnimation_HideBrightnessGrayscale; | 178 end_value = kWindowAnimation_HideBrightnessGrayscale; |
177 } | 179 } |
178 | 180 |
179 window->layer()->SetLayerBrightness(start_value); | 181 window->layer()->SetLayerBrightness(start_value); |
180 window->layer()->SetLayerGrayscale(start_value); | 182 window->layer()->SetLayerGrayscale(start_value); |
181 if (show) { | 183 if (show) { |
182 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); | 184 window->layer()->SetOpacity(kWindowAnimation_ShowOpacity); |
183 window->layer()->SetVisible(true); | 185 window->layer()->SetVisible(true); |
184 } | 186 } |
185 | 187 |
186 base::TimeDelta duration = | 188 base::TimeDelta default_duration = |
187 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); | 189 base::TimeDelta::FromMilliseconds(kBrightnessGrayscaleFadeDurationMs); |
| 190 base::TimeDelta duration = show ? |
| 191 views::corewm::GetWindowShowAnimationDuration(window, default_duration) : |
| 192 views::corewm::GetWindowHideAnimationDuration(window, default_duration); |
188 | 193 |
189 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); | 194 ui::ScopedLayerAnimationSettings settings(window->layer()->GetAnimator()); |
190 settings.SetTransitionDuration(duration); | 195 settings.SetTransitionDuration(duration); |
191 if (!show) { | 196 if (!show) { |
192 settings.AddObserver( | 197 settings.AddObserver( |
193 views::corewm::CreateHidingWindowAnimationObserver(window)); | 198 views::corewm::CreateHidingWindowAnimationObserver(window)); |
194 } | 199 } |
195 | 200 |
196 window->layer()->GetAnimator()-> | 201 window->layer()->GetAnimator()-> |
197 ScheduleTogether( | 202 ScheduleTogether( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 } | 546 } |
542 | 547 |
543 // Assume the shelf is overflowed, zoom off to the bottom right of the | 548 // Assume the shelf is overflowed, zoom off to the bottom right of the |
544 // work area. | 549 // work area. |
545 gfx::Rect work_area = | 550 gfx::Rect work_area = |
546 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); | 551 Shell::GetScreen()->GetDisplayNearestWindow(window).work_area(); |
547 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); | 552 return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0); |
548 } | 553 } |
549 | 554 |
550 } // namespace ash | 555 } // namespace ash |
OLD | NEW |