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

Side by Side Diff: ui/message_center/message_center_bubble.cc

Issue 12082064: makes NotificationView aware of border. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/message_center/notification_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/message_center/message_center_bubble.h" 5 #include "ui/message_center/message_center_bubble.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "grit/ui_strings.h" 8 #include "grit/ui_strings.h"
9 #include "third_party/skia/include/core/SkPaint.h" 9 #include "third_party/skia/include/core/SkPaint.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 bounds.Inset(gfx::Insets(kItemShadowBlur / 2, kItemShadowBlur / 2, 362 bounds.Inset(gfx::Insets(kItemShadowBlur / 2, kItemShadowBlur / 2,
363 kItemShadowBlur / 2, kItemShadowBlur / 2)); 363 kItemShadowBlur / 2, kItemShadowBlur / 2));
364 canvas->DrawRect(bounds, paint); 364 canvas->DrawRect(bounds, paint);
365 } 365 }
366 366
367 virtual gfx::Insets GetInsets() const OVERRIDE { 367 virtual gfx::Insets GetInsets() const OVERRIDE {
368 return GetItemShadowInsets(); 368 return GetItemShadowInsets();
369 } 369 }
370 }; 370 };
371 371
372 // A layout manager which is similar to views::FillLayout but respects the
373 // border.
374 class FillWithBorderLayout : public views::LayoutManager {
375 public:
376 FillWithBorderLayout() {}
377 virtual ~FillWithBorderLayout() {}
378
379 // views::LayoutManager overrides:
380 virtual void Layout(views::View* host) OVERRIDE {
381 if (!host->has_children())
382 return;
383 host->child_at(0)->SetBoundsRect(host->GetContentsBounds());
384 }
385
386 virtual gfx::Size GetPreferredSize(views::View* host) OVERRIDE {
387 DCHECK_EQ(1, host->child_count());
388 gfx::Size size = host->child_at(0)->GetPreferredSize();
389 gfx::Insets insets = host->GetInsets();
390 size.Enlarge(insets.width(), insets.height());
391 return size;
392 }
393
394 private:
395 DISALLOW_COPY_AND_ASSIGN(FillWithBorderLayout);
396 };
397
398 } // namespace 372 } // namespace
399 373
400 // Message Center contents. 374 // Message Center contents.
401 class MessageCenterContentsView : public views::View { 375 class MessageCenterContentsView : public views::View {
402 public: 376 public:
403 explicit MessageCenterContentsView(MessageCenterBubble* bubble, 377 explicit MessageCenterContentsView(MessageCenterBubble* bubble,
404 NotificationList::Delegate* list_delegate) 378 NotificationList::Delegate* list_delegate)
405 : list_delegate_(list_delegate), 379 : list_delegate_(list_delegate),
406 bubble_(bubble) { 380 bubble_(bubble) {
407 int between_child = UseNewDesign() ? 0 : 1; 381 int between_child = UseNewDesign() ? 0 : 1;
(...skipping 25 matching lines...) Expand all
433 void Update(const NotificationList::Notifications& notifications) { 407 void Update(const NotificationList::Notifications& notifications) {
434 scroll_content_->RemoveAllChildViews(true); 408 scroll_content_->RemoveAllChildViews(true);
435 scroll_content_->set_preferred_size(gfx::Size()); 409 scroll_content_->set_preferred_size(gfx::Size());
436 size_t num_children = 0; 410 size_t num_children = 0;
437 for (NotificationList::Notifications::const_iterator iter = 411 for (NotificationList::Notifications::const_iterator iter =
438 notifications.begin(); iter != notifications.end(); ++iter) { 412 notifications.begin(); iter != notifications.end(); ++iter) {
439 MessageView* view = 413 MessageView* view =
440 NotificationView::ViewForNotification(*iter, list_delegate_); 414 NotificationView::ViewForNotification(*iter, list_delegate_);
441 view->set_scroller(scroller_); 415 view->set_scroller(scroller_);
442 view->SetUpView(); 416 view->SetUpView();
443 if (UseNewDesign()) { 417 if (UseNewDesign())
444 views::View* container = new views::View(); 418 view->set_border(new MessageViewShadowBorder());
445 container->SetLayoutManager(new FillWithBorderLayout()); 419 scroll_content_->AddChildView(view);
446 container->set_border(new MessageViewShadowBorder());
447 container->AddChildView(view);
448 scroll_content_->AddChildView(container);
449 } else {
450 scroll_content_->AddChildView(view);
451 }
452 if (++num_children >= 420 if (++num_children >=
453 NotificationList::kMaxVisibleMessageCenterNotifications) { 421 NotificationList::kMaxVisibleMessageCenterNotifications) {
454 break; 422 break;
455 } 423 }
456 } 424 }
457 if (num_children == 0) { 425 if (num_children == 0) {
458 views::Label* label = new views::Label(l10n_util::GetStringUTF16( 426 views::Label* label = new views::Label(l10n_util::GetStringUTF16(
459 IDS_MESSAGE_CENTER_NO_MESSAGES)); 427 IDS_MESSAGE_CENTER_NO_MESSAGES));
460 label->SetFont(label->font().DeriveFont(1)); 428 label->SetFont(label->font().DeriveFont(1));
461 label->SetEnabledColor(SK_ColorGRAY); 429 label->SetEnabledColor(SK_ColorGRAY);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 522 }
555 523
556 void MessageCenterBubble::OnMouseExitedView() { 524 void MessageCenterBubble::OnMouseExitedView() {
557 } 525 }
558 526
559 size_t MessageCenterBubble::NumMessageViewsForTest() const { 527 size_t MessageCenterBubble::NumMessageViewsForTest() const {
560 return contents_view_->NumMessageViews(); 528 return contents_view_->NumMessageViews();
561 } 529 }
562 530
563 } // namespace message_center 531 } // namespace message_center
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/notification_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698