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

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

Issue 312233003: Add fade eliding for Views Labels; related cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refine alignment check; minor additional cleanup. 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 | « ui/views/controls/label_unittest.cc ('k') | ui/views/corewm/tooltip_aura_unittest.cc » ('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 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 #include "ui/views/corewm/tooltip_aura.h" 5 #include "ui/views/corewm/tooltip_aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/aura/window_tree_host.h" 10 #include "ui/aura/window_tree_host.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 l != result_lines.end(); ++l) { 128 l != result_lines.end(); ++l) {
129 if (!result.empty()) 129 if (!result.empty())
130 result.push_back('\n'); 130 result.push_back('\n');
131 int line_width = gfx::GetStringWidth(*l, font_list); 131 int line_width = gfx::GetStringWidth(*l, font_list);
132 // Since we only break at word boundaries, it could happen that due to some 132 // Since we only break at word boundaries, it could happen that due to some
133 // very long word, line_width is greater than the available_width. In such 133 // very long word, line_width is greater than the available_width. In such
134 // case, we simply truncate at available_width and add ellipses at the end. 134 // case, we simply truncate at available_width and add ellipses at the end.
135 if (line_width > available_width) { 135 if (line_width > available_width) {
136 *width = available_width; 136 *width = available_width;
137 result.append(gfx::ElideText(*l, font_list, available_width, 137 result.append(gfx::ElideText(*l, font_list, available_width,
138 gfx::ELIDE_AT_END)); 138 gfx::ELIDE_TAIL));
139 } else { 139 } else {
140 *width = std::max(*width, line_width); 140 *width = std::max(*width, line_width);
141 result.append(*l); 141 result.append(*l);
142 } 142 }
143 } 143 }
144 *text = result; 144 *text = result;
145 } 145 }
146 146
147 int TooltipAura::GetMaxWidth(const gfx::Point& location) const { 147 int TooltipAura::GetMaxWidth(const gfx::Point& location) const {
148 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure 148 // TODO(varunjain): implementation duplicated in tooltip_manager_aura. Figure
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 237 }
238 238
239 void TooltipAura::OnWidgetDestroying(views::Widget* widget) { 239 void TooltipAura::OnWidgetDestroying(views::Widget* widget) {
240 DCHECK_EQ(widget_, widget); 240 DCHECK_EQ(widget_, widget);
241 widget_ = NULL; 241 widget_ = NULL;
242 tooltip_window_ = NULL; 242 tooltip_window_ = NULL;
243 } 243 }
244 244
245 } // namespace corewm 245 } // namespace corewm
246 } // namespace views 246 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/label_unittest.cc ('k') | ui/views/corewm/tooltip_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698