summaryrefslogtreecommitdiffstats
path: root/ui/message_center
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 03:02:03 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-01 03:02:03 +0000
commit95f934c9858b6a4548810899d410ce0e80a596fb (patch)
tree74ce9d17d1ec6600b7cb0fb337002b2d2c303f24 /ui/message_center
parent553eae1b3098618283594626de4d1f3e307b582f (diff)
downloadchromium_src-95f934c9858b6a4548810899d410ce0e80a596fb.zip
chromium_src-95f934c9858b6a4548810899d410ce0e80a596fb.tar.gz
chromium_src-95f934c9858b6a4548810899d410ce0e80a596fb.tar.bz2
makes NotificationView aware of border.
Separating the shadow border from the card isn't a good idea because the shadow doesn't follow the slide-out animation of its contents. Rather we should specify the shadow border directly to the card, and make the card aware of the border. BUG=172010 TEST=on device, open the message center and swipe the notification. Review URL: https://chromiumcodereview.appspot.com/12082064 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180047 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/message_center')
-rw-r--r--ui/message_center/message_center_bubble.cc38
-rw-r--r--ui/message_center/notification_view.cc17
2 files changed, 16 insertions, 39 deletions
diff --git a/ui/message_center/message_center_bubble.cc b/ui/message_center/message_center_bubble.cc
index f7f4af3..72a4486 100644
--- a/ui/message_center/message_center_bubble.cc
+++ b/ui/message_center/message_center_bubble.cc
@@ -369,32 +369,6 @@ class MessageViewShadowBorder : public views::Border {
}
};
-// A layout manager which is similar to views::FillLayout but respects the
-// border.
-class FillWithBorderLayout : public views::LayoutManager {
- public:
- FillWithBorderLayout() {}
- virtual ~FillWithBorderLayout() {}
-
- // views::LayoutManager overrides:
- virtual void Layout(views::View* host) OVERRIDE {
- if (!host->has_children())
- return;
- host->child_at(0)->SetBoundsRect(host->GetContentsBounds());
- }
-
- virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE {
- DCHECK_EQ(1, host->child_count());
- gfx::Size size = host->child_at(0)->GetPreferredSize();
- gfx::Insets insets = host->GetInsets();
- size.Enlarge(insets.width(), insets.height());
- return size;
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FillWithBorderLayout);
-};
-
} // namespace
// Message Center contents.
@@ -440,15 +414,9 @@ class MessageCenterContentsView : public views::View {
NotificationView::ViewForNotification(*iter, list_delegate_);
view->set_scroller(scroller_);
view->SetUpView();
- if (UseNewDesign()) {
- views::View* container = new views::View();
- container->SetLayoutManager(new FillWithBorderLayout());
- container->set_border(new MessageViewShadowBorder());
- container->AddChildView(view);
- scroll_content_->AddChildView(container);
- } else {
- scroll_content_->AddChildView(view);
- }
+ if (UseNewDesign())
+ view->set_border(new MessageViewShadowBorder());
+ scroll_content_->AddChildView(view);
if (++num_children >=
NotificationList::kMaxVisibleMessageCenterNotifications) {
break;
diff --git a/ui/message_center/notification_view.cc b/ui/message_center/notification_view.cc
index 050b5b4..2342206 100644
--- a/ui/message_center/notification_view.cc
+++ b/ui/message_center/notification_view.cc
@@ -240,17 +240,25 @@ NotificationView::~NotificationView() {
void NotificationView::Layout() {
if (content_view_) {
- content_view_->SetBoundsRect(GetLocalBounds());
+ gfx::Rect contents_bounds = GetContentsBounds();
+ content_view_->SetBoundsRect(contents_bounds);
if (close_button()) {
gfx::Size size(close_button()->GetPreferredSize());
- close_button()->SetBounds(width() - size.width(), 0,
+ close_button()->SetBounds(contents_bounds.right() - size.width(), 0,
size.width(), size.height());
}
}
}
gfx::Size NotificationView::GetPreferredSize() {
- return content_view_ ? content_view_->GetPreferredSize() : gfx::Size();
+ if (!content_view_)
+ return gfx::Size();
+ gfx::Size size = content_view_->GetPreferredSize();
+ if (border()) {
+ gfx::Insets border_insets = border()->GetInsets();
+ size.Enlarge(border_insets.width(), border_insets.height());
+ }
+ return size;
}
void NotificationView::SetUpView() {
@@ -260,7 +268,6 @@ void NotificationView::SetUpView() {
// expand button. This allows the close and expand buttons to overlap the
// content as needed to provide a large enough click area
// (<http://crbug.com/168822> and touch area <http://crbug.com/168856>).
- set_background(views::Background::CreateSolidBackground(kBackgroundColor));
AddChildView(MakeContentView());
AddChildView(close_button());
}
@@ -278,6 +285,8 @@ void NotificationView::ButtonPressed(views::Button* sender,
views::View* NotificationView::MakeContentView() {
content_view_ = new views::View();
+ content_view_->set_background(
+ views::Background::CreateSolidBackground(kBackgroundColor));
// The top part of the content view is composed of an icon view on the left
// and a certain number of text views on the right (title and message or list