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

Unified Diff: ui/message_center/views/notification_view_md.cc

Issue 2966693002: Move overflow indicator to notifiction header. (Closed)
Patch Set: Resolve review comments. Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/message_center/views/notification_view_md.h ('k') | ui/strings/ui_strings.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2f9e2c54fd3867cc1128fe72d7664471bc5c9b29..9625f54d48f1e5f11fa31e8990e3ee3dcae9ae9e 100644
--- a/ui/message_center/views/notification_view_md.cc
+++ b/ui/message_center/views/notification_view_md.cc
@@ -72,7 +72,6 @@ const SkColor kActionButtonTextColor = SkColorSetRGB(0x33, 0x67, 0xD6);
constexpr int kMaxLinesForMessageView = 1;
constexpr int kMaxLinesForExpandedMessageView = 4;
-constexpr int kListNotificationOverflowIndicatorSpacing = 4;
constexpr int kCompactTitleMessageViewSpacing = 12;
constexpr int kProgressBarHeight = 4;
@@ -117,85 +116,31 @@ class ItemView : public views::View {
explicit ItemView(const message_center::NotificationItem& item);
~ItemView() override;
- void SetRemainingCount(int num_remaining);
- void SetRemainingCountVisible(bool visible);
-
private:
- class LayoutManager : public views::FillLayout {
- public:
- LayoutManager(ItemView* item_view)
- : views::FillLayout(), item_view_(item_view) {}
-
- void Layout(View* host) override {
- gfx::Rect container_bounds = host->GetContentsBounds();
- if (item_view_->remaining_count_->visible()) {
- // Show the full content of the overflow indicator and collapse the
- // message container.
- container_bounds.set_width(
- container_bounds.width() -
- item_view_->remaining_count_->GetPreferredSize().width() -
- kListNotificationOverflowIndicatorSpacing);
- }
- item_view_->container_->SetBoundsRect(container_bounds);
- item_view_->remaining_count_->SetBoundsRect(host->GetContentsBounds());
- }
-
- private:
- ItemView* item_view_;
- };
-
- // Container of the title and the message.
- views::View* container_;
- // Overflow indicator e.g. "+3" shown on the right bottom.
- views::Label* remaining_count_;
-
DISALLOW_COPY_AND_ASSIGN(ItemView);
};
ItemView::ItemView(const message_center::NotificationItem& item) {
- SetLayoutManager(new ItemView::LayoutManager(this));
-
- container_ = new views::View;
- AddChildView(container_);
- container_->SetLayoutManager(
- new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(),
- message_center::kItemTitleToMessagePadding));
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, gfx::Insets(), 0));
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::kDimTextBackgroundColor);
- container_->AddChildView(title);
+ AddChildView(title);
- views::Label* message = new views::Label(item.message);
+ views::Label* message = new views::Label(l10n_util::GetStringFUTF16(
+ IDS_MESSAGE_CENTER_LIST_NOTIFICATION_MESSAGE_WITH_DIVIDER, item.message));
message->set_collapse_when_hidden(true);
message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
message->SetEnabledColor(message_center::kDimTextColor);
message->SetBackgroundColor(message_center::kDimTextBackgroundColor);
- container_->AddChildView(message);
-
- remaining_count_ = new views::Label();
- remaining_count_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
- remaining_count_->SetEnabledColor(message_center::kDimTextColor);
- remaining_count_->SetBackgroundColor(message_center::kDimTextBackgroundColor);
- remaining_count_->SetVisible(false);
- AddChildView(remaining_count_);
+ AddChildView(message);
}
-ItemView::~ItemView() {}
-
-void ItemView::SetRemainingCount(int num_remaining) {
- if (num_remaining > 0) {
- remaining_count_->SetText(l10n_util::GetStringFUTF16Int(
- IDS_MESSAGE_CENTER_LIST_NOTIFICATION_OVERFLOW_INDICATOR,
- num_remaining));
- }
-}
-
-void ItemView::SetRemainingCountVisible(bool visible) {
- remaining_count_->SetVisible(visible);
-}
+ItemView::~ItemView() = default;
// CompactTitleMessageView /////////////////////////////////////////////////////
@@ -637,13 +582,11 @@ void NotificationViewMD::CreateOrUpdateListItemViews(
left_content_->AddChildView(item_view);
}
- if (!item_views_.empty()) {
- item_views_.front()->SetRemainingCount(items.size() - 1);
- item_views_.back()->SetRemainingCount(items.size() - item_views_.size());
+ list_items_count_ = items.size();
- // Needed when CreateOrUpdateViews is called for update.
+ // Needed when CreateOrUpdateViews is called for update.
+ if (!item_views_.empty())
left_content_->InvalidateLayout();
- }
}
void NotificationViewMD::CreateOrUpdateIconView(
@@ -811,13 +754,12 @@ 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) {
+ for (size_t i = kMaxLinesForMessageView; i < item_views_.size(); ++i) {
item_views_[i]->SetVisible(expanded);
}
- if (!item_views_.empty()) {
- item_views_.front()->SetRemainingCountVisible(!expanded);
- item_views_.back()->SetRemainingCountVisible(expanded);
- }
+ header_row_->SetOverflowIndicator(
+ list_items_count_ -
+ (expanded ? item_views_.size() : kMaxLinesForMessageView));
}
void NotificationViewMD::UpdateControlButtonsVisibility() {
« no previous file with comments | « ui/message_center/views/notification_view_md.h ('k') | ui/strings/ui_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698