OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_COCOA_INFO_BUBBLE_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_INFO_BUBBLE_VIEW_H_ |
6 #define CHROME_BROWSER_UI_COCOA_INFO_BUBBLE_VIEW_H_ | 6 #define CHROME_BROWSER_UI_COCOA_INFO_BUBBLE_VIEW_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "ui/views/bubble/bubble_border.h" |
11 | 12 |
12 namespace info_bubble { | 13 namespace info_bubble { |
13 | 14 |
14 // These values are in view coordinates. | 15 // These values are in view coordinates. |
15 const CGFloat kBubbleArrowHeight = 8.0; | 16 const CGFloat kBubbleArrowHeight = 8.0; |
16 const CGFloat kBubbleArrowWidth = 15.0; | 17 const CGFloat kBubbleArrowWidth = 15.0; |
17 const CGFloat kBubbleCornerRadius = 2.0; | 18 const CGFloat kBubbleCornerRadius = 2.0; |
18 const CGFloat kBubbleArrowXOffset = kBubbleArrowWidth + kBubbleCornerRadius; | 19 const CGFloat kBubbleArrowXOffset = kBubbleArrowWidth + kBubbleCornerRadius; |
19 | 20 |
20 // Constants that define where the bubble will have rounded corners. | 21 // Constants that define where the bubble will have rounded corners. |
21 enum CornerFlags { | 22 enum CornerFlags { |
22 kRoundedTopCorners = 1, | 23 kRoundedTopCorners = 1, |
23 kRoundedBottomCorners = 1 << 1, | 24 kRoundedBottomCorners = 1 << 1, |
24 kRoundedAllCorners = kRoundedTopCorners | kRoundedBottomCorners, | 25 kRoundedAllCorners = kRoundedTopCorners | kRoundedBottomCorners, |
25 }; | 26 }; |
26 | 27 |
27 enum BubbleArrowLocation { | |
28 kTopLeft, | |
29 kTopCenter, | |
30 kTopRight, | |
31 kNoArrow, | |
32 }; | |
33 | |
34 enum BubbleAlignment { | 28 enum BubbleAlignment { |
35 // The tip of the arrow points to the anchor point. | 29 // The tip of the arrow points to the anchor point. |
36 kAlignArrowToAnchor, | 30 kAlignArrowToAnchor, |
37 // The edge nearest to the arrow is lined up with the anchor point. | 31 // The edge nearest to the arrow is lined up with the anchor point. |
38 kAlignEdgeToAnchorEdge, | 32 kAlignEdgeToAnchorEdge, |
39 // Align the right edge to the anchor point. | 33 // Align the right edge to the anchor point. |
40 kAlignRightEdgeToAnchorEdge, | 34 kAlignRightEdgeToAnchorEdge, |
41 // Align the left edge to the anchor point. | 35 // Align the left edge to the anchor point. |
42 kAlignLeftEdgeToAnchorEdge, | 36 kAlignLeftEdgeToAnchorEdge, |
43 }; | 37 }; |
44 | 38 |
45 } // namespace info_bubble | 39 } // namespace info_bubble |
46 | 40 |
47 // Content view for a bubble with an arrow showing arbitrary content. | 41 // Content view for a bubble with an arrow showing arbitrary content. |
48 // This is where nonrectangular drawing happens. | 42 // This is where nonrectangular drawing happens. |
49 @interface InfoBubbleView : NSView { | 43 @interface InfoBubbleView : NSView { |
50 @private | 44 @private |
51 info_bubble::BubbleArrowLocation arrowLocation_; | 45 views::BubbleBorder::Arrow arrowLocation_; |
52 info_bubble::BubbleAlignment alignment_; | 46 info_bubble::BubbleAlignment alignment_; |
53 info_bubble::CornerFlags cornerFlags_; | 47 info_bubble::CornerFlags cornerFlags_; |
54 base::scoped_nsobject<NSColor> backgroundColor_; | 48 base::scoped_nsobject<NSColor> backgroundColor_; |
55 } | 49 } |
56 | 50 |
57 @property(assign, nonatomic) info_bubble::BubbleArrowLocation arrowLocation; | 51 @property(assign, nonatomic) views::BubbleBorder::Arrow arrowLocation; |
58 @property(assign, nonatomic) info_bubble::BubbleAlignment alignment; | 52 @property(assign, nonatomic) info_bubble::BubbleAlignment alignment; |
59 @property(assign, nonatomic) info_bubble::CornerFlags cornerFlags; | 53 @property(assign, nonatomic) info_bubble::CornerFlags cornerFlags; |
60 | 54 |
61 // Returns the point location in view coordinates of the tip of the arrow. | 55 // Returns the point location in view coordinates of the tip of the arrow. |
62 - (NSPoint)arrowTip; | 56 - (NSPoint)arrowTip; |
63 | 57 |
64 // Gets and sets the bubble's background color. | 58 // Gets and sets the bubble's background color. |
65 - (NSColor*)backgroundColor; | 59 - (NSColor*)backgroundColor; |
66 - (void)setBackgroundColor:(NSColor*)backgroundColor; | 60 - (void)setBackgroundColor:(NSColor*)backgroundColor; |
67 | 61 |
68 @end | 62 @end |
69 | 63 |
70 #endif // CHROME_BROWSER_UI_COCOA_INFO_BUBBLE_VIEW_H_ | 64 #endif // CHROME_BROWSER_UI_COCOA_INFO_BUBBLE_VIEW_H_ |
OLD | NEW |