| 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 Widget; | 26 class Widget; |
| 27 | 27 |
| 28 // TooltipManager implementation for Views. | 28 // TooltipManager implementation for Views. |
| 29 class TooltipManagerViews : public TooltipManager, | 29 class TooltipManagerViews : public TooltipManager, |
| 30 public MessageLoopForUI::Observer, | 30 public MessageLoopForUI::Observer { |
| 31 public Widget::Observer { | |
| 32 public: | 31 public: |
| 33 explicit TooltipManagerViews(views::View* root_view); | 32 explicit TooltipManagerViews(views::View* root_view); |
| 34 virtual ~TooltipManagerViews(); | 33 virtual ~TooltipManagerViews(); |
| 35 | 34 |
| 36 // TooltipManager. | 35 // TooltipManager. |
| 37 virtual void UpdateTooltip() OVERRIDE; | 36 virtual void UpdateTooltip() OVERRIDE; |
| 38 virtual void TooltipTextChanged(View* view) OVERRIDE; | 37 virtual void TooltipTextChanged(View* view) OVERRIDE; |
| 39 virtual void ShowKeyboardTooltip(View* view) OVERRIDE; | 38 virtual void ShowKeyboardTooltip(View* view) OVERRIDE; |
| 40 virtual void HideKeyboardTooltip() OVERRIDE; | 39 virtual void HideKeyboardTooltip() OVERRIDE; |
| 41 | 40 |
| 42 #if defined(USE_WAYLAND) | 41 #if defined(USE_WAYLAND) |
| 43 virtual base::MessagePumpObserver::EventStatus WillProcessEvent( | 42 virtual base::MessagePumpObserver::EventStatus WillProcessEvent( |
| 44 ui::WaylandEvent* event) OVERRIDE; | 43 ui::WaylandEvent* event) OVERRIDE; |
| 45 #else | 44 #else |
| 46 // MessageLoopForUI::Observer | 45 // MessageLoopForUI::Observer |
| 47 virtual base::EventStatus WillProcessEvent( | 46 virtual base::EventStatus WillProcessEvent( |
| 48 const base::NativeEvent& event) OVERRIDE; | 47 const base::NativeEvent& event) OVERRIDE; |
| 49 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; | 48 virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE; |
| 50 #endif | 49 #endif |
| 51 | 50 |
| 52 // Widget::Observer | |
| 53 virtual void OnWidgetClosing(Widget* widget) OVERRIDE; | |
| 54 | |
| 55 private: | 51 private: |
| 56 void TooltipTimerFired(); | 52 void TooltipTimerFired(); |
| 57 View* GetViewForTooltip(int x, int y, bool for_keyboard); | 53 View* GetViewForTooltip(int x, int y, bool for_keyboard); |
| 58 | 54 |
| 59 // Updates the tooltip if required (if there is any change in the tooltip | 55 // Updates the tooltip if required (if there is any change in the tooltip |
| 60 // text or the view. | 56 // text or the view. |
| 61 void UpdateIfRequired(int x, int y, bool for_keyboard); | 57 void UpdateIfRequired(int x, int y, bool for_keyboard); |
| 62 | 58 |
| 63 // Updates the tooltip. Gets the tooltip text from tooltip_view_ and displays | 59 // Updates the tooltip. Gets the tooltip text from tooltip_view_ and displays |
| 64 // it at the current mouse position. | 60 // it at the current mouse position. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 77 | 73 |
| 78 scoped_ptr<Widget> tooltip_widget_; | 74 scoped_ptr<Widget> tooltip_widget_; |
| 79 views::View* root_view_; | 75 views::View* root_view_; |
| 80 View* tooltip_view_; | 76 View* tooltip_view_; |
| 81 string16 tooltip_text_; | 77 string16 tooltip_text_; |
| 82 Label tooltip_label_; | 78 Label tooltip_label_; |
| 83 | 79 |
| 84 gfx::Point curr_mouse_pos_; | 80 gfx::Point curr_mouse_pos_; |
| 85 base::RepeatingTimer<TooltipManagerViews> tooltip_timer_; | 81 base::RepeatingTimer<TooltipManagerViews> tooltip_timer_; |
| 86 | 82 |
| 87 // true when the widget that owns us has closed. | |
| 88 bool widget_closed_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews); | 83 DISALLOW_COPY_AND_ASSIGN(TooltipManagerViews); |
| 91 }; | 84 }; |
| 92 | 85 |
| 93 } // namespace views | 86 } // namespace views |
| 94 | 87 |
| 95 #endif // VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ | 88 #endif // VIEWS_WIDGET_TOOLTIP_MANAGER_VIEWS_H_ |
| OLD | NEW |