[SyncFS] Build indexes from FileTracker entries on disk.
[chromium-blink-merge.git] / ui / views / corewm / tooltip_aura.h
blobead119f5d95889c4a1e2e5fc1a5f72f4d807ef4c
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"
13 namespace gfx {
14 class FontList;
15 } // namespace gfx
17 namespace views {
19 class Widget;
21 namespace corewm {
23 // Implementation of Tooltip that shows the tooltip using a Widget and Label.
24 class VIEWS_EXPORT TooltipAura : public Tooltip, public WidgetObserver {
25 public:
26 explicit TooltipAura(gfx::ScreenType screen_type);
27 virtual ~TooltipAura();
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,
34 int max_width,
35 base::string16* text,
36 int* width,
37 int* line_count);
39 private:
40 // Returns the max width of the tooltip when shown at the specified location.
41 int GetMaxWidth(const gfx::Point& location) const;
43 // Adjusts the bounds given by the arguments to fit inside the desktop
44 // and applies the adjusted bounds to the label_.
45 void SetTooltipBounds(const gfx::Point& mouse_pos,
46 int tooltip_width,
47 int tooltip_height);
49 // Destroys |widget_|.
50 void DestroyWidget();
52 // Tooltip:
53 virtual void SetText(aura::Window* window,
54 const base::string16& tooltip_text,
55 const gfx::Point& location) OVERRIDE;
56 virtual void Show() OVERRIDE;
57 virtual void Hide() OVERRIDE;
58 virtual bool IsVisible() OVERRIDE;
60 // WidgetObserver:
61 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE;
63 const gfx::ScreenType screen_type_;
65 // The label showing the tooltip.
66 Label label_;
68 // The widget containing the tooltip. May be NULL.
69 Widget* widget_;
71 // The window we're showing the tooltip for. Never NULL and valid while
72 // showing.
73 aura::Window* tooltip_window_;
75 DISALLOW_COPY_AND_ASSIGN(TooltipAura);
78 } // namespace corewm
79 } // namespace views
81 #endif // UI_VIEWS_COREWM_TOOLTIP_AURA_H_