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_SYSTEM_TRAY_BUBBLE_H_ | 5 #ifndef ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 6 #define ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/system/user/login_status.h" | 9 #include "ash/system/user/login_status.h" |
10 #include "ash/wm/shelf_auto_hide_behavior.h" | 10 #include "ash/wm/shelf_auto_hide_behavior.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class SystemTray; | 25 class SystemTray; |
26 class SystemTrayItem; | 26 class SystemTrayItem; |
27 | 27 |
28 namespace internal { | 28 namespace internal { |
29 | 29 |
30 class SystemTrayBubble; | 30 class SystemTrayBubble; |
31 | 31 |
32 class SystemTrayBubbleView : public views::BubbleDelegateView { | 32 class SystemTrayBubbleView : public views::BubbleDelegateView { |
33 public: | 33 public: |
| 34 class Host { |
| 35 public: |
| 36 Host() {} |
| 37 virtual ~Host() {} |
| 38 |
| 39 virtual void BubbleViewDestroyed() = 0; |
| 40 virtual gfx::Rect GetAnchorRect() const = 0; |
| 41 virtual void OnMouseEnteredView() = 0; |
| 42 virtual void OnMouseExitedView() = 0; |
| 43 |
| 44 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(Host); |
| 46 }; |
| 47 |
34 SystemTrayBubbleView(views::View* anchor, | 48 SystemTrayBubbleView(views::View* anchor, |
35 views::BubbleBorder::ArrowLocation arrow_location, | 49 views::BubbleBorder::ArrowLocation arrow_location, |
36 SystemTrayBubble* host, | 50 Host* host, |
37 bool can_activate); | 51 bool can_activate, |
| 52 int bubble_width); |
38 virtual ~SystemTrayBubbleView(); | 53 virtual ~SystemTrayBubbleView(); |
39 | 54 |
40 void SetBubbleBorder(views::BubbleBorder* border); | 55 // Creates a bubble border with the specified arrow offset. |
| 56 void SetBubbleBorder(int arrow_offset); |
41 | 57 |
| 58 // Called whenever the bubble anchor location may have moved. |
42 void UpdateAnchor(); | 59 void UpdateAnchor(); |
43 | 60 |
| 61 // Sets the maximum bubble height and resizes the bubble. |
| 62 void SetMaxHeight(int height); |
| 63 |
44 // Called when the host is destroyed. | 64 // Called when the host is destroyed. |
45 void reset_host() { host_ = NULL; } | 65 void reset_host() { host_ = NULL; } |
46 | 66 |
47 private: | 67 // Overridden from views::WidgetDelegate. |
48 friend class SystemTrayBubble; | 68 virtual bool CanActivate() const OVERRIDE; |
49 | 69 |
50 // Overridden from views::BubbleDelegateView. | 70 // Overridden from views::BubbleDelegateView. |
51 virtual void Init() OVERRIDE; | |
52 virtual gfx::Rect GetAnchorRect() OVERRIDE; | 71 virtual gfx::Rect GetAnchorRect() OVERRIDE; |
53 virtual bool CanActivate() const OVERRIDE; | |
54 | 72 |
55 // Overridden from views::View. | 73 // Overridden from views::View. |
56 virtual gfx::Size GetPreferredSize() OVERRIDE; | 74 virtual gfx::Size GetPreferredSize() OVERRIDE; |
57 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | 75 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; |
58 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | 76 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; |
59 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 77 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 78 |
| 79 protected: |
| 80 // Overridden from views::BubbleDelegateView. |
| 81 virtual void Init() OVERRIDE; |
| 82 virtual gfx::Rect GetBubbleBounds() OVERRIDE; |
| 83 |
| 84 // Overridden from views::View. |
60 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | 85 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; |
61 virtual void ViewHierarchyChanged(bool is_add, | 86 virtual void ViewHierarchyChanged(bool is_add, |
62 views::View* parent, | 87 views::View* parent, |
63 views::View* child) OVERRIDE; | 88 views::View* child) OVERRIDE; |
64 | 89 |
65 void set_max_height(int height) { max_height_ = height; } | 90 Host* host_; |
66 | |
67 SystemTrayBubble* host_; | |
68 bool can_activate_; | 91 bool can_activate_; |
69 int max_height_; | 92 int max_height_; |
| 93 int bubble_width_; |
70 | 94 |
71 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleView); | 95 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleView); |
72 }; | 96 }; |
73 | 97 |
74 class SystemTrayBubble : public aura::EventFilter, | 98 class SystemTrayBubble : public aura::EventFilter, |
75 public views::Widget::Observer { | 99 public views::Widget::Observer, |
| 100 public SystemTrayBubbleView::Host { |
76 public: | 101 public: |
77 enum BubbleType { | 102 enum BubbleType { |
78 BUBBLE_TYPE_DEFAULT, | 103 BUBBLE_TYPE_DEFAULT, |
79 BUBBLE_TYPE_DETAILED, | 104 BUBBLE_TYPE_DETAILED, |
80 BUBBLE_TYPE_NOTIFICATION | 105 BUBBLE_TYPE_NOTIFICATION |
81 }; | 106 }; |
82 | 107 |
83 enum AnchorType { | 108 enum AnchorType { |
84 ANCHOR_TYPE_TRAY, | 109 ANCHOR_TYPE_TRAY, |
85 ANCHOR_TYPE_BUBBLE | 110 ANCHOR_TYPE_BUBBLE |
(...skipping 16 matching lines...) Expand all Loading... |
102 virtual ~SystemTrayBubble(); | 127 virtual ~SystemTrayBubble(); |
103 | 128 |
104 // Change the items displayed in the bubble. | 129 // Change the items displayed in the bubble. |
105 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, | 130 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, |
106 BubbleType bubble_type); | 131 BubbleType bubble_type); |
107 | 132 |
108 // Creates |bubble_view_| and a child views for each member of |items_|. | 133 // Creates |bubble_view_| and a child views for each member of |items_|. |
109 // Also creates |bubble_widget_| and sets up animations. | 134 // Also creates |bubble_widget_| and sets up animations. |
110 void InitView(const InitParams& init_params); | 135 void InitView(const InitParams& init_params); |
111 | 136 |
112 gfx::Rect GetAnchorRect() const; | 137 // Overridden from TrayBubbleView::Host. |
| 138 virtual void BubbleViewDestroyed() OVERRIDE; |
| 139 virtual gfx::Rect GetAnchorRect() const OVERRIDE; |
| 140 virtual void OnMouseEnteredView() OVERRIDE; |
| 141 virtual void OnMouseExitedView() OVERRIDE; |
113 | 142 |
114 BubbleType bubble_type() const { return bubble_type_; } | 143 BubbleType bubble_type() const { return bubble_type_; } |
115 SystemTrayBubbleView* bubble_view() const { return bubble_view_; } | 144 SystemTrayBubbleView* bubble_view() const { return bubble_view_; } |
116 | 145 |
117 void DestroyItemViews(); | 146 void DestroyItemViews(); |
118 void StartAutoCloseTimer(int seconds); | 147 void StartAutoCloseTimer(int seconds); |
119 void StopAutoCloseTimer(); | 148 void StopAutoCloseTimer(); |
120 void RestartAutoCloseTimer(); | 149 void RestartAutoCloseTimer(); |
121 void Close(); | 150 void Close(); |
122 | 151 |
(...skipping 28 matching lines...) Expand all Loading... |
151 int autoclose_delay_; | 180 int autoclose_delay_; |
152 base::OneShotTimer<SystemTrayBubble> autoclose_; | 181 base::OneShotTimer<SystemTrayBubble> autoclose_; |
153 | 182 |
154 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); | 183 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); |
155 }; | 184 }; |
156 | 185 |
157 } // namespace internal | 186 } // namespace internal |
158 } // namespace ash | 187 } // namespace ash |
159 | 188 |
160 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 189 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
OLD | NEW |