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

Side by Side Diff: chrome/browser/cocoa/gradient_button_cell.mm

Issue 348018: Foo. (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/cocoa/gradient_button_cell.h ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/scoped_nsobject.h" 5 #import "base/scoped_nsobject.h"
6 #include "chrome/browser/cocoa/gradient_button_cell.h" 6 #include "chrome/browser/cocoa/gradient_button_cell.h"
7 #import "third_party/GTM/AppKit/GTMTheme.h" 7 #import "third_party/GTM/AppKit/GTMTheme.h"
8 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" 8 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h"
9 9
10 @interface GradientButtonCell (Private) 10 @interface GradientButtonCell (Private)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 fromRect:imageRect 336 fromRect:imageRect
337 operation:NSCompositeSourceOver 337 operation:NSCompositeSourceOver
338 fraction:[self isEnabled] ? 1.0 : 0.5]; 338 fraction:[self isEnabled] ? 1.0 : 0.5];
339 if (isTemplate) { 339 if (isTemplate) {
340 if (color) { 340 if (color) {
341 [color set]; 341 [color set];
342 NSRectFillUsingOperation(cellFrame, NSCompositeSourceAtop); 342 NSRectFillUsingOperation(cellFrame, NSCompositeSourceAtop);
343 } 343 }
344 } 344 }
345 345
346 if ([self title]) {
347 NSColor* textColor = [theme
348 textColorForStyle:GTMThemeStyleBookmarksBarButton
349 state:GTMThemeStateActiveWindow];
350 NSColor* hoverTextColor = [theme
351 textColorForStyle:GTMThemeStyleToolBar
352 state:GTMThemeStateActiveWindow];
353
354 NSColor* color = isMouseInside_
355 ? hoverTextColor : textColor;
356
357 NSDictionary* titleAttributes = [NSDictionary
358 dictionaryWithObjectsAndKeys:
359 color, NSForegroundColorAttributeName,
360 [self font], NSFontAttributeName,
361 nil];
362 NSPoint primaryPos = NSMakePoint(
363 cellFrame.origin.x + 4,
364 cellFrame.origin.y);
365
366 [[self title] drawAtPoint:primaryPos withAttributes:titleAttributes];
367 }
368
346 CGContextEndTransparencyLayer(context); 369 CGContextEndTransparencyLayer(context);
347 [NSGraphicsContext restoreGraphicsState]; 370 [NSGraphicsContext restoreGraphicsState];
348 } else { 371 } else {
349 [self drawUnderlayImageWithFrame:cellFrame inView:controlView]; 372 [self drawUnderlayImageWithFrame:cellFrame inView:controlView];
350 373
351 // NSCell draws these uncentered for some reason, probably because of the 374 // NSCell draws these uncentered for some reason, probably because of the
352 // of control in the xib 375 // of control in the xib
353 [super drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) 376 [super drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1)
354 inView:controlView]; 377 inView:controlView];
355 } 378 }
356 } 379 }
357 380
358 - (void)drawUnderlayImageWithFrame:(NSRect)cellFrame 381 - (void)drawUnderlayImageWithFrame:(NSRect)cellFrame
359 inView:(NSView*)controlView { 382 inView:(NSView*)controlView {
360 if (underlayImage_) { 383 if (underlayImage_) {
361 NSRect imageRect = NSZeroRect; 384 NSRect imageRect = NSZeroRect;
362 imageRect.size = [underlayImage_ size]; 385 imageRect.size = [underlayImage_ size];
363 [underlayImage_ setFlipped:[controlView isFlipped]]; 386 [underlayImage_ setFlipped:[controlView isFlipped]];
364 [underlayImage_ drawInRect:[self imageRectForBounds:cellFrame] 387 [underlayImage_ drawInRect:[self imageRectForBounds:cellFrame]
365 fromRect:imageRect 388 fromRect:imageRect
366 operation:NSCompositeSourceOver 389 operation:NSCompositeSourceOver
367 fraction:[self isEnabled] ? 1.0 : 0.5]; 390 fraction:[self isEnabled] ? 1.0 : 0.5];
368 } 391 }
369 } 392 }
370 393
371 @end 394 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/gradient_button_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698