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_TOOLTIPS_TOOLTIP_CONTROLLER_H_ | 5 #ifndef ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_ |
6 #define ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_ | 6 #define ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/timer.h" | 10 #include "base/timer.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // |max_width| to the width (in pixels) of the clipped text and |line_count| | 66 // |max_width| to the width (in pixels) of the clipped text and |line_count| |
67 // to the number of lines of text in the tooltip. |x| and |y| give the | 67 // to the number of lines of text in the tooltip. |x| and |y| give the |
68 // location of the tooltip in screen coordinates. | 68 // location of the tooltip in screen coordinates. |
69 static void TrimTooltipToFit(string16* text, | 69 static void TrimTooltipToFit(string16* text, |
70 int* max_width, | 70 int* max_width, |
71 int* line_count, | 71 int* line_count, |
72 int x, | 72 int x, |
73 int y); | 73 int y); |
74 | 74 |
75 void TooltipTimerFired(); | 75 void TooltipTimerFired(); |
| 76 void TooltipShownTimerFired(); |
76 | 77 |
77 // Updates the tooltip if required (if there is any change in the tooltip | 78 // Updates the tooltip if required (if there is any change in the tooltip |
78 // text or the aura::Window. | 79 // text or the aura::Window. |
79 void UpdateIfRequired(); | 80 void UpdateIfRequired(); |
80 | 81 |
81 // Only used in tests. | 82 // Only used in tests. |
82 bool IsTooltipVisible(); | 83 bool IsTooltipVisible(); |
83 | 84 |
84 bool IsDragDropInProgress(); | 85 bool IsDragDropInProgress(); |
85 | 86 |
86 aura::client::DragDropClient* drag_drop_client_; | 87 aura::client::DragDropClient* drag_drop_client_; |
87 | 88 |
88 aura::Window* tooltip_window_; | 89 aura::Window* tooltip_window_; |
89 string16 tooltip_text_; | 90 string16 tooltip_text_; |
90 | 91 |
91 // These fields are for tracking state when the user presses a mouse button. | 92 // These fields are for tracking state when the user presses a mouse button. |
92 aura::Window* tooltip_window_at_mouse_press_; | 93 aura::Window* tooltip_window_at_mouse_press_; |
93 string16 tooltip_text_at_mouse_press_; | 94 string16 tooltip_text_at_mouse_press_; |
94 bool mouse_pressed_; | 95 bool mouse_pressed_; |
95 | 96 |
96 scoped_ptr<Tooltip> tooltip_; | 97 scoped_ptr<Tooltip> tooltip_; |
97 | 98 |
98 base::RepeatingTimer<TooltipController> tooltip_timer_; | 99 base::RepeatingTimer<TooltipController> tooltip_timer_; |
99 | 100 |
| 101 // Timer to timeout the life of an on-screen tooltip. We hide the tooltip when |
| 102 // this timer fires. |
| 103 base::OneShotTimer<TooltipController> tooltip_shown_timer_; |
| 104 |
100 gfx::Point curr_mouse_loc_; | 105 gfx::Point curr_mouse_loc_; |
101 | 106 |
102 bool tooltips_enabled_; | 107 bool tooltips_enabled_; |
103 | 108 |
104 DISALLOW_COPY_AND_ASSIGN(TooltipController); | 109 DISALLOW_COPY_AND_ASSIGN(TooltipController); |
105 }; | 110 }; |
106 | 111 |
107 } // namespace internal | 112 } // namespace internal |
108 } // namespace ash | 113 } // namespace ash |
109 | 114 |
110 #endif // ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_ | 115 #endif // ASH_TOOLTIPS_TOOLTIP_CONTROLLER_H_ |
OLD | NEW |