Adjustments to bookmark bar folder menu placement issues.

1) Sub-menus should expose as much as possible without needing to be scrolled up when the dock is showing at the bottom.
2) Fix how menu bottom is misplaced and window is foreshortened when that last scroll-up is performed (for a menu which fits on the screen after being completely scrolled up).
3) Align the right edge of the menu with the right edge of the bookmark bar button from which it springs.
4) Tighten up the menu item spacing.

BUG=54701,69418,69346,59057
TEST=1) Place window near bottom of screen with dock showing. Pop up a folder menu (one which will completely fit on the screen after being fully scrolled up) and scroll fully up. Verify that the bottom it properly placed and all folder contents are shown. Verify that the menu right edge is aligned with the right edge of the button.
2) Have a bookmark folder menu with a submenu near the bottom. Pop up the folder menu and then the submenu. Verify all of the submenu appears.
3) All BookmarkBarFolderControllerTests menu unit tests pass.
4) All BookmarkBarFolderControllerMenuTests menu unit tests pass.

Review URL: http://codereview.chromium.org/6257005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71889 0039d316-1c4b-4281-b951-d872f2087c98
parent 358b3466
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -33,6 +33,9 @@ const int kNTPBookmarkBarPadding = ...@@ -33,6 +33,9 @@ const int kNTPBookmarkBarPadding =
// The height of buttons in the bookmark bar. // The height of buttons in the bookmark bar.
const int kBookmarkButtonHeight = kBookmarkBarHeight + kVisualHeightOffset; const int kBookmarkButtonHeight = kBookmarkBarHeight + kVisualHeightOffset;
// The height of buttons in a bookmark bar folder menu.
const CGFloat kBookmarkFolderButtonHeight = 24.0;
// The radius of the corner curves on the menu. Also used for sizing the shadow // The radius of the corner curves on the menu. Also used for sizing the shadow
// window behind the menu window at times when the menu can be scrolled. // window behind the menu window at times when the menu can be scrolled.
const CGFloat kBookmarkBarMenuCornerRadius = 4.0; const CGFloat kBookmarkBarMenuCornerRadius = 4.0;
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -54,16 +54,6 @@ const CGFloat kBookmarkVerticalPadding = 2.0; ...@@ -54,16 +54,6 @@ const CGFloat kBookmarkVerticalPadding = 2.0;
const CGFloat kBookmarkMenuButtonMinimumWidth = 100.0; const CGFloat kBookmarkMenuButtonMinimumWidth = 100.0;
const CGFloat kBookmarkMenuButtonMaximumWidth = 485.0; const CGFloat kBookmarkMenuButtonMaximumWidth = 485.0;
// TODO(mrossetti): Add constant (kBookmarkVerticalSeparation) for the gap
// between buttons in a folder menu. Right now we're using
// kBookmarkVerticalPadding, which is dual purpose and wrong.
// http://crbug.com/59057
// Convenience constant giving the vertical distance from the top extent of one
// folder button to the next button.
const CGFloat kBookmarkButtonVerticalSpan =
kBookmarkButtonHeight + kBookmarkVerticalPadding;
// The minimum separation between a folder menu and the edge of the screen. // The minimum separation between a folder menu and the edge of the screen.
// If the menu gets closer to the edge of the screen (either right or left) // If the menu gets closer to the edge of the screen (either right or left)
// then it is pops up in the opposite direction. // then it is pops up in the opposite direction.
...@@ -91,6 +81,12 @@ const CGFloat kScrollWindowVerticalMargin = 6.0; ...@@ -91,6 +81,12 @@ const CGFloat kScrollWindowVerticalMargin = 6.0;
// is set just above the bar so that it become distinctive when drawn. // is set just above the bar so that it become distinctive when drawn.
const CGFloat kBookmarkBarMenuOffset = 2.0; const CGFloat kBookmarkBarMenuOffset = 2.0;
// How far to offset a folder menu's left edge horizontally in relation to
// the left edge of the button from which it springs. Because of drawing
// differences, simply aligning the |frame| of each does not render the
// pproper result, so we have to offset.
const CGFloat kBookmarkBarButtonOffset = 2.0;
// Delay before opening a subfolder (and closing the previous one) // Delay before opening a subfolder (and closing the previous one)
// when hovering over a folder button. // when hovering over a folder button.
const NSTimeInterval kHoverOpenDelay = 0.3; const NSTimeInterval kHoverOpenDelay = 0.3;
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
} else { } else {
CGFloat nextVerticalOffset = [button frame].origin.y; CGFloat nextVerticalOffset = [button frame].origin.y;
EXPECT_CGFLOAT_EQ(lastVerticalOffset - EXPECT_CGFLOAT_EQ(lastVerticalOffset -
bookmarks::kBookmarkButtonVerticalSpan, bookmarks::kBookmarkFolderButtonHeight,
nextVerticalOffset); nextVerticalOffset);
lastVerticalOffset = nextVerticalOffset; lastVerticalOffset = nextVerticalOffset;
} }
...@@ -483,9 +483,11 @@ TEST_F(BookmarkBarFolderControllerTest, SimpleScroll) { ...@@ -483,9 +483,11 @@ TEST_F(BookmarkBarFolderControllerTest, SimpleScroll) {
break; break;
targetButton = button; targetButton = button;
} }
EXPECT_TRUE(targetButton != nil);
NSPoint hitPoint = [targetButton frame].origin; NSPoint hitPoint = [targetButton frame].origin;
hitPoint.x += 50.0; hitPoint.x += 50.0;
hitPoint.y += (bookmarks::kBookmarkButtonHeight / 2.0) - scrollPoint.y; hitPoint.y += (bookmarks::kBookmarkFolderButtonHeight / 2.0) - scrollPoint.y;
hitPoint = [targetButton convertPoint:hitPoint toView:scrollView];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
CGFloat height = NSHeight([window frame]); CGFloat height = NSHeight([window frame]);
...@@ -557,7 +559,7 @@ TEST_F(BookmarkBarFolderControllerTest, MenuPlacementWhileScrollingDeleting) { ...@@ -557,7 +559,7 @@ TEST_F(BookmarkBarFolderControllerTest, MenuPlacementWhileScrollingDeleting) {
// the top of the window has moved up, then delete a visible button and // the top of the window has moved up, then delete a visible button and
// make sure the top has not moved. // make sure the top has not moved.
oldTop = newTop; oldTop = newTop;
const CGFloat scrollOneBookmark = bookmarks::kBookmarkButtonHeight + const CGFloat scrollOneBookmark = bookmarks::kBookmarkFolderButtonHeight +
bookmarks::kBookmarkVerticalPadding; bookmarks::kBookmarkVerticalPadding;
NSUInteger buttonCounter = 0; NSUInteger buttonCounter = 0;
NSUInteger extraButtonLimit = 3; NSUInteger extraButtonLimit = 3;
...@@ -729,10 +731,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToFolder) { ...@@ -729,10 +731,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToFolder) {
// and grown vertically. // and grown vertically.
NSRect expectedToWindowFrame = oldToWindowFrame; NSRect expectedToWindowFrame = oldToWindowFrame;
expectedToWindowFrame.origin.x -= horizontalShift; expectedToWindowFrame.origin.x -= horizontalShift;
CGFloat diff = (bookmarks::kBookmarkBarHeight + expectedToWindowFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight;
2*bookmarks::kBookmarkVerticalPadding); expectedToWindowFrame.size.height += bookmarks::kBookmarkFolderButtonHeight;
expectedToWindowFrame.origin.y -= diff;
expectedToWindowFrame.size.height += diff;
EXPECT_NSRECT_EQ(expectedToWindowFrame, newToWindowFrame); EXPECT_NSRECT_EQ(expectedToWindowFrame, newToWindowFrame);
// Check button spacing. // Check button spacing.
...@@ -796,10 +796,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, DragCopyBarBookmarkToFolder) { ...@@ -796,10 +796,8 @@ TEST_F(BookmarkBarFolderControllerMenuTest, DragCopyBarBookmarkToFolder) {
EXPECT_NSRECT_EQ(oldToFolderFrame, newToFolderFrame); EXPECT_NSRECT_EQ(oldToFolderFrame, newToFolderFrame);
// The toWindow should have shifted down vertically and grown vertically. // The toWindow should have shifted down vertically and grown vertically.
NSRect expectedToWindowFrame = oldToWindowFrame; NSRect expectedToWindowFrame = oldToWindowFrame;
CGFloat diff = (bookmarks::kBookmarkBarHeight + expectedToWindowFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight;
2*bookmarks::kBookmarkVerticalPadding); expectedToWindowFrame.size.height += bookmarks::kBookmarkFolderButtonHeight;
expectedToWindowFrame.origin.y -= diff;
expectedToWindowFrame.size.height += diff;
EXPECT_NSRECT_EQ(expectedToWindowFrame, newToWindowFrame); EXPECT_NSRECT_EQ(expectedToWindowFrame, newToWindowFrame);
// Copy the button back to the bar after "3b". // Copy the button back to the bar after "3b".
...@@ -875,10 +873,9 @@ TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToSubfolder) { ...@@ -875,10 +873,9 @@ TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToSubfolder) {
EXPECT_NSRECT_EQ(oldToWindowFrame, newToWindowFrame); EXPECT_NSRECT_EQ(oldToWindowFrame, newToWindowFrame);
NSRect newToSubwindowFrame = [toSubwindow frame]; NSRect newToSubwindowFrame = [toSubwindow frame];
NSRect expectedToSubwindowFrame = oldToSubwindowFrame; NSRect expectedToSubwindowFrame = oldToSubwindowFrame;
expectedToSubwindowFrame.origin.y -= expectedToSubwindowFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight;
(bookmarks::kBookmarkButtonHeight + bookmarks::kVisualHeightOffset);
expectedToSubwindowFrame.size.height += expectedToSubwindowFrame.size.height +=
(bookmarks::kBookmarkButtonHeight + bookmarks::kVisualHeightOffset); bookmarks::kBookmarkFolderButtonHeight;
EXPECT_NSRECT_EQ(expectedToSubwindowFrame, newToSubwindowFrame); EXPECT_NSRECT_EQ(expectedToSubwindowFrame, newToSubwindowFrame);
} }
...@@ -1181,7 +1178,7 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { ...@@ -1181,7 +1178,7 @@ TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) {
EXPECT_TRUE(folderController); EXPECT_TRUE(folderController);
NSWindow* folderWindow = [folderController window]; NSWindow* folderWindow = [folderController window];
EXPECT_TRUE(folderWindow); EXPECT_TRUE(folderWindow);
CGFloat expectedHeight = (CGFloat)bookmarks::kBookmarkButtonHeight + CGFloat expectedHeight = (CGFloat)bookmarks::kBookmarkFolderButtonHeight +
(2*bookmarks::kBookmarkVerticalPadding); (2*bookmarks::kBookmarkVerticalPadding);
NSRect windowFrame = [folderWindow frame]; NSRect windowFrame = [folderWindow frame];
CGFloat windowHeight = NSHeight(windowFrame); CGFloat windowHeight = NSHeight(windowFrame);
......
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -231,10 +231,11 @@ ...@@ -231,10 +231,11 @@
if ([button isFolder]) { if ([button isFolder]) {
NSRect imageRect = NSZeroRect; NSRect imageRect = NSZeroRect;
imageRect.size = [arrowImage_ size]; imageRect.size = [arrowImage_ size];
NSRect drawRect = NSOffsetRect(imageRect, const CGFloat kArrowOffset = 1.0; // Required for proper centering.
NSWidth(cellFrame) - NSWidth(imageRect), CGFloat dX = NSWidth(cellFrame) - NSWidth(imageRect);
(NSHeight(cellFrame) / 2.0) - CGFloat dY = (NSHeight(cellFrame) / 2.0) - (NSHeight(imageRect) / 2.0) +
(NSHeight(imageRect) / 2.0)); kArrowOffset;
NSRect drawRect = NSOffsetRect(imageRect, dX, dY);
[arrowImage_ drawInRect:drawRect [arrowImage_ drawInRect:drawRect
fromRect:imageRect fromRect:imageRect
operation:NSCompositeSourceOver operation:NSCompositeSourceOver
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment