OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "chrome/browser/cocoa/bookmark_bubble_view.h" |
| 6 #import "third_party/GTM/AppKit/GTMTheme.h" |
| 7 |
| 8 namespace { |
| 9 // TODO(jrg): confirm constants with UI dudes |
| 10 const CGFloat kBubbleCornerRadius = 8.0; |
| 11 const CGFloat kBubbleArrowXOffset = 10.0; |
| 12 const CGFloat kBubbleArrowWidth = 15.0; |
| 13 const CGFloat kBubbleArrowHeight = 8.0; |
| 14 const CGFloat kBubbleBorderLineWidth = 1.0; |
| 15 } |
| 16 |
| 17 @implementation BookmarkBubbleView |
| 18 |
| 19 - (void)drawRect:(NSRect)rect { |
| 20 // Make room for the border to be seen. |
| 21 NSRect bounds = [self bounds]; |
| 22 bounds.size.height -= kBubbleArrowHeight; |
| 23 bounds = NSInsetRect(bounds, |
| 24 kBubbleBorderLineWidth/2.0, |
| 25 kBubbleBorderLineWidth/2.0); |
| 26 |
| 27 NSBezierPath* bezier = [NSBezierPath bezierPath]; |
| 28 rect.size.height -= kBubbleArrowHeight; |
| 29 |
| 30 // Start with a rounded rectangle. |
| 31 [bezier appendBezierPathWithRoundedRect:bounds |
| 32 xRadius:kBubbleCornerRadius |
| 33 yRadius:kBubbleCornerRadius]; |
| 34 |
| 35 // Add the bubble arrow (pointed at the star). |
| 36 NSPoint arrowStart = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); |
| 37 arrowStart.x += kBubbleArrowXOffset; |
| 38 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)]; |
| 39 [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth/2.0, |
| 40 arrowStart.y + kBubbleArrowHeight)]; |
| 41 [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth, |
| 42 arrowStart.y)]; |
| 43 [bezier closePath]; |
| 44 |
| 45 // Draw the outline... |
| 46 [[NSColor blackColor] set]; |
| 47 [bezier setLineWidth:kBubbleBorderLineWidth]; |
| 48 [bezier stroke]; |
| 49 |
| 50 // Then fill the inside. |
| 51 GTMTheme *theme = [GTMTheme defaultTheme]; |
| 52 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar |
| 53 state:NO]; |
| 54 [gradient drawInBezierPath:bezier angle:0.0]; |
| 55 } |
| 56 |
| 57 @end |
| 58 |
OLD | NEW |