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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/instant_opt_in_view.mm

Issue 6927058: Merge 83125 - Add and use gfx::ScopedNSGraphicsContextState (ui/gfx/scoped_ns_graphics_context_st... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/742/src/
Patch Set: Created 9 years, 7 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) 2010 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 #include <algorithm> 5 #include <algorithm>
6 6
7 #import "chrome/browser/ui/cocoa/location_bar/instant_opt_in_view.h" 7 #import "chrome/browser/ui/cocoa/location_bar/instant_opt_in_view.h"
8 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" 8 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
9 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
9 10
10 namespace { 11 namespace {
11 // How to round off the popup's corners. Goal is to match star and go 12 // How to round off the popup's corners. Goal is to match star and go
12 // buttons. 13 // buttons.
13 const CGFloat kPopupRoundingRadius = 3.5; 14 const CGFloat kPopupRoundingRadius = 3.5;
14 15
15 // How far from the top of the view to place the horizontal line. 16 // How far from the top of the view to place the horizontal line.
16 const CGFloat kHorizontalLineTopOffset = 2; 17 const CGFloat kHorizontalLineTopOffset = 2;
17 18
18 // How far from the sides to inset the horizontal line. 19 // How far from the sides to inset the horizontal line.
19 const CGFloat kHorizontalLineInset = 2; 20 const CGFloat kHorizontalLineInset = 2;
20 } 21 }
21 22
22 @implementation InstantOptInView 23 @implementation InstantOptInView
23 24
24 - (void)drawRect:(NSRect)rect { 25 - (void)drawRect:(NSRect)rect {
25 // Round off the bottom corners only. 26 // Round off the bottom corners only.
26 NSBezierPath* path = 27 NSBezierPath* path =
27 [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds] 28 [NSBezierPath gtm_bezierPathWithRoundRect:[self bounds]
28 topLeftCornerRadius:0 29 topLeftCornerRadius:0
29 topRightCornerRadius:0 30 topRightCornerRadius:0
30 bottomLeftCornerRadius:kPopupRoundingRadius 31 bottomLeftCornerRadius:kPopupRoundingRadius
31 bottomRightCornerRadius:kPopupRoundingRadius]; 32 bottomRightCornerRadius:kPopupRoundingRadius];
32 33
33 [NSGraphicsContext saveGraphicsState]; 34 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
34 [path addClip]; 35 [path addClip];
35 36
36 // Background is white. 37 // Background is white.
37 [[NSColor whiteColor] set]; 38 [[NSColor whiteColor] set];
38 NSRectFill(rect); 39 NSRectFill(rect);
39 40
40 // Draw a horizontal line 2 px down from the top of the view, inset at the 41 // Draw a horizontal line 2 px down from the top of the view, inset at the
41 // sides by 2 px. 42 // sides by 2 px.
42 CGFloat lineY = NSMaxY([self bounds]) - kHorizontalLineTopOffset; 43 CGFloat lineY = NSMaxY([self bounds]) - kHorizontalLineTopOffset;
43 CGFloat minX = std::min(NSMinX([self bounds]) + kHorizontalLineInset, 44 CGFloat minX = std::min(NSMinX([self bounds]) + kHorizontalLineInset,
44 NSMaxX([self bounds])); 45 NSMaxX([self bounds]));
45 CGFloat maxX = std::max(NSMaxX([self bounds]) - kHorizontalLineInset, 46 CGFloat maxX = std::max(NSMaxX([self bounds]) - kHorizontalLineInset,
46 NSMinX([self bounds])); 47 NSMinX([self bounds]));
47 48
48 [[NSColor lightGrayColor] set]; 49 [[NSColor lightGrayColor] set];
49 NSRectFill(NSMakeRect(minX, lineY, maxX - minX, 1)); 50 NSRectFill(NSMakeRect(minX, lineY, maxX - minX, 1));
50
51 [NSGraphicsContext restoreGraphicsState];
52 } 51 }
53 52
54 @end 53 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm ('k') | chrome/browser/ui/cocoa/styled_text_field_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698