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

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
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 14 matching lines...) Expand all
25 #include "ui/views/controls/label.h" 25 #include "ui/views/controls/label.h"
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; 36 const int kTextBottomPadding = 12;
37 const int kTextRightPadding = 23; 37 const int kTextRightPadding = 23;
38 const int kItemTitleToMessagePadding = 3; 38 const int kItemTitleToMessagePadding = 3;
39 const int kButtonHeight = 38; 39 const int kButtonHeight = 38;
40 const int kButtonHorizontalPadding = 16; 40 const int kButtonHorizontalPadding = 16;
41 const int kButtonVecticalPadding = 0; 41 const int kButtonVecticalPadding = 0;
42 const int kButtonIconTopPadding = 11; 42 const int kButtonIconTopPadding = 11;
43 const int kButtonIconToTitlePadding = 16; 43 const int kButtonIconToTitlePadding = 16;
44 const int kButtonTitleTopPadding = 0; 44 const int kButtonTitleTopPadding = 0;
45 45
46 const size_t kTitleCharacterLimit = 100; 46 const size_t kTitleCharacterLimit = 100;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 bool expanded) 356 bool expanded)
357 : MessageView(notification, observer, expanded) { 357 : MessageView(notification, observer, expanded) {
358 // Create the opaque background that's above the view's shadow. 358 // Create the opaque background that's above the view's shadow.
359 background_view_ = new views::View(); 359 background_view_ = new views::View();
360 background_view_->set_background(MakeBackground()); 360 background_view_->set_background(MakeBackground());
361 361
362 // Create the top_view_, which collects into a vertical box all content 362 // Create the top_view_, which collects into a vertical box all content
363 // at the top of the notification (to the right of the icon) except for the 363 // at the top of the notification (to the right of the icon) except for the
364 // close button. 364 // close button.
365 top_view_ = new ContainerView(); 365 top_view_ = new ContainerView();
366 top_view_->set_border(MakeBorder(kTextTopPadding - 5,
367 kTextBottomPadding - 4,
368 0, 0));
366 369
367 // Create the title view if appropriate. 370 // Create the title view if appropriate.
368 title_view_ = NULL; 371 title_view_ = NULL;
369 if (!notification.title().empty()) { 372 if (!notification.title().empty()) {
370 title_view_ = new views::Label( 373 title_view_ = new views::Label(
371 MaybeTruncateText( notification.title(), kTitleCharacterLimit)); 374 MaybeTruncateText( notification.title(), kTitleCharacterLimit));
372 title_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 375 title_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
373 if (is_expanded()) 376 if (is_expanded())
374 title_view_->SetMultiLine(true); 377 title_view_->SetMultiLine(true);
375 else 378 else
376 title_view_->SetElideBehavior(views::Label::ELIDE_AT_END); 379 title_view_->SetElideBehavior(views::Label::ELIDE_AT_END);
377 title_view_->SetFont(title_view_->font().DeriveFont(2)); 380 title_view_->SetFont(title_view_->font().DeriveFont(2));
378 title_view_->SetEnabledColor(message_center::kRegularTextColor); 381 title_view_->SetEnabledColor(message_center::kRegularTextColor);
379 title_view_->SetBackgroundColor(kRegularTextBackgroundColor); 382 title_view_->SetBackgroundColor(kRegularTextBackgroundColor);
380 title_view_->set_border(MakeBorder(kTextTopPadding, 3)); 383 title_view_->set_border(MakeBorder(0, 0));
msw 2013/04/04 18:44:50 nit: this seems unnecessary now.
381 top_view_->AddChildView(title_view_); 384 top_view_->AddChildView(title_view_);
382 } 385 }
383 386
384 // Create the message view if appropriate. 387 // Create the message view if appropriate.
385 message_view_ = NULL; 388 message_view_ = NULL;
386 if (!notification.message().empty()) { 389 if (!notification.message().empty()) {
387 message_view_ = new views::Label( 390 message_view_ = new views::Label(
388 MaybeTruncateText(notification.message(), kMessageCharacterLimit)); 391 MaybeTruncateText(notification.message(), kMessageCharacterLimit));
389 message_view_->SetVisible(!is_expanded() || !notification.items().size()); 392 message_view_->SetVisible(!is_expanded() || !notification.items().size());
390 message_view_->set_collapse_when_hidden(true); 393 message_view_->set_collapse_when_hidden(true);
391 message_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 394 message_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
392 if (is_expanded()) 395 if (is_expanded())
393 message_view_->SetMultiLine(true); 396 message_view_->SetMultiLine(true);
394 else 397 else
395 message_view_->SetElideBehavior(views::Label::ELIDE_AT_END); 398 message_view_->SetElideBehavior(views::Label::ELIDE_AT_END);
396 message_view_->SetEnabledColor(message_center::kRegularTextColor); 399 message_view_->SetEnabledColor(message_center::kRegularTextColor);
397 message_view_->SetBackgroundColor(kRegularTextBackgroundColor); 400 message_view_->SetBackgroundColor(kRegularTextBackgroundColor);
398 message_view_->set_border(MakeBorder(0, 3)); 401 message_view_->set_border(MakeBorder(1, 0));
399 top_view_->AddChildView(message_view_); 402 top_view_->AddChildView(message_view_);
400 } 403 }
401 404
402 // Create the list item views (up to a maximum). 405 // Create the list item views (up to a maximum).
403 std::vector<NotificationItem> items = notification.items(); 406 std::vector<NotificationItem> items = notification.items();
404 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { 407 for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
405 ItemView* item_view = new ItemView(items[i]); 408 ItemView* item_view = new ItemView(items[i]);
406 item_view->SetVisible(is_expanded()); 409 item_view->SetVisible(is_expanded());
407 item_view->set_border(MakeBorder(0, 4)); 410 item_view->set_border(MakeBorder(1, 0));
408 item_views_.push_back(item_view); 411 item_views_.push_back(item_view);
409 top_view_->AddChildView(item_view); 412 top_view_->AddChildView(item_view);
410 } 413 }
411 414
412 // Create the notification icon view. 415 // Create the notification icon view.
413 if (notification.type() == NOTIFICATION_TYPE_SIMPLE) { 416 if (notification.type() == NOTIFICATION_TYPE_SIMPLE) {
414 views::ImageView* icon_view = new views::ImageView(); 417 views::ImageView* icon_view = new views::ImageView();
415 icon_view->SetImage(notification.icon().AsImageSkia()); 418 icon_view->SetImage(notification.icon().AsImageSkia());
416 icon_view->SetImageSize(gfx::Size(kLegacyIconSize, kLegacyIconSize)); 419 icon_view->SetImageSize(gfx::Size(kLegacyIconSize, kLegacyIconSize));
417 icon_view->SetHorizontalAlignment(views::ImageView::CENTER); 420 icon_view->SetHorizontalAlignment(views::ImageView::CENTER);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 size_t limit) { 545 size_t limit) {
543 // Currently just truncate the text by the total number of characters. 546 // Currently just truncate the text by the total number of characters.
544 // TODO(mukai): add better assumption like number of lines. 547 // TODO(mukai): add better assumption like number of lines.
545 if (!is_expanded()) 548 if (!is_expanded())
546 return text; 549 return text;
547 550
548 return ui::TruncateString(text, limit); 551 return ui::TruncateString(text, limit);
549 } 552 }
550 553
551 } // namespace message_center 554 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698