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 3// found in the LICENSE file. 4 5#ifndef CHROME_BROWSER_UI_COCOA_ANIMATABLE_VIEW_H_ 6#define CHROME_BROWSER_UI_COCOA_ANIMATABLE_VIEW_H_ 7#pragma once 8 9#import <Cocoa/Cocoa.h> 10 11#import "base/mac/cocoa_protocols.h" 12#include "base/memory/scoped_nsobject.h" 13#import "chrome/browser/ui/cocoa/background_gradient_view.h" 14#import "chrome/browser/ui/cocoa/view_resizer.h" 15 16// A view that provides an animatable height property. Provides methods to 17// animate to a new height, set a new height immediately, or cancel any running 18// animations. 19// 20// AnimatableView sends an |animationDidEnd:| message to its delegate when the 21// animation ends normally and an |animationDidStop:| message when the animation 22// was canceled (even when canceled as a result of a new animation starting). 23 24@interface AnimatableView : BackgroundGradientView<NSAnimationDelegate> { 25 @protected 26 IBOutlet id delegate_; // weak, used to send animation ended messages. 27 28 @private 29 scoped_nsobject<NSAnimation> currentAnimation_; 30 id<ViewResizer> resizeDelegate_; // weak, usually owns us 31} 32 33// Properties for bindings. 34@property(assign, nonatomic) id delegate; 35@property(assign, nonatomic) id<ViewResizer> resizeDelegate; 36 37// Gets the current height of the view. If an animation is currently running, 38// this will give the current height at the time of the call, not the target 39// height at the end of the animation. 40- (CGFloat)height; 41 42// Sets the height of the view immediately. Cancels any running animations. 43- (void)setHeight:(CGFloat)newHeight; 44 45// Starts a new animation to the given |newHeight| for the given |duration|. 46// Cancels any running animations. 47- (void)animateToNewHeight:(CGFloat)newHeight 48 duration:(NSTimeInterval)duration; 49 50// Cancels any running animations, leaving the view at its current 51// (mid-animation) height. 52- (void)stopAnimation; 53 54// Gets the progress of any current animation. 55- (NSAnimationProgress)currentAnimationProgress; 56 57@end 58 59#endif // CHROME_BROWSER_UI_COCOA_ANIMATABLE_VIEW_H_ 60