OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ | 5 #ifndef VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
6 #define VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ | 6 #define VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
11 #include "views/controls/label.h" | 11 #include "views/controls/label.h" |
12 #include "views/widget/native_widget.h" | 12 #include "views/widget/native_widget.h" |
13 #include "views/widget/tooltip_manager.h" | 13 #include "views/widget/tooltip_manager.h" |
14 #include "views/widget/widget_delegate.h" | 14 #include "views/widget/widget_delegate.h" |
15 #include "views/view.h" | 15 #include "views/view.h" |
16 | 16 |
17 #if defined(USE_X11) | 17 #if defined(USE_X11) |
18 typedef union _XEvent XEvent; | 18 typedef union _XEvent XEvent; |
19 namespace ui { | 19 namespace ui { |
20 union WaylandEvent; | 20 union WaylandEvent; |
21 } | 21 } |
22 #endif | 22 #endif |
23 | 23 |
24 namespace views { | 24 namespace views { |
25 | 25 |
26 class MouseEvent; | |
26 class Widget; | 27 class Widget; |
27 | 28 |
28 // TooltipManager implementation for Views. | 29 // TooltipManager implementation for Views. |
29 class TooltipManagerViews : public TooltipManager, | 30 class TooltipManagerViews : public TooltipManager { |
30 public MessageLoopForUI::Observer { | |
31 public: | 31 public: |
32 explicit TooltipManagerViews(views::View* root_view); | 32 explicit TooltipManagerViews(views::View* root_view); |
33 virtual ~TooltipManagerViews(); | 33 virtual ~TooltipManagerViews(); |
34 | 34 |
35 void UpdateForMouseEvent(const MouseEvent& event); | |
sky
2011/10/28 17:47:27
Describe this, including where the MouseEvent come
sadrul
2011/10/28 21:42:52
Done.
| |
36 | |
35 // TooltipManager. | 37 // TooltipManager. |
36 virtual void UpdateTooltip() OVERRIDE; | 38 virtual void UpdateTooltip() OVERRIDE; |
37 virtual void TooltipTextChanged(View* view) OVERRIDE; | 39 virtual void TooltipTextChanged(View* view) OVERRIDE; |
38 virtual void ShowKeyboardTooltip(View* view) OVERRIDE; | 40 virtual void ShowKeyboardTooltip(View* view) OVERRIDE; |
39 virtual void HideKeyboardTooltip() OVERRIDE; | 41 virtual void HideKeyboardTooltip() OVERRIDE; |
40 | 42 |
41 #if defined(USE_WAYLAND) | |
42 virtual base::MessagePumpObserver::EventStatus WillProcessEvent( | |
43 ui::WaylandEvent* event) OVERRIDE; | |
44 #else | |
45 // MessageLoopForUI::Observer | |
46 virtual base::EventStatus WillProcessEvent( | |
47 const base::NativeEvent& event) OVERRIDE; | |
48 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; | |
49 #endif | |
50 | |
51 private: | 43 private: |
52 void TooltipTimerFired(); | 44 void TooltipTimerFired(); |
53 View* GetViewForTooltip(int x, int y, bool for_keyboard); | 45 View* GetViewForTooltip(int x, int y, bool for_keyboard); |
54 | 46 |
55 // Updates the tooltip if required (if there is any change in the tooltip | 47 // Updates the tooltip if required (if there is any change in the tooltip |
56 // text or the view. | 48 // text or the view. |
57 void UpdateIfRequired(int x, int y, bool for_keyboard); | 49 void UpdateIfRequired(int x, int y, bool for_keyboard); |
58 | 50 |
59 // Updates the tooltip. Gets the tooltip text from tooltip_view_ and displays | 51 // Updates the tooltip. Gets the tooltip text from tooltip_view_ and displays |
60 // it at the current mouse position. | 52 // it at the current mouse position. |
(...skipping 18 matching lines...) Expand all Loading... | |
79 | 71 |
80 gfx::Point curr_mouse_pos_; | 72 gfx::Point curr_mouse_pos_; |
81 base::RepeatingTimer<TooltipManagerViews> tooltip_timer_; | 73 base::RepeatingTimer<TooltipManagerViews> tooltip_timer_; |
82 | 74 |
83 DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews); | 75 DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews); |
84 }; | 76 }; |
85 | 77 |
86 } // namespace views | 78 } // namespace views |
87 | 79 |
88 #endif // VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ | 80 #endif // VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
OLD | NEW |