diff options
Diffstat (limited to 'chromium/ui/message_center/views/notification_view.cc')
-rw-r--r-- | chromium/ui/message_center/views/notification_view.cc | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/chromium/ui/message_center/views/notification_view.cc b/chromium/ui/message_center/views/notification_view.cc index abfc1efe689..b6e8bcc8d4b 100644 --- a/chromium/ui/message_center/views/notification_view.cc +++ b/chromium/ui/message_center/views/notification_view.cc @@ -10,10 +10,10 @@ #include "grit/ui_resources.h" #include "ui/base/layout.h" #include "ui/base/resource/resource_bundle.h" -#include "ui/base/text/text_elider.h" #include "ui/gfx/canvas.h" #include "ui/gfx/size.h" #include "ui/gfx/skia_util.h" +#include "ui/gfx/text_elider.h" #include "ui/message_center/message_center.h" #include "ui/message_center/message_center_style.h" #include "ui/message_center/message_center_switches.h" @@ -30,6 +30,10 @@ #include "ui/views/layout/fill_layout.h" #include "ui/views/widget/widget.h" +#if defined(USE_AURA) +#include "ui/base/cursor/cursor.h" +#endif + namespace { // Dimensions. @@ -53,12 +57,16 @@ const size_t kTitleCharacterLimit = const size_t kMessageCharacterLimit = message_center::kNotificationWidth * message_center::kMessageExpandedLineLimit / 3; +const size_t kContextMessageCharacterLimit = + message_center::kNotificationWidth * + message_center::kContextMessageLineLimit / 3; // Notification colors. The text background colors below are used only to keep // view::Label from modifying the text color and will not actually be drawn. // See view::Label's RecalculateColors() for details. const SkColor kRegularTextBackgroundColor = SK_ColorWHITE; const SkColor kDimTextBackgroundColor = SK_ColorWHITE; +const SkColor kContextTextBackgroundColor = SK_ColorWHITE; // static views::Background* MakeBackground( @@ -462,13 +470,17 @@ NotificationView::NotificationView(const Notification& notification, top_view_->set_border(MakeEmptyBorder( kTextTopPadding - 8, 0, kTextBottomPadding - 5, 0)); + const gfx::FontList default_label_font_list = views::Label().font_list(); + // Create the title view if appropriate. title_view_ = NULL; if (!notification.title().empty()) { - gfx::Font font = views::Label().font().DeriveFont(2); - int padding = kTitleLineHeight - font.GetHeight(); + const gfx::FontList& font_list = + default_label_font_list.DeriveFontListWithSizeDelta(2); + int padding = kTitleLineHeight - font_list.GetHeight(); title_view_ = new BoundedLabel( - ui::TruncateString(notification.title(), kTitleCharacterLimit), font); + gfx::TruncateString(notification.title(), kTitleCharacterLimit), + font_list); title_view_->SetLineHeight(kTitleLineHeight); title_view_->SetLineLimit(message_center::kTitleLineLimit); title_view_->SetColors(message_center::kRegularTextColor, @@ -481,18 +493,36 @@ NotificationView::NotificationView(const Notification& notification, // Create the message view if appropriate. message_view_ = NULL; if (!notification.message().empty()) { - int padding = kMessageLineHeight - views::Label().font().GetHeight(); + int padding = kMessageLineHeight - default_label_font_list.GetHeight(); message_view_ = new BoundedLabel( - ui::TruncateString(notification.message(), kMessageCharacterLimit)); + gfx::TruncateString(notification.message(), kMessageCharacterLimit)); message_view_->SetLineHeight(kMessageLineHeight); message_view_->SetVisible(!is_expanded() || !notification.items().size()); - message_view_->SetColors(message_center::kDimTextColor, + message_view_->SetColors(message_center::kRegularTextColor, kDimTextBackgroundColor); message_view_->set_border(MakeTextBorder(padding, 4, 0)); top_view_->AddChildView(message_view_); accessible_lines.push_back(notification.message()); } + // Create the context message view if appropriate. + context_message_view_ = NULL; + if (!notification.context_message().empty()) { + int padding = kMessageLineHeight - default_label_font_list.GetHeight(); + context_message_view_ = + new BoundedLabel(gfx::TruncateString(notification.context_message(), + kContextMessageCharacterLimit), + default_label_font_list); + context_message_view_->SetLineLimit( + message_center::kContextMessageLineLimit); + context_message_view_->SetLineHeight(kMessageLineHeight); + context_message_view_->SetColors(message_center::kDimTextColor, + kContextTextBackgroundColor); + context_message_view_->set_border(MakeTextBorder(padding, 4, 0)); + top_view_->AddChildView(context_message_view_); + accessible_lines.push_back(notification.context_message()); + } + // Create the progress bar view. progress_bar_view_ = NULL; if (notification.type() == NOTIFICATION_TYPE_PROGRESS) { @@ -504,7 +534,7 @@ NotificationView::NotificationView(const Notification& notification, } // Create the list item views (up to a maximum). - int padding = kMessageLineHeight - views::Label().font().GetHeight(); + int padding = kMessageLineHeight - default_label_font_list.GetHeight(); std::vector<NotificationItem> items = notification.items(); for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) { ItemView* item_view = new ItemView(items[i]); |