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

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

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/ui/cocoa/gradient_button_cell.h" 5 #include "chrome/browser/ui/cocoa/gradient_button_cell.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #import "base/memory/scoped_nsobject.h" 10 #import "base/mac/scoped_nsobject.h"
11 #import "chrome/browser/themes/theme_properties.h" 11 #import "chrome/browser/themes/theme_properties.h"
12 #import "chrome/browser/themes/theme_service.h" 12 #import "chrome/browser/themes/theme_service.h"
13 #import "chrome/browser/ui/cocoa/nsview_additions.h" 13 #import "chrome/browser/ui/cocoa/nsview_additions.h"
14 #import "chrome/browser/ui/cocoa/rect_path_utils.h"
14 #import "chrome/browser/ui/cocoa/themed_window.h" 15 #import "chrome/browser/ui/cocoa/themed_window.h"
15 #import "chrome/browser/ui/cocoa/rect_path_utils.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" 17 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h"
18 #import "ui/base/cocoa/nsgraphics_context_additions.h" 18 #import "ui/base/cocoa/nsgraphics_context_additions.h"
19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 19 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
20 20
21 @interface GradientButtonCell (Private) 21 @interface GradientButtonCell (Private)
22 - (void)sharedInit; 22 - (void)sharedInit;
23 23
24 // Get drawing parameters for a given cell frame in a given view. The inner 24 // Get drawing parameters for a given cell frame in a given view. The inner
25 // frame is the one required by |-drawInteriorWithFrame:inView:|. The inner and 25 // frame is the one required by |-drawInteriorWithFrame:inView:|. The inner and
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Draw the inner glow. 415 // Draw the inner glow.
416 if (hoverAlpha > 0) { 416 if (hoverAlpha > 0) {
417 [innerPath setLineWidth:2]; 417 [innerPath setLineWidth:2];
418 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2 * hoverAlpha] setStroke]; 418 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2 * hoverAlpha] setStroke];
419 [innerPath stroke]; 419 [innerPath stroke];
420 } 420 }
421 421
422 // Draw the top inner highlight. 422 // Draw the top inner highlight.
423 NSAffineTransform* highlightTransform = [NSAffineTransform transform]; 423 NSAffineTransform* highlightTransform = [NSAffineTransform transform];
424 [highlightTransform translateXBy:1 yBy:1]; 424 [highlightTransform translateXBy:1 yBy:1];
425 scoped_nsobject<NSBezierPath> highlightPath([innerPath copy]); 425 base::scoped_nsobject<NSBezierPath> highlightPath([innerPath copy]);
426 [highlightPath transformUsingAffineTransform:highlightTransform]; 426 [highlightPath transformUsingAffineTransform:highlightTransform];
427 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] setStroke]; 427 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.2] setStroke];
428 [highlightPath stroke]; 428 [highlightPath stroke];
429 429
430 // Draw the gradient inside. 430 // Draw the gradient inside.
431 [gradient drawInBezierPath:innerPath angle:90.0]; 431 [gradient drawInBezierPath:innerPath angle:90.0];
432 } 432 }
433 433
434 // Don't draw anything else for disabled flat buttons. 434 // Don't draw anything else for disabled flat buttons.
435 if (isFlatButton && ![self isEnabled]) 435 if (isFlatButton && ![self isEnabled])
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 CGContextRef context = 597 CGContextRef context =
598 (CGContextRef)([[NSGraphicsContext currentContext] graphicsPort]); 598 (CGContextRef)([[NSGraphicsContext currentContext] graphicsPort]);
599 599
600 ThemeService* themeProvider = static_cast<ThemeService*>( 600 ThemeService* themeProvider = static_cast<ThemeService*>(
601 [[controlView window] themeProvider]); 601 [[controlView window] themeProvider]);
602 NSColor* color = themeProvider ? 602 NSColor* color = themeProvider ?
603 themeProvider->GetNSColorTint(ThemeProperties::TINT_BUTTONS, true) : 603 themeProvider->GetNSColorTint(ThemeProperties::TINT_BUTTONS, true) :
604 [NSColor blackColor]; 604 [NSColor blackColor];
605 605
606 if (isTemplate && themeProvider && themeProvider->UsingDefaultTheme()) { 606 if (isTemplate && themeProvider && themeProvider->UsingDefaultTheme()) {
607 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); 607 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
608 [shadow.get() setShadowColor:themeProvider->GetNSColor( 608 [shadow.get() setShadowColor:themeProvider->GetNSColor(
609 ThemeProperties::COLOR_TOOLBAR_BEZEL, true)]; 609 ThemeProperties::COLOR_TOOLBAR_BEZEL, true)];
610 [shadow.get() setShadowOffset:NSMakeSize(0.0, -lineWidth)]; 610 [shadow.get() setShadowOffset:NSMakeSize(0.0, -lineWidth)];
611 [shadow setShadowBlurRadius:lineWidth]; 611 [shadow setShadowBlurRadius:lineWidth];
612 [shadow set]; 612 [shadow set];
613 } 613 }
614 614
615 CGContextBeginTransparencyLayer(context, 0); 615 CGContextBeginTransparencyLayer(context, 0);
616 NSRect imageRect = NSZeroRect; 616 NSRect imageRect = NSZeroRect;
617 imageRect.size = [[self image] size]; 617 imageRect.size = [[self image] size];
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 options:options 780 options:options
781 owner:self 781 owner:self
782 userInfo:nil]); 782 userInfo:nil]);
783 if (isMouseInside_ != mouseInView) { 783 if (isMouseInside_ != mouseInView) {
784 [self setMouseInside:mouseInView animate:NO]; 784 [self setMouseInside:mouseInView animate:NO];
785 [controlView setNeedsDisplay:YES]; 785 [controlView setNeedsDisplay:YES];
786 } 786 }
787 } 787 }
788 788
789 @end 789 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698