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

Side by Side Diff: ui/message_center/notification_view.cc

Issue 11638035: Set a display limit of 8 on multiple-item notifications items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/message_center/message_center_constants.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/notification_view.h" 5 #include "ui/message_center/notification_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "grit/ui_resources.h" 8 #include "grit/ui_resources.h"
9 #include "ui/base/accessibility/accessible_view_state.h" 9 #include "ui/base/accessibility/accessible_view_state.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // close button row, and all item rows. 132 // close button row, and all item rows.
133 layout->StartRow(0, 0); 133 layout->StartRow(0, 0);
134 views::ImageView* icon = new views::ImageView(); 134 views::ImageView* icon = new views::ImageView();
135 icon->SetImageSize(gfx::Size(message_center::kNotificationIconWidth, 135 icon->SetImageSize(gfx::Size(message_center::kNotificationIconWidth,
136 message_center::kNotificationIconWidth)); 136 message_center::kNotificationIconWidth));
137 icon->SetImage(notification_.primary_icon); 137 icon->SetImage(notification_.primary_icon);
138 icon->SetHorizontalAlignment(views::ImageView::LEADING); 138 icon->SetHorizontalAlignment(views::ImageView::LEADING);
139 icon->SetVerticalAlignment(views::ImageView::LEADING); 139 icon->SetVerticalAlignment(views::ImageView::LEADING);
140 icon->set_border(MakePadding(kIconTopPadding, kIconLeftPadding, 140 icon->set_border(MakePadding(kIconTopPadding, kIconLeftPadding,
141 kIconBottomPadding, kIconToTextPadding)); 141 kIconBottomPadding, kIconToTextPadding));
142 layout->AddView(icon, 1, 2 + notification_.items.size()); 142 int displayed_item_count =
143 std::min(notification_.items.size(), kNotificationMaxItems);
144 layout->AddView(icon, 1, 2 + displayed_item_count);
143 145
144 // First row: Title. This vertically spans the close button padding row and 146 // First row: Title. This vertically spans the close button padding row and
145 // the close button row. 147 // the close button row.
146 // TODO(dharcourt): Skip the title Label when there's no title text. 148 // TODO(dharcourt): Skip the title Label when there's no title text.
147 views::Label* title = new views::Label(notification_.title); 149 views::Label* title = new views::Label(notification_.title);
148 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); 150 title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
149 title->SetElideBehavior(views::Label::ELIDE_AT_END); 151 title->SetElideBehavior(views::Label::ELIDE_AT_END);
150 title->SetFont(title->font().DeriveFont(4)); 152 title->SetFont(title->font().DeriveFont(4));
151 title->SetEnabledColor(kTitleColor); 153 title->SetEnabledColor(kTitleColor);
152 title->SetBackgroundColor(kTitleBackgroundColor); 154 title->SetBackgroundColor(kTitleBackgroundColor);
153 title->set_border(MakePadding(kTextTopPadding, 0, 3, kTextToClosePadding)); 155 title->set_border(MakePadding(kTextTopPadding, 0, 3, kTextToClosePadding));
154 layout->AddView(title, 1, 2); 156 layout->AddView(title, 1, 2);
155 157
156 // First row: Close button padding. 158 // First row: Close button padding.
157 views::View* padding = new views::ImageView(); 159 views::View* padding = new views::ImageView();
158 padding->set_border(MakePadding(kCloseTopPadding, 1, 0, 0)); 160 padding->set_border(MakePadding(kCloseTopPadding, 1, 0, 0));
159 layout->AddView(padding); 161 layout->AddView(padding);
160 162
161 // Second row: Close button, which has to be on a row of its own because its 163 // Second row: Close button, which has to be on a row of its own because its
162 // top padding can't be set using empty borders (ImageButtons don't support 164 // top padding can't be set using empty borders (ImageButtons don't support
163 // borders). The resize factor of this row (100) is much higher than that of 165 // borders). The resize factor of this row (100) is much higher than that of
164 // other rows (0) to ensure the first row's height stays at kCloseTopPadding. 166 // other rows (0) to ensure the first row's height stays at kCloseTopPadding.
165 layout->StartRow(100, 0); 167 layout->StartRow(100, 0);
166 layout->SkipColumns(2); 168 layout->SkipColumns(2);
167 DCHECK(close_button_); 169 DCHECK(close_button_);
168 layout->AddView(close_button_); 170 layout->AddView(close_button_);
169 171
170 // One row for each notification item, including appropriate padding. 172 // One row for each notification item, including appropriate padding.
171 for (int i = 0, n = notification_.items.size(); i < n; ++i) { 173 for (int i = 0; i < displayed_item_count; ++i) {
172 int bottom_padding = (i < n - 1) ? 4 : (kTextBottomPadding - 2); 174 int bottom_padding =
175 (i < displayed_item_count - 1) ? 4 : (kTextBottomPadding - 2);
173 layout->StartRow(0, 0); 176 layout->StartRow(0, 0);
174 layout->SkipColumns(1); 177 layout->SkipColumns(1);
175 ItemView* item = new ItemView(notification_.items[i]); 178 ItemView* item = new ItemView(notification_.items[i]);
176 item->set_border(MakePadding(0, 0, bottom_padding, kTextToClosePadding)); 179 item->set_border(MakePadding(0, 0, bottom_padding, kTextToClosePadding));
177 layout->AddView(item); 180 layout->AddView(item);
178 layout->SkipColumns(1); 181 layout->SkipColumns(1);
179 } 182 }
180 } 183 }
181 184
182 } // namespace message_center 185 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/message_center_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698