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

Unified Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm

Issue 6531019: The bookmark folder menus look bad when squeezed up against the bottom of a s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm
===================================================================
--- chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm (revision 75175)
+++ chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm (working copy)
@@ -458,7 +458,8 @@
// coordinates). The top left is positioned in a manner similar to
// cascading menus. Windows may grow to either the right or left of
// their parent (if a sub-folder) so we need to know |windowWidth|.
-- (NSPoint)windowTopLeftForWidth:(int)windowWidth {
+- (NSPoint)windowTopLeftForWidth:(int)windowWidth height:(int)windowHeight {
+ CGFloat kMinSqueezedMenuHeight = 40.0;
mrossetti 2011/02/17 03:38:30 It would probably be better if this constant were
mafv 2011/02/17 21:25:00 Done. This is now based on kBookmarkFolderButtonH
NSPoint newWindowTopLeft;
if (![parentController_ isKindOfClass:[self class]]) {
// If we're not popping up from one of ourselves, we must be
@@ -485,6 +486,16 @@
newWindowTopLeft.x = std::max(newWindowTopLeft.x - spillOff,
NSMinX(screenFrame));
}
+ // The menu looks bad when it is squeezed up against the bottom of the
+ // screen and ends up being only a few pixels tall. If it meets the
+ // threshold for this case, instead show the menu above the button.
+ NSRect visFrame = [[[parentButton_ window] screen] visibleFrame];
+ if ((newWindowTopLeft.y - NSMinY(visFrame) < kMinSqueezedMenuHeight) &&
mrossetti 2011/02/17 03:38:30 Have you tried this with a bookmark bar folder whi
mafv 2011/02/17 21:25:00 Yes.
+ (windowHeight > kMinSqueezedMenuHeight)) {
+ newWindowTopLeft.y = std::min(
+ newWindowTopLeft.y + windowHeight + NSHeight([parentButton_ frame]),
+ NSMaxY(visFrame));
+ }
} else {
// Parent is a folder: expose as much as we can vertically; grow right/left.
newWindowTopLeft.x = [self childFolderWindowLeftForWidth:windowWidth];
@@ -702,7 +713,8 @@
folderFrame.size.height += deltaMenuHeight;
[folderView_ setFrameSize:folderFrame.size];
CGFloat windowWidth = [self adjustButtonWidths] + padding_;
- NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth];
+ NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth
+ height:deltaMenuHeight];
CGFloat left = newWindowTopLeft.x;
NSSize newSize = NSMakeSize(windowWidth, deltaMenuHeight);
[self adjustWindowLeft:left size:newSize scrollingBy:0.0];
@@ -762,7 +774,8 @@
// base the window width on this ideal button width.
CGFloat buttonWidth = [self adjustButtonWidths];
CGFloat windowWidth = buttonWidth + padding_;
- NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth];
+ NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth
+ height:height];
// Make sure as much of a submenu is exposed (which otherwise would be a
// problem if the parent button is close to the bottom of the screen).
if ([parentController_ isKindOfClass:[self class]]) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698