Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: ui/views/corewm/tooltip_aura.h

Issue 340543004: views: Support longer tooltips. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more simplification Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/views/corewm/tooltip_aura.cc » ('j') | ui/views/corewm/tooltip_aura.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ui/views/widget/widget_observer.h" 11 #include "ui/views/widget/widget_observer.h"
12 12
13 namespace gfx { 13 namespace gfx {
14 class FontList; 14 class FontList;
15 } // namespace gfx 15 } // namespace gfx
16 16
17 namespace views { 17 namespace views {
18 18
19 class Widget; 19 class Widget;
20 20
21 namespace corewm { 21 namespace corewm {
22 22
23 // Implementation of Tooltip that shows the tooltip using a Widget and Label. 23 // Implementation of Tooltip that shows the tooltip using a Widget and Label.
24 class VIEWS_EXPORT TooltipAura : public Tooltip, public WidgetObserver { 24 class VIEWS_EXPORT TooltipAura : public Tooltip, public WidgetObserver {
25 public: 25 public:
26 // Preferred maximum tooltip width, in pixels. If a tooltip's text is wider
27 // than this width, it will be wrapped (unless doing so would truncate words
28 // in the text).
29 static const int kPreferredWidthPixels;
30
26 explicit TooltipAura(gfx::ScreenType screen_type); 31 explicit TooltipAura(gfx::ScreenType screen_type);
27 virtual ~TooltipAura(); 32 virtual ~TooltipAura();
28 33
29 // Trims the tooltip to fit in the width |max_width|, setting |text| to the 34 // Trims |text| to fit in |max_size|, setting |text| to the clipped result,
30 // clipped result, |width| to the width (in pixels) of the clipped text 35 // |width| to the width (in pixels) of the clipped text and |line_count| to
31 // and |line_count| to the number of lines of text in the tooltip. |font_list| 36 // the number of lines of text in the tooltip. |font_list| is used to layout
32 // is used to layout |text|. |max_width| comes from GetMaxWidth(). 37 // |text|. |max_size| comes from GetMaxSize().
33 static void TrimTooltipToFit(const gfx::FontList& font_list, 38 static void TrimTooltipToFit(const gfx::FontList& font_list,
34 int max_width, 39 const gfx::Size& max_size,
35 base::string16* text, 40 base::string16* text,
36 int* width, 41 int* width,
37 int* line_count); 42 int* line_count);
38 43
39 private: 44 private:
40 // Returns the max width of the tooltip when shown at the specified location. 45 // Returns the max size of the tooltip when shown at the specified location.
41 int GetMaxWidth(const gfx::Point& location) const; 46 gfx::Size GetMaxSize(const gfx::Point& location) const;
42 47
43 // Adjusts the bounds given by the arguments to fit inside the desktop 48 // Adjusts the bounds given by the arguments to fit inside the desktop
44 // and applies the adjusted bounds to the label_. 49 // and applies the adjusted bounds to |label_|.
45 void SetTooltipBounds(const gfx::Point& mouse_pos, 50 void SetTooltipBounds(const gfx::Point& mouse_pos,
46 int tooltip_width, 51 const gfx::Size& tooltip_size);
47 int tooltip_height);
48 52
49 // Destroys |widget_|. 53 // Destroys |widget_|.
50 void DestroyWidget(); 54 void DestroyWidget();
51 55
52 // Tooltip: 56 // Tooltip:
53 virtual void SetText(aura::Window* window, 57 virtual void SetText(aura::Window* window,
54 const base::string16& tooltip_text, 58 const base::string16& tooltip_text,
55 const gfx::Point& location) OVERRIDE; 59 const gfx::Point& location) OVERRIDE;
56 virtual void Show() OVERRIDE; 60 virtual void Show() OVERRIDE;
57 virtual void Hide() OVERRIDE; 61 virtual void Hide() OVERRIDE;
(...skipping 14 matching lines...) Expand all
72 // showing. 76 // showing.
73 aura::Window* tooltip_window_; 77 aura::Window* tooltip_window_;
74 78
75 DISALLOW_COPY_AND_ASSIGN(TooltipAura); 79 DISALLOW_COPY_AND_ASSIGN(TooltipAura);
76 }; 80 };
77 81
78 } // namespace corewm 82 } // namespace corewm
79 } // namespace views 83 } // namespace views
80 84
81 #endif // UI_VIEWS_COREWM_TOOLTIP_AURA_H_ 85 #endif // UI_VIEWS_COREWM_TOOLTIP_AURA_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/corewm/tooltip_aura.cc » ('j') | ui/views/corewm/tooltip_aura.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698