Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.mm

Issue 8792001: A BookmarkBarFolderButtonCell should have the favicon aligned left when no title is provided (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: ASSERTS on pointers Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #import "chrome/browser/bookmarks/bookmark_model.h" 9 #import "chrome/browser/bookmarks/bookmark_model.h"
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 size.height += 4; 111 size.height += 4;
112 return size; 112 return size;
113 } 113 }
114 114
115 - (void)setBookmarkCellText:(NSString*)title 115 - (void)setBookmarkCellText:(NSString*)title
116 image:(NSImage*)image { 116 image:(NSImage*)image {
117 title = [title stringByReplacingOccurrencesOfString:@"\n" 117 title = [title stringByReplacingOccurrencesOfString:@"\n"
118 withString:@" "]; 118 withString:@" "];
119 title = [title stringByReplacingOccurrencesOfString:@"\r" 119 title = [title stringByReplacingOccurrencesOfString:@"\r"
120 withString:@" "]; 120 withString:@" "];
121 // If there is no title, squeeze things tight by displaying only the image; by 121
122 // default, Cocoa leaves extra space in an attempt to display an empty title.
123 if ([title length]) { 122 if ([title length]) {
124 [self setImagePosition:NSImageLeft]; 123 [self setImagePosition:NSImageLeft];
125 [self setTitle:title]; 124 [self setTitle:title];
125 } else if ([self isFolderButtonCell]) {
126 // Left-align icons for bookmarks within folders, regardless of whether
127 // there is a title.
128 [self setImagePosition:NSImageLeft];
126 } else { 129 } else {
130 // For bookmarks without a title that aren't visible directly in the
131 // bookmarks bar, squeeze things tighter by displaying only the image.
132 // By default, Cocoa leaves extra space in an attempt to display an
133 // empty title.
127 [self setImagePosition:NSImageOnly]; 134 [self setImagePosition:NSImageOnly];
128 } 135 }
129 136
130 if (image) 137 if (image)
131 [self setImage:image]; 138 [self setImage:image];
132 } 139 }
133 140
134 - (void)setBookmarkNode:(const BookmarkNode*)node { 141 - (void)setBookmarkNode:(const BookmarkNode*)node {
135 [self setRepresentedObject:[NSValue valueWithPointer:node]]; 142 [self setRepresentedObject:[NSValue valueWithPointer:node]];
136 } 143 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 NSRect drawRect = NSOffsetRect(imageRect, dX, dY); 253 NSRect drawRect = NSOffsetRect(imageRect, dX, dY);
247 [arrowImage_ drawInRect:drawRect 254 [arrowImage_ drawInRect:drawRect
248 fromRect:imageRect 255 fromRect:imageRect
249 operation:NSCompositeSourceOver 256 operation:NSCompositeSourceOver
250 fraction:[self isEnabled] ? 1.0 : 0.5 257 fraction:[self isEnabled] ? 1.0 : 0.5
251 neverFlipped:YES]; 258 neverFlipped:YES];
252 } 259 }
253 } 260 }
254 261
255 @end 262 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_button_cell_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698