Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5085)

Unified Diff: chrome/browser/cocoa/download_shelf_controller.mm

Issue 159060: Use a real download item.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: first round of review comments addressed Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.mm ('k') | chrome/browser/cocoa/gradient_button_cell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/download_shelf_controller.mm
===================================================================
--- chrome/browser/cocoa/download_shelf_controller.mm (revision 21145)
+++ chrome/browser/cocoa/download_shelf_controller.mm (working copy)
@@ -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 @@
[paragraphStyle.get() setAlignment:NSRightTextAlignment];
NSDictionary* linkAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
- self, NSLinkAttributeName,
+ @"", NSLinkAttributeName,
[NSCursor pointingHandCursor], NSCursorAttributeName,
paragraphStyle.get(), NSParagraphStyleAttributeName,
nil];
@@ -181,17 +182,21 @@
}
- (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
@@ -199,6 +204,15 @@
[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
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.mm ('k') | chrome/browser/cocoa/gradient_button_cell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698