OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/bookmark_bar_controller.h" | 5 #import "chrome/browser/cocoa/bookmark_bar_controller.h" |
6 #include "app/l10n_util_mac.h" | 6 #include "app/l10n_util_mac.h" |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/mac_util.h" | 8 #include "base/mac_util.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "chrome/browser/bookmarks/bookmark_editor.h" | 10 #include "chrome/browser/bookmarks/bookmark_editor.h" |
(...skipping 2227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2238 toIndex -= buttonCount; | 2238 toIndex -= buttonCount; |
2239 [folderController_ moveButtonFromIndex:fromIndex toIndex:toIndex]; | 2239 [folderController_ moveButtonFromIndex:fromIndex toIndex:toIndex]; |
2240 } | 2240 } |
2241 } | 2241 } |
2242 } | 2242 } |
2243 | 2243 |
2244 - (void)removeButton:(NSInteger)buttonIndex animate:(BOOL)animate { | 2244 - (void)removeButton:(NSInteger)buttonIndex animate:(BOOL)animate { |
2245 if (buttonIndex < (NSInteger)[buttons_ count]) { | 2245 if (buttonIndex < (NSInteger)[buttons_ count]) { |
2246 // The button being removed is showing in the bar. | 2246 // The button being removed is showing in the bar. |
2247 BookmarkButton* oldButton = [buttons_ objectAtIndex:buttonIndex]; | 2247 BookmarkButton* oldButton = [buttons_ objectAtIndex:buttonIndex]; |
| 2248 if (oldButton == [folderController_ parentButton]) { |
| 2249 // If we are deleting a button whose folder is currently open, close it! |
| 2250 [self closeAllBookmarkFolders]; |
| 2251 } |
2248 NSRect poofFrame = [oldButton bounds]; | 2252 NSRect poofFrame = [oldButton bounds]; |
2249 NSPoint poofPoint = NSMakePoint(NSMidX(poofFrame), NSMidY(poofFrame)); | 2253 NSPoint poofPoint = NSMakePoint(NSMidX(poofFrame), NSMidY(poofFrame)); |
2250 poofPoint = [oldButton convertPoint:poofPoint toView:nil]; | 2254 poofPoint = [oldButton convertPoint:poofPoint toView:nil]; |
2251 poofPoint = [[oldButton window] convertBaseToScreen:poofPoint]; | 2255 poofPoint = [[oldButton window] convertBaseToScreen:poofPoint]; |
2252 NSRect oldFrame = [oldButton frame]; | 2256 NSRect oldFrame = [oldButton frame]; |
2253 [oldButton removeFromSuperview]; | 2257 [oldButton removeFromSuperview]; |
2254 if (animate) | 2258 if (animate) |
2255 NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault, poofPoint, | 2259 NSShowAnimationEffect(NSAnimationEffectDisappearingItemDefault, poofPoint, |
2256 NSZeroSize, nil, nil, nil); | 2260 NSZeroSize, nil, nil, nil); |
2257 CGFloat xOffset = NSWidth(oldFrame) + bookmarks::kBookmarkHorizontalPadding; | 2261 CGFloat xOffset = NSWidth(oldFrame) + bookmarks::kBookmarkHorizontalPadding; |
(...skipping 12 matching lines...) Expand all Loading... |
2270 [self reconfigureBookmarkBar]; | 2274 [self reconfigureBookmarkBar]; |
2271 } else if (folderController_) { | 2275 } else if (folderController_) { |
2272 // The button being removed is in the OTS (off-the-side) and the OTS | 2276 // The button being removed is in the OTS (off-the-side) and the OTS |
2273 // menu is showing so we need to remove the button. | 2277 // menu is showing so we need to remove the button. |
2274 NSInteger index = buttonIndex - displayedButtonCount_; | 2278 NSInteger index = buttonIndex - displayedButtonCount_; |
2275 [folderController_ removeButton:index animate:YES]; | 2279 [folderController_ removeButton:index animate:YES]; |
2276 } | 2280 } |
2277 } | 2281 } |
2278 | 2282 |
2279 @end | 2283 @end |
OLD | NEW |