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 UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_H_ |
6 #define UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_H_ | 6 #define UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 | 10 |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/timer/timer.h" | 13 #include "base/timer/timer.h" |
14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
15 #include "ui/events/event_handler.h" | 15 #include "ui/events/event_handler.h" |
16 #include "ui/gfx/geometry/point.h" | 16 #include "ui/gfx/geometry/point.h" |
17 #include "ui/views/views_export.h" | 17 #include "ui/views/views_export.h" |
18 #include "ui/wm/public/tooltip_client.h" | 18 #include "ui/wm/public/tooltip_client.h" |
19 | 19 |
20 namespace aura { | 20 namespace aura { |
21 class Window; | 21 class Window; |
22 } | 22 } |
23 | 23 |
24 namespace views { | 24 namespace views { |
25 namespace corewm { | 25 namespace corewm { |
26 | 26 |
27 class Tooltip; | 27 class Tooltip; |
28 | 28 |
29 namespace test { | 29 namespace test { |
30 class TooltipControllerTestHelper; | 30 class TooltipControllerTestHelper; |
31 } // namespace test | 31 } // namespace test |
32 | 32 |
33 // TooltipController provides tooltip functionality for aura. | 33 // TooltipController provides tooltip functionality for aura. |
34 class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient, | 34 class VIEWS_EXPORT TooltipController : public aura::client::TooltipClient, |
35 public ui::EventHandler, | 35 public ui::EventHandler, |
36 public aura::WindowObserver { | 36 public aura::WindowObserver { |
37 public: | 37 public: |
38 explicit TooltipController(scoped_ptr<Tooltip> tooltip); | 38 explicit TooltipController(std::unique_ptr<Tooltip> tooltip); |
39 ~TooltipController() override; | 39 ~TooltipController() override; |
40 | 40 |
41 // Overridden from aura::client::TooltipClient. | 41 // Overridden from aura::client::TooltipClient. |
42 int GetMaxWidth(const gfx::Point& location) const override; | 42 int GetMaxWidth(const gfx::Point& location) const override; |
43 void UpdateTooltip(aura::Window* target) override; | 43 void UpdateTooltip(aura::Window* target) override; |
44 void SetTooltipShownTimeout(aura::Window* target, int timeout_in_ms) override; | 44 void SetTooltipShownTimeout(aura::Window* target, int timeout_in_ms) override; |
45 void SetTooltipsEnabled(bool enable) override; | 45 void SetTooltipsEnabled(bool enable) override; |
46 | 46 |
47 // Overridden from ui::EventHandler. | 47 // Overridden from ui::EventHandler. |
48 void OnKeyEvent(ui::KeyEvent* event) override; | 48 void OnKeyEvent(ui::KeyEvent* event) override; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 void SetTooltipWindow(aura::Window* target); | 81 void SetTooltipWindow(aura::Window* target); |
82 | 82 |
83 aura::Window* tooltip_window_; | 83 aura::Window* tooltip_window_; |
84 base::string16 tooltip_text_; | 84 base::string16 tooltip_text_; |
85 const void* tooltip_id_; | 85 const void* tooltip_id_; |
86 | 86 |
87 // These fields are for tracking state when the user presses a mouse button. | 87 // These fields are for tracking state when the user presses a mouse button. |
88 aura::Window* tooltip_window_at_mouse_press_; | 88 aura::Window* tooltip_window_at_mouse_press_; |
89 base::string16 tooltip_text_at_mouse_press_; | 89 base::string16 tooltip_text_at_mouse_press_; |
90 | 90 |
91 scoped_ptr<Tooltip> tooltip_; | 91 std::unique_ptr<Tooltip> tooltip_; |
92 | 92 |
93 base::RepeatingTimer tooltip_timer_; | 93 base::RepeatingTimer tooltip_timer_; |
94 | 94 |
95 // Timer to timeout the life of an on-screen tooltip. We hide the tooltip when | 95 // Timer to timeout the life of an on-screen tooltip. We hide the tooltip when |
96 // this timer fires. | 96 // this timer fires. |
97 base::OneShotTimer tooltip_shown_timer_; | 97 base::OneShotTimer tooltip_shown_timer_; |
98 | 98 |
99 // Location of the last event in |tooltip_window_|'s coordinates. | 99 // Location of the last event in |tooltip_window_|'s coordinates. |
100 gfx::Point curr_mouse_loc_; | 100 gfx::Point curr_mouse_loc_; |
101 | 101 |
102 bool tooltips_enabled_; | 102 bool tooltips_enabled_; |
103 | 103 |
104 std::map<aura::Window*, int> tooltip_shown_timeout_map_; | 104 std::map<aura::Window*, int> tooltip_shown_timeout_map_; |
105 | 105 |
106 DISALLOW_COPY_AND_ASSIGN(TooltipController); | 106 DISALLOW_COPY_AND_ASSIGN(TooltipController); |
107 }; | 107 }; |
108 | 108 |
109 } // namespace corewm | 109 } // namespace corewm |
110 } // namespace views | 110 } // namespace views |
111 | 111 |
112 #endif // UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_H_ | 112 #endif // UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_H_ |
OLD | NEW |