From 8bdda244e2d7b826b81b73cf1f9469d4cfe26bcd Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Tue, 6 Apr 2010 04:18:04 +0000 Subject: Mac: Make content bubbles wider in languages that have long translations of "Manage" and "Done. xib changes: Anchor bubble view on right side, make it autoresize horizontally. Same for divider line, radio groups, and title. Make widthbased tweakers at bottom horizontally autoresize. Hook up manage and done buttons to controller. BUG=39393 TEST=See bug. Review URL: http://codereview.chromium.org/1527012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43698 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/nibs/ContentBlockedCookies.xib | 43 ++++++++++++++++++---- chrome/app/nibs/ContentBlockedImages.xib | 42 ++++++++++++++++----- chrome/app/nibs/ContentBlockedJavaScript.xib | 42 ++++++++++++++++----- chrome/app/nibs/ContentBlockedPlugins.xib | 42 ++++++++++++++++----- chrome/app/nibs/ContentBlockedPopups.xib | 42 ++++++++++++++++----- chrome/app/nibs/ContentBubbleGeolocation.xib | 32 +++++++++++++--- .../cocoa/content_blocked_bubble_controller.h | 3 ++ .../cocoa/content_blocked_bubble_controller.mm | 22 +++++++++++ 8 files changed, 215 insertions(+), 53 deletions(-) diff --git a/chrome/app/nibs/ContentBlockedCookies.xib b/chrome/app/nibs/ContentBlockedCookies.xib index d214603..af1ffca 100644 --- a/chrome/app/nibs/ContentBlockedCookies.xib +++ b/chrome/app/nibs/ContentBlockedCookies.xib @@ -8,7 +8,7 @@ 353.00 YES - + YES @@ -50,12 +50,12 @@ YES - 276 + 274 YES - 268 + 266 {{17, 54}, {282, 14}} YES @@ -91,7 +91,7 @@ - 36 + 34 {{20, 43}, {276, 5}} {0, 0} @@ -125,7 +125,7 @@ - 292 + 294 YES @@ -155,7 +155,7 @@ - 289 + 291 YES @@ -269,6 +269,22 @@ 30 + + + manageButton_ + + + + 33 + + + + doneButton_ + + + + 34 + @@ -475,7 +491,7 @@ - 30 + 34 @@ -520,12 +536,18 @@ YES allowBlockRadioGroup_ bubble_ + contentsContainer_ + doneButton_ + manageButton_ titleLabel_ YES NSMatrix InfoBubbleView + NSView + NSButton + NSButton NSTextField @@ -634,6 +656,13 @@ NSWindow IBProjectSource + browser/cocoa/chrome_browser_window.h + + + + NSWindow + + IBProjectSource browser/cocoa/themed_window.h diff --git a/chrome/app/nibs/ContentBlockedImages.xib b/chrome/app/nibs/ContentBlockedImages.xib index 989ff0a..a1a4899b 100644 --- a/chrome/app/nibs/ContentBlockedImages.xib +++ b/chrome/app/nibs/ContentBlockedImages.xib @@ -2,13 +2,13 @@ 1050 - 9L30 - 680 + 9L31a + 677 949.54 353.00 YES - + YES @@ -50,12 +50,12 @@ YES - 276 + 274 YES - 268 + 266 {{17, 100}, {282, 14}} YES @@ -91,7 +91,7 @@ - 292 + 290 {{20, 54}, {276, 38}} YES @@ -297,7 +297,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 36 + 34 {{20, 43}, {276, 5}} {0, 0} @@ -324,7 +324,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 292 + 294 YES @@ -354,7 +354,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 289 + 291 YES @@ -484,6 +484,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 30 + + + manageButton_ + + + + 31 + + + + doneButton_ + + + + 32 + @@ -725,7 +741,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 30 + 32 @@ -770,12 +786,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES allowBlockRadioGroup_ bubble_ + contentsContainer_ + doneButton_ + manageButton_ titleLabel_ YES NSMatrix InfoBubbleView + NSView + NSButton + NSButton NSTextField diff --git a/chrome/app/nibs/ContentBlockedJavaScript.xib b/chrome/app/nibs/ContentBlockedJavaScript.xib index e05a1ab..6741853 100644 --- a/chrome/app/nibs/ContentBlockedJavaScript.xib +++ b/chrome/app/nibs/ContentBlockedJavaScript.xib @@ -2,13 +2,13 @@ 1050 - 9L30 - 680 + 9L31a + 677 949.54 353.00 YES - + YES @@ -50,12 +50,12 @@ YES - 276 + 274 YES - 268 + 266 {{17, 100}, {282, 14}} YES @@ -91,7 +91,7 @@ - 292 + 290 {{20, 54}, {276, 38}} YES @@ -297,7 +297,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 36 + 34 {{20, 43}, {276, 5}} {0, 0} @@ -324,7 +324,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 292 + 294 YES @@ -354,7 +354,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 289 + 291 YES @@ -484,6 +484,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 30 + + + manageButton_ + + + + 31 + + + + doneButton_ + + + + 32 + @@ -725,7 +741,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 30 + 32 @@ -770,12 +786,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES allowBlockRadioGroup_ bubble_ + contentsContainer_ + doneButton_ + manageButton_ titleLabel_ YES NSMatrix InfoBubbleView + NSView + NSButton + NSButton NSTextField diff --git a/chrome/app/nibs/ContentBlockedPlugins.xib b/chrome/app/nibs/ContentBlockedPlugins.xib index 103439d..c83c9f5 100644 --- a/chrome/app/nibs/ContentBlockedPlugins.xib +++ b/chrome/app/nibs/ContentBlockedPlugins.xib @@ -2,13 +2,13 @@ 1050 - 9L30 - 680 + 9L31a + 677 949.54 353.00 YES - + YES @@ -50,12 +50,12 @@ YES - 276 + 274 YES - 268 + 266 {{17, 100}, {282, 14}} YES @@ -91,7 +91,7 @@ - 292 + 290 {{20, 54}, {276, 38}} YES @@ -297,7 +297,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 36 + 34 {{20, 43}, {276, 5}} {0, 0} @@ -324,7 +324,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 292 + 294 YES @@ -354,7 +354,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 289 + 291 YES @@ -484,6 +484,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 30 + + + manageButton_ + + + + 31 + + + + doneButton_ + + + + 32 + @@ -725,7 +741,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 30 + 32 @@ -770,12 +786,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES allowBlockRadioGroup_ bubble_ + contentsContainer_ + doneButton_ + manageButton_ titleLabel_ YES NSMatrix InfoBubbleView + NSView + NSButton + NSButton NSTextField diff --git a/chrome/app/nibs/ContentBlockedPopups.xib b/chrome/app/nibs/ContentBlockedPopups.xib index 3926208..b5e1810 100644 --- a/chrome/app/nibs/ContentBlockedPopups.xib +++ b/chrome/app/nibs/ContentBlockedPopups.xib @@ -2,13 +2,13 @@ 1050 - 9L30 - 680 + 9L31a + 677 949.54 353.00 YES - + YES @@ -50,12 +50,12 @@ YES - 276 + 274 YES - 268 + 266 {{17, 100}, {282, 14}} YES @@ -91,7 +91,7 @@ - 292 + 290 {{20, 54}, {276, 38}} YES @@ -297,7 +297,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 36 + 34 {{20, 43}, {276, 5}} {0, 0} @@ -324,7 +324,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 292 + 294 YES @@ -354,7 +354,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 289 + 291 YES @@ -484,6 +484,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA 30 + + + manageButton_ + + + + 31 + + + + doneButton_ + + + + 32 + @@ -725,7 +741,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA - 30 + 32 @@ -770,12 +786,18 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA YES allowBlockRadioGroup_ bubble_ + contentsContainer_ + doneButton_ + manageButton_ titleLabel_ YES NSMatrix InfoBubbleView + NSView + NSButton + NSButton NSTextField diff --git a/chrome/app/nibs/ContentBubbleGeolocation.xib b/chrome/app/nibs/ContentBubbleGeolocation.xib index 170d02f..f3a9046 100644 --- a/chrome/app/nibs/ContentBubbleGeolocation.xib +++ b/chrome/app/nibs/ContentBubbleGeolocation.xib @@ -8,7 +8,7 @@ 353.00 YES - + YES @@ -55,7 +55,7 @@ YES - 36 + 34 {{20, 43}, {276, 5}} {0, 0} @@ -89,7 +89,7 @@ - 292 + 294 YES @@ -123,7 +123,7 @@ - 289 + 291 YES @@ -153,7 +153,7 @@ - 292 + 290 {{20, 54}, {276, 14}} NSView @@ -244,6 +244,22 @@ 43 + + + manageButton_ + + + + 45 + + + + doneButton_ + + + + 46 + @@ -439,7 +455,7 @@ - 44 + 46 @@ -485,6 +501,8 @@ allowBlockRadioGroup_ bubble_ contentsContainer_ + doneButton_ + manageButton_ titleLabel_ @@ -492,6 +510,8 @@ NSMatrix InfoBubbleView NSView + NSButton + NSButton NSTextField diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.h b/chrome/browser/cocoa/content_blocked_bubble_controller.h index 6b325a4..669c437 100644 --- a/chrome/browser/cocoa/content_blocked_bubble_controller.h +++ b/chrome/browser/cocoa/content_blocked_bubble_controller.h @@ -31,6 +31,9 @@ typedef std::map PopupLinks; IBOutlet NSTextField* titleLabel_; IBOutlet NSMatrix* allowBlockRadioGroup_; + IBOutlet NSButton* manageButton_; + IBOutlet NSButton* doneButton_; + // The container for the bubble contents of the geolocation bubble. IBOutlet NSView* contentsContainer_; diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm index 684a70b..0bd90a4 100644 --- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm +++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm @@ -53,6 +53,8 @@ const int kGeoPadding = 8; // Padding between host names in the geolocation bubble. const int kGeoHostPadding = 4; +// Minimal padding between "Manage" and "Done" buttons. +const int kManageDonePadding = 8; // Like |ReplaceStringPlaceholders(const string16&, const string16&, size_t*)|, // but for a NSString formatString. @@ -97,6 +99,7 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { - (void)initializeRadioGroup; - (void)initializePopupList; - (void)initializeGeoLists; +- (void)sizeToFitManageDoneButtons; - (void)popupLinkClicked:(id)sender; - (void)clearGeolocationForCurrentHost:(id)sender; @end @@ -348,6 +351,22 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { [contentsContainer_ setFrame:containerFrame]; } +- (void)sizeToFitManageDoneButtons { + CGFloat actualWidth = NSWidth([[[self window] contentView] frame]); + CGFloat requiredWidth = NSMaxX([manageButton_ frame]) + kManageDonePadding + + NSWidth([[doneButton_ superview] frame]) - NSMinX([doneButton_ frame]); + if (requiredWidth <= actualWidth || !doneButton_ || !manageButton_) + return; + + // Resize window, autoresizing takes care of the rest. + NSSize size = NSMakeSize(requiredWidth - actualWidth, 0); + size = [[[self window] contentView] convertSize:size toView:nil]; + NSRect frame = [[self window] frame]; + frame.origin.x -= size.width; + frame.size.width += size.width; + [[self window] setFrame:frame display:NO]; +} + - (void)awakeFromNib { DCHECK([self window]); DCHECK_EQ(self, [[self window] delegate]); @@ -355,6 +374,9 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { [bubble_ setBubbleType:kWhiteInfoBubble]; [bubble_ setArrowLocation:kTopRight]; + // Adapt window size to bottom buttons. Do this before all other layouting. + [self sizeToFitManageDoneButtons]; + [self initializeTitle]; if (allowBlockRadioGroup_) // not bound in cookie bubble xib [self initializeRadioGroup]; -- cgit v1.1