diff options
author | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 19:41:53 +0000 |
---|---|---|
committer | thakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-21 19:41:53 +0000 |
commit | c7594166521973b656f13d7c08b75db7b603246f (patch) | |
tree | f6bbc6d48b88e63676e5ddcaee51b47a6df7b427 /chrome/browser/cocoa/download_shelf_controller.mm | |
parent | 6ee6185045be58242771fe6e0504b4147e0c1a2d (diff) | |
download | chromium_src-c7594166521973b656f13d7c08b75db7b603246f.zip chromium_src-c7594166521973b656f13d7c08b75db7b603246f.tar.gz chromium_src-c7594166521973b656f13d7c08b75db7b603246f.tar.bz2 |
Use a real download item.
BUG=14659,17100
TEST=Download multiple things. Items should now be inserted from the left. When a download is in progress, the time to completion should be displayed, when it's done the time should fade out and the filename should move down. Download items should appear in a sweep animation. Clicking the download directly should open it; clicking the arrow on the right of the download item should show the correct context menu. If a download filename is long, it should be elided in the middle.
Review URL: http://codereview.chromium.org/159060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21201 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 | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm index 896b72e..ccb672d 100644 --- a/chrome/browser/cocoa/download_shelf_controller.mm +++ b/chrome/browser/cocoa/download_shelf_controller.mm @@ -17,20 +17,21 @@ namespace { -// TODO(thakis): These are all temporary until there's a download item view. - // Border padding of a download item. -const int kDownloadItemBorderPadding = 4; +const int kDownloadItemBorderPadding = 3; -// Width of a download item. +// Width of a download item, must match width in DownloadItem.xib. const int kDownloadItemWidth = 200; -// Height of a download item. -const int kDownloadItemHeight = 32; +// Height of a download item, must match height in DownloadItem.xib. +const int kDownloadItemHeight = 34; // Horizontal padding between two download items. const int kDownloadItemPadding = 10; +// Duration for the open-new-leftmost-item animation, in seconds. +const NSTimeInterval kDownloadItemOpenDuration = 0.8; + } // namespace @interface DownloadShelfController(Private) @@ -69,7 +70,7 @@ const int kDownloadItemPadding = 10; [paragraphStyle.get() setAlignment:NSRightTextAlignment]; NSDictionary* linkAttributes = [NSDictionary dictionaryWithObjectsAndKeys: - self, NSLinkAttributeName, + @"", NSLinkAttributeName, [NSCursor pointingHandCursor], NSCursorAttributeName, paragraphStyle.get(), NSParagraphStyleAttributeName, nil]; @@ -191,17 +192,21 @@ const int kDownloadItemPadding = 10; } - (void)addDownloadItem:(BaseDownloadItemModel*)model { - // TODO(thakis): we need to delete these at some point. There's no explicit - // mass delete on windows, figure out where they do it. - // TODO(thakis): RTL support? // (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) - int startX = kDownloadItemBorderPadding + - (kDownloadItemWidth + kDownloadItemPadding) * - [downloadItemControllers_ count]; + // Shift all existing items to the right + for (DownloadItemController* itemController in downloadItemControllers_.get()) { + NSRect frame = [[itemController view] frame]; + frame.origin.x += kDownloadItemWidth + kDownloadItemPadding; + [[[itemController view] animator] setFrame:frame]; + } + // Insert new item at the left + int startX = kDownloadItemBorderPadding; + + // Start at width 0... NSRect position = NSMakeRect(startX, kDownloadItemBorderPadding, - kDownloadItemWidth, kDownloadItemHeight); + 0, kDownloadItemHeight); scoped_nsobject<DownloadItemController> controller( [[DownloadItemController alloc] initWithFrame:position model:model @@ -209,6 +214,15 @@ const int kDownloadItemPadding = 10; [downloadItemControllers_ addObject:controller.get()]; [[self view] addSubview:[controller.get() view]]; + + // ...then animate in + NSRect frame = [[controller.get() view] frame]; + frame.size.width = kDownloadItemWidth; + + [NSAnimationContext beginGrouping]; + [[NSAnimationContext currentContext] setDuration:kDownloadItemOpenDuration]; + [[[controller.get() view] animator] setFrame:frame]; + [NSAnimationContext endGrouping]; } @end |