OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bundle_locations.h" | 7 #include "base/mac/bundle_locations.h" |
8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" | 10 #import "chrome/browser/bookmarks/bookmark_model_factory.h" |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
753 metrics.canScrollDown != metrics.couldScrollDown || | 753 metrics.canScrollDown != metrics.couldScrollDown || |
754 metrics.scrollDelta != 0.0) { | 754 metrics.scrollDelta != 0.0) { |
755 if (metrics.canScrollUp || metrics.canScrollDown) | 755 if (metrics.canScrollUp || metrics.canScrollDown) |
756 [self addOrUpdateScrollTracking]; | 756 [self addOrUpdateScrollTracking]; |
757 else | 757 else |
758 [self removeScrollTracking]; | 758 [self removeScrollTracking]; |
759 } | 759 } |
760 } | 760 } |
761 | 761 |
762 - (void)adjustWindowForButtonCount:(NSUInteger)buttonCount { | 762 - (void)adjustWindowForButtonCount:(NSUInteger)buttonCount { |
763 if (buttonCount == 0) { | |
Alexei Svitkine (slow)
2014/08/19 17:01:38
Please add a comment explaining this logic.
Gaja
2014/08/20 05:51:32
Moved this part of code into -removeButton functio
| |
764 [self adjustWindowLeft:0 size:NSMakeSize(0, 0) scrollingBy:0.0]; | |
Alexei Svitkine (slow)
2014/08/19 17:01:38
Why make the window 0 size instead of calling -clo
Gaja
2014/08/20 05:51:32
I do think so. Changes in patch set 2, please revi
| |
765 return; | |
766 } | |
763 NSRect folderFrame = [folderView_ frame]; | 767 NSRect folderFrame = [folderView_ frame]; |
764 CGFloat newMenuHeight = | 768 CGFloat newMenuHeight = |
765 (CGFloat)[self menuHeightForButtonCount:[buttons_ count]]; | 769 (CGFloat)[self menuHeightForButtonCount:buttonCount]; |
766 CGFloat deltaMenuHeight = newMenuHeight - NSHeight(folderFrame); | 770 CGFloat deltaMenuHeight = newMenuHeight - NSHeight(folderFrame); |
767 // If the height has changed then also change the origin, and adjust the | 771 // If the height has changed then also change the origin, and adjust the |
768 // scroll (if scrolling). | 772 // scroll (if scrolling). |
769 if ([self canScrollUp]) { | 773 if ([self canScrollUp]) { |
770 NSPoint scrollPoint = [scrollView_ documentVisibleRect].origin; | 774 NSPoint scrollPoint = [scrollView_ documentVisibleRect].origin; |
771 scrollPoint.y += deltaMenuHeight; | 775 scrollPoint.y += deltaMenuHeight; |
772 [[scrollView_ documentView] scrollPoint:scrollPoint]; | 776 [[scrollView_ documentView] scrollPoint:scrollPoint]; |
773 } | 777 } |
774 folderFrame.size.height += deltaMenuHeight; | 778 folderFrame.size.height += deltaMenuHeight; |
775 [folderView_ setFrameSize:folderFrame.size]; | 779 [folderView_ setFrameSize:folderFrame.size]; |
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1929 // Search for and adjust submenus, if necessary. | 1933 // Search for and adjust submenus, if necessary. |
1930 NSInteger buttonCount = [buttons_ count]; | 1934 NSInteger buttonCount = [buttons_ count]; |
1931 if (buttonCount) { | 1935 if (buttonCount) { |
1932 BookmarkButton* subButton = [folderController_ parentButton]; | 1936 BookmarkButton* subButton = [folderController_ parentButton]; |
1933 for (NSButton* aButton in buttons_.get()) { | 1937 for (NSButton* aButton in buttons_.get()) { |
1934 // If this button is showing its menu then we need to move the menu, too. | 1938 // If this button is showing its menu then we need to move the menu, too. |
1935 if (aButton == subButton) | 1939 if (aButton == subButton) |
1936 [folderController_ | 1940 [folderController_ |
1937 offsetFolderMenuWindow:NSMakeSize(0.0, chrome::kBookmarkBarHeight)]; | 1941 offsetFolderMenuWindow:NSMakeSize(0.0, chrome::kBookmarkBarHeight)]; |
1938 } | 1942 } |
1939 } else { | 1943 } else if (parentButton_ != [barController_ otherBookmarksButton]) { |
1940 // If all nodes have been removed from this folder then add in the | 1944 // If all nodes have been removed from this folder then add in the |
1941 // 'empty' placeholder button. | 1945 // 'empty' placeholder button except for "Other bookmarks" folder |
1946 // as we are going to hide it. | |
1942 NSRect buttonFrame = | 1947 NSRect buttonFrame = |
1943 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); | 1948 GetFirstButtonFrameForHeight([self menuHeightForButtonCount:1]); |
1944 BookmarkButton* button = [self makeButtonForNode:nil | 1949 BookmarkButton* button = [self makeButtonForNode:nil |
1945 frame:buttonFrame]; | 1950 frame:buttonFrame]; |
1946 [buttons_ addObject:button]; | 1951 [buttons_ addObject:button]; |
1947 [folderView_ addSubview:button]; | 1952 [folderView_ addSubview:button]; |
1948 buttonCount = 1; | 1953 buttonCount = 1; |
1949 } | 1954 } |
1950 | 1955 |
1951 [self adjustWindowForButtonCount:buttonCount]; | 1956 [self adjustWindowForButtonCount:buttonCount]; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1992 | 1997 |
1993 - (void)setIgnoreAnimations:(BOOL)ignore { | 1998 - (void)setIgnoreAnimations:(BOOL)ignore { |
1994 ignoreAnimations_ = ignore; | 1999 ignoreAnimations_ = ignore; |
1995 } | 2000 } |
1996 | 2001 |
1997 - (BookmarkButton*)buttonThatMouseIsIn { | 2002 - (BookmarkButton*)buttonThatMouseIsIn { |
1998 return buttonThatMouseIsIn_; | 2003 return buttonThatMouseIsIn_; |
1999 } | 2004 } |
2000 | 2005 |
2001 @end // BookmarkBarFolderController | 2006 @end // BookmarkBarFolderController |
OLD | NEW |