| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_AURA_H_ | 5 #ifndef UI_VIEWS_COREWM_TOOLTIP_AURA_H_ |
| 6 #define UI_VIEWS_COREWM_TOOLTIP_AURA_H_ | 6 #define UI_VIEWS_COREWM_TOOLTIP_AURA_H_ |
| 7 | 7 |
| 8 #include "ui/gfx/screen_type_delegate.h" | 8 #include "ui/gfx/screen_type_delegate.h" |
| 9 #include "ui/views/controls/label.h" | 9 #include "ui/views/controls/label.h" |
| 10 #include "ui/views/corewm/tooltip.h" | 10 #include "ui/views/corewm/tooltip.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 public: | 21 public: |
| 22 explicit TooltipAura(gfx::ScreenType screen_type); | 22 explicit TooltipAura(gfx::ScreenType screen_type); |
| 23 virtual ~TooltipAura(); | 23 virtual ~TooltipAura(); |
| 24 | 24 |
| 25 // Trims the tooltip to fit in the width |max_width|, setting |text| to the | 25 // Trims the tooltip to fit in the width |max_width|, setting |text| to the |
| 26 // clipped result, |width| to the width (in pixels) of the clipped text | 26 // clipped result, |width| to the width (in pixels) of the clipped text |
| 27 // and |line_count| to the number of lines of text in the tooltip. |x| and |y| | 27 // and |line_count| to the number of lines of text in the tooltip. |x| and |y| |
| 28 // give the location of the tooltip in screen coordinates. |max_width| comes | 28 // give the location of the tooltip in screen coordinates. |max_width| comes |
| 29 // from GetMaxWidth(). | 29 // from GetMaxWidth(). |
| 30 static void TrimTooltipToFit(int max_width, | 30 static void TrimTooltipToFit(int max_width, |
| 31 string16* text, | 31 base::string16* text, |
| 32 int* width, | 32 int* width, |
| 33 int* line_count); | 33 int* line_count); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 // Returns the max width of the tooltip when shown at the specified location. | 36 // Returns the max width of the tooltip when shown at the specified location. |
| 37 int GetMaxWidth(const gfx::Point& location) const; | 37 int GetMaxWidth(const gfx::Point& location) const; |
| 38 | 38 |
| 39 // Returns the bounds to fit the tooltip in. | 39 // Returns the bounds to fit the tooltip in. |
| 40 gfx::Rect GetBoundsForTooltip(const gfx::Point& origin) const; | 40 gfx::Rect GetBoundsForTooltip(const gfx::Point& origin) const; |
| 41 | 41 |
| 42 // Adjusts the bounds given by the arguments to fit inside the desktop | 42 // Adjusts the bounds given by the arguments to fit inside the desktop |
| 43 // and applies the adjusted bounds to the label_. | 43 // and applies the adjusted bounds to the label_. |
| 44 void SetTooltipBounds(const gfx::Point& mouse_pos, | 44 void SetTooltipBounds(const gfx::Point& mouse_pos, |
| 45 int tooltip_width, | 45 int tooltip_width, |
| 46 int tooltip_height); | 46 int tooltip_height); |
| 47 | 47 |
| 48 // Makes sure |widget_| is valid, creating as necessary. | 48 // Makes sure |widget_| is valid, creating as necessary. |
| 49 void CreateWidget(); | 49 void CreateWidget(); |
| 50 | 50 |
| 51 // Destroys |widget_|. | 51 // Destroys |widget_|. |
| 52 void DestroyWidget(); | 52 void DestroyWidget(); |
| 53 | 53 |
| 54 // Tooltip: | 54 // Tooltip: |
| 55 virtual void SetText(aura::Window* window, | 55 virtual void SetText(aura::Window* window, |
| 56 const string16& tooltip_text, | 56 const base::string16& tooltip_text, |
| 57 const gfx::Point& location) OVERRIDE; | 57 const gfx::Point& location) OVERRIDE; |
| 58 virtual void Show() OVERRIDE; | 58 virtual void Show() OVERRIDE; |
| 59 virtual void Hide() OVERRIDE; | 59 virtual void Hide() OVERRIDE; |
| 60 virtual bool IsVisible() OVERRIDE; | 60 virtual bool IsVisible() OVERRIDE; |
| 61 | 61 |
| 62 // WidgetObserver: | 62 // WidgetObserver: |
| 63 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE; | 63 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE; |
| 64 | 64 |
| 65 const gfx::ScreenType screen_type_; | 65 const gfx::ScreenType screen_type_; |
| 66 | 66 |
| 67 // The label showing the tooltip. | 67 // The label showing the tooltip. |
| 68 Label label_; | 68 Label label_; |
| 69 | 69 |
| 70 // The widget containing the tooltip. May be NULL. | 70 // The widget containing the tooltip. May be NULL. |
| 71 Widget* widget_; | 71 Widget* widget_; |
| 72 | 72 |
| 73 // The window we're showing the tooltip for. Never NULL and valid while | 73 // The window we're showing the tooltip for. Never NULL and valid while |
| 74 // showing. | 74 // showing. |
| 75 aura::Window* tooltip_window_; | 75 aura::Window* tooltip_window_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(TooltipAura); | 77 DISALLOW_COPY_AND_ASSIGN(TooltipAura); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace corewm | 80 } // namespace corewm |
| 81 } // namespace views | 81 } // namespace views |
| 82 | 82 |
| 83 #endif // UI_VIEWS_COREWM_TOOLTIP_AURA_H_ | 83 #endif // UI_VIEWS_COREWM_TOOLTIP_AURA_H_ |
| OLD | NEW |