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 76b7827614857c9bc70cc7febf930f0f3d8a3b3d..2ccf3818765e0c88098b4a4c63a3bb7b9252ff8b 100644 |
--- a/ui/message_center/views/notification_view.cc |
+++ b/ui/message_center/views/notification_view.cc |
@@ -14,6 +14,7 @@ |
#include "ui/base/cursor/cursor.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/layout.h" |
+#include "ui/gfx/animation/slide_animation.h" |
Jun Mukai
2015/11/24 17:51:12
this is not used here?
yoshiki
2015/11/25 15:14:28
Done.
|
#include "ui/gfx/canvas.h" |
#include "ui/gfx/geometry/size.h" |
#include "ui/gfx/skia_util.h" |
@@ -26,6 +27,7 @@ |
#include "ui/message_center/views/constants.h" |
#include "ui/message_center/views/message_center_controller.h" |
#include "ui/message_center/views/notification_button.h" |
+#include "ui/message_center/views/notification_progress_bar.h" |
#include "ui/message_center/views/padded_button.h" |
#include "ui/message_center/views/proportional_image_view.h" |
#include "ui/native_theme/native_theme.h" |
@@ -48,8 +50,6 @@ |
namespace { |
// Dimensions. |
-const int kProgressBarWidth = message_center::kNotificationWidth - |
- message_center::kTextLeftPadding - message_center::kTextRightPadding; |
const int kProgressBarBottomPadding = 0; |
// static |
@@ -157,67 +157,6 @@ void ItemView::SetVisible(bool visible) { |
child_at(i)->SetVisible(visible); |
} |
-// NotificationProgressBar ///////////////////////////////////////////////////// |
- |
-class NotificationProgressBar : public views::ProgressBar { |
- public: |
- NotificationProgressBar(); |
- ~NotificationProgressBar() override; |
- |
- private: |
- // Overriden from View |
- gfx::Size GetPreferredSize() const override; |
- void OnPaint(gfx::Canvas* canvas) override; |
- |
- DISALLOW_COPY_AND_ASSIGN(NotificationProgressBar); |
-}; |
- |
-NotificationProgressBar::NotificationProgressBar() { |
-} |
- |
-NotificationProgressBar::~NotificationProgressBar() { |
-} |
- |
-gfx::Size NotificationProgressBar::GetPreferredSize() const { |
- 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(); |
- |
- // 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>(content_bounds.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); |
-} |
- |
} // namespace |
namespace message_center { |
@@ -234,6 +173,7 @@ NotificationView* NotificationView::Create(MessageCenterController* controller, |
case NOTIFICATION_TYPE_MULTIPLE: |
case NOTIFICATION_TYPE_SIMPLE: |
case NOTIFICATION_TYPE_PROGRESS: |
+ case NOTIFICATION_TYPE_PROGRESS_INDETERMINATE: |
break; |
default: |
// If the caller asks for an unrecognized kind of view (entirely possible |
@@ -291,6 +231,7 @@ void NotificationView::CreateOrUpdateViews(const Notification& notification) { |
CreateOrUpdateTitleView(notification); |
CreateOrUpdateMessageView(notification); |
CreateOrUpdateProgressBarView(notification); |
+ CreateOrUpdateIndeterminateProgressBarView(notification); |
CreateOrUpdateListItemViews(notification); |
CreateOrUpdateIconView(notification); |
CreateOrUpdateImageView(notification); |
@@ -331,7 +272,8 @@ NotificationView::NotificationView(MessageCenterController* controller, |
bottom_view_(NULL), |
image_container_(NULL), |
image_view_(NULL), |
- progress_bar_view_(NULL) { |
+ progress_bar_view_(NULL), |
+ indeterminate_progress_bar_view_(NULL) { |
// Create the top_view_, which collects into a vertical box all content |
// at the top of the notification (to the right of the icon) except for the |
// close button. |
@@ -674,6 +616,30 @@ void NotificationView::CreateOrUpdateProgressBarView( |
progress_bar_view_->SetVisible(!notification.items().size()); |
} |
+void NotificationView::CreateOrUpdateIndeterminateProgressBarView( |
+ const Notification& notification) { |
+ if (notification.type() != NOTIFICATION_TYPE_PROGRESS_INDETERMINATE) { |
+ if (indeterminate_progress_bar_view_) { |
+ // Deletion will also remove |progress_bar_view_| from its parent. |
+ delete indeterminate_progress_bar_view_; |
+ indeterminate_progress_bar_view_ = NULL; |
+ } |
+ return; |
+ } |
+ |
+ DCHECK(top_view_ != NULL); |
+ |
+ if (!indeterminate_progress_bar_view_) { |
+ indeterminate_progress_bar_view_ = |
+ new NotificationIndeterminateProgressBar(); |
+ indeterminate_progress_bar_view_->SetBorder(MakeProgressBarBorder( |
+ message_center::kProgressBarTopPadding, kProgressBarBottomPadding)); |
+ top_view_->AddChildView(indeterminate_progress_bar_view_); |
+ } |
+ |
+ indeterminate_progress_bar_view_->SetVisible(!notification.items().size()); |
+} |
+ |
void NotificationView::CreateOrUpdateListItemViews( |
const Notification& notification) { |
for (size_t i = 0; i < item_views_.size(); ++i) |