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

Side by Side Diff: ui/message_center/cocoa/notification_controller.mm

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/gfx/text_elider_unittest.cc ('k') | ui/message_center/views/bounded_label.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #import "ui/message_center/cocoa/notification_controller.h" 5 #import "ui/message_center/cocoa/notification_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 // This could be possible when the input text contains only spaces. 826 // This could be possible when the input text contains only spaces.
827 if (wrapped.empty()) 827 if (wrapped.empty())
828 return base::string16(); 828 return base::string16();
829 829
830 if (wrapped.size() > lines) { 830 if (wrapped.size() > lines) {
831 // Add an ellipsis to the last line. If this ellipsis makes the last line 831 // Add an ellipsis to the last line. If this ellipsis makes the last line
832 // too wide, that line will be further elided by the gfx::ElideText below. 832 // too wide, that line will be further elided by the gfx::ElideText below.
833 base::string16 last = 833 base::string16 last =
834 wrapped[lines - 1] + base::UTF8ToUTF16(gfx::kEllipsis); 834 wrapped[lines - 1] + base::UTF8ToUTF16(gfx::kEllipsis);
835 if (gfx::GetStringWidth(last, font_list) > width) 835 if (gfx::GetStringWidth(last, font_list) > width)
836 last = gfx::ElideText(last, font_list, width, gfx::ELIDE_AT_END); 836 last = gfx::ElideText(last, font_list, width, gfx::ELIDE_TAIL);
837 wrapped.resize(lines - 1); 837 wrapped.resize(lines - 1);
838 wrapped.push_back(last); 838 wrapped.push_back(last);
839 } 839 }
840 840
841 *actualLines = wrapped.size(); 841 *actualLines = wrapped.size();
842 return lines == 1 ? wrapped[0] : JoinString(wrapped, '\n'); 842 return lines == 1 ? wrapped[0] : JoinString(wrapped, '\n');
843 } 843 }
844 844
845 - (base::string16)wrapText:(const base::string16&)text 845 - (base::string16)wrapText:(const base::string16&)text
846 forFont:(NSFont*)nsfont 846 forFont:(NSFont*)nsfont
847 maxNumberOfLines:(size_t)lines { 847 maxNumberOfLines:(size_t)lines {
848 size_t unused; 848 size_t unused;
849 return [self wrapText:text 849 return [self wrapText:text
850 forFont:nsfont 850 forFont:nsfont
851 maxNumberOfLines:lines 851 maxNumberOfLines:lines
852 actualLines:&unused]; 852 actualLines:&unused];
853 } 853 }
854 854
855 @end 855 @end
OLDNEW
« no previous file with comments | « ui/gfx/text_elider_unittest.cc ('k') | ui/message_center/views/bounded_label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698