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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_COREWM_TOOLTIP_AURA_H_
6 #define UI_VIEWS_COREWM_TOOLTIP_AURA_H_
8 #include "ui/gfx/screen_type_delegate.h"
9 #include "ui/views/controls/label.h"
10 #include "ui/views/corewm/tooltip.h"
11 #include "ui/views/widget/widget_observer.h"
23 // Implementation of Tooltip that shows the tooltip using a Widget and Label.
24 class VIEWS_EXPORT TooltipAura
: public Tooltip
, public WidgetObserver
{
27 ~TooltipAura() override
;
29 // Trims the tooltip to fit in the width |max_width|, setting |text| to the
30 // clipped result, |width| to the width (in pixels) of the clipped text
31 // and |line_count| to the number of lines of text in the tooltip. |font_list|
32 // is used to layout |text|. |max_width| comes from GetMaxWidth().
33 static void TrimTooltipToFit(const gfx::FontList
& font_list
,
40 // Adjusts the bounds given by the arguments to fit inside the desktop
41 // and applies the adjusted bounds to the label_.
42 void SetTooltipBounds(const gfx::Point
& mouse_pos
,
43 const gfx::Size
& tooltip_size
);
45 // Destroys |widget_|.
49 int GetMaxWidth(const gfx::Point
& location
,
50 aura::Window
* context
) const override
;
51 void SetText(aura::Window
* window
,
52 const base::string16
& tooltip_text
,
53 const gfx::Point
& location
) override
;
56 bool IsVisible() override
;
59 void OnWidgetDestroying(Widget
* widget
) override
;
61 // The label showing the tooltip.
64 // The widget containing the tooltip. May be NULL.
67 // The window we're showing the tooltip for. Never NULL and valid while
69 aura::Window
* tooltip_window_
;
71 DISALLOW_COPY_AND_ASSIGN(TooltipAura
);
77 #endif // UI_VIEWS_COREWM_TOOLTIP_AURA_H_