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

Unified Diff: ui/message_center/views/notification_view.cc

Issue 18662006: Support creating progress bar notification for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable test for Linux Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: ui/message_center/views/notification_view.cc
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index 0522e751398cb249f58d0f4a41c014ac006031b2..3a3daf17e8e76d0ba07c4be32b4d11b5877c2f03 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -24,6 +24,7 @@
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
+#include "ui/views/controls/progress_bar.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/widget.h"
@@ -38,6 +39,9 @@ const int kTextLeftPadding = kIconSize + message_center::kIconToTextPadding;
const int kTextBottomPadding = 12;
const int kTextRightPadding = 23;
const int kItemTitleToMessagePadding = 3;
+const int kProgressBarWidth = message_center::kNotificationWidth -
+ kTextLeftPadding - kTextRightPadding;
+const int kProgressBarHeight = 8;
const int kButtonVecticalPadding = 0;
const int kButtonTitleTopPadding = 0;
@@ -75,6 +79,11 @@ views::Border* MakeTextBorder(int padding, int top, int bottom) {
}
// static
+views::Border* MakeProgressBarBorder(int top, int bottom) {
+ return MakeEmptyBorder(top, kTextLeftPadding, bottom, kTextRightPadding);
+}
+
+// static
views::Border* MakeSeparatorBorder(int top, int left, SkColor color) {
return views::Border::CreateSolidSidedBorder(top, left, 0, 0, color);
}
@@ -223,6 +232,33 @@ gfx::Size ProportionalImageView::GetImageSizeForWidth(int width) {
return message_center::GetImageSizeForWidth(width, size);
}
+// NotificationProgressBar /////////////////////////////////////////////////////
+
+class NotificationProgressBar : public views::ProgressBar {
+ public:
+ NotificationProgressBar();
+ virtual ~NotificationProgressBar();
+
+ private:
+ // Overriden from View
+ virtual gfx::Size GetPreferredSize() OVERRIDE;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationProgressBar);
+};
+
+NotificationProgressBar::NotificationProgressBar() {
+}
+
+NotificationProgressBar::~NotificationProgressBar() {
+}
+
+gfx::Size NotificationProgressBar::GetPreferredSize() {
+ gfx::Size pref_size(kProgressBarWidth, kProgressBarHeight);
+ gfx::Insets insets = GetInsets();
+ pref_size.Enlarge(insets.width(), insets.height());
+ return pref_size;
+}
+
// NotificationButton //////////////////////////////////////////////////////////
// NotificationButtons render the action buttons of notifications.
@@ -345,6 +381,7 @@ MessageView* NotificationView::Create(const Notification& notification,
case NOTIFICATION_TYPE_IMAGE:
case NOTIFICATION_TYPE_MULTIPLE:
case NOTIFICATION_TYPE_SIMPLE:
+ case NOTIFICATION_TYPE_PROGRESS:
break;
default:
// If the caller asks for an unrecognized kind of view (entirely possible
@@ -422,6 +459,15 @@ NotificationView::NotificationView(const Notification& notification,
accessible_lines.push_back(notification.message());
}
+ // Create the progress bar view.
+ progress_bar_view_ = NULL;
+ if (notification.type() == NOTIFICATION_TYPE_PROGRESS) {
+ progress_bar_view_ = new NotificationProgressBar();
+ progress_bar_view_->set_border(MakeProgressBarBorder(12, 2));
dewittj 2013/07/15 15:32:15 What are these constants? Can we name them?
jianli 2013/07/23 19:04:53 Done.
+ progress_bar_view_->SetValue(notification.progress() / 100.0);
+ top_view_->AddChildView(progress_bar_view_);
+ }
+
// Create the list item views (up to a maximum).
int padding = kMessageLineHeight - views::Label().font().GetHeight();
std::vector<NotificationItem> items = notification.items();

Powered by Google App Engine
This is Rietveld 408576698