| OLD | NEW |
| 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 #import "chrome/browser/cocoa/info_bubble_view.h" | 5 #import "chrome/browser/cocoa/info_bubble_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "third_party/GTM/AppKit/GTMTheme.h" | 8 #import "third_party/GTM/AppKit/GTMTheme.h" |
| 9 | 9 |
| 10 namespace { | 10 // TODO(andybons): confirm constants with UI dudes. |
| 11 // TODO(andybons): confirm constants with UI dudes | 11 extern const CGFloat kBubbleArrowHeight = 8.0; |
| 12 const CGFloat kBubbleCornerRadius = 8.0; | 12 extern const CGFloat kBubbleArrowWidth = 15.0; |
| 13 const CGFloat kBubbleArrowXOffset = 10.0; | 13 extern const CGFloat kBubbleArrowXOffset = 10.0; |
| 14 const CGFloat kBubbleArrowWidth = 15.0; | 14 extern const CGFloat kBubbleCornerRadius = 8.0; |
| 15 const CGFloat kBubbleArrowHeight = 8.0; | |
| 16 } | |
| 17 | 15 |
| 18 @implementation InfoBubbleView | 16 @implementation InfoBubbleView |
| 19 | 17 |
| 20 @synthesize arrowLocation = arrowLocation_; | 18 @synthesize arrowLocation = arrowLocation_; |
| 19 @synthesize bubbleType = bubbleType_; |
| 21 | 20 |
| 22 - (id)initWithFrame:(NSRect)frameRect { | 21 - (id)initWithFrame:(NSRect)frameRect { |
| 23 if ((self = [super initWithFrame:frameRect])) { | 22 if ((self = [super initWithFrame:frameRect])) { |
| 24 arrowLocation_ = kTopLeft; | 23 arrowLocation_ = kTopLeft; |
| 24 bubbleType_ = kGradientInfoBubble; |
| 25 } | 25 } |
| 26 | 26 |
| 27 return self; | 27 return self; |
| 28 } | 28 } |
| 29 | 29 |
| 30 - (void)drawRect:(NSRect)rect { | 30 - (void)drawRect:(NSRect)rect { |
| 31 // Make room for the border to be seen. | 31 // Make room for the border to be seen. |
| 32 NSRect bounds = [self bounds]; | 32 NSRect bounds = [self bounds]; |
| 33 bounds.size.height -= kBubbleArrowHeight; | 33 bounds.size.height -= kBubbleArrowHeight; |
| 34 NSBezierPath* bezier = [NSBezierPath bezierPath]; | 34 NSBezierPath* bezier = [NSBezierPath bezierPath]; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 54 } | 54 } |
| 55 NSPoint arrowStart = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); | 55 NSPoint arrowStart = NSMakePoint(NSMinX(bounds), NSMaxY(bounds)); |
| 56 arrowStart.x += dX; | 56 arrowStart.x += dX; |
| 57 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)]; | 57 [bezier moveToPoint:NSMakePoint(arrowStart.x, arrowStart.y)]; |
| 58 [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth/2.0, | 58 [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth/2.0, |
| 59 arrowStart.y + kBubbleArrowHeight)]; | 59 arrowStart.y + kBubbleArrowHeight)]; |
| 60 [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth, | 60 [bezier lineToPoint:NSMakePoint(arrowStart.x + kBubbleArrowWidth, |
| 61 arrowStart.y)]; | 61 arrowStart.y)]; |
| 62 [bezier closePath]; | 62 [bezier closePath]; |
| 63 | 63 |
| 64 // Then fill the inside. | 64 // Then fill the inside depending on the type of bubble. |
| 65 GTMTheme *theme = [GTMTheme defaultTheme]; | 65 if (bubbleType_ == kGradientInfoBubble) { |
| 66 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar | 66 GTMTheme *theme = [GTMTheme defaultTheme]; |
| 67 state:NO]; | 67 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar |
| 68 [gradient drawInBezierPath:bezier angle:0.0]; | 68 state:NO]; |
| 69 [gradient drawInBezierPath:bezier angle:0.0]; |
| 70 } else if (bubbleType_ == kWhiteInfoBubble) { |
| 71 [[NSColor whiteColor] set]; |
| 72 [bezier fill]; |
| 73 } |
| 69 } | 74 } |
| 70 | 75 |
| 71 @end | 76 @end |
| OLD | NEW |