OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/cocoa/download_shelf_controller.h" | 5 #import "chrome/browser/cocoa/download_shelf_controller.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "chrome/browser/browser.h" | 10 #include "chrome/browser/browser.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 @implementation DownloadShelfController | 40 @implementation DownloadShelfController |
41 | 41 |
42 - (id)initWithBrowser:(Browser*)browser | 42 - (id)initWithBrowser:(Browser*)browser |
43 resizeDelegate:(id<ViewResizer>)resizeDelegate { | 43 resizeDelegate:(id<ViewResizer>)resizeDelegate { |
44 if ((self = [super initWithNibName:@"DownloadShelf" | 44 if ((self = [super initWithNibName:@"DownloadShelf" |
45 bundle:mac_util::MainAppBundle()])) { | 45 bundle:mac_util::MainAppBundle()])) { |
46 resizeDelegate_ = resizeDelegate; | 46 resizeDelegate_ = resizeDelegate; |
47 shelfHeight_ = [[self view] bounds].size.height; | 47 shelfHeight_ = [[self view] bounds].size.height; |
48 | 48 |
49 // Reset the download shelf's frame to zero. It will be properly positioned | 49 // Reset the download shelf's frame height to zero. It will be properly |
50 // and sized the first time we try to set its height. | 50 // positioned and sized the first time we try to set its height. (Just |
51 [[self view] setFrame:NSZeroRect]; | 51 // setting the rect to NSZeroRect does not work: it confuses Cocoa's view |
| 52 // layout logic. If the shelf's width is too small, cocoa makes the download |
| 53 // item container view wider than the browser window). |
| 54 NSRect frame = [[self view] frame]; |
| 55 frame.size.height = 0; |
| 56 [[self view] setFrame:frame]; |
52 | 57 |
53 downloadItemControllers_.reset([[NSMutableArray alloc] init]); | 58 downloadItemControllers_.reset([[NSMutableArray alloc] init]); |
54 | 59 |
55 // This calls show:, so it needs to be last. | |
56 bridge_.reset(new DownloadShelfMac(browser, self)); | 60 bridge_.reset(new DownloadShelfMac(browser, self)); |
57 } | 61 } |
58 return self; | 62 return self; |
59 } | 63 } |
60 | 64 |
61 - (void)awakeFromNib { | 65 - (void)awakeFromNib { |
62 // Initialize "Show all downloads" link. | 66 // Initialize "Show all downloads" link. |
63 | 67 |
64 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | 68 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( |
65 [[NSParagraphStyle defaultParagraphStyle] mutableCopy]); | 69 [[NSParagraphStyle defaultParagraphStyle] mutableCopy]); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 [self remove:[downloadItemControllers_ lastObject]]; | 252 [self remove:[downloadItemControllers_ lastObject]]; |
249 } | 253 } |
250 | 254 |
251 // Finally, move the remaining items to the right. Skip the first item when | 255 // Finally, move the remaining items to the right. Skip the first item when |
252 // laying out the items, so that the longer animation duration we set up above | 256 // laying out the items, so that the longer animation duration we set up above |
253 // is not overwritten. | 257 // is not overwritten. |
254 [self layoutItems:YES]; | 258 [self layoutItems:YES]; |
255 } | 259 } |
256 | 260 |
257 @end | 261 @end |
OLD | NEW |