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/tray/system_tray_bubble_view.h" |
9 #include "ash/system/user/login_status.h" | 10 #include "ash/system/user/login_status.h" |
10 #include "ash/wm/shelf_auto_hide_behavior.h" | 11 #include "ash/wm/shelf_auto_hide_behavior.h" |
11 #include "base/base_export.h" | 12 #include "base/base_export.h" |
12 #include "base/timer.h" | 13 #include "base/timer.h" |
13 #include "ui/aura/event_filter.h" | 14 #include "ui/aura/event_filter.h" |
14 #include "ui/views/bubble/bubble_delegate.h" | |
15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
16 | 16 |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 namespace aura { | 19 namespace aura { |
20 class LocatedEvent; | 20 class LocatedEvent; |
21 } | 21 } |
22 | 22 |
23 namespace ash { | 23 namespace ash { |
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; | |
31 | |
32 class SystemTrayBubbleView : public views::BubbleDelegateView { | |
33 public: | |
34 SystemTrayBubbleView(views::View* anchor, | |
35 views::BubbleBorder::ArrowLocation arrow_location, | |
36 SystemTrayBubble* host, | |
37 bool can_activate); | |
38 virtual ~SystemTrayBubbleView(); | |
39 | |
40 void SetBubbleBorder(views::BubbleBorder* border); | |
41 | |
42 void UpdateAnchor(); | |
43 | |
44 // Called when the host is destroyed. | |
45 void reset_host() { host_ = NULL; } | |
46 | |
47 private: | |
48 friend class SystemTrayBubble; | |
49 | |
50 // Overridden from views::BubbleDelegateView. | |
51 virtual void Init() OVERRIDE; | |
52 virtual gfx::Rect GetAnchorRect() OVERRIDE; | |
53 virtual bool CanActivate() const OVERRIDE; | |
54 | |
55 // Overridden from views::View. | |
56 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
57 virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE; | |
58 virtual void OnMouseExited(const views::MouseEvent& event) OVERRIDE; | |
59 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | |
60 virtual void ChildPreferredSizeChanged(View* child) OVERRIDE; | |
61 virtual void ViewHierarchyChanged(bool is_add, | |
62 views::View* parent, | |
63 views::View* child) OVERRIDE; | |
64 | |
65 void set_max_height(int height) { max_height_ = height; } | |
66 | |
67 SystemTrayBubble* host_; | |
68 bool can_activate_; | |
69 int max_height_; | |
70 | |
71 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubbleView); | |
72 }; | |
73 | |
74 class SystemTrayBubble : public aura::EventFilter, | 30 class SystemTrayBubble : public aura::EventFilter, |
75 public views::Widget::Observer { | 31 public views::Widget::Observer, |
| 32 public SystemTrayBubbleView::Host { |
76 public: | 33 public: |
77 enum BubbleType { | 34 enum BubbleType { |
78 BUBBLE_TYPE_DEFAULT, | 35 BUBBLE_TYPE_DEFAULT, |
79 BUBBLE_TYPE_DETAILED, | 36 BUBBLE_TYPE_DETAILED, |
80 BUBBLE_TYPE_NOTIFICATION | 37 BUBBLE_TYPE_NOTIFICATION |
81 }; | 38 }; |
82 | 39 |
83 enum AnchorType { | 40 enum AnchorType { |
84 ANCHOR_TYPE_TRAY, | 41 ANCHOR_TYPE_TRAY, |
85 ANCHOR_TYPE_BUBBLE | 42 ANCHOR_TYPE_BUBBLE |
(...skipping 16 matching lines...) Expand all Loading... |
102 virtual ~SystemTrayBubble(); | 59 virtual ~SystemTrayBubble(); |
103 | 60 |
104 // Change the items displayed in the bubble. | 61 // Change the items displayed in the bubble. |
105 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, | 62 void UpdateView(const std::vector<ash::SystemTrayItem*>& items, |
106 BubbleType bubble_type); | 63 BubbleType bubble_type); |
107 | 64 |
108 // Creates |bubble_view_| and a child views for each member of |items_|. | 65 // Creates |bubble_view_| and a child views for each member of |items_|. |
109 // Also creates |bubble_widget_| and sets up animations. | 66 // Also creates |bubble_widget_| and sets up animations. |
110 void InitView(const InitParams& init_params); | 67 void InitView(const InitParams& init_params); |
111 | 68 |
112 gfx::Rect GetAnchorRect() const; | 69 // Overridden from SystemTrayBubbleView::Host. |
| 70 virtual void BubbleViewDestroyed() OVERRIDE; |
| 71 virtual gfx::Rect GetAnchorRect() const OVERRIDE; |
| 72 virtual void OnMouseEnteredView() OVERRIDE; |
| 73 virtual void OnMouseExitedView() OVERRIDE; |
113 | 74 |
114 BubbleType bubble_type() const { return bubble_type_; } | 75 BubbleType bubble_type() const { return bubble_type_; } |
115 SystemTrayBubbleView* bubble_view() const { return bubble_view_; } | 76 SystemTrayBubbleView* bubble_view() const { return bubble_view_; } |
116 | 77 |
117 void DestroyItemViews(); | 78 void DestroyItemViews(); |
118 void StartAutoCloseTimer(int seconds); | 79 void StartAutoCloseTimer(int seconds); |
119 void StopAutoCloseTimer(); | 80 void StopAutoCloseTimer(); |
120 void RestartAutoCloseTimer(); | 81 void RestartAutoCloseTimer(); |
121 void Close(); | 82 void Close(); |
| 83 void SetVisible(bool is_visible); |
| 84 bool IsVisible(); |
122 | 85 |
123 private: | 86 private: |
124 void CreateItemViews(user::LoginStatus login_status); | 87 void CreateItemViews(user::LoginStatus login_status); |
125 | 88 |
126 // Closes the bubble if the event happened outside the bounds. | 89 // Closes the bubble if the event happened outside the bounds. |
127 // Returns true if the event should be stopped from being propagated farther. | 90 // Returns true if the event should be stopped from being propagated farther. |
128 bool ProcessLocatedEvent(const aura::LocatedEvent& event); | 91 bool ProcessLocatedEvent(const aura::LocatedEvent& event); |
129 | 92 |
130 // Overridden from aura::EventFilter. | 93 // Overridden from aura::EventFilter. |
131 virtual bool PreHandleKeyEvent(aura::Window* target, | 94 virtual bool PreHandleKeyEvent(aura::Window* target, |
(...skipping 19 matching lines...) Expand all Loading... |
151 int autoclose_delay_; | 114 int autoclose_delay_; |
152 base::OneShotTimer<SystemTrayBubble> autoclose_; | 115 base::OneShotTimer<SystemTrayBubble> autoclose_; |
153 | 116 |
154 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); | 117 DISALLOW_COPY_AND_ASSIGN(SystemTrayBubble); |
155 }; | 118 }; |
156 | 119 |
157 } // namespace internal | 120 } // namespace internal |
158 } // namespace ash | 121 } // namespace ash |
159 | 122 |
160 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ | 123 #endif // ASH_SYSTEM_TRAY_SYSTEM_TRAY_BUBBLE_H_ |
OLD | NEW |