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

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

Issue 12079033: mac: Move bookmark hierarchy arrow from a pdf to a png. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove pdf Created 7 years, 10 months 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/app/theme/menu_hierarchy_arrow.pdf ('k') | chrome/chrome_dll_bundle.gypi » ('j') | 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"
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h"
12 #include "content/public/browser/user_metrics.h" 12 #include "content/public/browser/user_metrics.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "grit/ui_resources.h"
14 #include "ui/base/l10n/l10n_util_mac.h" 15 #include "ui/base/l10n/l10n_util_mac.h"
16 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/mac/nsimage_cache.h" 17 #include "ui/gfx/mac/nsimage_cache.h"
16 18
17 using content::UserMetricsAction; 19 using content::UserMetricsAction;
18 20
21 const int kHierarchyButtonXMargin = 4;
19 22
20 @interface BookmarkButtonCell(Private) 23 @interface BookmarkButtonCell(Private)
21 - (void)configureBookmarkButtonCell; 24 - (void)configureBookmarkButtonCell;
22 - (void)applyTextColor; 25 - (void)applyTextColor;
23 @end 26 @end
24 27
25 28
26 @implementation BookmarkButtonCell 29 @implementation BookmarkButtonCell
27 30
28 @synthesize startingChildIndex = startingChildIndex_; 31 @synthesize startingChildIndex = startingChildIndex_;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 219
217 // See comment above mouseEntered:, above. 220 // See comment above mouseEntered:, above.
218 - (void)mouseExited:(NSEvent*)event { 221 - (void)mouseExited:(NSEvent*)event {
219 [[self controlView] mouseExited:event]; 222 [[self controlView] mouseExited:event];
220 [super mouseExited:event]; 223 [super mouseExited:event];
221 } 224 }
222 225
223 - (void)setDrawFolderArrow:(BOOL)draw { 226 - (void)setDrawFolderArrow:(BOOL)draw {
224 drawFolderArrow_ = draw; 227 drawFolderArrow_ = draw;
225 if (draw && !arrowImage_) { 228 if (draw && !arrowImage_) {
229 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
226 arrowImage_.reset( 230 arrowImage_.reset(
227 [gfx::GetCachedImageWithName(@"menu_hierarchy_arrow.pdf") retain]); 231 [rb.GetImageNamed(IDR_MENU_HIERARCHY_ARROW).ToNSImage() retain]);
Robert Sesek 2013/01/29 17:55:17 drive-by: GetNativeImageNamed
Nico 2013/01/29 18:05:02 Done.
228 } 232 }
229 } 233 }
230 234
231 // Add extra size for the arrow so it doesn't overlap the text. 235 // Add extra size for the arrow so it doesn't overlap the text.
232 // Does not sanity check to be sure this is actually a folder node. 236 // Does not sanity check to be sure this is actually a folder node.
233 - (NSSize)cellSize { 237 - (NSSize)cellSize {
234 NSSize cellSize = [super cellSize]; 238 NSSize cellSize = [super cellSize];
235 if (drawFolderArrow_) { 239 if (drawFolderArrow_) {
236 cellSize.width += [arrowImage_ size].width; // plus margin? 240 cellSize.width += [arrowImage_ size].width + 2 * kHierarchyButtonXMargin;
237 } 241 }
238 return cellSize; 242 return cellSize;
239 } 243 }
240 244
241 // Override cell drawing to add a submenu arrow like a real menu. 245 // Override cell drawing to add a submenu arrow like a real menu.
242 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 246 - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
243 // First draw "everything else". 247 // First draw "everything else".
244 [super drawInteriorWithFrame:cellFrame inView:controlView]; 248 [super drawInteriorWithFrame:cellFrame inView:controlView];
245 249
246 // If asked to do so, and if a folder, draw the arrow. 250 // If asked to do so, and if a folder, draw the arrow.
247 if (!drawFolderArrow_) 251 if (!drawFolderArrow_)
248 return; 252 return;
249 BookmarkButton* button = static_cast<BookmarkButton*>([self controlView]); 253 BookmarkButton* button = static_cast<BookmarkButton*>([self controlView]);
250 DCHECK([button respondsToSelector:@selector(isFolder)]); 254 DCHECK([button respondsToSelector:@selector(isFolder)]);
251 if ([button isFolder]) { 255 if ([button isFolder]) {
252 NSRect imageRect = NSZeroRect; 256 NSRect imageRect = NSZeroRect;
253 imageRect.size = [arrowImage_ size]; 257 imageRect.size = [arrowImage_ size];
254 const CGFloat kArrowOffset = 1.0; // Required for proper centering. 258 const CGFloat kArrowOffset = 1.0; // Required for proper centering.
255 CGFloat dX = NSWidth(cellFrame) - NSWidth(imageRect); 259 CGFloat dX =
260 NSWidth(cellFrame) - NSWidth(imageRect) - kHierarchyButtonXMargin;
256 CGFloat dY = (NSHeight(cellFrame) / 2.0) - (NSHeight(imageRect) / 2.0) + 261 CGFloat dY = (NSHeight(cellFrame) / 2.0) - (NSHeight(imageRect) / 2.0) +
257 kArrowOffset; 262 kArrowOffset;
258 NSRect drawRect = NSOffsetRect(imageRect, dX, dY); 263 NSRect drawRect = NSOffsetRect(imageRect, dX, dY);
259 [arrowImage_ drawInRect:drawRect 264 [arrowImage_ drawInRect:drawRect
260 fromRect:imageRect 265 fromRect:imageRect
261 operation:NSCompositeSourceOver 266 operation:NSCompositeSourceOver
262 fraction:[self isEnabled] ? 1.0 : 0.5 267 fraction:[self isEnabled] ? 1.0 : 0.5
263 respectFlipped:YES 268 respectFlipped:YES
264 hints:nil]; 269 hints:nil];
265 } 270 }
266 } 271 }
267 272
268 - (int)verticalTextOffset { 273 - (int)verticalTextOffset {
269 return 0; 274 return 0;
270 } 275 }
271 276
272 @end 277 @end
OLDNEW
« no previous file with comments | « chrome/app/theme/menu_hierarchy_arrow.pdf ('k') | chrome/chrome_dll_bundle.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698