summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 05:40:43 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 05:40:43 +0000
commit09f1e97c9849196d1675a81f5bb505544d085d53 (patch)
tree9fc5c0bbf3c6a1e0ddbdb1efe8111e287b7a006d /chrome/browser/cocoa
parent25964ef7c3b8913992d295c3d48fc227a614ed42 (diff)
downloadchromium_src-09f1e97c9849196d1675a81f5bb505544d085d53.zip
chromium_src-09f1e97c9849196d1675a81f5bb505544d085d53.tar.gz
chromium_src-09f1e97c9849196d1675a81f5bb505544d085d53.tar.bz2
Mac: Make download shelf use GTM ui stuff.
xib changes (a bit more complicated than anticipated, because GTMUI decided to resize the image view to 0x0, since its image is only loaded in DownloadShelfController's awakeFromNib -- hence I couldn't make the image view a child of the width-based resizer): * Replace text view with a button that has a HyperlinkView cell * Change its text to ^IDS_SHOW_ALL_DOWNLOADS * Add localizer and ui localizer/layout tweaker objects * Put close button and new button into a width-based tweaker * Put item container and image view into a box * Let width-based tweaker resize said box No intended functionality change. This is a prerequisite for http://codereview.chromium.org/371059 . BUG=None TEST=download shelf still looks like it did before, resizing hides download items when the icon would touch them. Review URL: http://codereview.chromium.org/377026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31421 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_controller.mm1
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.h5
-rw-r--r--chrome/browser/cocoa/download_shelf_controller.mm62
3 files changed, 4 insertions, 64 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmark_bar_controller.mm
index 8909574..8a8bb95 100644
--- a/chrome/browser/cocoa/bookmark_bar_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_controller.mm
@@ -46,7 +46,6 @@
@end
@interface BookmarkBarController(Private)
-- (void)applyContentAreaOffset:(BOOL)apply immediately:(BOOL)immediately;
- (void)showBookmarkBar:(BOOL)enable immediately:(BOOL)immediately;
- (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu;
- (void)addFolderNode:(const BookmarkNode*)node toMenu:(NSMenu*)menu;
diff --git a/chrome/browser/cocoa/download_shelf_controller.h b/chrome/browser/cocoa/download_shelf_controller.h
index cc6413c..872ac3b 100644
--- a/chrome/browser/cocoa/download_shelf_controller.h
+++ b/chrome/browser/cocoa/download_shelf_controller.h
@@ -36,8 +36,7 @@ class DownloadShelf;
@interface DownloadShelfController : NSViewController<NSTextViewDelegate> {
@private
- IBOutlet NSScrollView* linkContainer_;
- IBOutlet NSTextView* showAllDownloadsLink_;
+ IBOutlet NSButton* showAllDownloadsLink_;
IBOutlet NSImageView* image_;
@@ -59,6 +58,8 @@ class DownloadShelf;
- (id)initWithBrowser:(Browser*)browser
resizeDelegate:(id<ViewResizer>)resizeDelegate;
+- (IBAction)showDownloadsTab:(id)sender;
+
// Returns our view cast as an AnimatableView.
- (AnimatableView*)animatableView;
diff --git a/chrome/browser/cocoa/download_shelf_controller.mm b/chrome/browser/cocoa/download_shelf_controller.mm
index 81af11e..13bdc69 100644
--- a/chrome/browser/cocoa/download_shelf_controller.mm
+++ b/chrome/browser/cocoa/download_shelf_controller.mm
@@ -37,9 +37,7 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
} // namespace
@interface DownloadShelfController(Private)
-- (void)applyContentAreaOffset:(BOOL)apply;
- (void)showDownloadShelf:(BOOL)enable;
-- (void)resizeDownloadLinkToFit;
- (void)layoutItems:(BOOL)skipFirst;
- (void)closed;
@end
@@ -73,34 +71,10 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
- (void)awakeFromNib {
[[self animatableView] setResizeDelegate:resizeDelegate_];
- // Initialize "Show all downloads" link.
-
- scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
- [[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
- [paragraphStyle.get() setAlignment:NSRightTextAlignment];
-
- NSFont* font = [NSFont systemFontOfSize:
- [NSFont systemFontSizeForControlSize:NSRegularControlSize]];
- NSDictionary* linkAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
- @"", NSLinkAttributeName,
- [NSCursor pointingHandCursor], NSCursorAttributeName,
- paragraphStyle.get(), NSParagraphStyleAttributeName,
- font, NSFontAttributeName,
- nil];
- NSString* text =
- base::SysWideToNSString(l10n_util::GetString(IDS_SHOW_ALL_DOWNLOADS));
- scoped_nsobject<NSAttributedString> linkText([[NSAttributedString alloc]
- initWithString:text attributes:linkAttributes]);
-
- [[showAllDownloadsLink_ textStorage] setAttributedString:linkText.get()];
- [showAllDownloadsLink_ setDelegate:self];
-
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
NSImage* favicon = rb.GetNSImageNamed(IDR_DOWNLOADS_FAVICON);
DCHECK(favicon);
[image_ setImage:favicon];
-
- [self resizeDownloadLinkToFit];
}
- (void)dealloc {
@@ -113,42 +87,8 @@ const NSTimeInterval kDownloadShelfCloseDuration = 0.12;
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
- [[showAllDownloadsLink_ textContainer] setLineFragmentPadding:0.0];
- (void)[[showAllDownloadsLink_ layoutManager] glyphRangeForTextContainer:
- [showAllDownloadsLink_ textContainer]];
- NSRect textRect = [[showAllDownloadsLink_ layoutManager]
- usedRectForTextContainer:[showAllDownloadsLink_ textContainer]];
-
- int offsetX = [showAllDownloadsLink_ frame].size.width - textRect.size.width;
-
- // Fit link itself.
- NSRect linkFrame = [linkContainer_ frame];
- linkFrame.origin.x += offsetX;
- linkFrame.size.width -= offsetX;
- [linkContainer_ setFrame:linkFrame];
- [linkContainer_ setNeedsDisplay:YES];
-
- // Move image.
- NSRect imageFrame = [image_ frame];
- imageFrame.origin.x += offsetX;
- [image_ setFrame:imageFrame];
- [image_ setNeedsDisplay:YES];
-
- // Change item container size.
- NSRect itemFrame = [itemContainerView_ frame];
- itemFrame.size.width += offsetX;
- [itemContainerView_ setFrame:itemFrame];
- [itemContainerView_ setNeedsDisplay:YES];
-}
-
-- (BOOL)textView:(NSTextView *)aTextView
- clickedOnLink:(id)link
- atIndex:(NSUInteger)charIndex {
+- (void)showDownloadsTab:(id)sender {
bridge_->browser()->ShowDownloadsTab();
- return YES;
}
- (void)remove:(DownloadItemController*)download {