OLD | NEW |
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 kRegularTextBackgroundColor); | 392 kRegularTextBackgroundColor); |
393 title_view_->set_border(MakeTextBorder(3, 0)); | 393 title_view_->set_border(MakeTextBorder(3, 0)); |
394 top_view_->AddChildView(title_view_); | 394 top_view_->AddChildView(title_view_); |
395 } | 395 } |
396 | 396 |
397 // Create the message view if appropriate. | 397 // Create the message view if appropriate. |
398 message_view_ = NULL; | 398 message_view_ = NULL; |
399 if (!notification.message().empty()) { | 399 if (!notification.message().empty()) { |
400 message_view_ = new BoundedLabel( | 400 message_view_ = new BoundedLabel( |
401 ui::TruncateString(notification.message(), kMessageCharacterLimit)); | 401 ui::TruncateString(notification.message(), kMessageCharacterLimit)); |
| 402 message_view_->SetLineHeight(kMessageLineHeight); |
402 message_view_->SetVisible(!is_expanded() || !notification.items().size()); | 403 message_view_->SetVisible(!is_expanded() || !notification.items().size()); |
403 message_view_->SetColors(kDimTextColor, kDimTextBackgroundColor); | 404 message_view_->SetColors(kDimTextColor, kDimTextBackgroundColor); |
404 message_view_->set_border(MakeTextBorder(4, 1)); | 405 message_view_->set_border(MakeTextBorder(4, 1)); |
405 top_view_->AddChildView(message_view_); | 406 top_view_->AddChildView(message_view_); |
406 } | 407 } |
407 | 408 |
408 // Create the list item views (up to a maximum). | 409 // Create the list item views (up to a maximum). |
409 std::vector<NotificationItem> items = notification.items(); | 410 std::vector<NotificationItem> items = notification.items(); |
410 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { | 411 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { |
411 ItemView* item_view = new ItemView(items[i]); | 412 ItemView* item_view = new ItemView(items[i]); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 int content_width = width - GetInsets().width(); | 488 int content_width = width - GetInsets().width(); |
488 int top_height = top_view_->GetHeightForWidth(content_width); | 489 int top_height = top_view_->GetHeightForWidth(content_width); |
489 int bottom_height = bottom_view_->GetHeightForWidth(content_width); | 490 int bottom_height = bottom_view_->GetHeightForWidth(content_width); |
490 int total_height = std::max(top_height, kIconSize) + | 491 int total_height = std::max(top_height, kIconSize) + |
491 bottom_height + GetInsets().height(); | 492 bottom_height + GetInsets().height(); |
492 | 493 |
493 // Fix for http://crbug.com/230448: Adjust the height when the message_view's | 494 // Fix for http://crbug.com/230448: Adjust the height when the message_view's |
494 // line limit would be different for the specified width than it currently is. | 495 // line limit would be different for the specified width than it currently is. |
495 // TODO(dharcourt): Avoid BoxLayout and directly compute the correct height. | 496 // TODO(dharcourt): Avoid BoxLayout and directly compute the correct height. |
496 if (message_view_ && title_view_) { | 497 if (message_view_ && title_view_) { |
497 int used_limit = message_view_->line_limit(); | 498 int used_limit = message_view_->GetLineLimit(); |
498 int correct_limit = GetMessageLineLimit(width); | 499 int correct_limit = GetMessageLineLimit(width); |
499 if (used_limit != correct_limit) { | 500 if (used_limit != correct_limit) { |
500 total_height -= GetMessageHeight(content_width, used_limit); | 501 total_height -= GetMessageHeight(content_width, used_limit); |
501 total_height += GetMessageHeight(content_width, correct_limit); | 502 total_height += GetMessageHeight(content_width, correct_limit); |
502 } | 503 } |
503 } | 504 } |
504 | 505 |
505 return total_height; | 506 return total_height; |
506 } | 507 } |
507 | 508 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 return message_view_ ? | 605 return message_view_ ? |
605 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; | 606 message_view_->GetLinesForWidthAndLimit(width, limit) : 0; |
606 } | 607 } |
607 | 608 |
608 int NotificationView::GetMessageHeight(int width, int limit) { | 609 int NotificationView::GetMessageHeight(int width, int limit) { |
609 return message_view_ ? | 610 return message_view_ ? |
610 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 611 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
611 } | 612 } |
612 | 613 |
613 } // namespace message_center | 614 } // namespace message_center |
OLD | NEW |