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

Side by Side Diff: ui/message_center/views/notification_view.cc

Issue 256883002: Update notification style: allow 2-line titles if the message is blank. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix rsesek comments. Created 6 years, 7 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/message_center/views/constants.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/message_center/views/notification_view.h" 5 #include "ui/message_center/views/notification_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 MakeEmptyBorder(kTextTopPadding - 8, 0, kTextBottomPadding - 5, 0)); 316 MakeEmptyBorder(kTextTopPadding - 8, 0, kTextBottomPadding - 5, 0));
317 317
318 const gfx::FontList default_label_font_list = views::Label().font_list(); 318 const gfx::FontList default_label_font_list = views::Label().font_list();
319 319
320 // Create the title view if appropriate. 320 // Create the title view if appropriate.
321 title_view_ = NULL; 321 title_view_ = NULL;
322 if (!notification.title().empty()) { 322 if (!notification.title().empty()) {
323 const gfx::FontList& font_list = 323 const gfx::FontList& font_list =
324 default_label_font_list.DeriveWithSizeDelta(2); 324 default_label_font_list.DeriveWithSizeDelta(2);
325 int padding = kTitleLineHeight - font_list.GetHeight(); 325 int padding = kTitleLineHeight - font_list.GetHeight();
326 int title_lines = notification.message().empty() ? kTitleNoMessageLineLimit
327 : kTitleLineLimit;
328 int title_character_limit =
329 kNotificationWidth * title_lines / kMinPixelsPerTitleCharacter;
326 title_view_ = new BoundedLabel( 330 title_view_ = new BoundedLabel(
327 gfx::TruncateString(notification.title(), kTitleCharacterLimit), 331 gfx::TruncateString(notification.title(), title_character_limit),
328 font_list); 332 font_list);
329 title_view_->SetLineHeight(kTitleLineHeight); 333 title_view_->SetLineHeight(kTitleLineHeight);
330 title_view_->SetLineLimit(message_center::kTitleLineLimit); 334 title_view_->SetLineLimit(title_lines);
331 title_view_->SetColors(message_center::kRegularTextColor, 335 title_view_->SetColors(message_center::kRegularTextColor,
332 kRegularTextBackgroundColor); 336 kRegularTextBackgroundColor);
333 title_view_->SetBorder(MakeTextBorder(padding, 3, 0)); 337 title_view_->SetBorder(MakeTextBorder(padding, 3, 0));
334 top_view_->AddChildView(title_view_); 338 top_view_->AddChildView(title_view_);
335 accessible_lines.push_back(notification.title()); 339 accessible_lines.push_back(notification.title());
336 } 340 }
337 341
338 // Create the message view if appropriate. 342 // Create the message view if appropriate.
339 message_view_ = NULL; 343 message_view_ = NULL;
340 if (!notification.message().empty()) { 344 if (!notification.message().empty()) {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 DCHECK_GT(message_line_limit, 0); 608 DCHECK_GT(message_line_limit, 0);
605 return message_line_limit; 609 return message_line_limit;
606 } 610 }
607 611
608 int NotificationView::GetMessageHeight(int width, int limit) { 612 int NotificationView::GetMessageHeight(int width, int limit) {
609 return message_view_ ? 613 return message_view_ ?
610 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 614 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
611 } 615 }
612 616
613 } // namespace message_center 617 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/constants.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698