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_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ | 5 #ifndef ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ |
6 #define ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ | 6 #define ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ |
7 | 7 |
8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
9 #include "ash/wm/shelf_layout_manager.h" | 9 #include "ash/wm/shelf_layout_manager.h" |
10 #include "ash/wm/shelf_types.h" | 10 #include "ash/wm/shelf_types.h" |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
14 #include "ui/aura/event_filter.h" | |
Daniel Erat
2012/07/24 16:39:50
nit: fix alphabetization
Jun Mukai
2012/07/25 07:10:05
Done.
| |
14 #include "ui/views/bubble/bubble_border.h" | 15 #include "ui/views/bubble/bubble_border.h" |
15 #include "ui/views/bubble/bubble_delegate.h" | 16 #include "ui/views/bubble/bubble_delegate.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class Timer; | 19 class Timer; |
19 } | 20 } |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 class BubbleDelegateView; | 23 class BubbleDelegateView; |
23 class Label; | 24 class Label; |
24 } | 25 } |
25 | 26 |
26 namespace ash { | 27 namespace ash { |
27 namespace test { | 28 namespace test { |
28 class LauncherTooltipManagerTest; | 29 class LauncherTooltipManagerTest; |
29 class LauncherViewTest; | 30 class LauncherViewTest; |
30 } | 31 } |
31 | 32 |
32 namespace internal { | 33 namespace internal { |
34 class LauncherView; | |
33 | 35 |
34 // LauncherTooltipManager manages the tooltip balloon poping up on launcher | 36 // LauncherTooltipManager manages the tooltip balloon poping up on launcher |
35 // items. | 37 // items. |
36 class ASH_EXPORT LauncherTooltipManager : public ShelfLayoutManager::Observer { | 38 class ASH_EXPORT LauncherTooltipManager : public aura::EventFilter, |
39 public ShelfLayoutManager::Observer { | |
37 public: | 40 public: |
38 LauncherTooltipManager(ShelfAlignment alignment, | 41 LauncherTooltipManager(ShelfAlignment alignment, |
39 ShelfLayoutManager* shelf_layout_manager); | 42 ShelfLayoutManager* shelf_layout_manager, |
43 LauncherView* launcher_view); | |
40 virtual ~LauncherTooltipManager(); | 44 virtual ~LauncherTooltipManager(); |
41 | 45 |
42 // Called when the bubble is closed. | 46 // Called when the bubble is closed. |
43 void OnBubbleClosed(views::BubbleDelegateView* view); | 47 void OnBubbleClosed(views::BubbleDelegateView* view); |
44 | 48 |
45 // Shows the tooltip after a delay. It also has the appearing animation. | 49 // Shows the tooltip after a delay. It also has the appearing animation. |
46 void ShowDelayed(views::View* anchor, const string16& text); | 50 void ShowDelayed(views::View* anchor, const string16& text); |
47 | 51 |
48 // Shows the tooltip immediately. It omits the appearing animation. | 52 // Shows the tooltip immediately. It omits the appearing animation. |
49 void ShowImmediately(views::View* anchor, const string16& text); | 53 void ShowImmediately(views::View* anchor, const string16& text); |
50 | 54 |
51 // Closes the tooltip. | 55 // Closes the tooltip. |
52 void Close(); | 56 void Close(); |
53 | 57 |
54 // Changes the arrow location of the tooltip in case that the launcher | 58 // Changes the arrow location of the tooltip in case that the launcher |
55 // arrangement has changed. | 59 // arrangement has changed. |
56 void SetArrowLocation(ShelfAlignment alignment); | 60 void SetArrowLocation(ShelfAlignment alignment); |
57 | 61 |
58 // Resets the timer for the delayed showing |view_|. If the timer isn't | 62 // Resets the timer for the delayed showing |view_|. If the timer isn't |
59 // running, it starts a new timer. | 63 // running, it starts a new timer. |
60 void ResetTimer(); | 64 void ResetTimer(); |
61 | 65 |
62 // Stops the timer for the delayed showing |view_|. | 66 // Stops the timer for the delayed showing |view_|. |
63 void StopTimer(); | 67 void StopTimer(); |
64 | 68 |
65 // Returns true if the tooltip is currently visible. | 69 // Returns true if the tooltip is currently visible. |
66 bool IsVisible(); | 70 bool IsVisible(); |
67 | 71 |
68 protected: | 72 protected: |
73 // aura::EventFilter overrides: | |
74 virtual bool PreHandleKeyEvent(aura::Window* target, | |
75 aura::KeyEvent* event) OVERRIDE; | |
76 virtual bool PreHandleMouseEvent(aura::Window* target, | |
77 aura::MouseEvent* event) OVERRIDE; | |
78 virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target, | |
79 aura::TouchEvent* event) OVERRIDE; | |
80 virtual ui::GestureStatus PreHandleGestureEvent( | |
81 aura::Window* target, | |
82 aura::GestureEvent* event) OVERRIDE; | |
83 | |
69 // ShelfLayoutManager::Observer overrides: | 84 // ShelfLayoutManager::Observer overrides: |
70 virtual void WillDeleteShelf() OVERRIDE; | 85 virtual void WillDeleteShelf() OVERRIDE; |
71 virtual void WillChangeVisibilityState( | 86 virtual void WillChangeVisibilityState( |
72 ShelfLayoutManager::VisibilityState new_state) OVERRIDE; | 87 ShelfLayoutManager::VisibilityState new_state) OVERRIDE; |
73 virtual void OnAutoHideStateChanged( | 88 virtual void OnAutoHideStateChanged( |
74 ShelfLayoutManager::AutoHideState new_state) OVERRIDE; | 89 ShelfLayoutManager::AutoHideState new_state) OVERRIDE; |
75 | 90 |
76 private: | 91 private: |
77 class LauncherTooltipBubble; | 92 class LauncherTooltipBubble; |
78 friend class test::LauncherViewTest; | 93 friend class test::LauncherViewTest; |
79 friend class test::LauncherTooltipManagerTest; | 94 friend class test::LauncherTooltipManagerTest; |
80 | 95 |
81 void ShowInternal(); | 96 void ShowInternal(); |
82 void CreateBubble(views::View* anchor, const string16& text); | 97 void CreateBubble(views::View* anchor, const string16& text); |
83 | 98 |
84 LauncherTooltipBubble* view_; | 99 LauncherTooltipBubble* view_; |
100 views::Widget* widget_; | |
85 views::View* anchor_; | 101 views::View* anchor_; |
86 string16 text_; | 102 string16 text_; |
87 ShelfAlignment alignment_; | 103 ShelfAlignment alignment_; |
88 scoped_ptr<base::Timer> timer_; | 104 scoped_ptr<base::Timer> timer_; |
89 | 105 |
90 ShelfLayoutManager* shelf_layout_manager_; | 106 ShelfLayoutManager* shelf_layout_manager_; |
107 LauncherView* launcher_view_; | |
91 | 108 |
92 DISALLOW_COPY_AND_ASSIGN(LauncherTooltipManager); | 109 DISALLOW_COPY_AND_ASSIGN(LauncherTooltipManager); |
93 }; | 110 }; |
94 | 111 |
95 } // namespace internal | 112 } // namespace internal |
96 } // namespace ash | 113 } // namespace ash |
97 | 114 |
98 #endif // ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ | 115 #endif // ASH_LAUNCHER_LAUNCHER_TOOLTIP_MANAGER_H_ |
OLD | NEW |