summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authormaf@chromium.org <maf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 00:54:33 +0000
committermaf@chromium.org <maf@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-18 00:54:33 +0000
commit92a9ae8958c2da23e2beecb7aa66cb7e42677836 (patch)
tree2d0f65c51693dbfc5f3e2578096fde980355765f /chrome/browser/ui
parent0815da72e7a85a810ba3841b30eb4f357d8e54f9 (diff)
downloadchromium_src-92a9ae8958c2da23e2beecb7aa66cb7e42677836.zip
chromium_src-92a9ae8958c2da23e2beecb7aa66cb7e42677836.tar.gz
chromium_src-92a9ae8958c2da23e2beecb7aa66cb7e42677836.tar.bz2
The bookmark folder menus look bad when squeezed up against the bottom of a screen.
Detect this case and automatically switch to showing the menu above the button in this case. BUG=69996 TEST=NONE Review URL: http://codereview.chromium.org/6531019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75342 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm21
1 files changed, 18 insertions, 3 deletions
diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm
index 53bb97d..3362886 100644
--- a/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm
+++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm
@@ -458,7 +458,8 @@ struct LayoutMetrics {
// 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 = bookmarks::kBookmarkFolderButtonHeight * 2.0;
NSPoint newWindowTopLeft;
if (![parentController_ isKindOfClass:[self class]]) {
// If we're not popping up from one of ourselves, we must be
@@ -485,6 +486,18 @@ struct LayoutMetrics {
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];
+ CGFloat availableVerticalSpace = newWindowTopLeft.y -
+ (NSMinY(visFrame) + bookmarks::kScrollWindowVerticalMargin);
+ if ((availableVerticalSpace < kMinSqueezedMenuHeight) &&
+ (windowHeight > availableVerticalSpace)) {
+ 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 +715,8 @@ struct LayoutMetrics {
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 +776,8 @@ struct LayoutMetrics {
// 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]]) {