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

Issue 21118002: Show progress bar notifications for Mac. (Closed)

Created:
7 years, 4 months ago by jianli
Modified:
7 years, 4 months ago
Reviewers:
Robert Sesek, dewittj
CC:
chromium-reviews
Visibility:
Public.

Description

Show progress bar notifications for Mac. BUG=170924 TEST=manual test by creating a progress bar notification R=dewittj@chromium.org, rsesek@chromium.org Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=214276

Patch Set 1 #

Total comments: 6

Patch Set 2 : Fix per feedbacks #

Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -0 lines) Patch
M ui/message_center/cocoa/notification_controller.h View 1 chunk +3 lines, -0 lines 0 comments Download
M ui/message_center/cocoa/notification_controller.mm View 1 3 chunks +56 lines, -0 lines 0 comments Download

Messages

Total messages: 9 (0 generated)
jianli
7 years, 4 months ago (2013-07-29 18:28:33 UTC) #1
Robert Sesek
Can you post a link to a screen shot? https://codereview.chromium.org/21118002/diff/1/ui/message_center/cocoa/notification_controller.mm File ui/message_center/cocoa/notification_controller.mm (right): https://codereview.chromium.org/21118002/diff/1/ui/message_center/cocoa/notification_controller.mm#newcode24 ui/message_center/cocoa/notification_controller.mm:24: ...
7 years, 4 months ago (2013-07-29 18:50:26 UTC) #2
jianli
https://codereview.chromium.org/21118002/diff/1/ui/message_center/cocoa/notification_controller.mm File ui/message_center/cocoa/notification_controller.mm (right): https://codereview.chromium.org/21118002/diff/1/ui/message_center/cocoa/notification_controller.mm#newcode24 ui/message_center/cocoa/notification_controller.mm:24: const SkColor kProgressBarBackgroundColor = SkColorSetRGB(230, 230, 230); On 2013/07/29 ...
7 years, 4 months ago (2013-07-29 19:05:40 UTC) #3
Robert Sesek
lgtm
7 years, 4 months ago (2013-07-29 19:06:25 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jianli@chromium.org/21118002/22001
7 years, 4 months ago (2013-07-29 20:10:56 UTC) #5
dewittj
rubber stamp lgtm
7 years, 4 months ago (2013-07-30 00:29:40 UTC) #6
jianli
Committed patchset #2 manually as r214276 (presubmit successful).
7 years, 4 months ago (2013-07-30 00:32:55 UTC) #7
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jianli@chromium.org/21118002/22001
7 years, 4 months ago (2013-07-30 05:46:12 UTC) #8
commit-bot: I haz the power
7 years, 4 months ago (2013-07-30 05:46:21 UTC) #9
Message was sent while issue was closed.
Failed to apply patch for ui/message_center/cocoa/notification_controller.mm:
While running patch -p1 --forward --force --no-backup-if-mismatch;
  patching file ui/message_center/cocoa/notification_controller.mm
  Hunk #1 succeeded at 53 with fuzz 2 (offset 34 lines).
  Hunk #2 FAILED at 352.
  Hunk #3 FAILED at 432.
  2 out of 3 hunks FAILED -- saving rejects to file
ui/message_center/cocoa/notification_controller.mm.rej

Patch:       ui/message_center/cocoa/notification_controller.mm
Index: ui/message_center/cocoa/notification_controller.mm
diff --git a/ui/message_center/cocoa/notification_controller.mm
b/ui/message_center/cocoa/notification_controller.mm
index
afea9e6ca4e6a57b0a240c842f641c8e29010f90..175ed52497f68cbef4553573be2ac8b4b7a45561
100644
--- a/ui/message_center/cocoa/notification_controller.mm
+++ b/ui/message_center/cocoa/notification_controller.mm
@@ -19,6 +19,40 @@
 #include "ui/message_center/message_center_style.h"
 #include "ui/message_center/notification.h"
 
+const CGFloat kProgressBarThickness = 8;
+const CGFloat kProgressBarTopPadding = 12;
+const SkColor kProgressBarBackgroundColor = SkColorSetRGB(230, 230, 230);
+const SkColor kProgressBarBackgroundBorderColor = SkColorSetRGB(208, 208, 208);
+const SkColor kProgressBarSliceColor = SkColorSetRGB(78, 156, 245);
+const SkColor kProgressBarSliceBorderColor = SkColorSetRGB(110, 188, 249);
+
+@interface MCNotificationProgressBar : NSProgressIndicator
+@end
+
+@implementation MCNotificationProgressBar
+- (void)drawRect:(NSRect)dirtyRect {
+  NSRect sliceRect, remainderRect;
+  double progressFraction = ([self doubleValue] - [self minValue]) /
+      ([self maxValue] - [self minValue]);
+  NSDivideRect(dirtyRect, &sliceRect, &remainderRect,
+               NSWidth(dirtyRect) * progressFraction, NSMinXEdge);
+
+  // For slice part.
+  [gfx::SkColorToCalibratedNSColor(kProgressBarSliceBorderColor)
+      drawSwatchInRect:sliceRect];
+  [gfx::SkColorToCalibratedNSColor(kProgressBarSliceColor)
+      drawSwatchInRect:NSInsetRect(sliceRect, 1.0, 1.0)];
+
+  // For remainder part.
+  [gfx::SkColorToCalibratedNSColor(kProgressBarBackgroundBorderColor)
+      drawSwatchInRect:remainderRect];
+  [gfx::SkColorToCalibratedNSColor(kProgressBarBackgroundColor)
+      drawSwatchInRect:NSInsetRect(remainderRect, 1.0, 1.0)];
+}
+@end
+
+////////////////////////////////////////////////////////////////////////////////
+
 @interface MCNotificationButtonCell : NSButtonCell {
   BOOL hovered_;
 }
@@ -318,17 +352,37 @@
     [[self view] addSubview:listItemView_];
   }
 
+  // Create the progress bar view if needed.
+  [progressBarView_ removeFromSuperview];
+  NSRect progressBarFrame = NSZeroRect;
+  if (notification->type() == message_center::NOTIFICATION_TYPE_PROGRESS) {
+    progressBarFrame = [self currentContentRect];
+    progressBarFrame.origin.y = NSMinY(messageFrame) -
+        kProgressBarTopPadding - kProgressBarThickness;
+    progressBarFrame.size.height = kProgressBarThickness;
+    progressBarView_.reset(
+        [[MCNotificationProgressBar alloc] initWithFrame:progressBarFrame]);
+    // Setting indeterminate to NO does not work with custom drawRect.
+    [progressBarView_ setIndeterminate:YES];
+    [progressBarView_ setStyle:NSProgressIndicatorBarStyle];
+    [progressBarView_ setDoubleValue:notification->progress()];
+    [[self view] addSubview:progressBarView_];
+  }
+
   // If the bottom-most element so far is out of the rootView's bounds, resize
   // the view.
   CGFloat minY = NSMinY(messageFrame);
   if (listItemView_ && NSMinY(listFrame) < minY)
     minY = NSMinY(listFrame);
+  if (progressBarView_ && NSMinY(progressBarFrame) < minY)
+    minY = NSMinY(progressBarFrame);
   if (minY < messagePadding) {
     CGFloat delta = messagePadding - minY;
     rootFrame.size.height += delta;
     titleFrame.origin.y += delta;
     messageFrame.origin.y += delta;
     listFrame.origin.y += delta;
+    progressBarFrame.origin.y += delta;
   }
 
   // Add the bottom container view.
@@ -398,11 +452,13 @@
   titleFrame.origin.y += NSHeight(frame);
   messageFrame.origin.y += NSHeight(frame);
   listFrame.origin.y += NSHeight(frame);
+  progressBarFrame.origin.y += NSHeight(frame);
 
   [[self view] setFrame:rootFrame];
   [title_ setFrame:titleFrame];
   [message_ setFrame:messageFrame];
   [listItemView_ setFrame:listFrame];
+  [progressBarView_ setFrame:progressBarFrame];
 
   return rootFrame;
 }

Powered by Google App Engine
This is Rietveld 408576698