Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/views/message_center_bubble.h" | 5 #include "ui/message_center/views/message_center_bubble.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "grit/ui_strings.h" | 9 #include "grit/ui_strings.h" |
| 10 #include "third_party/skia/include/core/SkPaint.h" | 10 #include "third_party/skia/include/core/SkPaint.h" |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 private: | 282 private: |
| 283 int min_height_; | 283 int min_height_; |
| 284 int max_height_; | 284 int max_height_; |
| 285 | 285 |
| 286 DISALLOW_COPY_AND_ASSIGN(BoundedScrollView); | 286 DISALLOW_COPY_AND_ASSIGN(BoundedScrollView); |
| 287 }; | 287 }; |
| 288 | 288 |
| 289 // Displays a list of messages. | 289 // Displays a list of messages. |
| 290 class MessageListView : public views::View { | 290 class MessageListView : public views::View { |
| 291 public: | 291 public: |
| 292 MessageListView() { | 292 MessageListView(views::View* container) : container_(container) { |
| 293 if (IsRichNotificationEnabled()) { | 293 if (IsRichNotificationEnabled()) { |
| 294 // Set the margin to 0 for the layout. BoxLayout assumes the same margin | 294 // Set the margin to 0 for the layout. BoxLayout assumes the same margin |
| 295 // for top and bottom, but the bottom margin here should be smaller | 295 // for top and bottom, but the bottom margin here should be smaller |
| 296 // because of the shadow of message view. Use an empty border instead | 296 // because of the shadow of message view. Use an empty border instead |
| 297 // to provide this margin. | 297 // to provide this margin. |
| 298 gfx::Insets shadow_insets = MessageView::GetShadowInsets(); | 298 gfx::Insets shadow_insets = MessageView::GetShadowInsets(); |
| 299 SetLayoutManager( | 299 SetLayoutManager( |
| 300 new views::BoxLayout(views::BoxLayout::kVertical, | 300 new views::BoxLayout(views::BoxLayout::kVertical, |
| 301 0, | 301 0, |
| 302 0, | 302 0, |
| 303 kMarginBetweenItems - shadow_insets.bottom())); | 303 kMarginBetweenItems - shadow_insets.bottom())); |
| 304 set_background(views::Background::CreateSolidBackground( | 304 set_background(views::Background::CreateSolidBackground( |
| 305 kMessageCenterBackgroundColor)); | 305 kMessageCenterBackgroundColor)); |
| 306 set_border(views::Border::CreateEmptyBorder( | 306 set_border(views::Border::CreateEmptyBorder( |
| 307 kMarginBetweenItems - shadow_insets.top(), /* top */ | 307 kMarginBetweenItems - shadow_insets.top(), /* top */ |
| 308 kMarginBetweenItems - shadow_insets.left(), /* left */ | 308 kMarginBetweenItems - shadow_insets.left(), /* left */ |
| 309 0, /* bottom */ | 309 0, /* bottom */ |
| 310 kMarginBetweenItems - shadow_insets.right() /* right */ )); | 310 kMarginBetweenItems - shadow_insets.right() /* right */ )); |
| 311 } else { | 311 } else { |
| 312 views::BoxLayout* layout = | 312 views::BoxLayout* layout = |
| 313 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1); | 313 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1); |
| 314 layout->set_spread_blank_space(true); | 314 layout->set_spread_blank_space(true); |
| 315 SetLayoutManager(layout); | 315 SetLayoutManager(layout); |
| 316 } | 316 } |
| 317 } | 317 } |
| 318 | 318 |
| 319 virtual ~MessageListView() { | 319 virtual ~MessageListView() { |
| 320 } | 320 } |
| 321 | 321 |
| 322 protected: | |
| 323 // Overridden from views::View: | |
| 324 void ChildPreferredSizeChanged(View* child) { | |
| 325 container_->Layout(); | |
| 326 } | |
|
dharcourt
2013/03/13 22:47:51
Without this the MessageCenterView never would get
| |
| 327 | |
| 322 private: | 328 private: |
| 329 views::View* container_; // Weak reference. | |
| 330 | |
| 323 DISALLOW_COPY_AND_ASSIGN(MessageListView); | 331 DISALLOW_COPY_AND_ASSIGN(MessageListView); |
| 324 }; | 332 }; |
| 325 | 333 |
| 326 } // namespace | 334 } // namespace |
| 327 | 335 |
| 328 // View that displays the whole message center. | 336 // View that displays the whole message center. |
| 329 class MessageCenterView : public views::View { | 337 class MessageCenterView : public views::View { |
| 330 public: | 338 public: |
| 331 MessageCenterView(MessageCenterBubble* bubble, | 339 MessageCenterView(MessageCenterBubble* bubble, |
| 332 NotificationChangeObserver* observer) | 340 NotificationChangeObserver* observer) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 346 const int min_height = kMessageBubbleBaseMinHeight - button_height; | 354 const int min_height = kMessageBubbleBaseMinHeight - button_height; |
| 347 const int max_height = bubble_->max_height() - button_height; | 355 const int max_height = bubble_->max_height() - button_height; |
| 348 scroller_ = new BoundedScrollView(min_height, max_height); | 356 scroller_ = new BoundedScrollView(min_height, max_height); |
| 349 | 357 |
| 350 if (get_use_acceleration_when_possible()) { | 358 if (get_use_acceleration_when_possible()) { |
| 351 scroller_->SetPaintToLayer(true); | 359 scroller_->SetPaintToLayer(true); |
| 352 scroller_->SetFillsBoundsOpaquely(false); | 360 scroller_->SetFillsBoundsOpaquely(false); |
| 353 scroller_->layer()->SetMasksToBounds(true); | 361 scroller_->layer()->SetMasksToBounds(true); |
| 354 } | 362 } |
| 355 | 363 |
| 356 message_list_view_ = new MessageListView(); | 364 message_list_view_ = new MessageListView(this); |
| 357 scroller_->SetContents(message_list_view_); | 365 scroller_->SetContents(message_list_view_); |
| 358 | 366 |
| 359 AddChildView(scroller_); | 367 AddChildView(scroller_); |
| 360 AddChildView(button_view_); | 368 AddChildView(button_view_); |
| 361 } | 369 } |
| 362 | 370 |
| 363 void FocusContents() { | 371 void FocusContents() { |
| 364 } | 372 } |
| 365 | 373 |
| 366 void UpdateAllNotifications( | 374 void UpdateAllNotifications( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 } | 493 } |
| 486 | 494 |
| 487 void MessageCenterBubble::OnMouseExitedView() { | 495 void MessageCenterBubble::OnMouseExitedView() { |
| 488 } | 496 } |
| 489 | 497 |
| 490 size_t MessageCenterBubble::NumMessageViewsForTest() const { | 498 size_t MessageCenterBubble::NumMessageViewsForTest() const { |
| 491 return contents_view_->NumMessageViews(); | 499 return contents_view_->NumMessageViews(); |
| 492 } | 500 } |
| 493 | 501 |
| 494 } // namespace message_center | 502 } // namespace message_center |
| OLD | NEW |