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

Side by Side Diff: ui/aura_shell/shell_tooltip_manager.cc

Issue 8780001: aura: Make aura::TooltipClient completely static? (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged with upstream Created 9 years 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "ui/aura_shell/shell_tooltip_manager.h" 5 #include "ui/aura_shell/shell_tooltip_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 11 matching lines...) Expand all
22 #include "ui/views/background.h" 22 #include "ui/views/background.h"
23 #include "ui/views/border.h" 23 #include "ui/views/border.h"
24 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
25 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
26 26
27 namespace { 27 namespace {
28 28
29 SkColor kTooltipBackground = 0xFFFFFFCC; 29 SkColor kTooltipBackground = 0xFFFFFFCC;
30 SkColor kTooltipBorder = 0xFF000000; 30 SkColor kTooltipBorder = 0xFF000000;
31 int kTooltipBorderWidth = 1; 31 int kTooltipBorderWidth = 1;
32 int kTooltipHorizontalPadding = 3;
33 int kTooltipVerticalPadding = 1;
32 int kTooltipTimeoutMs = 500; 34 int kTooltipTimeoutMs = 500;
33 35
34 // FIXME: get cursor offset from actual cursor size. 36 // FIXME: get cursor offset from actual cursor size.
35 int kCursorOffsetX = 10; 37 int kCursorOffsetX = 10;
36 int kCursorOffsetY = 15; 38 int kCursorOffsetY = 15;
37 39
38 // Maximum number of characters we allow in a tooltip. 40 // Maximum number of characters we allow in a tooltip.
39 const size_t kMaxTooltipLength = 1024; 41 const size_t kMaxTooltipLength = 1024;
40 42
41 // Maximum number of lines we allow in the tooltip. 43 // Maximum number of lines we allow in the tooltip.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 widget_->Close(); 121 widget_->Close();
120 } 122 }
121 123
122 // Updates the text on the tooltip and resizes to fit. 124 // Updates the text on the tooltip and resizes to fit.
123 void SetText(string16 tooltip_text, gfx::Point location) { 125 void SetText(string16 tooltip_text, gfx::Point location) {
124 int max_width, line_count; 126 int max_width, line_count;
125 TrimTooltipToFit(&tooltip_text, &max_width, &line_count, 127 TrimTooltipToFit(&tooltip_text, &max_width, &line_count,
126 location.x(), location.y()); 128 location.x(), location.y());
127 label_.SetText(tooltip_text); 129 label_.SetText(tooltip_text);
128 130
129 SetTooltipBounds(location, max_width + 2 * kTooltipBorderWidth, 131 SetTooltipBounds(location,
130 label_.GetPreferredSize().height()); 132 max_width + 2 * kTooltipBorderWidth + 2 * kTooltipHorizontalPadding,
133 label_.GetPreferredSize().height() + 2 * kTooltipVerticalPadding);
131 } 134 }
132 135
133 // Shows the tooltip. 136 // Shows the tooltip.
134 void Show() { 137 void Show() {
135 widget_->Show(); 138 widget_->Show();
136 } 139 }
137 140
138 // Hides the tooltip. 141 // Hides the tooltip.
139 void Hide() { 142 void Hide() {
140 widget_->Hide(); 143 widget_->Hide();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 ui::ResourceBundle::BaseFont); 274 ui::ResourceBundle::BaseFont);
272 } 275 }
273 276
274 // static 277 // static
275 int TooltipClient::GetMaxWidth(int x, int y) { 278 int TooltipClient::GetMaxWidth(int x, int y) {
276 gfx::Rect monitor_bounds = 279 gfx::Rect monitor_bounds =
277 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point(x, y)); 280 gfx::Screen::GetMonitorAreaNearestPoint(gfx::Point(x, y));
278 return (monitor_bounds.width() + 1) / 2; 281 return (monitor_bounds.width() + 1) / 2;
279 } 282 }
280 283
284 // static
285 void TooltipClient::UpdateTooltip(Window* target) {
286 if (aura_shell::Shell::GetInstance()->tooltip_manager())
287 aura_shell::Shell::GetInstance()->tooltip_manager()->UpdateTooltip(target);
288 }
289
281 } // namespace aura 290 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698