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

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

Issue 1447933002: Implement an indeterminate progress-bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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/views/notification_view.cc
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index 76b7827614857c9bc70cc7febf930f0f3d8a3b3d..32c477e39110cfed8aecf6b749197f5ec6180809 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"
#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 {
@@ -670,6 +609,7 @@ void NotificationView::CreateOrUpdateProgressBarView(
top_view_->AddChildView(progress_bar_view_);
}
+ progress_bar_view_->SetIndeterminate(notification.progress() < 0);
progress_bar_view_->SetValue(notification.progress() / 100.0);
progress_bar_view_->SetVisible(!notification.items().size());
}

Powered by Google App Engine
This is Rietveld 408576698