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

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

Issue 14322007: Add line height setting to views::Label & use it for notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 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/bounded_label.cc ('k') | ui/views/controls/button/text_button.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) 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/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 kRegularTextBackgroundColor); 405 kRegularTextBackgroundColor);
406 title_view_->set_border(MakeTextBorder(3, 0)); 406 title_view_->set_border(MakeTextBorder(3, 0));
407 top_view_->AddChildView(title_view_); 407 top_view_->AddChildView(title_view_);
408 } 408 }
409 409
410 // Create the message view if appropriate. 410 // Create the message view if appropriate.
411 message_view_ = NULL; 411 message_view_ = NULL;
412 if (!notification.message().empty()) { 412 if (!notification.message().empty()) {
413 message_view_ = new BoundedLabel( 413 message_view_ = new BoundedLabel(
414 ui::TruncateString(notification.message(), kMessageCharacterLimit)); 414 ui::TruncateString(notification.message(), kMessageCharacterLimit));
415 message_view_->SetLineHeight(kMessageLineHeight);
415 message_view_->SetVisible(!is_expanded() || !notification.items().size()); 416 message_view_->SetVisible(!is_expanded() || !notification.items().size());
416 message_view_->SetColors(kDimTextColor, kDimTextBackgroundColor); 417 message_view_->SetColors(kDimTextColor, kDimTextBackgroundColor);
417 message_view_->set_border(MakeTextBorder(4, 1)); 418 message_view_->set_border(MakeTextBorder(4, 1));
418 top_view_->AddChildView(message_view_); 419 top_view_->AddChildView(message_view_);
419 } 420 }
420 421
421 // Create the list item views (up to a maximum). 422 // Create the list item views (up to a maximum).
422 std::vector<NotificationItem> items = notification.items(); 423 std::vector<NotificationItem> items = notification.items();
423 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { 424 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
424 ItemView* item_view = new ItemView(items[i]); 425 ItemView* item_view = new ItemView(items[i]);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 int content_width = width - GetInsets().width(); 501 int content_width = width - GetInsets().width();
501 int top_height = top_view_->GetHeightForWidth(content_width); 502 int top_height = top_view_->GetHeightForWidth(content_width);
502 int bottom_height = bottom_view_->GetHeightForWidth(content_width); 503 int bottom_height = bottom_view_->GetHeightForWidth(content_width);
503 int total_height = std::max(top_height, kIconSize) + 504 int total_height = std::max(top_height, kIconSize) +
504 bottom_height + GetInsets().height(); 505 bottom_height + GetInsets().height();
505 506
506 // Fix for http://crbug.com/230448: Adjust the height when the message_view's 507 // Fix for http://crbug.com/230448: Adjust the height when the message_view's
507 // line limit would be different for the specified width than it currently is. 508 // line limit would be different for the specified width than it currently is.
508 // TODO(dharcourt): Avoid BoxLayout and directly compute the correct height. 509 // TODO(dharcourt): Avoid BoxLayout and directly compute the correct height.
509 if (message_view_ && title_view_) { 510 if (message_view_ && title_view_) {
510 int used_limit = message_view_->line_limit(); 511 int used_limit = message_view_->GetLineLimit();
511 int correct_limit = GetMessageLineLimit(width); 512 int correct_limit = GetMessageLineLimit(width);
512 if (used_limit != correct_limit) { 513 if (used_limit != correct_limit) {
513 total_height -= GetMessageHeight(content_width, used_limit); 514 total_height -= GetMessageHeight(content_width, used_limit);
514 total_height += GetMessageHeight(content_width, correct_limit); 515 total_height += GetMessageHeight(content_width, correct_limit);
515 } 516 }
516 } 517 }
517 518
518 return total_height; 519 return total_height;
519 } 520 }
520 521
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 return message_view_ ? 624 return message_view_ ?
624 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; 625 message_view_->GetLinesForWidthAndLimit(width, limit) : 0;
625 } 626 }
626 627
627 int NotificationView::GetMessageHeight(int width, int limit) { 628 int NotificationView::GetMessageHeight(int width, int limit) {
628 return message_view_ ? 629 return message_view_ ?
629 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; 630 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0;
630 } 631 }
631 632
632 } // namespace message_center 633 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/bounded_label.cc ('k') | ui/views/controls/button/text_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698