| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 // Dimensions. | 52 // Dimensions. |
| 53 const int kProgressBarBottomPadding = 0; | 53 const int kProgressBarBottomPadding = 0; |
| 54 | 54 |
| 55 // static | 55 // static |
| 56 std::unique_ptr<views::Border> MakeEmptyBorder(int top, | 56 std::unique_ptr<views::Border> MakeEmptyBorder(int top, |
| 57 int left, | 57 int left, |
| 58 int bottom, | 58 int bottom, |
| 59 int right) { | 59 int right) { |
| 60 return views::Border::CreateEmptyBorder(top, left, bottom, right); | 60 return views::CreateEmptyBorder(top, left, bottom, right); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // static | 63 // static |
| 64 std::unique_ptr<views::Border> MakeTextBorder(int padding, | 64 std::unique_ptr<views::Border> MakeTextBorder(int padding, |
| 65 int top, | 65 int top, |
| 66 int bottom) { | 66 int bottom) { |
| 67 // Split the padding between the top and the bottom, then add the extra space. | 67 // Split the padding between the top and the bottom, then add the extra space. |
| 68 return MakeEmptyBorder(padding / 2 + top, | 68 return MakeEmptyBorder(padding / 2 + top, |
| 69 message_center::kTextLeftPadding, | 69 message_center::kTextLeftPadding, |
| 70 (padding + 1) / 2 + bottom, | 70 (padding + 1) / 2 + bottom, |
| 71 message_center::kTextRightPadding); | 71 message_center::kTextRightPadding); |
| 72 } | 72 } |
| 73 | 73 |
| 74 // static | 74 // static |
| 75 std::unique_ptr<views::Border> MakeProgressBarBorder(int top, int bottom) { | 75 std::unique_ptr<views::Border> MakeProgressBarBorder(int top, int bottom) { |
| 76 return MakeEmptyBorder(top, | 76 return MakeEmptyBorder(top, |
| 77 message_center::kTextLeftPadding, | 77 message_center::kTextLeftPadding, |
| 78 bottom, | 78 bottom, |
| 79 message_center::kTextRightPadding); | 79 message_center::kTextRightPadding); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 std::unique_ptr<views::Border> MakeSeparatorBorder(int top, | 83 std::unique_ptr<views::Border> MakeSeparatorBorder(int top, |
| 84 int left, | 84 int left, |
| 85 SkColor color) { | 85 SkColor color) { |
| 86 return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color); | 86 return views::CreateSolidSidedBorder(top, left, 0, 0, color); |
| 87 } | 87 } |
| 88 | 88 |
| 89 // ItemView //////////////////////////////////////////////////////////////////// | 89 // ItemView //////////////////////////////////////////////////////////////////// |
| 90 | 90 |
| 91 // ItemViews are responsible for drawing each list notification item's title and | 91 // ItemViews are responsible for drawing each list notification item's title and |
| 92 // message next to each other within a single column. | 92 // message next to each other within a single column. |
| 93 class ItemView : public views::View { | 93 class ItemView : public views::View { |
| 94 public: | 94 public: |
| 95 explicit ItemView(const message_center::NotificationItem& item); | 95 explicit ItemView(const message_center::NotificationItem& item); |
| 96 ~ItemView() override; | 96 ~ItemView() override; |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 image_container_->AddChildView(image_view_); | 570 image_container_->AddChildView(image_view_); |
| 571 bottom_view_->AddChildViewAt(image_container_, 0); | 571 bottom_view_->AddChildViewAt(image_container_, 0); |
| 572 } | 572 } |
| 573 | 573 |
| 574 DCHECK(image_view_); | 574 DCHECK(image_view_); |
| 575 image_view_->SetImage(notification.image().AsImageSkia(), ideal_size); | 575 image_view_->SetImage(notification.image().AsImageSkia(), ideal_size); |
| 576 | 576 |
| 577 gfx::Size scaled_size = message_center::GetImageSizeForContainerSize( | 577 gfx::Size scaled_size = message_center::GetImageSizeForContainerSize( |
| 578 ideal_size, notification.image().Size()); | 578 ideal_size, notification.image().Size()); |
| 579 image_view_->SetBorder(ideal_size != scaled_size | 579 image_view_->SetBorder(ideal_size != scaled_size |
| 580 ? views::Border::CreateSolidBorder( | 580 ? views::CreateSolidBorder( |
| 581 message_center::kNotificationImageBorderSize, | 581 message_center::kNotificationImageBorderSize, |
| 582 SK_ColorTRANSPARENT) | 582 SK_ColorTRANSPARENT) |
| 583 : NULL); | 583 : NULL); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void NotificationView::CreateOrUpdateActionButtonViews( | 586 void NotificationView::CreateOrUpdateActionButtonViews( |
| 587 const Notification& notification) { | 587 const Notification& notification) { |
| 588 std::vector<ButtonInfo> buttons = notification.buttons(); | 588 std::vector<ButtonInfo> buttons = notification.buttons(); |
| 589 bool new_buttons = action_buttons_.size() != buttons.size(); | 589 bool new_buttons = action_buttons_.size() != buttons.size(); |
| 590 | 590 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 665 |
| 666 return message_line_limit; | 666 return message_line_limit; |
| 667 } | 667 } |
| 668 | 668 |
| 669 int NotificationView::GetMessageHeight(int width, int limit) const { | 669 int NotificationView::GetMessageHeight(int width, int limit) const { |
| 670 return message_view_ ? | 670 return message_view_ ? |
| 671 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; | 671 message_view_->GetSizeForWidthAndLines(width, limit).height() : 0; |
| 672 } | 672 } |
| 673 | 673 |
| 674 } // namespace message_center | 674 } // namespace message_center |
| OLD | NEW |