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

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

Issue 8917011: Change signature of |ui::ElideText()|. Add a truncate mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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
« no previous file with comments | « printing/print_settings_initializer.cc ('k') | ui/base/text/text_elider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 base::SplitString(*text, '\n', &lines); 88 base::SplitString(*text, '\n', &lines);
89 if (lines.size() > kMaxLines) 89 if (lines.size() > kMaxLines)
90 lines.resize(kMaxLines); 90 lines.resize(kMaxLines);
91 *line_count = static_cast<int>(lines.size()); 91 *line_count = static_cast<int>(lines.size());
92 92
93 // Format each line to fit. 93 // Format each line to fit.
94 gfx::Font font = GetDefaultFont(); 94 gfx::Font font = GetDefaultFont();
95 string16 result; 95 string16 result;
96 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end(); 96 for (std::vector<string16>::iterator i = lines.begin(); i != lines.end();
97 ++i) { 97 ++i) {
98 string16 elided_text = ui::ElideText(*i, font, available_width, false); 98 string16 elided_text =
99 ui::ElideText(*i, font, available_width, ui::ELIDE_AT_END);
99 *max_width = std::max(*max_width, font.GetStringWidth(elided_text)); 100 *max_width = std::max(*max_width, font.GetStringWidth(elided_text));
100 if (!result.empty()) 101 if (!result.empty())
101 result.push_back('\n'); 102 result.push_back('\n');
102 result.append(elided_text); 103 result.append(elided_text);
103 } 104 }
104 *text = result; 105 *text = result;
105 } 106 }
106 107
107 // Creates a widget of type TYPE_TOOLTIP 108 // Creates a widget of type TYPE_TOOLTIP
108 views::Widget* CreateTooltip() { 109 views::Widget* CreateTooltip() {
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 string16 tooltip_text(tooltip_text_); 288 string16 tooltip_text(tooltip_text_);
288 gfx::Point widget_loc = curr_mouse_loc_; 289 gfx::Point widget_loc = curr_mouse_loc_;
289 widget_loc = widget_loc.Add(tooltip_window_->GetScreenBounds().origin()); 290 widget_loc = widget_loc.Add(tooltip_window_->GetScreenBounds().origin());
290 tooltip_->SetText(tooltip_text, widget_loc); 291 tooltip_->SetText(tooltip_text, widget_loc);
291 tooltip_->Show(); 292 tooltip_->Show();
292 } 293 }
293 } 294 }
294 } 295 }
295 296
296 } // namespace aura_shell 297 } // namespace aura_shell
OLDNEW
« no previous file with comments | « printing/print_settings_initializer.cc ('k') | ui/base/text/text_elider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698