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

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: Fix per feedbacks 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
« no previous file with comments | « ui/message_center/views/notification_view.h ('k') | ui/views/controls/progress_bar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7947f47eb345f77ef8ec08504dc2a1a523b0923c 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,11 @@ 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 kProgressBarTopPadding = 12;
+const int kProgressBarBottomPadding = 2;
const int kButtonVecticalPadding = 0;
const int kButtonTitleTopPadding = 0;
@@ -75,6 +81,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 +234,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 +383,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 +461,16 @@ 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(
+ kProgressBarTopPadding, kProgressBarBottomPadding));
+ 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();
« no previous file with comments | « ui/message_center/views/notification_view.h ('k') | ui/views/controls/progress_bar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698