Chromium Code Reviews| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm |
| =================================================================== |
| --- chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm (revision 71802) |
| +++ chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm (working copy) |
| @@ -29,11 +29,11 @@ |
| // Amount to scroll by per timer fire. We scroll rather slowly; to |
| // accomodate we do several at a time. |
| const CGFloat kBookmarkBarFolderScrollAmount = |
| - 3 * bookmarks::kBookmarkButtonVerticalSpan; |
| + 3 * bookmarks::kBookmarkFolderButtonHeight; |
| // Amount to scroll for each scroll wheel roll. |
| const CGFloat kBookmarkBarFolderScrollWheelAmount = |
| - 1 * bookmarks::kBookmarkButtonVerticalSpan; |
| + 1 * bookmarks::kBookmarkFolderButtonHeight; |
| // Determining adjustments to the layout of the folder menu window in response |
| // to resizing and scrolling relies on many visual factors. The following |
| @@ -473,7 +473,8 @@ |
| [[parentButton_ window] |
| convertBaseToScreen:[[parentButton_ superview] |
| convertPoint:NSZeroPoint toView:nil]]; |
| - newWindowTopLeft = NSMakePoint(buttonBottomLeftInScreen.x, |
| + newWindowTopLeft = NSMakePoint(buttonBottomLeftInScreen.x + |
|
mafv
2011/01/19 22:39:39
Indentation in this function looks weird. I see wh
mrossetti
2011/01/20 01:41:42
Done.
|
| + bookmarks::kBookmarkBarButtonOffset, |
| bookmarkBarBottomLeftInScreen.y + |
| bookmarks::kBookmarkBarMenuOffset); |
| // Make sure the window is on-screen; if not, push left. It is |
| @@ -486,11 +487,11 @@ |
| NSMinX(screenFrame)); |
| } |
| } else { |
| - // Parent is a folder; grow right/left. |
| + // Parent is a folder: expose as much as we can vertically; grow right/left. |
| newWindowTopLeft.x = [self childFolderWindowLeftForWidth:windowWidth]; |
| NSPoint topOfWindow = NSMakePoint(0, |
| - (NSMaxY([parentButton_ frame]) + |
| - bookmarks::kBookmarkVerticalPadding)); |
| + NSMaxY([parentButton_ frame]) - |
| + bookmarks::kBookmarkVerticalPadding); |
| topOfWindow = [[parentButton_ window] |
| convertBaseToScreen:[[parentButton_ superview] |
| convertPoint:topOfWindow toView:nil]]; |
| @@ -508,8 +509,8 @@ |
| - (int)menuHeightForButtonCount:(int)buttonCount { |
| // This does not take into account any padding which may be required at the |
| // top and/or bottom of the window. |
| - return (buttonCount * bookmarks::kBookmarkButtonVerticalSpan) + |
| - bookmarks::kBookmarkVerticalPadding; |
| + return (buttonCount * bookmarks::kBookmarkFolderButtonHeight) + |
| + 2 * bookmarks::kBookmarkVerticalPadding; |
| } |
| - (void)adjustWindowLeft:(CGFloat)windowLeft |
| @@ -569,10 +570,10 @@ |
| metrics.canScrollDown = metrics.folderTop > maximumY; |
| // Accommodate changes in the bottom of the menu. |
| - [self adjustMetricsForMenuTopChanges:layoutMetrics]; |
| + [self adjustMetricsForMenuBottomChanges:layoutMetrics]; |
| // Accommodate changes in the top of the menu. |
| - [self adjustMetricsForMenuBottomChanges:layoutMetrics]; |
| + [self adjustMetricsForMenuTopChanges:layoutMetrics]; |
| metrics.scrollerFrame.origin.y += metrics.deltaScrollerY; |
| metrics.scrollerFrame.size.height += metrics.deltaScrollerHeight; |
| @@ -586,7 +587,7 @@ |
| metrics.windowFrame.size.width = metrics.windowSize.width; |
| } |
| -- (void)adjustMetricsForMenuTopChanges:(LayoutMetrics*)layoutMetrics { |
| +- (void)adjustMetricsForMenuBottomChanges:(LayoutMetrics*)layoutMetrics { |
| LayoutMetrics& metrics(*layoutMetrics); |
| if (metrics.canScrollUp) { |
| if (!metrics.couldScrollUp) { |
| @@ -598,7 +599,7 @@ |
| metrics.deltaScrollerY = verticalScrollArrowHeight_; |
| metrics.deltaScrollerHeight = -metrics.deltaScrollerY; |
| // Adjust the scroll delta if we've grown the window and it is |
| - // now scroll-up-able, but don't adjust it factor if we've |
| + // now scroll-up-able, but don't adjust it if we've |
| // scrolled down and it wasn't scroll-up-able but now is. |
| if (metrics.canScrollDown == metrics.couldScrollDown) { |
| CGFloat deltaScroll = metrics.deltaWindowY + metrics.deltaScrollerY + |
| @@ -613,17 +614,12 @@ |
| // Could -> Can't |
| metrics.deltaWindowY = metrics.folderY - metrics.oldWindowY; |
| metrics.deltaWindowHeight = -metrics.deltaWindowY; |
| - metrics.deltaVisibleY = -bookmarks::kScrollWindowVerticalMargin; |
| + metrics.deltaVisibleY = -metrics.visibleFrame.origin.y; |
| metrics.deltaVisibleHeight = -metrics.deltaVisibleY; |
| metrics.deltaScrollerY = -verticalScrollArrowHeight_; |
| metrics.deltaScrollerHeight = -metrics.deltaScrollerY; |
| - // Adjust the scroll delta if we are no longer scroll-up-able |
| - // and the scroll-down-able-ness hasn't changed. |
| - if (metrics.canScrollDown == metrics.couldScrollDown) { |
| - CGFloat deltaScroll = metrics.deltaWindowY + metrics.deltaScrollerY + |
| - metrics.deltaVisibleY; |
| - metrics.scrollPoint.y += deltaScroll; |
| - } |
| + // We are no longer scroll-up-able so the scroll point drops to zero. |
| + metrics.scrollPoint.y = 0.0; |
| } else { |
| // Couldn't -> Can't |
| // Check for menu height change by looking at the relative tops of the |
| @@ -635,7 +631,7 @@ |
| } |
| } |
| -- (void)adjustMetricsForMenuBottomChanges:(LayoutMetrics*)layoutMetrics { |
| +- (void)adjustMetricsForMenuTopChanges:(LayoutMetrics*)layoutMetrics { |
| LayoutMetrics& metrics(*layoutMetrics); |
| if (metrics.canScrollDown == metrics.couldScrollDown) { |
| if (!metrics.canScrollDown) { |
| @@ -733,9 +729,10 @@ |
| // http://crbug.com/35966 |
| NSRect buttonsOuterFrame = NSMakeRect( |
| 0, |
| - (height - bookmarks::kBookmarkButtonVerticalSpan), |
| + height - bookmarks::kBookmarkFolderButtonHeight - |
| + bookmarks::kBookmarkVerticalPadding, |
| bookmarks::kDefaultBookmarkWidth, |
| - bookmarks::kBookmarkButtonHeight); |
| + bookmarks::kBookmarkFolderButtonHeight); |
| // TODO(jrg): combine with addNodesToButtonList: code from |
| // bookmark_bar_controller.mm (but use y offset) |
| @@ -755,7 +752,7 @@ |
| frame:buttonsOuterFrame]; |
| [buttons_ addObject:button]; |
| [folderView_ addSubview:button]; |
| - buttonsOuterFrame.origin.y -= bookmarks::kBookmarkButtonVerticalSpan; |
| + buttonsOuterFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; |
| } |
| } |
| [self layOutWindowWithHeight:height]; |
| @@ -770,8 +767,10 @@ |
| // 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]]) { |
| - newWindowTopLeft.y = MAX(newWindowTopLeft.y, |
| - height + bookmarks::kScrollWindowVerticalMargin); |
| + CGFloat minimumY = NSMinY([[[self window] screen] visibleFrame]) + |
| + bookmarks::kScrollWindowVerticalMargin + |
| + height; |
| + newWindowTopLeft.y = MAX(newWindowTopLeft.y, minimumY); |
| } |
| NSWindow* window = [self window]; |
| NSRect windowFrame = NSMakeRect(newWindowTopLeft.x, |
| @@ -1449,7 +1448,7 @@ |
| // topmost button's frame (and there will always be one) offset upward in |
| // anticipation of insertion. |
| NSRect newButtonFrame = [[buttons_ objectAtIndex:0] frame]; |
| - newButtonFrame.origin.y += bookmarks::kBookmarkButtonVerticalSpan; |
| + newButtonFrame.origin.y += bookmarks::kBookmarkFolderButtonHeight; |
| // When adding a button to an empty folder we must remove the 'empty' |
| // placeholder button. This can be detected by checking for a parent |
| // child count of 1. |
| @@ -1473,7 +1472,7 @@ |
| // which is where the new button will be located. |
| newButtonFrame = [button frame]; |
| NSRect buttonFrame = [button frame]; |
| - buttonFrame.origin.y += bookmarks::kBookmarkButtonVerticalSpan; |
| + buttonFrame.origin.y += bookmarks::kBookmarkFolderButtonHeight; |
| [button setFrame:buttonFrame]; |
| } |
| [[button cell] mouseExited:nil]; // De-highlight. |
| @@ -1545,7 +1544,7 @@ |
| for (NSInteger i = fromIndex; i < toIndex; ++i) { |
| BookmarkButton* button = [buttons_ objectAtIndex:i]; |
| NSRect frame = [button frame]; |
| - frame.origin.y += bookmarks::kBookmarkButtonVerticalSpan; |
| + frame.origin.y += bookmarks::kBookmarkFolderButtonHeight; |
| [button setFrameOrigin:frame.origin]; |
| } |
| } else { |
| @@ -1554,7 +1553,7 @@ |
| for (NSInteger i = fromIndex - 1; i >= toIndex; --i) { |
| BookmarkButton* button = [buttons_ objectAtIndex:i]; |
| NSRect buttonFrame = [button frame]; |
| - buttonFrame.origin.y -= bookmarks::kBookmarkButtonVerticalSpan; |
| + buttonFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; |
| [button setFrameOrigin:buttonFrame.origin]; |
| } |
| } |
| @@ -1596,7 +1595,7 @@ |
| for (NSInteger i = 0; i < buttonIndex; ++i) { |
| BookmarkButton* button = [buttons_ objectAtIndex:i]; |
| NSRect buttonFrame = [button frame]; |
| - buttonFrame.origin.y -= bookmarks::kBookmarkButtonVerticalSpan; |
| + buttonFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; |
| [button setFrame:buttonFrame]; |
| } |
| // Search for and adjust submenus, if necessary. |
| @@ -1614,13 +1613,8 @@ |
| // If all nodes have been removed from this folder then add in the |
| // 'empty' placeholder button. |
| NSRect buttonFrame = |
| - NSMakeRect(0, |
| - bookmarks::kBookmarkButtonHeight - |
| - (bookmarks::kBookmarkBarHeight - |
| - bookmarks::kBookmarkVerticalPadding), |
| - bookmarks::kDefaultBookmarkWidth, |
| - (bookmarks::kBookmarkBarHeight - |
| - 2 * bookmarks::kBookmarkVerticalPadding)); |
| + NSMakeRect(0.0, 0.0, bookmarks::kDefaultBookmarkWidth, |
| + bookmarks::kBookmarkFolderButtonHeight); |
| BookmarkButton* button = [self makeButtonForNode:nil |
| frame:buttonFrame]; |
| [buttons_ addObject:button]; |