Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: ash/system/tray/tray_bubble_view.h

Issue 11154022: Re-factor Ash Message Center code part 3/4 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 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) 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 ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_
6 #define ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_ 6 #define ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_
7 7
8 #include "ui/views/bubble/bubble_delegate.h" 8 #include "ui/views/bubble/bubble_delegate.h"
9 9
10 // Specialized bubble view for bubbles associated with a tray icon (e.g the
miket_OOO 2012/10/16 01:05:42 e.g.
stevenjb 2012/10/16 19:16:06 Done.
11 // Ash status area). Mostly this handles custom anchor location and arrow and
12 // border rendering. This also has its own delegate for handling mouse events
13 // and other implementation specific details.
14
10 namespace ui { 15 namespace ui {
11 class LocatedEvent; 16 class LocatedEvent;
12 } 17 }
13 18
14 namespace views { 19 namespace views {
15 class View; 20 class View;
16 class Widget; 21 class Widget;
17 } 22 }
18 23
19 namespace ash { 24 // TODO(stevenjb): Move this out of message_center namespace once in views.
25 namespace message_center {
20 26
27 namespace internal {
21 class TrayBubbleBorder; 28 class TrayBubbleBorder;
22 class TrayBubbleBackground; 29 class TrayBubbleBackground;
30 }
23 31
24 // Specialized bubble view for status area tray bubbles.
25 // Mostly this handles custom anchor location and arrow and border rendering.
26 class TrayBubbleView : public views::BubbleDelegateView { 32 class TrayBubbleView : public views::BubbleDelegateView {
27 public: 33 public:
28 enum AnchorType { 34 enum AnchorType {
29 ANCHOR_TYPE_TRAY, 35 ANCHOR_TYPE_TRAY,
30 ANCHOR_TYPE_BUBBLE 36 ANCHOR_TYPE_BUBBLE
31 }; 37 };
32 38
33 enum AnchorAlignment { 39 enum AnchorAlignment {
34 ANCHOR_ALIGNMENT_BOTTOM, 40 ANCHOR_ALIGNMENT_BOTTOM,
35 ANCHOR_ALIGNMENT_LEFT, 41 ANCHOR_ALIGNMENT_LEFT,
36 ANCHOR_ALIGNMENT_RIGHT 42 ANCHOR_ALIGNMENT_RIGHT
37 }; 43 };
38 44
39 class Delegate { 45 class Delegate {
40 public: 46 public:
41 typedef TrayBubbleView::AnchorType AnchorType; 47 typedef TrayBubbleView::AnchorType AnchorType;
42 typedef TrayBubbleView::AnchorAlignment AnchorAlignment; 48 typedef TrayBubbleView::AnchorAlignment AnchorAlignment;
43 49
44 Delegate() {} 50 Delegate() {}
45 virtual ~Delegate() {} 51 virtual ~Delegate() {}
46 52
53 // Called when the view is destroyed. Any pointers to the view should be
54 // cleared when this gets called.
47 virtual void BubbleViewDestroyed() = 0; 55 virtual void BubbleViewDestroyed() = 0;
56
57 // Called when the mouse enters/exits the view.
48 virtual void OnMouseEnteredView() = 0; 58 virtual void OnMouseEnteredView() = 0;
49 virtual void OnMouseExitedView() = 0; 59 virtual void OnMouseExitedView() = 0;
50 virtual string16 GetAccessibleName() = 0; 60
61 // Called from GetAccessibleState(); should return the appropriate
62 // accesible name for the bubble.
miket_OOO 2012/10/16 01:05:42 accessible
stevenjb 2012/10/16 19:16:06 Done.
63 virtual string16 GetAccessibleNameForBubble() = 0;
64
65 // Passes responsibility for BubbleDelegateView::GetAnchorRect to the
66 // delegate.
51 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget, 67 virtual gfx::Rect GetAnchorRect(views::Widget* anchor_widget,
52 AnchorType anchor_type, 68 AnchorType anchor_type,
53 AnchorAlignment anchor_alignment) = 0; 69 AnchorAlignment anchor_alignment) = 0;
54 70
71 // Called when a bubble wants to hide/destroy itself (e.g. last visible
72 // child view was closed).
73 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0;
74
55 private: 75 private:
56 DISALLOW_COPY_AND_ASSIGN(Delegate); 76 DISALLOW_COPY_AND_ASSIGN(Delegate);
57 }; 77 };
58 78
59 struct InitParams { 79 struct InitParams {
60 static const int kArrowDefaultOffset; 80 static const int kArrowDefaultOffset;
61 81
62 InitParams(AnchorType anchor_type, 82 InitParams(AnchorType anchor_type,
63 AnchorAlignment anchor_alignment, 83 AnchorAlignment anchor_alignment,
64 int bubble_width); 84 int bubble_width);
(...skipping 27 matching lines...) Expand all
92 112
93 // Sets the maximum bubble height and resizes the bubble. 113 // Sets the maximum bubble height and resizes the bubble.
94 void SetMaxHeight(int height); 114 void SetMaxHeight(int height);
95 115
96 // Returns the border insets. Called by TrayEventFilter. 116 // Returns the border insets. Called by TrayEventFilter.
97 void GetBorderInsets(gfx::Insets* insets) const; 117 void GetBorderInsets(gfx::Insets* insets) const;
98 118
99 // Called when the delegate is destroyed. 119 // Called when the delegate is destroyed.
100 void reset_delegate() { delegate_ = NULL; } 120 void reset_delegate() { delegate_ = NULL; }
101 121
122 Delegate* delegate() { return delegate_; }
123
102 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } 124 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; }
103 bool is_gesture_dragging() const { return is_gesture_dragging_; } 125 bool is_gesture_dragging() const { return is_gesture_dragging_; }
104 126
105 // Overridden from views::WidgetDelegate. 127 // Overridden from views::WidgetDelegate.
106 virtual bool CanActivate() const OVERRIDE; 128 virtual bool CanActivate() const OVERRIDE;
107 virtual views::NonClientFrameView* CreateNonClientFrameView( 129 virtual views::NonClientFrameView* CreateNonClientFrameView(
108 views::Widget* widget) OVERRIDE; 130 views::Widget* widget) OVERRIDE;
109 virtual bool WidgetHasHitTestMask() const OVERRIDE; 131 virtual bool WidgetHasHitTestMask() const OVERRIDE;
110 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE; 132 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
111 133
(...skipping 17 matching lines...) Expand all
129 151
130 // Overridden from views::View. 152 // Overridden from views::View.
131 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; 153 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE;
132 virtual void ViewHierarchyChanged(bool is_add, 154 virtual void ViewHierarchyChanged(bool is_add,
133 views::View* parent, 155 views::View* parent,
134 views::View* child) OVERRIDE; 156 views::View* child) OVERRIDE;
135 157
136 private: 158 private:
137 InitParams params_; 159 InitParams params_;
138 Delegate* delegate_; 160 Delegate* delegate_;
139 TrayBubbleBorder* bubble_border_; 161 internal::TrayBubbleBorder* bubble_border_;
140 TrayBubbleBackground* bubble_background_; 162 internal::TrayBubbleBackground* bubble_background_;
141 bool is_gesture_dragging_; 163 bool is_gesture_dragging_;
142 164
143 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); 165 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView);
144 }; 166 };
145 167
146 } // namespace ash 168 } // namespace message_center
147 169
148 #endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_ 170 #endif // ASH_SYSTEM_TRAY_TRAY_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698