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

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

Issue 159776: Rewrites the Mac view resizing logic to have the BrowserWindowController... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 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/toolbar_controller.h ('k') | chrome/browser/cocoa/toolbar_controller_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/toolbar_controller.mm
===================================================================
--- chrome/browser/cocoa/toolbar_controller.mm (revision 22499)
+++ chrome/browser/cocoa/toolbar_controller.mm (working copy)
@@ -23,6 +23,12 @@
// Name of image in the bundle for the yellow of the star icon.
static NSString* const kStarredImageName = @"starred.pdf";
+// Height of the toolbar in pixels when the bookmark bar is closed.
+static const float kBaseToolbarHeight = 39.0;
+
+// Overlap (in pixels) between the toolbar and the bookmark bar.
+static const float kBookmarkBarOverlap = 5.0;
+
@interface ToolbarController(Private)
- (void)initCommandStatus:(CommandUpdater*)commands;
- (void)prefChanged:(std::wstring*)prefName;
@@ -54,8 +60,7 @@
- (id)initWithModel:(ToolbarModel*)model
commands:(CommandUpdater*)commands
profile:(Profile*)profile
- webContentView:(NSView*)webContentView
- infoBarsView:(NSView*)infoBarsView
+ resizeDelegate:(id<ViewResizer>)resizeDelegate
bookmarkDelegate:(id<BookmarkURLOpener>)delegate {
DCHECK(model && commands && profile);
if ((self = [super initWithNibName:@"Toolbar"
@@ -63,9 +68,8 @@
toolbarModel_ = model;
commands_ = commands;
profile_ = profile;
+ resizeDelegate_ = resizeDelegate;
bookmarkBarDelegate_ = delegate;
- webContentView_ = webContentView;
- infoBarsView_ = infoBarsView;
hasToolbar_ = YES;
// Register for notifications about state changes for the toolbar buttons
@@ -109,10 +113,9 @@
// Create a sub-controller for the bookmark bar.
bookmarkBarController_.reset([[BookmarkBarController alloc]
initWithProfile:profile_
- parentView:[self view]
- webContentView:webContentView_
- infoBarsView:infoBarsView_
- delegate:bookmarkBarDelegate_]);
+ initialWidth:NSWidth([[self view] frame])
+ resizeDelegate:self
+ urlDelegate:bookmarkBarDelegate_]);
// Add bookmark bar to the view hierarchy. This also triggers the
// nib load. The bookmark bar is defined (in the nib) to be
@@ -121,6 +124,22 @@
[[self view] addSubview:[bookmarkBarController_ view]];
}
+- (void)resizeView:(NSView*)view newHeight:(float)height {
+ DCHECK(view == [bookmarkBarController_ view]);
+
+ // The bookmark bar is always rooted at the bottom of the toolbar view, with
+ // width equal to the toolbar's width. The toolbar view is resized to
+ // accomodate the new bookmark bar height.
+ NSRect frame = NSMakeRect(0, 0, [[self view] bounds].size.width, height);
+ [view setFrame:frame];
+
+ float newToolbarHeight = kBaseToolbarHeight + height - kBookmarkBarOverlap;
+ if (newToolbarHeight < kBaseToolbarHeight)
+ newToolbarHeight = kBaseToolbarHeight;
+
+ [resizeDelegate_ resizeView:[self view] newHeight:newToolbarHeight];
+}
+
- (LocationBar*)locationBar {
return locationBarView_.get();
}
« no previous file with comments | « chrome/browser/cocoa/toolbar_controller.h ('k') | chrome/browser/cocoa/toolbar_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698