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

Unified Diff: chrome/browser/ui/cocoa/new_tab_button.mm

Issue 2763093002: cocoa: draw new tab button with heavier stroke in high contrast (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/new_tab_button.mm
diff --git a/chrome/browser/ui/cocoa/new_tab_button.mm b/chrome/browser/ui/cocoa/new_tab_button.mm
index 3224e675066a5b43bfe63928b6a36589320d1415..97b3414f29a3251f6c5054192a43c633ff75c30c 100644
--- a/chrome/browser/ui/cocoa/new_tab_button.mm
+++ b/chrome/browser/ui/cocoa/new_tab_button.mm
@@ -32,6 +32,7 @@
const CGFloat k10PercentAlpha = 0.1;
const CGFloat k20PercentAlpha = 0.2;
const CGFloat k25PercentAlpha = 0.25;
+const CGFloat k100PercentAlpha = 1.0;
NSImage* GetMaskImageFromCell(NewTabButtonCell* aCell) {
return [aCell imageForState:image_button_cell::kDefaultState view:nil];
@@ -185,8 +186,17 @@ - (NSImage*)imageForState:(image_button_cell::ButtonState)state
// Returns a new tab button image bezier path with the specified line width.
+ (NSBezierPath*)newTabButtonBezierPathWithLineWidth:(CGFloat)lineWidth;
-// NSCustomImageRep custom drawing method that renders the new tab button image.
-+ (void)drawNewTabButtonImage:(NewTabButtonCustomImageRep*)imageRep;
+// Draws the new tab button image to |imageRep|, with either a normal stroke or
+// a heavy stroke for increased visibility.
++ (void)drawNewTabButtonImage:(NewTabButtonCustomImageRep*)imageRep
+ withHeavyStroke:(BOOL)heavyStroke;
+
+// NSCustomImageRep custom drawing method shims for normal and heavy strokes
+// respectively.
++ (void)drawNewTabButtonImageWithNormalStroke:
+ (NewTabButtonCustomImageRep*)imageRep;
++ (void)drawNewTabButtonImageWithHeavyStroke:
+ (NewTabButtonCustomImageRep*)imageRep;
// Returns a new tab button image filled with |fillColor|.
- (NSImage*)imageWithFillColor:(NSColor*)fillColor;
@@ -318,9 +328,13 @@ - (NSImage*)imageForState:(image_button_cell::ButtonState)state
NOTREACHED();
}
+ SEL drawSelector = @selector(drawNewTabButtonImageWithNormalStroke:);
+ if (theme && theme->ShouldIncreaseContrast())
+ drawSelector = @selector(drawNewTabButtonImageWithHeavyStroke:);
+
base::scoped_nsobject<NewTabButtonCustomImageRep> imageRep(
[[NewTabButtonCustomImageRep alloc]
- initWithDrawSelector:@selector(drawNewTabButtonImage:)
+ initWithDrawSelector:drawSelector
delegate:[NewTabButton class]]);
[imageRep setDestView:self];
[imageRep setFillColor:fillColor];
@@ -398,7 +412,8 @@ + (NSBezierPath*)newTabButtonBezierPathWithLineWidth:(CGFloat)lineWidth {
return bezierPath;
}
-+ (void)drawNewTabButtonImage:(NewTabButtonCustomImageRep*)imageRep {
++ (void)drawNewTabButtonImage:(NewTabButtonCustomImageRep*)imageRep
+ withHeavyStroke:(BOOL)heavyStroke {
[[NSGraphicsContext currentContext]
cr_setPatternPhase:[imageRep patternPhasePosition]
forView:[imageRep destView]];
@@ -414,8 +429,9 @@ + (void)drawNewTabButtonImage:(NewTabButtonCustomImageRep*)imageRep {
[bezierPath fill];
}
+ CGFloat alpha = heavyStroke ? k100PercentAlpha : k25PercentAlpha;
static NSColor* strokeColor =
- [[NSColor colorWithCalibratedWhite:0 alpha:k25PercentAlpha] retain];
+ [[NSColor colorWithCalibratedWhite:0 alpha:alpha] retain];
[strokeColor set];
[bezierPath stroke];
@@ -485,6 +501,16 @@ + (void)drawNewTabButtonImage:(NewTabButtonCustomImageRep*)imageRep {
}
}
++ (void)drawNewTabButtonImageWithNormalStroke:
+ (NewTabButtonCustomImageRep*)image {
+ [self drawNewTabButtonImage:image withHeavyStroke:NO];
+}
+
++ (void)drawNewTabButtonImageWithHeavyStroke:
+ (NewTabButtonCustomImageRep*)image {
+ [self drawNewTabButtonImage:image withHeavyStroke:YES];
+}
+
- (NSImage*)imageWithFillColor:(NSColor*)fillColor {
NSImage* image =
[[[NSImage alloc] initWithSize:newTabButtonImageSize] autorelease];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698