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 5bc79bc9a6ec7150cd32af78df7421cb7ea801c4..807c85f37c47db0e3669d6cc594516130cb15c31 100644 |
| --- a/ui/message_center/views/notification_view_md.cc |
| +++ b/ui/message_center/views/notification_view_md.cc |
| @@ -86,6 +86,53 @@ 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; |
| + |
| + // Overridden from views::View: |
| + void SetVisible(bool visible) override; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ItemView); |
| +}; |
| + |
| +ItemView::ItemView(const message_center::NotificationItem& item) { |
| + SetLayoutManager( |
| + new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
| + message_center::kItemTitleToMessagePadding)); |
| + |
| + views::Label* title = new views::Label(item.title); |
| + title->set_collapse_when_hidden(true); |
| + title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + title->SetEnabledColor(message_center::kRegularTextColor); |
| + title->SetBackgroundColor(message_center::kRegularTextBackgroundColor); |
| + AddChildView(title); |
| + |
| + views::Label* message = new views::Label(item.message); |
| + message->set_collapse_when_hidden(true); |
| + message->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| + message->SetEnabledColor(message_center::kDimTextColor); |
| + message->SetBackgroundColor(message_center::kDimTextBackgroundColor); |
| + AddChildView(message); |
| + |
| + PreferredSizeChanged(); |
|
yoshiki
2017/06/05 04:29:13
I think this is not necessary, since the preferred
tetsui
2017/06/13 03:44:33
Done.
|
| + SchedulePaint(); |
|
yoshiki
2017/06/05 04:29:13
I also think this is not necessary, since adding a
tetsui
2017/06/13 03:44:33
Done.
|
| +} |
| + |
| +ItemView::~ItemView() {} |
| + |
| +void ItemView::SetVisible(bool visible) { |
| + views::View::SetVisible(visible); |
| + for (int i = 0; i < child_count(); ++i) |
| + child_at(i)->SetVisible(visible); |
|
yoshiki
2017/06/05 04:29:13
It looks necessary? I think setting visibility of
tetsui
2017/06/13 03:44:33
Done.
|
| +} |
| + |
| } // anonymous namespace |
| // //////////////////////////////////////////////////////////// |
| @@ -372,7 +419,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(); |
| + |
| + if (items.size() == 0) |
| + return; |
| + |
| + DCHECK(top_view_); |
|
yoshiki
2017/06/05 04:29:13
Should we check main_view_ instead of top_view_, s
tetsui
2017/06/13 03:44:33
Done.
|
| + for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { |
| + ItemView* item_view = new ItemView(items[i]); |
| + item_views_.push_back(item_view); |
| + main_view_->AddChildView(item_view); |
| + } |
| } |
| void NotificationViewMD::CreateOrUpdateIconView( |