| 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_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #import "base/mac/bundle_locations.h" | 9 #import "base/mac/bundle_locations.h" |
| 10 #import "base/mac/foundation_util.h" | 10 #import "base/mac/foundation_util.h" |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 | 1089 |
| 1090 // (Private) | 1090 // (Private) |
| 1091 - (BOOL)doBookmarkBarAnimation { | 1091 - (BOOL)doBookmarkBarAnimation { |
| 1092 BookmarkBarToolbarView* view = [self controlledView]; | 1092 BookmarkBarToolbarView* view = [self controlledView]; |
| 1093 if ([self isAnimatingFromState:BookmarkBar::HIDDEN | 1093 if ([self isAnimatingFromState:BookmarkBar::HIDDEN |
| 1094 toState:BookmarkBar::SHOW]) { | 1094 toState:BookmarkBar::SHOW]) { |
| 1095 [view setShowsDivider:YES]; | 1095 [view setShowsDivider:YES]; |
| 1096 [view setHidden:NO]; | 1096 [view setHidden:NO]; |
| 1097 // Height takes into account the extra height we have since the toolbar | 1097 // Height takes into account the extra height we have since the toolbar |
| 1098 // only compresses when we're done. | 1098 // only compresses when we're done. |
| 1099 [view animateToNewHeight:(chrome::kBookmarkBarHeight - | 1099 [view animateToNewHeight:(chrome::kMinimumBookmarkBarHeight - |
| 1100 bookmarks::kBookmarkBarOverlap) | 1100 bookmarks::kBookmarkBarOverlap) |
| 1101 duration:kBookmarkBarAnimationDuration]; | 1101 duration:kBookmarkBarAnimationDuration]; |
| 1102 } else if ([self isAnimatingFromState:BookmarkBar::SHOW | 1102 } else if ([self isAnimatingFromState:BookmarkBar::SHOW |
| 1103 toState:BookmarkBar::HIDDEN]) { | 1103 toState:BookmarkBar::HIDDEN]) { |
| 1104 [view setShowsDivider:YES]; | 1104 [view setShowsDivider:YES]; |
| 1105 [view setHidden:NO]; | 1105 [view setHidden:NO]; |
| 1106 [view animateToNewHeight:0 | 1106 [view animateToNewHeight:0 |
| 1107 duration:kBookmarkBarAnimationDuration]; | 1107 duration:kBookmarkBarAnimationDuration]; |
| 1108 } else if ([self isAnimatingFromState:BookmarkBar::SHOW | 1108 } else if ([self isAnimatingFromState:BookmarkBar::SHOW |
| 1109 toState:BookmarkBar::DETACHED]) { | 1109 toState:BookmarkBar::DETACHED]) { |
| 1110 [view setShowsDivider:YES]; | 1110 [view setShowsDivider:YES]; |
| 1111 [view setHidden:NO]; | 1111 [view setHidden:NO]; |
| 1112 [view animateToNewHeight:chrome::kNTPBookmarkBarHeight | 1112 [view animateToNewHeight:chrome::kNTPMinimumBookmarkBarHeight |
| 1113 duration:kBookmarkBarAnimationDuration]; | 1113 duration:kBookmarkBarAnimationDuration]; |
| 1114 } else if ([self isAnimatingFromState:BookmarkBar::DETACHED | 1114 } else if ([self isAnimatingFromState:BookmarkBar::DETACHED |
| 1115 toState:BookmarkBar::SHOW]) { | 1115 toState:BookmarkBar::SHOW]) { |
| 1116 [view setShowsDivider:YES]; | 1116 [view setShowsDivider:YES]; |
| 1117 [view setHidden:NO]; | 1117 [view setHidden:NO]; |
| 1118 // Height takes into account the extra height we have since the toolbar | 1118 // Height takes into account the extra height we have since the toolbar |
| 1119 // only compresses when we're done. | 1119 // only compresses when we're done. |
| 1120 [view animateToNewHeight:(chrome::kBookmarkBarHeight - | 1120 [view animateToNewHeight:(chrome::kMinimumBookmarkBarHeight - |
| 1121 bookmarks::kBookmarkBarOverlap) | 1121 bookmarks::kBookmarkBarOverlap) |
| 1122 duration:kBookmarkBarAnimationDuration]; | 1122 duration:kBookmarkBarAnimationDuration]; |
| 1123 } else { | 1123 } else { |
| 1124 // Oops! An animation we don't know how to handle. | 1124 // Oops! An animation we don't know how to handle. |
| 1125 return NO; | 1125 return NO; |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 return YES; | 1128 return YES; |
| 1129 } | 1129 } |
| 1130 | 1130 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1159 // toolbar by 1pt. In this case the bookmark bar needs to add 1pt of space | 1159 // toolbar by 1pt. In this case the bookmark bar needs to add 1pt of space |
| 1160 // above the bookmark icons in order to maintain the proper distance from | 1160 // above the bookmark icons in order to maintain the proper distance from |
| 1161 // toolbar items. See https://crbug.com/326245 . | 1161 // toolbar items. See https://crbug.com/326245 . |
| 1162 lineWidth = [[self view] cr_lineWidth]; | 1162 lineWidth = [[self view] cr_lineWidth]; |
| 1163 isRetina = (lineWidth < 1); | 1163 isRetina = (lineWidth < 1); |
| 1164 | 1164 |
| 1165 // Only adjust the height if Retina and not Material Design. | 1165 // Only adjust the height if Retina and not Material Design. |
| 1166 reduceHeight = | 1166 reduceHeight = |
| 1167 isRetina && !ui::MaterialDesignController::IsModeMaterial(); | 1167 isRetina && !ui::MaterialDesignController::IsModeMaterial(); |
| 1168 | 1168 |
| 1169 return reduceHeight ? chrome::kBookmarkBarHeight + 1 | 1169 return reduceHeight ? chrome::kMinimumBookmarkBarHeight + 1 |
| 1170 : chrome::kBookmarkBarHeight; | 1170 : chrome::kMinimumBookmarkBarHeight; |
| 1171 case BookmarkBar::DETACHED: | 1171 case BookmarkBar::DETACHED: |
| 1172 return chrome::kNTPBookmarkBarHeight; | 1172 return chrome::kNTPMinimumBookmarkBarHeight; |
| 1173 case BookmarkBar::HIDDEN: | 1173 case BookmarkBar::HIDDEN: |
| 1174 return 0; | 1174 return 0; |
| 1175 } | 1175 } |
| 1176 } | 1176 } |
| 1177 | 1177 |
| 1178 // Recursively add the given bookmark node and all its children to | 1178 // Recursively add the given bookmark node and all its children to |
| 1179 // menu, one menu item per node. | 1179 // menu, one menu item per node. |
| 1180 - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu { | 1180 - (void)addNode:(const BookmarkNode*)child toMenu:(NSMenu*)menu { |
| 1181 NSString* title = [BookmarkMenuCocoaController menuTitleForNode:child]; | 1181 NSString* title = [BookmarkMenuCocoaController menuTitleForNode:child]; |
| 1182 NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title | 1182 NSMenuItem* item = [[[NSMenuItem alloc] initWithTitle:title |
| (...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3090 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 3090 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 3091 (const BookmarkNode*)node { | 3091 (const BookmarkNode*)node { |
| 3092 // See if it's in the bar, then if it is in the hierarchy of visible | 3092 // See if it's in the bar, then if it is in the hierarchy of visible |
| 3093 // folder menus. | 3093 // folder menus. |
| 3094 if (bookmarkModel_->bookmark_bar_node() == node) | 3094 if (bookmarkModel_->bookmark_bar_node() == node) |
| 3095 return self; | 3095 return self; |
| 3096 return [folderController_ controllerForNode:node]; | 3096 return [folderController_ controllerForNode:node]; |
| 3097 } | 3097 } |
| 3098 | 3098 |
| 3099 @end | 3099 @end |
| OLD | NEW |