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

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

Issue 260009: Several background pattern fixes on the Mac.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 2 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) 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 #include "chrome/browser/cocoa/find_bar_view.h" 5 #import "chrome/browser/cocoa/find_bar_view.h"
6 6
7 @implementation FindBarView 7 @implementation FindBarView
8 8
9 - (void)drawRect:(NSRect)rect { 9 - (void)drawRect:(NSRect)rect {
10 CGFloat curveSize = 8; 10 CGFloat curveSize = 8;
11 // TODO(rohitrao): Make this prettier. 11 // TODO(rohitrao): Make this prettier.
12 rect = NSInsetRect([self bounds], 0.5, 0.5); 12 rect = NSInsetRect([self bounds], 0.5, 0.5);
13 rect = NSOffsetRect(rect, 0, 1.0); 13 rect = NSOffsetRect(rect, 0, 1.0);
14 14
15 NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect)); 15 NSPoint topLeft = NSMakePoint(NSMinX(rect), NSMaxY(rect));
16 NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect)); 16 NSPoint topRight = NSMakePoint(NSMaxX(rect), NSMaxY(rect));
17 NSPoint midLeft1 = 17 NSPoint midLeft1 =
18 NSMakePoint(NSMinX(rect) + curveSize, NSMaxY(rect) - curveSize); 18 NSMakePoint(NSMinX(rect) + curveSize, NSMaxY(rect) - curveSize);
19 NSPoint midLeft2 = 19 NSPoint midLeft2 =
20 NSMakePoint(NSMinX(rect) + curveSize, NSMinY(rect) + curveSize); 20 NSMakePoint(NSMinX(rect) + curveSize, NSMinY(rect) + curveSize);
21 NSPoint midRight1 = 21 NSPoint midRight1 =
22 NSMakePoint(NSMaxX(rect) - curveSize, NSMinY(rect) + curveSize); 22 NSMakePoint(NSMaxX(rect) - curveSize, NSMinY(rect) + curveSize);
23 NSPoint midRight2 = 23 NSPoint midRight2 =
24 NSMakePoint(NSMaxX(rect) - curveSize, NSMaxY(rect) - curveSize); 24 NSMakePoint(NSMaxX(rect) - curveSize, NSMaxY(rect) - curveSize);
25 NSPoint bottomLeft = 25 NSPoint bottomLeft =
26 NSMakePoint(NSMinX(rect) + (2 * curveSize), NSMinY(rect)); 26 NSMakePoint(NSMinX(rect) + (2 * curveSize), NSMinY(rect));
27 NSPoint bottomRight = 27 NSPoint bottomRight =
28 NSMakePoint(NSMaxX(rect) - (2 * curveSize), NSMinY(rect)); 28 NSMakePoint(NSMaxX(rect) - (2 * curveSize), NSMinY(rect));
29 29
30 NSBezierPath *path = [NSBezierPath bezierPath]; 30 NSBezierPath* path = [NSBezierPath bezierPath];
31 [path moveToPoint:topLeft]; 31 [path moveToPoint:topLeft];
32 [path curveToPoint:midLeft1 32 [path curveToPoint:midLeft1
33 controlPoint1:NSMakePoint(midLeft1.x, topLeft.y) 33 controlPoint1:NSMakePoint(midLeft1.x, topLeft.y)
34 controlPoint2:NSMakePoint(midLeft1.x, topLeft.y)]; 34 controlPoint2:NSMakePoint(midLeft1.x, topLeft.y)];
35 [path lineToPoint:midLeft2]; 35 [path lineToPoint:midLeft2];
36 [path curveToPoint:bottomLeft 36 [path curveToPoint:bottomLeft
37 controlPoint1:NSMakePoint(midLeft2.x, bottomLeft.y) 37 controlPoint1:NSMakePoint(midLeft2.x, bottomLeft.y)
38 controlPoint2:NSMakePoint(midLeft2.x, bottomLeft.y)]; 38 controlPoint2:NSMakePoint(midLeft2.x, bottomLeft.y)];
39 39
40 [path lineToPoint:bottomRight]; 40 [path lineToPoint:bottomRight];
41 [path curveToPoint:midRight1 41 [path curveToPoint:midRight1
42 controlPoint1:NSMakePoint(midRight1.x, bottomLeft.y) 42 controlPoint1:NSMakePoint(midRight1.x, bottomLeft.y)
43 controlPoint2:NSMakePoint(midRight1.x, bottomLeft.y)]; 43 controlPoint2:NSMakePoint(midRight1.x, bottomLeft.y)];
44 [path lineToPoint:midRight2]; 44 [path lineToPoint:midRight2];
45 [path curveToPoint:topRight 45 [path curveToPoint:topRight
46 controlPoint1:NSMakePoint(midRight2.x, topLeft.y) 46 controlPoint1:NSMakePoint(midRight2.x, topLeft.y)
47 controlPoint2:NSMakePoint(midRight2.x, topLeft.y)]; 47 controlPoint2:NSMakePoint(midRight2.x, topLeft.y)];
48 NSGraphicsContext* context = [NSGraphicsContext currentContext];
49 [context saveGraphicsState];
50 [path addClip];
48 51
49 [NSGraphicsContext saveGraphicsState]; 52 // Set the pattern phase
50 [path addClip]; 53 NSPoint phase = [self gtm_themePatternPhase];
51 [super drawRect:rect]; 54
52 [NSGraphicsContext restoreGraphicsState]; 55 [context setPatternPhase:phase];
56 [super drawBackground];
57 [context restoreGraphicsState];
53 58
54 [[self strokeColor] set]; 59 [[self strokeColor] set];
55 [path stroke]; 60 [path stroke];
56 } 61 }
57 62
58 @end 63 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_shelf_view.mm ('k') | chrome/browser/cocoa/status_bubble_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698