#ifndef UI_BASE_COCOA_ANIMATION_UTILS_H_
#define UI_BASE_COCOA_ANIMATION_UTILS_H_
#include "build/build_config.h"
#if BUILDFLAG(IS_MAC)
#import <Cocoa/Cocoa.h>
#endif
#import <QuartzCore/QuartzCore.h>
#if BUILDFLAG(IS_MAC)
class WithNoAnimation {
public:
WithNoAnimation() {
[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:0.0];
}
~WithNoAnimation() {
[NSAnimationContext endGrouping];
}
};
#endif
class ScopedCAActionDisabler {
public:
ScopedCAActionDisabler() {
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithBool:YES]
forKey:kCATransactionDisableActions];
}
~ScopedCAActionDisabler() {
[CATransaction commit];
}
};
class ScopedCAActionSetDuration {
public:
explicit ScopedCAActionSetDuration(NSTimeInterval duration) {
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:duration]
forKey:kCATransactionAnimationDuration];
}
~ScopedCAActionSetDuration() {
[CATransaction commit];
}
};
#endif