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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.mm

Issue 8789010: Fix up bookmarks bar folders to always be scrolled to the top when they are opened. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments, style cleanup Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
6 6
7 #include "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/browser/bookmarks/bookmark_model.h" 9 #include "chrome/browser/bookmarks/bookmark_model.h"
10 #include "chrome/browser/bookmarks/bookmark_utils.h" 10 #include "chrome/browser/bookmarks/bookmark_utils.h"
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 [self layOutWindowWithHeight:height]; 780 [self layOutWindowWithHeight:height];
781 } 781 }
782 782
783 - (void)layOutWindowWithHeight:(CGFloat)height { 783 - (void)layOutWindowWithHeight:(CGFloat)height {
784 // Lay out the window by adjusting all button widths to be consistent, then 784 // Lay out the window by adjusting all button widths to be consistent, then
785 // base the window width on this ideal button width. 785 // base the window width on this ideal button width.
786 CGFloat buttonWidth = [self adjustButtonWidths]; 786 CGFloat buttonWidth = [self adjustButtonWidths];
787 CGFloat windowWidth = buttonWidth + padding_; 787 CGFloat windowWidth = buttonWidth + padding_;
788 NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth 788 NSPoint newWindowTopLeft = [self windowTopLeftForWidth:windowWidth
789 height:height]; 789 height:height];
790
790 // Make sure as much of a submenu is exposed (which otherwise would be a 791 // Make sure as much of a submenu is exposed (which otherwise would be a
791 // problem if the parent button is close to the bottom of the screen). 792 // problem if the parent button is close to the bottom of the screen).
792 if ([parentController_ isKindOfClass:[self class]]) { 793 if ([parentController_ isKindOfClass:[self class]]) {
793 CGFloat minimumY = NSMinY([[[self window] screen] visibleFrame]) + 794 CGFloat minimumY = NSMinY([[[self window] screen] visibleFrame]) +
794 bookmarks::kScrollWindowVerticalMargin + 795 bookmarks::kScrollWindowVerticalMargin +
795 height; 796 height;
796 newWindowTopLeft.y = MAX(newWindowTopLeft.y, minimumY); 797 newWindowTopLeft.y = MAX(newWindowTopLeft.y, minimumY);
797 } 798 }
799
798 NSWindow* window = [self window]; 800 NSWindow* window = [self window];
799 NSRect windowFrame = NSMakeRect(newWindowTopLeft.x, 801 NSRect windowFrame = NSMakeRect(newWindowTopLeft.x,
800 newWindowTopLeft.y - height, 802 newWindowTopLeft.y - height,
801 windowWidth, height); 803 windowWidth, height);
802 [window setFrame:windowFrame display:NO]; 804 [window setFrame:windowFrame display:NO];
805
803 NSRect folderFrame = NSMakeRect(0, 0, windowWidth, height); 806 NSRect folderFrame = NSMakeRect(0, 0, windowWidth, height);
804 [folderView_ setFrame:folderFrame]; 807 [folderView_ setFrame:folderFrame];
808
809 // For some reason, when opening a "large" bookmark folder (containing 12 or
810 // more items) using the keyboard, the scroll view seems to want to be
811 // offset by default: [ http://crbug.com/101099 ]. Explicitly reseting the
812 // scroll position here is a bit hacky, but it does seem to work.
813 [[scrollView_ contentView] scrollToPoint:NSMakePoint(0, 0)];
814
805 NSSize newSize = NSMakeSize(windowWidth, 0.0); 815 NSSize newSize = NSMakeSize(windowWidth, 0.0);
806 [self adjustWindowLeft:newWindowTopLeft.x size:newSize scrollingBy:0.0]; 816 [self adjustWindowLeft:newWindowTopLeft.x size:newSize scrollingBy:0.0];
807 [self configureWindowLevel]; 817 [self configureWindowLevel];
818
808 [window display]; 819 [window display];
809 } 820 }
810 821
811 // TODO(mrossetti): See if the following can be moved into view's viewWillDraw:. 822 // TODO(mrossetti): See if the following can be moved into view's viewWillDraw:.
812 - (CGFloat)adjustButtonWidths { 823 - (CGFloat)adjustButtonWidths {
813 CGFloat width = bookmarks::kBookmarkMenuButtonMinimumWidth; 824 CGFloat width = bookmarks::kBookmarkMenuButtonMinimumWidth;
814 // Use the cell's size as the base for determining the desired width of the 825 // Use the cell's size as the base for determining the desired width of the
815 // button rather than the button's current width. -[cell cellSize] always 826 // button rather than the button's current width. -[cell cellSize] always
816 // returns the 'optimum' size of the cell based on the cell's contents even 827 // returns the 'optimum' size of the cell based on the cell's contents even
817 // if it's less than the current button size. Relying on the button size 828 // if it's less than the current button size. Relying on the button size
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 1997
1987 - (void)setIgnoreAnimations:(BOOL)ignore { 1998 - (void)setIgnoreAnimations:(BOOL)ignore {
1988 ignoreAnimations_ = ignore; 1999 ignoreAnimations_ = ignore;
1989 } 2000 }
1990 2001
1991 - (BookmarkButton*)buttonThatMouseIsIn { 2002 - (BookmarkButton*)buttonThatMouseIsIn {
1992 return buttonThatMouseIsIn_; 2003 return buttonThatMouseIsIn_;
1993 } 2004 }
1994 2005
1995 @end // BookmarkBarFolderController 2006 @end // BookmarkBarFolderController
OLDNEW
« 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