Chromium Code Reviews| 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 "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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1380 [buttons_ objectAtIndex:static_cast<NSUInteger>(index)]; | 1380 [buttons_ objectAtIndex:static_cast<NSUInteger>(index)]; |
| 1381 if ([button showsBorderOnlyWhileMouseInside]) { | 1381 if ([button showsBorderOnlyWhileMouseInside]) { |
| 1382 [button setShowsBorderOnlyWhileMouseInside:NO]; | 1382 [button setShowsBorderOnlyWhileMouseInside:NO]; |
| 1383 [button setShowsBorderOnlyWhileMouseInside:YES]; | 1383 [button setShowsBorderOnlyWhileMouseInside:YES]; |
| 1384 } | 1384 } |
| 1385 } | 1385 } |
| 1386 } | 1386 } |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 | 1389 |
| 1390 // Adjust the horizontal width and the visibility of the "For quick access" | 1390 // Adjust the horizontal width, x position and the visibility of the "For quick |
| 1391 // text field and "Import bookmarks..." button based on the current width | 1391 // access" text field and "Import bookmarks..." button based on the current |
| 1392 // of the containing |buttonView_| (which is affected by window width). | 1392 // width of the containing |buttonView_| (which is affected by window width). |
| 1393 - (void)adjustNoItemContainerWidthsForMaxX:(CGFloat)maxViewX { | 1393 - (void)adjustNoItemContainerForMaxX:(CGFloat)maxViewX { |
| 1394 if (![[buttonView_ noItemContainer] isHidden]) { | 1394 if (![[buttonView_ noItemContainer] isHidden]) { |
| 1395 // Reset initial frames for the two items, then adjust as necessary. | 1395 // Reset initial frames for the two items, then adjust as necessary. |
| 1396 NSTextField* noItemTextfield = [buttonView_ noItemTextfield]; | 1396 NSTextField* noItemTextfield = [buttonView_ noItemTextfield]; |
| 1397 [noItemTextfield setFrame:originalNoItemsRect_]; | 1397 NSRect noItemsRect(originalNoItemsRect_); |
|
Alexei Svitkine (slow)
2013/04/15 21:05:29
Nit: use = instead.
beaudoin
2013/04/16 15:00:22
Done.
| |
| 1398 NSRect importBookmarksRect(originalImportBookmarksRect_); | |
|
Alexei Svitkine (slow)
2013/04/15 21:05:29
Nit: use = instead.
beaudoin
2013/04/16 15:00:22
Done.
| |
| 1399 if (![appsPageShortcutButton_ isHidden]) { | |
| 1400 noItemsRect.origin.x += NSWidth([appsPageShortcutButton_ frame]); | |
|
Alexei Svitkine (slow)
2013/04/15 21:05:29
Use a local variable for width.
beaudoin
2013/04/16 15:00:22
Done.
| |
| 1401 importBookmarksRect.origin.x += NSWidth([appsPageShortcutButton_ frame]); | |
| 1402 } | |
| 1403 [noItemTextfield setFrame:noItemsRect]; | |
| 1398 [noItemTextfield setHidden:NO]; | 1404 [noItemTextfield setHidden:NO]; |
| 1399 NSButton* importBookmarksButton = [buttonView_ importBookmarksButton]; | 1405 NSButton* importBookmarksButton = [buttonView_ importBookmarksButton]; |
| 1400 [importBookmarksButton setFrame:originalImportBookmarksRect_]; | 1406 [importBookmarksButton setFrame:importBookmarksRect]; |
| 1401 [importBookmarksButton setHidden:NO]; | 1407 [importBookmarksButton setHidden:NO]; |
| 1402 // Check each to see if they need to be shrunk or hidden. | 1408 // Check each to see if they need to be shrunk or hidden. |
| 1403 if ([self shrinkOrHideView:importBookmarksButton forMaxX:maxViewX]) | 1409 if ([self shrinkOrHideView:importBookmarksButton forMaxX:maxViewX]) |
| 1404 [self shrinkOrHideView:noItemTextfield forMaxX:maxViewX]; | 1410 [self shrinkOrHideView:noItemTextfield forMaxX:maxViewX]; |
| 1405 } | 1411 } |
| 1406 } | 1412 } |
| 1407 | 1413 |
| 1408 // Scans through all buttons from left to right, calculating from scratch where | 1414 // Scans through all buttons from left to right, calculating from scratch where |
| 1409 // they should be based on the preceding widths, until it finds the one | 1415 // they should be based on the preceding widths, until it finds the one |
| 1410 // requested. | 1416 // requested. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1511 break; | 1517 break; |
| 1512 } | 1518 } |
| 1513 ++displayedButtonCount_; | 1519 ++displayedButtonCount_; |
| 1514 [buttons_ addObject:button]; | 1520 [buttons_ addObject:button]; |
| 1515 [buttonView_ addSubview:button]; | 1521 [buttonView_ addSubview:button]; |
| 1516 } | 1522 } |
| 1517 | 1523 |
| 1518 // While we're here, adjust the horizontal width and the visibility | 1524 // While we're here, adjust the horizontal width and the visibility |
| 1519 // of the "For quick access" and "Import bookmarks..." text fields. | 1525 // of the "For quick access" and "Import bookmarks..." text fields. |
| 1520 if (![buttons_ count]) | 1526 if (![buttons_ count]) |
| 1521 [self adjustNoItemContainerWidthsForMaxX:maxViewX]; | 1527 [self adjustNoItemContainerForMaxX:maxViewX]; |
| 1522 } | 1528 } |
| 1523 | 1529 |
| 1524 #pragma mark Private Methods Exposed for Testing | 1530 #pragma mark Private Methods Exposed for Testing |
| 1525 | 1531 |
| 1526 - (BookmarkBarView*)buttonView { | 1532 - (BookmarkBarView*)buttonView { |
| 1527 return buttonView_; | 1533 return buttonView_; |
| 1528 } | 1534 } |
| 1529 | 1535 |
| 1530 - (NSMutableArray*)buttons { | 1536 - (NSMutableArray*)buttons { |
| 1531 return buttons_.get(); | 1537 return buttons_.get(); |
| (...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2662 - (id<BookmarkButtonControllerProtocol>)controllerForNode: | 2668 - (id<BookmarkButtonControllerProtocol>)controllerForNode: |
| 2663 (const BookmarkNode*)node { | 2669 (const BookmarkNode*)node { |
| 2664 // See if it's in the bar, then if it is in the hierarchy of visible | 2670 // See if it's in the bar, then if it is in the hierarchy of visible |
| 2665 // folder menus. | 2671 // folder menus. |
| 2666 if (bookmarkModel_->bookmark_bar_node() == node) | 2672 if (bookmarkModel_->bookmark_bar_node() == node) |
| 2667 return self; | 2673 return self; |
| 2668 return [folderController_ controllerForNode:node]; | 2674 return [folderController_ controllerForNode:node]; |
| 2669 } | 2675 } |
| 2670 | 2676 |
| 2671 @end | 2677 @end |
| OLD | NEW |