Chromium Code Reviews| Index: ui/message_center/views/notification_view_md.cc |
| diff --git a/ui/message_center/views/notification_view_md.cc b/ui/message_center/views/notification_view_md.cc |
| index d8b64defbcc427a886f99b737449cf58b6b46f99..081f80853db523dca82b3facc4cc7e1d2de0a7da 100644 |
| --- a/ui/message_center/views/notification_view_md.cc |
| +++ b/ui/message_center/views/notification_view_md.cc |
| @@ -7,6 +7,7 @@ |
| #include <stddef.h> |
| #include "base/strings/string_util.h" |
| +#include "base/strings/utf_string_conversions.h" |
| #include "ui/base/cursor/cursor.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/gfx/geometry/size.h" |
| @@ -90,6 +91,34 @@ const gfx::ImageSkia GetProductIcon() { |
| return gfx::CreateVectorIcon(kProductIcon, kSmallImageColor); |
| } |
| +// ItemView //////////////////////////////////////////////////////////////////// |
| + |
| +// ItemViews are responsible for drawing each list notification item's title and |
| +// message next to each other within a single column. |
| +class ItemView : public views::View { |
| + public: |
| + explicit ItemView(const message_center::NotificationItem& item); |
| + ~ItemView() override; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ItemView); |
| +}; |
| + |
| +ItemView::ItemView(const message_center::NotificationItem& item) { |
| + SetLayoutManager( |
| + new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(), 0)); |
| + |
| + views::Label* message = |
| + new views::Label(item.title + base::ASCIIToUTF16(" - ") + item.message); |
|
fukino
2017/06/13 04:27:09
We should have separate between title and message
fukino
2017/06/13 04:27:09
Can we have darker color for item.title than item.
tetsui
2017/06/13 04:55:03
In my understanding, list notification and bundle
tetsui
2017/06/13 04:55:03
Done.
|
| + message->set_collapse_when_hidden(true); |
| + message->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + message->SetEnabledColor(message_center::kDimTextColor); |
| + message->SetBackgroundColor(message_center::kDimTextBackgroundColor); |
| + AddChildView(message); |
| +} |
| + |
| +ItemView::~ItemView() {} |
| + |
| } // anonymous namespace |
| // //////////////////////////////////////////////////////////// |
| @@ -347,6 +376,8 @@ void NotificationViewMD::CreateOrUpdateMessageView( |
| } else { |
| message_view_->SetText(text); |
| } |
| + |
| + message_view_->SetVisible(notification.items().empty()); |
| } |
| void NotificationViewMD::CreateOrUpdateProgressBarView( |
| @@ -356,7 +387,21 @@ void NotificationViewMD::CreateOrUpdateProgressBarView( |
| void NotificationViewMD::CreateOrUpdateListItemViews( |
| const Notification& notification) { |
| - // TODO(yoshiki): Implement this. |
| + for (auto* item_view : item_views_) |
| + delete item_view; |
| + item_views_.clear(); |
| + |
| + const std::vector<NotificationItem>& items = notification.items(); |
| + |
| + for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { |
| + ItemView* item_view = new ItemView(items[i]); |
| + item_views_.push_back(item_view); |
| + left_content_->AddChildView(item_view); |
| + } |
| + |
| + // Needed when CreateOrUpdateViews is called for update. |
| + left_content_->Layout(); |
| + left_content_->SchedulePaint(); |
| } |
| void NotificationViewMD::CreateOrUpdateIconView( |
| @@ -485,6 +530,11 @@ bool NotificationViewMD::IsExpandable() { |
| if (image_view_) |
| return true; |
| + // Expandable if there are multiple list items. |
| + if (item_views_.size() > 1) { |
|
fukino
2017/06/13 04:27:09
nit: We usually omit curly braces for 1-line if st
tetsui
2017/06/13 04:55:03
Done.
|
| + return true; |
| + } |
| + |
| // TODO(fukino): Expandable if both progress bar and message exist. |
| return false; |
| @@ -507,6 +557,9 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) { |
| if (image_container_) |
| image_container_->SetVisible(expanded); |
| actions_row_->SetVisible(expanded && actions_row_->has_children()); |
| + for (size_t i = 1; i < item_views_.size(); ++i) { |
| + item_views_[i]->SetVisible(expanded); |
| + } |
| } |
| void NotificationViewMD::UpdateControlButtonsVisibility() { |