| Index: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
|
| diff --git a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
|
| index 21db378bdfaed2e6de368580ed485aa7ebf46649..392c7ca623d000ad1e3d3cd9f8c08cbf94c51ff2 100644
|
| --- a/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
|
| +++ b/chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm
|
| @@ -13,6 +13,7 @@
|
| #include "content/browser/user_metrics.h"
|
| #include "grit/generated_resources.h"
|
| #include "ui/base/l10n/l10n_util_mac.h"
|
| +#include "ui/gfx/mac/nsimage_cache.h"
|
|
|
|
|
| @interface BookmarkButtonCell(Private)
|
| @@ -23,6 +24,9 @@
|
|
|
| @implementation BookmarkButtonCell
|
|
|
| +@synthesize startingChildIndex = startingChildIndex_;
|
| +@synthesize drawFolderArrow = drawFolderArrow_;
|
| +
|
| + (id)buttonCellForNode:(const BookmarkNode*)node
|
| contextMenu:(NSMenu*)contextMenu
|
| cellText:(NSString*)cellText
|
| @@ -69,6 +73,10 @@
|
| [self configureBookmarkButtonCell];
|
| }
|
|
|
| +- (BOOL)isFolderButtonCell {
|
| + return NO;
|
| +}
|
| +
|
| // Perform all normal init routines specific to the BookmarkButtonCell.
|
| - (void)configureBookmarkButtonCell {
|
| [self setButtonType:NSMomentaryPushInButton];
|
| @@ -200,4 +208,48 @@
|
| [super mouseExited:event];
|
| }
|
|
|
| +- (void)setDrawFolderArrow:(BOOL)draw {
|
| + drawFolderArrow_ = draw;
|
| + if (draw && !arrowImage_) {
|
| + arrowImage_.reset(
|
| + [gfx::GetCachedImageWithName(@"menu_hierarchy_arrow.pdf") retain]);
|
| + }
|
| +}
|
| +
|
| +// Add extra size for the arrow so it doesn't overlap the text.
|
| +// Does not sanity check to be sure this is actually a folder node.
|
| +- (NSSize)cellSize {
|
| + NSSize cellSize = [super cellSize];
|
| + if (drawFolderArrow_) {
|
| + cellSize.width += [arrowImage_ size].width; // plus margin?
|
| + }
|
| + return cellSize;
|
| +}
|
| +
|
| +// Override cell drawing to add a submenu arrow like a real menu.
|
| +- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
|
| + // First draw "everything else".
|
| + [super drawInteriorWithFrame:cellFrame inView:controlView];
|
| +
|
| + // If asked to do so, and if a folder, draw the arrow.
|
| + if (!drawFolderArrow_)
|
| + return;
|
| + BookmarkButton* button = static_cast<BookmarkButton*>([self controlView]);
|
| + DCHECK([button respondsToSelector:@selector(isFolder)]);
|
| + if ([button isFolder]) {
|
| + NSRect imageRect = NSZeroRect;
|
| + imageRect.size = [arrowImage_ size];
|
| + const CGFloat kArrowOffset = 1.0; // Required for proper centering.
|
| + CGFloat dX = NSWidth(cellFrame) - NSWidth(imageRect);
|
| + CGFloat dY = (NSHeight(cellFrame) / 2.0) - (NSHeight(imageRect) / 2.0) +
|
| + kArrowOffset;
|
| + NSRect drawRect = NSOffsetRect(imageRect, dX, dY);
|
| + [arrowImage_ drawInRect:drawRect
|
| + fromRect:imageRect
|
| + operation:NSCompositeSourceOver
|
| + fraction:[self isEnabled] ? 1.0 : 0.5
|
| + neverFlipped:YES];
|
| + }
|
| +}
|
| +
|
| @end
|
|
|