| 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 29 matching lines...) Expand all Loading... |
| 40 }; // namespace | 40 }; // namespace |
| 41 | 41 |
| 42 @interface OffTheSideButtonCell : BookmarkButtonCell | 42 @interface OffTheSideButtonCell : BookmarkButtonCell |
| 43 @end | 43 @end |
| 44 @implementation OffTheSideButtonCell | 44 @implementation OffTheSideButtonCell |
| 45 | 45 |
| 46 - (BOOL)isOffTheSideButtonCell { | 46 - (BOOL)isOffTheSideButtonCell { |
| 47 return YES; | 47 return YES; |
| 48 } | 48 } |
| 49 | 49 |
| 50 - (NSString*)accessibilityTitle { |
| 51 return l10n_util::GetNSString(IDS_ACCNAME_BOOKMARKS_CHEVRON); |
| 52 } |
| 53 |
| 54 - (NSRect)imageRectForBounds:(NSRect)theRect { |
| 55 NSRect imageRect = [super imageRectForBounds:theRect]; |
| 56 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 57 // Make sure the chevron icon stays centered. Normally a bookmark bar item |
| 58 // with no label has its icon placed at a fixed x-position. |
| 59 CGFloat totalWidth = NSMaxX(theRect); |
| 60 imageRect.origin.x = (totalWidth - [self image].size.width) / 2; |
| 61 } |
| 62 return imageRect; |
| 63 } |
| 64 |
| 50 @end | 65 @end |
| 51 | 66 |
| 52 @interface BookmarkButtonCell(Private) | 67 @interface BookmarkButtonCell(Private) |
| 53 // Returns YES if the cell is the offTheSide button cell. | 68 // Returns YES if the cell is the offTheSide button cell. |
| 54 - (BOOL)isOffTheSideButtonCell; | 69 - (BOOL)isOffTheSideButtonCell; |
| 55 - (void)configureBookmarkButtonCell; | 70 - (void)configureBookmarkButtonCell; |
| 56 - (void)applyTextColor; | 71 - (void)applyTextColor; |
| 57 // Returns the title the button cell displays. Note that a button cell can | 72 // Returns the title the button cell displays. Note that a button cell can |
| 58 // have a title string assigned but it won't be visible if its image position | 73 // have a title string assigned but it won't be visible if its image position |
| 59 // is NSImageOnly. | 74 // is NSImageOnly. |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 const CGFloat kLineWidth = [controlView cr_lineWidth]; | 458 const CGFloat kLineWidth = [controlView cr_lineWidth]; |
| 444 if ([self isMaterialDesignButtonType] && ![self isFolderButtonCell] && | 459 if ([self isMaterialDesignButtonType] && ![self isFolderButtonCell] && |
| 445 kLineWidth < 1) { | 460 kLineWidth < 1) { |
| 446 return -kLineWidth; | 461 return -kLineWidth; |
| 447 } | 462 } |
| 448 return 0.0; | 463 return 0.0; |
| 449 } | 464 } |
| 450 | 465 |
| 451 | 466 |
| 452 @end | 467 @end |
| OLD | NEW |