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

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

Issue 149276: Mac version of the download shelf views (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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_shelf_controller.h ('k') | chrome/browser/cocoa/download_shelf_mac.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 20197)
+++ chrome/browser/cocoa/download_shelf_controller.mm (working copy)
@@ -2,18 +2,36 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#import "download_shelf_controller.h"
+#import "chrome/browser/cocoa/download_shelf_controller.h"
#include "app/l10n_util.h"
#include "base/mac_util.h"
#include "base/sys_string_conversions.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"
#include "chrome/browser/cocoa/download_shelf_mac.h"
#import "chrome/browser/cocoa/download_shelf_view.h"
#include "grit/generated_resources.h"
+namespace {
+// TODO(thakis): These are all temporary until there's a download item view.
+
+// Border padding of a download item.
+const int kDownloadItemBorderPadding = 4;
+
+// Width of a download item.
+const int kDownloadItemWidth = 200;
+
+// Height of a download item.
+const int kDownloadItemHeight = 32;
+
+// Horizontal padding between two download items.
+const int kDownloadItemPadding = 10;
+
+} // namespace
+
@interface DownloadShelfController(Private)
- (void)applyContentAreaOffset:(BOOL)apply;
- (void)positionBar;
@@ -33,6 +51,8 @@
[self positionBar];
[[[contentArea_ window] contentView] addSubview:[self view]];
+ downloadItemControllers_.reset([[NSMutableArray alloc] init]);
+
// This calls show:, so it needs to be last.
bridge_.reset(new DownloadShelfMac(browser, self));
}
@@ -70,18 +90,17 @@
// Initializes the download shelf at the bottom edge of |contentArea_|.
- (void)positionBar {
- // Set the bar's height to zero and position it at the bottom of the
- // content area, within the window's content view (as opposed to the
- // tab strip, which is a sibling). We'll enlarge it and slide the
- // content area up when we need to show this strip.
+ // Set the bar's height to zero and position it at the bottom of the content
+ // area, within the window's content view (as opposed to the tab strip, which
+ // is a sibling). We'll enlarge it and slide the content area up when we need
+ // to show this strip.
NSRect contentFrame = [contentArea_ frame];
- NSRect barFrame = NSMakeRect(0, 0,
- contentFrame.size.width, shelfHeight_);
+ NSRect barFrame = NSMakeRect(0, 0, contentFrame.size.width, shelfHeight_);
[[self view] setFrame:barFrame];
}
-// Called when the contentArea's frame changes. Enlarge the view to
-// stay with the bottom of the contentArea.
+// Called when the contentArea's frame changes. Enlarge the view to stay with
+// the bottom of the contentArea.
- (void)resizeDownloadShelf {
NSRect barFrame = [[self view] frame];
barFrame.origin.y = 0;
@@ -102,10 +121,9 @@
barIsVisible_ = enable;
}
-// Apply a contents box offset to make (or remove) room for the
-// download shelf. If apply==YES, always make room (the contentView_ is
-// "full size"). If apply==NO we are trying to undo an offset. If no
-// offset there is nothing to undo.
+// Apply a contents box offset to make (or remove) room for the download shelf.
+// If apply is YES, always make room (the contentView_ is "full size"). If apply
+// is NO, we are trying to undo an offset. If no offset there is nothing to undo.
- (void)applyContentAreaOffset:(BOOL)apply {
if (!contentAreaHasOffset_ && apply) {
// There is no offset to unconditionally apply.
@@ -142,8 +160,23 @@
[self showDownloadShelf:NO];
}
-- (void)addDownloadItem:(NSView*)view {
- [[self view] addSubview:view];
+- (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];
+
+ NSRect position = NSMakeRect(startX, kDownloadItemBorderPadding,
+ kDownloadItemWidth, kDownloadItemHeight);
+ scoped_nsobject<DownloadItemController> controller(
+ [[DownloadItemController alloc] initWithFrame:position model:model]);
+ [downloadItemControllers_ addObject:controller.get()];
+
+ [[self view] addSubview:[controller.get() view]];
}
@end
« no previous file with comments | « chrome/browser/cocoa/download_shelf_controller.h ('k') | chrome/browser/cocoa/download_shelf_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698