Index: ui/message_center/message_center_bubble.cc |
diff --git a/ui/message_center/message_center_bubble.cc b/ui/message_center/message_center_bubble.cc |
index 863e77c1a3cdb94ca187deb352af56398d41b5b5..3b0e73cca8a2c4afa73f36695422bb4e2eb74ca8 100644 |
--- a/ui/message_center/message_center_bubble.cc |
+++ b/ui/message_center/message_center_bubble.cc |
@@ -28,10 +28,11 @@ namespace { |
const int kMessageBubbleBaseMinHeight = 80; |
const int kMessageBubbleBaseMaxHeight = 400; |
const int kMarginBetweenItems = 10; |
-const SkColor kMessageCenterBackgroundColor = SkColorSetRGB(0xd3, 0xd3, 0xd3); |
+const int kItemShadowHeight = 4; |
+const SkColor kMessageCenterBackgroundColor = SkColorSetRGB(0xe5, 0xe5, 0xe5); |
const SkColor kBorderDarkColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); |
-const SkColor kMessageItemBorderWidth = 1; |
-const SkColor kMessageItemBorderColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); |
+const SkColor kMessageItemShadowColorBase = SkColorSetARGB(0.3 * 255, 0, 0, 0); |
+const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0); |
// The view for the buttons at the bottom of the web notification tray. |
class WebNotificationButtonView : public views::View, |
@@ -148,13 +149,22 @@ class FixedSizedScrollView : public views::ScrollView { |
class ScrollContentView : public views::View { |
public: |
ScrollContentView() { |
+ // Set the margin to 0 for the layout. BoxLayout assumes the same margin |
+ // for top and bottom, but the bottom margin here should be smaller |
+ // because of the shadow of message view. Use an empty border instead |
+ // to provide this margin. |
SetLayoutManager( |
new views::BoxLayout(views::BoxLayout::kVertical, |
- kMarginBetweenItems, |
- kMarginBetweenItems, |
- kMarginBetweenItems)); |
+ 0, |
+ 0, |
+ kMarginBetweenItems - kItemShadowHeight)); |
set_background(views::Background::CreateSolidBackground( |
kMessageCenterBackgroundColor)); |
+ set_border(views::Border::CreateEmptyBorder( |
+ kMarginBetweenItems, /* top */ |
+ kMarginBetweenItems, /* left */ |
+ kMarginBetweenItems - kItemShadowHeight, /* bottom */ |
+ kMarginBetweenItems /* right */ )); |
} |
virtual ~ScrollContentView() { |
@@ -173,6 +183,30 @@ class ScrollContentView : public views::View { |
DISALLOW_COPY_AND_ASSIGN(ScrollContentView); |
}; |
+// A view to draw gradient shadow for each MessageView. |
+class MessageViewShadow : public views::View { |
+ public: |
+ MessageViewShadow() |
+ : painter_(views::Painter::CreateVerticalGradient( |
+ kMessageItemShadowColorBase, kTransparentColor)) { |
+ } |
+ |
+ private: |
+ // views::View overrides: |
+ virtual gfx::Size GetPreferredSize() OVERRIDE { |
+ // The preferred size must not be empty. Thus put an arbitrary non-zero |
+ // width here. It will be just ignored by the vertical box layout. |
+ return gfx::Size(1, kItemShadowHeight); |
+ } |
+ |
+ virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
+ painter_->Paint(canvas, bounds().size()); |
+ } |
+ |
+ scoped_ptr<views::Painter> painter_; |
+ DISALLOW_COPY_AND_ASSIGN(MessageViewShadow); |
+}; |
+ |
} // namespace |
// Message Center contents. |
@@ -209,10 +243,14 @@ class MessageCenterContentsView : public views::View { |
MessageView* view = |
MessageViewFactory::ViewForNotification(*iter, list_delegate_); |
view->set_scroller(scroller_); |
- view->set_border(views::Border::CreateSolidBorder( |
- kMessageItemBorderWidth, kMessageItemBorderColor)); |
view->SetUpView(); |
- scroll_content_->AddChildView(view); |
+ |
+ views::View* container = new views::View(); |
+ container->SetLayoutManager( |
+ new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
+ container->AddChildView(view); |
+ container->AddChildView(new MessageViewShadow()); |
+ scroll_content_->AddChildView(container); |
if (++num_children >= |
NotificationList::kMaxVisibleMessageCenterNotifications) { |
break; |