diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 23:24:23 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 23:24:23 +0000 |
commit | 8c8d9a30879460088e60797c98537fd90a23d998 (patch) | |
tree | 20d2ed1168c2d72302d4c531568bafb9d501b82b /chrome/browser/cocoa/download_shelf_controller.mm | |
parent | 0ac5ce097edbbc2f7f0f362c30f51e79c513f493 (diff) | |
download | chromium_src-8c8d9a30879460088e60797c98537fd90a23d998.zip chromium_src-8c8d9a30879460088e60797c98537fd90a23d998.tar.gz chromium_src-8c8d9a30879460088e60797c98537fd90a23d998.tar.bz2 |
[Mac] Adds animations for the download shelf.
Nib file changes:
- Connected DownloadShelfView's delegate_ to DownloadShelfController.
BUG=http://crbug.com/25602
TEST=Download shelf should animate open/closed.
Review URL: http://codereview.chromium.org/342083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31156 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/download_shelf_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/download_shelf_controller.mm | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm index 122a132..81af11e 100644 --- a/chrome/browser/cocoa/download_shelf_controller.mm +++ b/chrome/browser/cocoa/download_shelf_controller.mm @@ -9,6 +9,7 @@ #include "base/mac_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/browser.h" +#import "chrome/browser/cocoa/animatable_view.h" #import "chrome/browser/cocoa/browser_window_controller.h" #include "chrome/browser/cocoa/browser_window_cocoa.h" #include "chrome/browser/cocoa/download_item_controller.h" @@ -30,6 +31,9 @@ const int kDownloadItemPadding = 0; // Duration for the open-new-leftmost-item animation, in seconds. const NSTimeInterval kDownloadItemOpenDuration = 0.8; +// Duration for download shelf closing animation, in seconds. +const NSTimeInterval kDownloadShelfCloseDuration = 0.12; + } // namespace @interface DownloadShelfController(Private) @@ -67,6 +71,8 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8; } - (void)awakeFromNib { + [[self animatableView] setResizeDelegate:resizeDelegate_]; + // Initialize "Show all downloads" link. scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( @@ -103,6 +109,10 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8; [super dealloc]; } +- (AnimatableView*)animatableView { + return static_cast<AnimatableView*>([self view]); +} + - (void)resizeDownloadLinkToFit { // Get width required by localized download link text. // http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/Tasks/StringHeight.html @@ -163,6 +173,7 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8; // We need to explicitly release our download controllers here since they need // to remove themselves as observers before the remaining shutdown happens. - (void)exiting { + [[self animatableView] stopAnimation]; downloadItemControllers_.reset(); } @@ -172,8 +183,17 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8; if ([self isVisible] == enable) return; - [resizeDelegate_ resizeView:[self view] - newHeight:(enable ? shelfHeight_ : 0)]; + // Animate the shelf out, but not in. + // TODO(rohitrao): We do not animate on the way in because Cocoa is already + // doing a lot of work to set up the download arrow animation. I've chosen to + // do no animation over janky animation. Find a way to make animating in + // smoother. + AnimatableView* view = [self animatableView]; + if (enable) + [view setHeight:shelfHeight_]; + else + [view animateToNewHeight:0 duration:kDownloadShelfCloseDuration]; + barIsVisible_ = enable; } @@ -197,10 +217,11 @@ const NSTimeInterval kDownloadItemOpenDuration = 0.8; bridge_->Close(); else [self showDownloadShelf:NO]; +} - // TODO(port): When closing the shelf is animated, call this only after the - // animation has ended: - [self closed]; +- (void)animationDidEnd:(NSAnimation*)animation { + if (![self isVisible]) + [self closed]; } - (float)height { |