Chromium Code Reviews| Index: ui/message_center/views/message_view.cc |
| diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc |
| index 8657aecf5d64bbf9b22a8bbdcfe83f62f413ba1c..1bdccc75d942edfd0982c41f6192b24fcbfcc13e 100644 |
| --- a/ui/message_center/views/message_view.cc |
| +++ b/ui/message_center/views/message_view.cc |
| @@ -18,6 +18,7 @@ |
| #include "ui/message_center/views/padded_button.h" |
| #include "ui/views/background.h" |
| #include "ui/views/controls/button/image_button.h" |
| +#include "ui/views/controls/image_view.h" |
| #include "ui/views/controls/scroll_view.h" |
| #include "ui/views/focus/focus_manager.h" |
| #include "ui/views/painter.h" |
| @@ -38,6 +39,7 @@ namespace message_center { |
| MessageView::MessageView(MessageViewController* controller, |
| const std::string& notification_id, |
| const NotifierId& notifier_id, |
| + const gfx::ImageSkia& small_image_skia, |
| const base::string16& display_source) |
| : controller_(controller), |
| notification_id_(notification_id), |
| @@ -53,6 +55,14 @@ MessageView::MessageView(MessageViewController* controller, |
| views::Background::CreateSolidBackground(kNotificationBackgroundColor)); |
| AddChildView(background_view_); |
| + views::ImageView* small_image = new views::ImageView(); |
|
Dmitry Titov
2014/01/29 23:07:05
this one could be small_image_view... if the small
dewittj
2014/01/30 00:41:56
Done.
|
| + small_image->SetImage(small_image_skia); |
| + small_image->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize)); |
| + // The small image view should be added to view hierarchy by the derived |
| + // class. This ensures that it is on top of other views. |
| + small_image->set_owned_by_client(); |
| + small_image_view_.reset(small_image); |
| + |
| PaddedButton *close = new PaddedButton(this); |
| close->SetPadding(-kCloseIconRightPadding, kCloseIconTopPadding); |
| close->SetNormalImage(IDR_NOTIFICATION_CLOSE); |
| @@ -139,6 +149,8 @@ bool MessageView::OnKeyReleased(const ui::KeyEvent& event) { |
| } |
| void MessageView::OnPaint(gfx::Canvas* canvas) { |
| + DCHECK_EQ(this, close_button_->parent()); |
| + DCHECK_EQ(this, small_image_view_->parent()); |
| SlideOutView::OnPaint(canvas); |
| views::Painter::PaintFocusPainter(this, canvas, focus_painter_.get()); |
| } |
| @@ -163,9 +175,19 @@ void MessageView::Layout() { |
| // Close button. |
| gfx::Size close_size(close_button_->GetPreferredSize()); |
| - close_button_->SetBounds( |
| - content_bounds.right() - close_size.width(), content_bounds.y(), |
| - close_size.width(), close_size.height()); |
| + gfx::Rect close_rect(content_bounds.right() - close_size.width(), |
| + content_bounds.y(), |
| + close_size.width(), |
| + close_size.height()); |
| + close_button_->SetBoundsRect(close_rect); |
| + |
| + gfx::Size small_image_size(small_image_view_->GetPreferredSize()); |
| + gfx::Rect small_image_rect(small_image_size); |
| + small_image_rect.set_origin(gfx::Point( |
| + content_bounds.right() - small_image_size.width() - kSmallImagePadding, |
| + content_bounds.bottom() - small_image_size.height() - |
| + kSmallImagePadding)); |
| + small_image_view_->SetBoundsRect(small_image_rect); |
| } |
| void MessageView::OnGestureEvent(ui::GestureEvent* event) { |