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 ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_ | 5 #ifndef UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ |
6 #define ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_ | 6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | |
9 #include "ui/views/bubble/bubble_delegate.h" | 8 #include "ui/views/bubble/bubble_delegate.h" |
| 9 #include "ui/views/views_export.h" |
10 | 10 |
11 // Specialized bubble view for bubbles associated with a tray icon (e.g. the | 11 // Specialized bubble view for bubbles associated with a tray icon (e.g. the |
12 // Ash status area). Mostly this handles custom anchor location and arrow and | 12 // Ash status area). Mostly this handles custom anchor location and arrow and |
13 // border rendering. This also has its own delegate for handling mouse events | 13 // border rendering. This also has its own delegate for handling mouse events |
14 // and other implementation specific details. | 14 // and other implementation specific details. |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 class LocatedEvent; | 17 class LocatedEvent; |
18 } | 18 } |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 class View; | 21 class View; |
22 class Widget; | 22 class Widget; |
23 } | 23 } |
24 | 24 |
25 // TODO(stevenjb): Move this out of message_center namespace once in views. | 25 namespace views { |
26 namespace message_center { | |
27 | 26 |
28 namespace internal { | 27 namespace internal { |
29 class TrayBubbleBorder; | 28 class TrayBubbleBorder; |
30 class TrayBubbleBackground; | 29 class TrayBubbleBackground; |
31 } | 30 } |
32 | 31 |
33 class ASH_EXPORT TrayBubbleView : public views::BubbleDelegateView { | 32 class VIEWS_EXPORT TrayBubbleView : public views::BubbleDelegateView { |
34 public: | 33 public: |
35 enum AnchorType { | 34 enum AnchorType { |
36 ANCHOR_TYPE_TRAY, | 35 ANCHOR_TYPE_TRAY, |
37 ANCHOR_TYPE_BUBBLE | 36 ANCHOR_TYPE_BUBBLE |
38 }; | 37 }; |
39 | 38 |
40 enum AnchorAlignment { | 39 enum AnchorAlignment { |
41 ANCHOR_ALIGNMENT_BOTTOM, | 40 ANCHOR_ALIGNMENT_BOTTOM, |
42 ANCHOR_ALIGNMENT_LEFT, | 41 ANCHOR_ALIGNMENT_LEFT, |
43 ANCHOR_ALIGNMENT_RIGHT | 42 ANCHOR_ALIGNMENT_RIGHT |
44 }; | 43 }; |
45 | 44 |
46 class ASH_EXPORT Delegate { | 45 class VIEWS_EXPORT Delegate { |
47 public: | 46 public: |
48 typedef TrayBubbleView::AnchorType AnchorType; | 47 typedef TrayBubbleView::AnchorType AnchorType; |
49 typedef TrayBubbleView::AnchorAlignment AnchorAlignment; | 48 typedef TrayBubbleView::AnchorAlignment AnchorAlignment; |
50 | 49 |
51 Delegate() {} | 50 Delegate() {} |
52 virtual ~Delegate() {} | 51 virtual ~Delegate() {} |
53 | 52 |
54 // Called when the view is destroyed. Any pointers to the view should be | 53 // Called when the view is destroyed. Any pointers to the view should be |
55 // cleared when this gets called. | 54 // cleared when this gets called. |
56 virtual void BubbleViewDestroyed() = 0; | 55 virtual void BubbleViewDestroyed() = 0; |
(...skipping 13 matching lines...) Expand all Loading... |
70 AnchorAlignment anchor_alignment) = 0; | 69 AnchorAlignment anchor_alignment) = 0; |
71 | 70 |
72 // Called when a bubble wants to hide/destroy itself (e.g. last visible | 71 // Called when a bubble wants to hide/destroy itself (e.g. last visible |
73 // child view was closed). | 72 // child view was closed). |
74 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0; | 73 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0; |
75 | 74 |
76 private: | 75 private: |
77 DISALLOW_COPY_AND_ASSIGN(Delegate); | 76 DISALLOW_COPY_AND_ASSIGN(Delegate); |
78 }; | 77 }; |
79 | 78 |
80 struct InitParams { | 79 struct VIEWS_EXPORT InitParams { |
81 static const int kArrowDefaultOffset; | 80 static const int kArrowDefaultOffset; |
82 | 81 |
83 InitParams(AnchorType anchor_type, | 82 InitParams(AnchorType anchor_type, |
84 AnchorAlignment anchor_alignment, | 83 AnchorAlignment anchor_alignment, |
85 int bubble_width); | 84 int bubble_width); |
86 AnchorType anchor_type; | 85 AnchorType anchor_type; |
87 AnchorAlignment anchor_alignment; | 86 AnchorAlignment anchor_alignment; |
88 int bubble_width; | 87 int bubble_width; |
89 int max_height; | 88 int max_height; |
90 bool can_activate; | 89 bool can_activate; |
91 bool close_on_deactivate; | 90 bool close_on_deactivate; |
92 SkColor top_color; | 91 SkColor top_color; |
93 SkColor arrow_color; | 92 SkColor arrow_color; |
94 views::BubbleBorder::ArrowLocation arrow_location; | 93 views::BubbleBorder::ArrowLocation arrow_location; |
95 int arrow_offset; | 94 int arrow_offset; |
96 views::BubbleBorder::Shadow shadow; | 95 views::BubbleBorder::Shadow shadow; |
97 }; | 96 }; |
98 | 97 |
99 // Constructs and returns a TrayBubbleView. init_params may be modified. | 98 // Constructs and returns a TrayBubbleView. init_params may be modified. |
100 static TrayBubbleView* Create(aura::Window* parent_window, | 99 static TrayBubbleView* Create(gfx::NativeView parent_window, |
101 views::View* anchor, | 100 views::View* anchor, |
102 Delegate* delegate, | 101 Delegate* delegate, |
103 InitParams* init_params); | 102 InitParams* init_params); |
104 | 103 |
105 virtual ~TrayBubbleView(); | 104 virtual ~TrayBubbleView(); |
106 | 105 |
107 // Sets up animations, and show the bubble. Must occur after CreateBubble() | 106 // Sets up animations, and show the bubble. Must occur after CreateBubble() |
108 // is called. | 107 // is called. |
109 void InitializeAndShowBubble(); | 108 void InitializeAndShowBubble(); |
110 | 109 |
111 // Called whenever the bubble size or location may have changed. | 110 // Called whenever the bubble size or location may have changed. |
112 void UpdateBubble(); | 111 void UpdateBubble(); |
113 | 112 |
114 // Sets the maximum bubble height and resizes the bubble. | 113 // Sets the maximum bubble height and resizes the bubble. |
115 void SetMaxHeight(int height); | 114 void SetMaxHeight(int height); |
116 | 115 |
| 116 // Sets whether or not to paint the bubble border arrow. |
| 117 void SetPaintArrow(bool paint_arrow); |
| 118 |
117 // Returns the border insets. Called by TrayEventFilter. | 119 // Returns the border insets. Called by TrayEventFilter. |
118 void GetBorderInsets(gfx::Insets* insets) const; | 120 void GetBorderInsets(gfx::Insets* insets) const; |
119 | 121 |
120 // Called when the delegate is destroyed. | 122 // Called when the delegate is destroyed. |
121 void reset_delegate() { delegate_ = NULL; } | 123 void reset_delegate() { delegate_ = NULL; } |
122 | 124 |
123 Delegate* delegate() { return delegate_; } | 125 Delegate* delegate() { return delegate_; } |
124 | 126 |
125 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } | 127 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } |
126 bool is_gesture_dragging() const { return is_gesture_dragging_; } | 128 bool is_gesture_dragging() const { return is_gesture_dragging_; } |
127 | 129 |
128 // Overridden from views::WidgetDelegate. | 130 // Overridden from views::WidgetDelegate. |
129 virtual bool CanActivate() const OVERRIDE; | 131 virtual bool CanActivate() const OVERRIDE; |
130 virtual views::NonClientFrameView* CreateNonClientFrameView( | 132 virtual views::NonClientFrameView* CreateNonClientFrameView( |
131 views::Widget* widget) OVERRIDE; | 133 views::Widget* widget) OVERRIDE; |
132 virtual bool WidgetHasHitTestMask() const OVERRIDE; | 134 virtual bool WidgetHasHitTestMask() const OVERRIDE; |
133 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; | 135 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; |
134 | 136 |
135 // Overridden from views::BubbleDelegateView. | 137 // Overridden from views::BubbleDelegateView. |
136 virtual gfx::Rect GetAnchorRect() OVERRIDE; | 138 virtual gfx::Rect GetAnchorRect() OVERRIDE; |
137 | 139 |
138 // Overridden from views::View. | 140 // Overridden from views::View. |
139 virtual gfx::Size GetPreferredSize() OVERRIDE; | 141 virtual gfx::Size GetPreferredSize() OVERRIDE; |
140 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; | 142 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; |
141 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; | 143 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; |
142 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 144 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
143 | 145 |
144 protected: | 146 protected: |
145 TrayBubbleView(aura::Window* parent_window, | 147 TrayBubbleView(gfx::NativeView parent_window, |
146 views::View* anchor, | 148 views::View* anchor, |
147 Delegate* delegate, | 149 Delegate* delegate, |
148 const InitParams& init_params); | 150 const InitParams& init_params); |
149 | 151 |
150 // Overridden from views::BubbleDelegateView. | 152 // Overridden from views::BubbleDelegateView. |
151 virtual void Init() OVERRIDE; | 153 virtual void Init() OVERRIDE; |
152 | 154 |
153 // Overridden from views::View. | 155 // Overridden from views::View. |
154 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 156 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
155 virtual void ViewHierarchyChanged(bool is_add, | 157 virtual void ViewHierarchyChanged(bool is_add, |
156 views::View* parent, | 158 views::View* parent, |
157 views::View* child) OVERRIDE; | 159 views::View* child) OVERRIDE; |
158 | 160 |
159 private: | 161 private: |
160 InitParams params_; | 162 InitParams params_; |
161 Delegate* delegate_; | 163 Delegate* delegate_; |
162 internal::TrayBubbleBorder* bubble_border_; | 164 internal::TrayBubbleBorder* bubble_border_; |
163 internal::TrayBubbleBackground* bubble_background_; | 165 internal::TrayBubbleBackground* bubble_background_; |
164 bool is_gesture_dragging_; | 166 bool is_gesture_dragging_; |
165 | 167 |
166 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); | 168 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); |
167 }; | 169 }; |
168 | 170 |
169 } // namespace message_center | 171 } // namespace views |
170 | 172 |
171 #endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_ | 173 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ |
OLD | NEW |