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

Unified Diff: ui/message_center/message_view_multiple.cc

Issue 11410008: Created initial multi-item notification view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
Index: ui/message_center/message_view_multiple.cc
diff --git a/ui/message_center/message_view_multiple.cc b/ui/message_center/message_view_multiple.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2a60f6fc86048c9d9f7d468e800b370a4f6d8dac
--- /dev/null
+++ b/ui/message_center/message_view_multiple.cc
@@ -0,0 +1,153 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/message_center/message_view_multiple.h"
+
+#include "base/utf_string_conversions.h"
+#include "grit/ui_resources.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/views/controls/button/image_button.h"
+#include "ui/views/controls/image_view.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/grid_layout.h"
+
+namespace message_center {
+
+const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
+const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa);
+
+// Temporarily here, this will later get merged into the Notification class.
miket_OOO 2012/11/15 18:35:32 Use TODO format. Can you do this work now, rather
dharcourt 2012/11/16 02:37:00 Done.
+struct MessageViewMultiple::NotificationItem {
+ string16 title;
+ string16 details;
+ NotificationItem(string16 title, string16 details)
+ : title(title),
+ details(details) {
benwells 2012/11/15 22:27:08 drive by suggestion: you can use {} on one line he
dharcourt 2012/11/16 02:37:00 Thanks for the review & the suggestion.
+ }
+};
+
+MessageViewMultiple::MessageViewMultiple(
+ NotificationList::Delegate* list_delegate,
+ const NotificationList::Notification& notification)
+ : MessageView(list_delegate, notification) {
+}
+
+MessageViewMultiple::MessageViewMultiple() {
+}
+
+MessageViewMultiple::~MessageViewMultiple() {
+}
+
+// TODO(dharcourt): Make this a subclass of BaseFormatView or of a
+// BaseFormatView superclass and leverage that class' SetUpView().
+void MessageViewMultiple::SetUpView() {
+ DCHECK(close_button_);
+
+ // Create some bogus notification items for now. Later they'll come from the
+ // Notification object.
+ // TODO(dharcourt): Figure out if there's a simpler to provide a string16
+ // constant than UTF8ToUTF16(const char *).
+ std::vector<NotificationItem> items;
+ items.push_back(NotificationItem(
+ UTF8ToUTF16("Andy Rubin"),
+ UTF8ToUTF16("This is an imporant message!")));
miket_OOO 2012/11/15 18:35:32 spelling
+ items.push_back(NotificationItem(
+ UTF8ToUTF16("James Bergen Plummer"),
+ UTF8ToUTF16("Just took a look at the proposal")));
+ items.push_back(NotificationItem(
+ UTF8ToUTF16("Adam Cohen"),
+ UTF8ToUTF16("I see that you went to the conference")));
+ items.push_back(NotificationItem(
+ UTF8ToUTF16("Mike Jurka"),
+ UTF8ToUTF16("I ate Cleron's sandwhich!")));
miket_OOO 2012/11/15 18:35:32 spelling
dharcourt 2012/11/16 02:37:00 Funny. The mockup had a typo which I kepth even th
+ items.push_back(NotificationItem(
+ UTF8ToUTF16("Winson Chung"),
+ UTF8ToUTF16("I saw mike steal a sandwhich :-)")));
+
+ SkColor bg_color = notification_.is_read ?
+ kNotificationReadColor : kNotificationColor;
+ set_background(views::Background::CreateSolidBackground(bg_color));
+
+ // TODO(dharcourt): If possible, us GridLayout fill functionality to make the
miket_OOO 2012/11/15 18:35:32 spelling
dharcourt 2012/11/16 02:37:00 Done.
+ // message as wide as possible without reference to the kWebNotificationWidth.
+ // TODO(dharcourt): Verify intended meaning of MessageView size constants.
+ const int padding_width = kPaddingHorizontal / 2;
+ const int message_width = kWebNotificationWidth - kWebNotificationIconSize -
+ kWebNotificationButtonWidth - (padding_width * 3);
+
+ views::GridLayout* layout = new views::GridLayout(this);
+ SetLayoutManager(layout);
+
+ // Three columns (icon, messages, close button) surrounded by padding.
+ views::ColumnSet* columns = layout->AddColumnSet(0);
+ columns->AddPaddingColumn(0, padding_width);
+ columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING,
+ 0, /* resize weight */
+ views::GridLayout::FIXED,
+ kWebNotificationIconSize, kWebNotificationIconSize);
+ columns->AddPaddingColumn(0, padding_width);
+ columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
+ 100, /* resize weight */
+ views::GridLayout::FIXED,
+ message_width, message_width);
+ columns->AddPaddingColumn(0, padding_width);
+ columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING,
+ 0, /* resize weight */
+ views::GridLayout::FIXED,
+ kWebNotificationButtonWidth,
+ kWebNotificationButtonWidth);
+
+ // First row has the icon, title, and close button after some top padding.
+ layout->AddPaddingRow(0, kPaddingBetweenItems);
+ layout->StartRow(0, 0);
+
+ views::ImageView* icon = new views::ImageView;
+ icon->SetImageSize(
+ gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize));
+ icon->SetImage(notification_.image);
+ layout->AddView(icon, 1, 1 + items.size());
+
+ views::Label* title = new views::Label(notification_.title);
+ title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD));
+ layout->AddView(title);
+
+ close_button_ = new views::ImageButton(this);
+ close_button_->SetImage(
+ views::CustomButton::STATE_NORMAL,
+ ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
+ IDR_MESSAGE_CLOSE));
+ close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
+ views::ImageButton::ALIGN_MIDDLE);
+ layout->AddView(close_button_);
+
+ // One row for each notification item.
+ for (std::vector<NotificationItem>::const_iterator i = items.begin();
+ i != items.end();
+ ++i) {
+ views::Label* item_title = new views::Label(i->title);
+ item_title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ layout->StartRow(0,0);
+ layout->SkipColumns(2);
+ layout->AddView(item_title);
+ // TODO(dharcourt): Item details.
+ }
+
+ // TODO(dharcourt): Add a horizontal line.
+
+ // One row for the summary message. TODO(dharcourt): Make it optional.
+ views::Label* message = new views::Label(notification_.message);
+ message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ message->SetMultiLine(true);
+ layout->StartRow(0, 0);
+ layout->SkipColumns(2);
+ layout->AddView(message);
+
+ // TODO(dharcourt): Add a second icon to the right of the summary message.
+
+ // Bottom padding.
+ layout->AddPaddingRow(0, kPaddingBetweenItems);
+}
+
+} // namespace message_center

Powered by Google App Engine
This is Rietveld 408576698