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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 11428149: Alternate NTP: Move bookmark bar to bottom (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 8 years 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
Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 617db847c7890353df56332a0acdecabc1872a23..99fbc9ac953e087ebd2d01d838c5682b4a9a0259 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -32,6 +32,7 @@
#import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
#import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
+#include "chrome/browser/ui/search/search_ui.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -212,7 +213,7 @@ willPositionSheet:(NSWindow*)sheet
// immediately below the toolbar.
BOOL placeBookmarkBarBelowInfoBar = [self placeBookmarkBarBelowInfoBar];
if (!placeBookmarkBarBelowInfoBar)
- maxY = [self layoutBookmarkBarAtMinX:minX maxY:maxY width:width];
+ maxY = [self layoutTopBookmarkBarAtMinX:minX maxY:maxY width:width];
// The floating bar backing view doesn't actually add any height.
NSRect floatingBarBackingRect =
@@ -235,13 +236,19 @@ willPositionSheet:(NSWindow*)sheet
// presentation mode in which case it's at the top of the visual content area.
maxY = [self layoutInfoBarAtMinX:minX maxY:maxY width:width];
- // If the bookmark bar is detached, place it next in the visual content area.
- if (placeBookmarkBarBelowInfoBar)
- maxY = [self layoutBookmarkBarAtMinX:minX maxY:maxY width:width];
-
// Place the download shelf, if any, at the bottom of the view.
minY = [self layoutDownloadShelfAtMinX:minX minY:minY width:width];
+ // If the bookmark bar is detached, place it next in the visual content area.
kuan 2012/12/04 09:12:28 nit: update comments?
sail 2012/12/04 18:00:07 Done.
+ if (placeBookmarkBarBelowInfoBar) {
+ if ([bookmarkBarController_ shouldShowAtBottomWhenDetached]) {
+ [self layoutBottomBookmarkBarInContentFrame:
+ NSMakeRect(minX, minY, width, maxY - minY)];
+ } else {
+ maxY = [self layoutTopBookmarkBarAtMinX:minX maxY:maxY width:width];
+ }
+ }
+
// Finally, the content area takes up all of the remaining space.
NSRect contentAreaRect = NSMakeRect(minX, minY, width, maxY - minY);
[self layoutTabContentArea:contentAreaRect];
@@ -370,20 +377,21 @@ willPositionSheet:(NSWindow*)sheet
[bookmarkBarController_ isAnimatingFromState:bookmarks::kDetachedState];
}
-- (CGFloat)layoutBookmarkBarAtMinX:(CGFloat)minX
- maxY:(CGFloat)maxY
- width:(CGFloat)width {
+- (CGFloat)layoutTopBookmarkBarAtMinX:(CGFloat)minX
+ maxY:(CGFloat)maxY
+ width:(CGFloat)width {
+ [bookmarkBarController_ updateHiddenState];
+
NSView* bookmarkBarView = [bookmarkBarController_ view];
- NSRect bookmarkBarFrame = [bookmarkBarView frame];
- BOOL oldHidden = [bookmarkBarView isHidden];
- BOOL newHidden = ![self isBookmarkBarVisible];
- if (oldHidden != newHidden)
- [bookmarkBarView setHidden:newHidden];
- bookmarkBarFrame.origin.x = minX;
- bookmarkBarFrame.origin.y = maxY - NSHeight(bookmarkBarFrame);
- bookmarkBarFrame.size.width = width;
- [bookmarkBarView setFrame:bookmarkBarFrame];
- maxY -= NSHeight(bookmarkBarFrame);
+ NSRect frame = [bookmarkBarView frame];
+ frame.origin.x = minX;
+ frame.origin.y = maxY - NSHeight(frame);
+ frame.size.width = width;
+ [bookmarkBarView setFrame:frame];
+ maxY -= NSHeight(frame);
+
+ // Pin the bookmark bar to the top of the window and make the width flexible.
+ [bookmarkBarView setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
// TODO(viettrungluu): Does this really belong here? Calling it shouldn't be
// necessary in the non-NTP case.
@@ -392,6 +400,29 @@ willPositionSheet:(NSWindow*)sheet
return maxY;
}
+- (void)layoutBottomBookmarkBarInContentFrame:(NSRect)contentFrame {
+ [bookmarkBarController_ updateHiddenState];
+
+ NSView* bookmarkBarView = [bookmarkBarController_ view];
+ NSRect frame;
+ frame.size.width = NSWidth(contentFrame) -
+ chrome::search::kHorizontalPaddingForBottomBookmarkBar * 2;
+ frame.size.width = std::min(frame.size.width,
+ static_cast<CGFloat>(chrome::search::kMaxWidthForBottomBookmarkBar));
+ frame.size.height = NSHeight([bookmarkBarView frame]);
+ frame.origin.x = NSMinX(contentFrame) +
+ roundf((NSWidth(contentFrame)- frame.size.width) / 2.0);
+ frame.origin.y = NSMinY(contentFrame);
+ [bookmarkBarView setFrame:frame];
+
+ // Disable auto-resizing.
+ [bookmarkBarView setAutoresizingMask:0];
+
+ // TODO(viettrungluu): Does this really belong here? Calling it shouldn't be
+ // necessary in the non-NTP case.
+ [bookmarkBarController_ layoutSubviews];
+}
+
- (void)layoutFloatingBarBackingView:(NSRect)frame
presentationMode:(BOOL)presentationMode {
// Only display when in presentation mode.

Powered by Google App Engine
This is Rietveld 408576698