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

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

Issue 13560002: Added padding below text in notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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/views/notification_view.h" 5 #include "ui/message_center/views/notification_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "grit/ui_resources.h" 9 #include "grit/ui_resources.h"
10 #include "ui/base/accessibility/accessible_view_state.h" 10 #include "ui/base/accessibility/accessible_view_state.h"
(...skipping 15 matching lines...) Expand all
26 #include "ui/views/layout/box_layout.h" 26 #include "ui/views/layout/box_layout.h"
27 #include "ui/views/layout/fill_layout.h" 27 #include "ui/views/layout/fill_layout.h"
28 28
29 namespace { 29 namespace {
30 30
31 // Dimensions. 31 // Dimensions.
32 const int kIconColumnWidth = message_center::kNotificationIconSize; 32 const int kIconColumnWidth = message_center::kNotificationIconSize;
33 const int kLegacyIconSize = 40; 33 const int kLegacyIconSize = 40;
34 const int kTextLeftPadding = kIconColumnWidth + 34 const int kTextLeftPadding = kIconColumnWidth +
35 message_center::kIconToTextPadding; 35 message_center::kIconToTextPadding;
36 const int kTextBottomPadding = 6;
dharcourt 2013/04/03 17:41:45 This wasn't being used.
37 const int kTextRightPadding = 23; 36 const int kTextRightPadding = 23;
38 const int kItemTitleToMessagePadding = 3; 37 const int kItemTitleToMessagePadding = 3;
39 const int kButtonHeight = 38; 38 const int kButtonHeight = 38;
40 const int kButtonHorizontalPadding = 16; 39 const int kButtonHorizontalPadding = 16;
41 const int kButtonVecticalPadding = 0; 40 const int kButtonVecticalPadding = 0;
42 const int kButtonIconTopPadding = 11; 41 const int kButtonIconTopPadding = 11;
43 const int kButtonIconToTitlePadding = 16; 42 const int kButtonIconToTitlePadding = 16;
44 const int kButtonTitleTopPadding = 0; 43 const int kButtonTitleTopPadding = 0;
45 44
46 const size_t kTitleCharacterLimit = 100; 45 const size_t kTitleCharacterLimit = 100;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 MaybeTruncateText(notification.message(), kMessageCharacterLimit)); 387 MaybeTruncateText(notification.message(), kMessageCharacterLimit));
389 message_view_->SetVisible(!is_expanded() || !notification.items().size()); 388 message_view_->SetVisible(!is_expanded() || !notification.items().size());
390 message_view_->set_collapse_when_hidden(true); 389 message_view_->set_collapse_when_hidden(true);
391 message_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 390 message_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
392 if (is_expanded()) 391 if (is_expanded())
393 message_view_->SetMultiLine(true); 392 message_view_->SetMultiLine(true);
394 else 393 else
395 message_view_->SetElideBehavior(views::Label::ELIDE_AT_END); 394 message_view_->SetElideBehavior(views::Label::ELIDE_AT_END);
396 message_view_->SetEnabledColor(message_center::kRegularTextColor); 395 message_view_->SetEnabledColor(message_center::kRegularTextColor);
397 message_view_->SetBackgroundColor(kRegularTextBackgroundColor); 396 message_view_->SetBackgroundColor(kRegularTextBackgroundColor);
398 message_view_->set_border(MakeBorder(0, 3)); 397 message_view_->set_border(MakeBorder(0, 4));
399 top_view_->AddChildView(message_view_); 398 top_view_->AddChildView(message_view_);
400 } 399 }
401 400
402 // Create the list item views (up to a maximum). 401 // Create the list item views (up to a maximum).
403 std::vector<NotificationItem> items = notification.items(); 402 std::vector<NotificationItem> items = notification.items();
404 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { 403 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
405 ItemView* item_view = new ItemView(items[i]); 404 ItemView* item_view = new ItemView(items[i]);
406 item_view->SetVisible(is_expanded()); 405 item_view->SetVisible(is_expanded());
407 item_view->set_border(MakeBorder(0, 4)); 406 item_view->set_border(MakeBorder(0, 4));
408 item_views_.push_back(item_view); 407 item_views_.push_back(item_view);
409 top_view_->AddChildView(item_view); 408 top_view_->AddChildView(item_view);
410 } 409 }
411 410
411 // Add padding below the title/message/list text.
412 views::View* padding_view = new views::ImageView();
msw 2013/04/03 18:04:26 Adding a view for padding is rather heavy-weight.
dharcourt 2013/04/04 18:33:52 I was able to accomplish this using borders, which
msw 2013/04/04 18:44:49 Awesome, that's even better.
413 padding_view->set_border(MakeBorder(5, 0));
414 top_view_->AddChildView(padding_view);
415
412 // Create the notification icon view. 416 // Create the notification icon view.
413 if (notification.type() == NOTIFICATION_TYPE_SIMPLE) { 417 if (notification.type() == NOTIFICATION_TYPE_SIMPLE) {
414 views::ImageView* icon_view = new views::ImageView(); 418 views::ImageView* icon_view = new views::ImageView();
415 icon_view->SetImage(notification.icon().AsImageSkia()); 419 icon_view->SetImage(notification.icon().AsImageSkia());
416 icon_view->SetImageSize(gfx::Size(kLegacyIconSize, kLegacyIconSize)); 420 icon_view->SetImageSize(gfx::Size(kLegacyIconSize, kLegacyIconSize));
417 icon_view->SetHorizontalAlignment(views::ImageView::CENTER); 421 icon_view->SetHorizontalAlignment(views::ImageView::CENTER);
418 icon_view->SetVerticalAlignment(views::ImageView::CENTER); 422 icon_view->SetVerticalAlignment(views::ImageView::CENTER);
419 icon_view->set_background(MakeBackground(kLegacyIconBackgroundColor)); 423 icon_view->set_background(MakeBackground(kLegacyIconBackgroundColor));
420 icon_view_ = icon_view; 424 icon_view_ = icon_view;
421 } else { 425 } else {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 size_t limit) { 546 size_t limit) {
543 // Currently just truncate the text by the total number of characters. 547 // Currently just truncate the text by the total number of characters.
544 // TODO(mukai): add better assumption like number of lines. 548 // TODO(mukai): add better assumption like number of lines.
545 if (!is_expanded()) 549 if (!is_expanded())
546 return text; 550 return text;
547 551
548 return ui::TruncateString(text, limit); 552 return ui::TruncateString(text, limit);
549 } 553 }
550 554
551 } // namespace message_center 555 } // 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