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 7947f47eb345f77ef8ec08504dc2a1a523b0923c..dde4e6d2b4e7e69383dcfb0282de7b518a781016 100644 |
--- a/ui/message_center/views/notification_view.cc |
+++ b/ui/message_center/views/notification_view.cc |
@@ -13,6 +13,7 @@ |
#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/message_center/message_center.h" |
#include "ui/message_center/message_center_style.h" |
#include "ui/message_center/message_center_switches.h" |
@@ -41,9 +42,7 @@ 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 kProgressBarBottomPadding = 0; |
const int kButtonVecticalPadding = 0; |
const int kButtonTitleTopPadding = 0; |
@@ -244,6 +243,7 @@ class NotificationProgressBar : public views::ProgressBar { |
private: |
// Overriden from View |
virtual gfx::Size GetPreferredSize() OVERRIDE; |
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
DISALLOW_COPY_AND_ASSIGN(NotificationProgressBar); |
}; |
@@ -255,12 +255,49 @@ NotificationProgressBar::~NotificationProgressBar() { |
} |
gfx::Size NotificationProgressBar::GetPreferredSize() { |
- gfx::Size pref_size(kProgressBarWidth, kProgressBarHeight); |
+ gfx::Size pref_size(kProgressBarWidth, message_center::kProgressBarThickness); |
gfx::Insets insets = GetInsets(); |
pref_size.Enlarge(insets.width(), insets.height()); |
return pref_size; |
} |
+void NotificationProgressBar::OnPaint(gfx::Canvas* canvas) { |
+ gfx::Rect content_bounds = GetContentsBounds(); |
+ int bar_left = content_bounds.x(); |
+ int bar_top = content_bounds.y(); |
+ int bar_width = content_bounds.width(); |
+ int bar_height = content_bounds.height(); |
+ |
+ // Draw background. |
+ SkPath background_path; |
+ background_path.addRoundRect(gfx::RectToSkRect(content_bounds), |
+ message_center::kProgressBarCornerRadius, |
+ message_center::kProgressBarCornerRadius); |
+ SkPaint background_paint; |
+ background_paint.setStyle(SkPaint::kFill_Style); |
+ background_paint.setFlags(SkPaint::kAntiAlias_Flag); |
+ background_paint.setColor(message_center::kProgressBarBackgroundColor); |
+ canvas->DrawPath(background_path, background_paint); |
+ |
+ // Draw slice. |
+ const int slice_width = |
+ static_cast<int>(bar_width * GetNormalizedValue() + 0.5); |
+ if (slice_width < 1) |
+ return; |
+ |
+ gfx::Rect slice_bounds = content_bounds; |
+ slice_bounds.set_width(slice_width); |
+ SkPath slice_path; |
+ slice_path.addRoundRect(gfx::RectToSkRect(slice_bounds), |
+ message_center::kProgressBarCornerRadius, |
+ message_center::kProgressBarCornerRadius); |
+ SkPaint slice_paint; |
+ slice_paint.setStyle(SkPaint::kFill_Style); |
+ slice_paint.setFlags(SkPaint::kAntiAlias_Flag); |
+ slice_paint.setColor(message_center::kProgressBarSliceColor); |
+ canvas->DrawPath(slice_path, slice_paint); |
+} |
+ |
// NotificationButton ////////////////////////////////////////////////////////// |
// NotificationButtons render the action buttons of notifications. |
@@ -466,7 +503,7 @@ NotificationView::NotificationView(const Notification& notification, |
if (notification.type() == NOTIFICATION_TYPE_PROGRESS) { |
progress_bar_view_ = new NotificationProgressBar(); |
progress_bar_view_->set_border(MakeProgressBarBorder( |
- kProgressBarTopPadding, kProgressBarBottomPadding)); |
+ message_center::kProgressBarTopPadding, kProgressBarBottomPadding)); |
dewittj
2013/08/05 22:34:39
Why move one to message_center and not the other?
jianli
2013/08/05 22:42:16
We do not need extra bottom padding for progress b
|
progress_bar_view_->SetValue(notification.progress() / 100.0); |
top_view_->AddChildView(progress_bar_view_); |
} |