| OLD | NEW |
| 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_button_cell.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 9 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 9 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 @implementation OffTheSideButtonCell | 47 @implementation OffTheSideButtonCell |
| 48 | 48 |
| 49 - (BOOL)isOffTheSideButtonCell { | 49 - (BOOL)isOffTheSideButtonCell { |
| 50 return YES; | 50 return YES; |
| 51 } | 51 } |
| 52 | 52 |
| 53 - (NSString*)accessibilityTitle { | 53 - (NSString*)accessibilityTitle { |
| 54 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_CHEVRON); | 54 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_CHEVRON); |
| 55 } | 55 } |
| 56 | 56 |
| 57 - (NSRect)imageRectForBounds:(NSRect)theRect { |
| 58 NSRect imageRect = [super imageRectForBounds:theRect]; |
| 59 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 60 // Make sure the chevron icon stays centered. Normally a bookmark bar item |
| 61 // with no label has its icon placed at a fixed x-position. |
| 62 CGFloat totalWidth = NSMaxX(theRect); |
| 63 imageRect.origin.x = (totalWidth - [self image].size.width) / 2; |
| 64 } |
| 65 return imageRect; |
| 66 } |
| 67 |
| 57 @end | 68 @end |
| 58 | 69 |
| 59 @interface BookmarkButtonCell(Private) | 70 @interface BookmarkButtonCell(Private) |
| 60 // Returns YES if the cell is the offTheSide button cell. | 71 // Returns YES if the cell is the offTheSide button cell. |
| 61 - (BOOL)isOffTheSideButtonCell; | 72 - (BOOL)isOffTheSideButtonCell; |
| 62 - (void)configureBookmarkButtonCell; | 73 - (void)configureBookmarkButtonCell; |
| 63 - (void)applyTextColor; | 74 - (void)applyTextColor; |
| 64 // Returns the title the button cell displays. Note that a button cell can | 75 // Returns the title the button cell displays. Note that a button cell can |
| 65 // have a title string assigned but it won't be visible if its image position | 76 // have a title string assigned but it won't be visible if its image position |
| 66 // is NSImageOnly. | 77 // is NSImageOnly. |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 const CGFloat kLineWidth = [controlView cr_lineWidth]; | 461 const CGFloat kLineWidth = [controlView cr_lineWidth]; |
| 451 if ([self isMaterialDesignButtonType] && ![self isFolderButtonCell] && | 462 if ([self isMaterialDesignButtonType] && ![self isFolderButtonCell] && |
| 452 kLineWidth < 1) { | 463 kLineWidth < 1) { |
| 453 return -kLineWidth; | 464 return -kLineWidth; |
| 454 } | 465 } |
| 455 return 0.0; | 466 return 0.0; |
| 456 } | 467 } |
| 457 | 468 |
| 458 | 469 |
| 459 @end | 470 @end |
| OLD | NEW |