OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_COCOA_ANIMATION_UTILS_H | 5 #ifndef CHROME_BROWSER_UI_COCOA_ANIMATION_UTILS_H |
6 #define CHROME_BROWSER_UI_COCOA_ANIMATION_UTILS_H | 6 #define CHROME_BROWSER_UI_COCOA_ANIMATION_UTILS_H |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #import <Cocoa/Cocoa.h> | 9 #import <Cocoa/Cocoa.h> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 WithNoAnimation() { | 24 WithNoAnimation() { |
25 [NSAnimationContext beginGrouping]; | 25 [NSAnimationContext beginGrouping]; |
26 [[NSAnimationContext currentContext] setDuration:0.0]; | 26 [[NSAnimationContext currentContext] setDuration:0.0]; |
27 } | 27 } |
28 | 28 |
29 ~WithNoAnimation() { | 29 ~WithNoAnimation() { |
30 [NSAnimationContext endGrouping]; | 30 [NSAnimationContext endGrouping]; |
31 } | 31 } |
32 }; | 32 }; |
33 | 33 |
| 34 // Disables actions within a scope. |
| 35 class ScopedCAActionDisabler { |
| 36 public: |
| 37 ScopedCAActionDisabler() { |
| 38 [CATransaction begin]; |
| 39 [CATransaction setValue:[NSNumber numberWithBool:YES] |
| 40 forKey:kCATransactionDisableActions]; |
| 41 } |
| 42 |
| 43 ~ScopedCAActionDisabler() { |
| 44 [CATransaction commit]; |
| 45 } |
| 46 }; |
| 47 |
| 48 // Sets a duration on actions within a scope. |
| 49 class ScopedCAActionSetDuration { |
| 50 public: |
| 51 explicit ScopedCAActionSetDuration(NSTimeInterval duration) { |
| 52 [CATransaction begin]; |
| 53 [CATransaction setValue:[NSNumber numberWithFloat:duration] |
| 54 forKey:kCATransactionAnimationDuration]; |
| 55 } |
| 56 |
| 57 ~ScopedCAActionSetDuration() { |
| 58 [CATransaction commit]; |
| 59 } |
| 60 }; |
34 | 61 |
35 #endif // CHROME_BROWSER_UI_COCOA_ANIMATION_UTILS_H | 62 #endif // CHROME_BROWSER_UI_COCOA_ANIMATION_UTILS_H |
OLD | NEW |