OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_view.h" | 5 #include "ui/message_center/views/message_center_view.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 const SkColor kNoNotificationsTextColor = SkColorSetRGB(0xb4, 0xb4, 0xb4); | 54 const SkColor kNoNotificationsTextColor = SkColorSetRGB(0xb4, 0xb4, 0xb4); |
55 const SkColor kBorderDarkColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); | 55 const SkColor kBorderDarkColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); |
56 const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0); | 56 const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0); |
57 const SkColor kButtonTextHighlightColor = SkColorSetRGB(0x2a, 0x2a, 0x2a); | 57 const SkColor kButtonTextHighlightColor = SkColorSetRGB(0x2a, 0x2a, 0x2a); |
58 const SkColor kButtonTextHoverColor = SkColorSetRGB(0x2a, 0x2a, 0x2a); | 58 const SkColor kButtonTextHoverColor = SkColorSetRGB(0x2a, 0x2a, 0x2a); |
59 const int kAnimateClearingNextNotificationDelayMS = 40; | 59 const int kAnimateClearingNextNotificationDelayMS = 40; |
60 | 60 |
61 static const int kDefaultFrameRateHz = 60; | 61 static const int kDefaultFrameRateHz = 60; |
62 static const int kDefaultAnimationDurationMs = 120; | 62 static const int kDefaultAnimationDurationMs = 120; |
63 | 63 |
64 // PoorMessageCenterButtonBar ////////////////////////////////////////////////// | 64 } // namespace |
65 | |
66 // The view for the buttons at the bottom of the message center window used | |
67 // when kEnableRichNotifications is false (hence the "poor" in the name :-). | |
68 class PoorMessageCenterButtonBar : public MessageCenterButtonBar, | |
69 public views::ButtonListener { | |
70 public: | |
71 PoorMessageCenterButtonBar(MessageCenterView* message_center_view, | |
72 MessageCenter* message_center); | |
73 | |
74 // Overridden from views::ButtonListener: | |
75 virtual void ButtonPressed(views::Button* sender, | |
76 const ui::Event& event) OVERRIDE; | |
77 | |
78 private: | |
79 DISALLOW_COPY_AND_ASSIGN(PoorMessageCenterButtonBar); | |
80 }; | |
81 | |
82 PoorMessageCenterButtonBar::PoorMessageCenterButtonBar( | |
83 MessageCenterView* message_center_view, MessageCenter* message_center) | |
84 : MessageCenterButtonBar(message_center_view, message_center) { | |
85 set_background(views::Background::CreateBackgroundPainter( | |
86 true, | |
87 views::Painter::CreateVerticalGradient(kBackgroundLightColor, | |
88 kBackgroundDarkColor))); | |
89 set_border(views::Border::CreateSolidSidedBorder( | |
90 2, 0, 0, 0, kBorderDarkColor)); | |
91 | |
92 views::GridLayout* layout = new views::GridLayout(this); | |
93 SetLayoutManager(layout); | |
94 views::ColumnSet* columns = layout->AddColumnSet(0); | |
95 columns->AddPaddingColumn(100, 0); | |
96 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::CENTER, | |
97 0, /* resize percent */ | |
98 views::GridLayout::USE_PREF, 0, 0); | |
99 columns->AddPaddingColumn(0, 4); | |
100 | |
101 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance(); | |
102 views::LabelButton* close_all_button = new views::LabelButton( | |
103 this, resource_bundle.GetLocalizedString(IDS_MESSAGE_CENTER_CLEAR_ALL)); | |
104 close_all_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
105 close_all_button->set_request_focus_on_press(false); | |
106 close_all_button->SetTextColor(views::Button::STATE_NORMAL, kFooterTextColor); | |
107 close_all_button->SetTextColor(views::Button::STATE_HOVERED, | |
108 kButtonTextHoverColor); | |
109 | |
110 layout->AddPaddingRow(0, 4); | |
111 layout->StartRow(0, 0); | |
112 layout->AddView(close_all_button); | |
113 set_close_all_button(close_all_button); | |
114 } | |
115 | |
116 void PoorMessageCenterButtonBar::ButtonPressed(views::Button* sender, | |
117 const ui::Event& event) { | |
118 if (sender == close_all_button()) | |
119 message_center_view()->ClearAllNotifications(); | |
120 } | |
121 | 65 |
122 // NotificationCenterButton //////////////////////////////////////////////////// | 66 // NotificationCenterButton //////////////////////////////////////////////////// |
123 | 67 |
124 class NotificationCenterButton : public views::ToggleImageButton { | 68 class NotificationCenterButton : public views::ToggleImageButton { |
125 public: | 69 public: |
126 NotificationCenterButton(views::ButtonListener* listener, | 70 NotificationCenterButton(views::ButtonListener* listener, |
127 int normal_id, | 71 int normal_id, |
128 int hover_id, | 72 int hover_id, |
129 int pressed_id, | 73 int pressed_id, |
130 int text_id); | 74 int text_id); |
(...skipping 29 matching lines...) Expand all Loading... | |
160 return gfx::Size(kButtonSize, kButtonSize); | 104 return gfx::Size(kButtonSize, kButtonSize); |
161 } | 105 } |
162 | 106 |
163 void NotificationCenterButton::OnPaintFocusBorder(gfx::Canvas* canvas) { | 107 void NotificationCenterButton::OnPaintFocusBorder(gfx::Canvas* canvas) { |
164 if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { | 108 if (HasFocus() && (focusable() || IsAccessibilityFocusable())) { |
165 canvas->DrawRect(gfx::Rect(2, 1, width() - 4, height() - 3), | 109 canvas->DrawRect(gfx::Rect(2, 1, width() - 4, height() - 3), |
166 kFocusBorderColor); | 110 kFocusBorderColor); |
167 } | 111 } |
168 } | 112 } |
169 | 113 |
170 // RichMessageCenterButtonBar ////////////////////////////////////////////////// | 114 // MessageCenterButtonBar ////////////////////////////////////////////////// |
171 | 115 |
172 // TODO(mukai): Merge this into MessageCenterButtonBar and get rid of | 116 MessageCenterButtonBar::MessageCenterButtonBar( |
173 // PoorMessageCenterButtonBar when the kEnableRichNotifications flag disappears. | 117 MessageCenterView* message_center_view, |
174 class RichMessageCenterButtonBar : public MessageCenterButtonBar, | 118 MessageCenter* message_center) |
175 public views::ButtonListener { | 119 : message_center_view_(message_center_view), |
176 public: | 120 message_center_(message_center), |
177 RichMessageCenterButtonBar(MessageCenterView* message_center_view, | 121 close_all_button_(NULL) { |
178 MessageCenter* message_center); | |
179 | |
180 private: | |
181 // Overridden from MessageCenterButtonBar: | |
182 virtual void SetAllButtonsEnabled(bool enabled) OVERRIDE; | |
183 | |
184 // Overridden from views::View: | |
185 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE; | |
186 | |
187 // Overridden from views::ButtonListener: | |
188 virtual void ButtonPressed(views::Button* sender, | |
189 const ui::Event& event) OVERRIDE; | |
190 | |
191 NotificationCenterButton* settings_button_; | |
192 NotificationCenterButton* quiet_mode_button_; | |
193 | |
194 DISALLOW_COPY_AND_ASSIGN(RichMessageCenterButtonBar); | |
195 }; | |
196 | |
197 RichMessageCenterButtonBar::RichMessageCenterButtonBar( | |
198 MessageCenterView* message_center_view, MessageCenter* message_center) | |
199 : MessageCenterButtonBar(message_center_view, message_center) { | |
200 if (get_use_acceleration_when_possible()) | 122 if (get_use_acceleration_when_possible()) |
201 SetPaintToLayer(true); | 123 SetPaintToLayer(true); |
202 set_background(views::Background::CreateSolidBackground( | 124 set_background(views::Background::CreateSolidBackground( |
203 kMessageCenterBackgroundColor)); | 125 kMessageCenterBackgroundColor)); |
204 | 126 |
205 views::Label* notification_label = new views::Label(l10n_util::GetStringUTF16( | 127 views::Label* notification_label = new views::Label(l10n_util::GetStringUTF16( |
206 IDS_MESSAGE_CENTER_FOOTER_TITLE)); | 128 IDS_MESSAGE_CENTER_FOOTER_TITLE)); |
207 notification_label->SetAutoColorReadabilityEnabled(false); | 129 notification_label->SetAutoColorReadabilityEnabled(false); |
208 notification_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 130 notification_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
209 notification_label->SetEnabledColor(kRegularTextColor); | 131 notification_label->SetEnabledColor(kRegularTextColor); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 views::ColumnSet* column = layout->AddColumnSet(0); | 180 views::ColumnSet* column = layout->AddColumnSet(0); |
259 column->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 181 column->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
260 1.0f, views::GridLayout::USE_PREF, 0, 0); | 182 1.0f, views::GridLayout::USE_PREF, 0, 0); |
261 column->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 183 column->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
262 0, views::GridLayout::USE_PREF, 0, 0); | 184 0, views::GridLayout::USE_PREF, 0, 0); |
263 layout->StartRow(0, 0); | 185 layout->StartRow(0, 0); |
264 layout->AddView(notification_label); | 186 layout->AddView(notification_label); |
265 layout->AddView(button_container); | 187 layout->AddView(button_container); |
266 } | 188 } |
267 | 189 |
268 // Overridden from MessageCenterButtonBar: | 190 MessageCenterButtonBar::~MessageCenterButtonBar() {} |
269 void RichMessageCenterButtonBar::SetAllButtonsEnabled(bool enabled) { | 191 |
270 MessageCenterButtonBar::SetAllButtonsEnabled(enabled); | 192 void MessageCenterButtonBar::SetAllButtonsEnabled(bool enabled) { |
193 if (close_all_button_) | |
194 close_all_button_->SetEnabled(enabled); | |
271 settings_button_->SetEnabled(enabled); | 195 settings_button_->SetEnabled(enabled); |
272 quiet_mode_button_->SetEnabled(enabled); | 196 quiet_mode_button_->SetEnabled(enabled); |
273 } | 197 } |
274 | 198 |
199 void MessageCenterButtonBar::SetCloseAllVisible(bool visible) { | |
200 if (close_all_button_) | |
201 close_all_button_->SetVisible(visible); | |
202 } | |
203 | |
275 // Overridden from views::View: | 204 // Overridden from views::View: |
276 void RichMessageCenterButtonBar::ChildVisibilityChanged(views::View* child) { | 205 void MessageCenterButtonBar::ChildVisibilityChanged(views::View* child) { |
277 InvalidateLayout(); | 206 InvalidateLayout(); |
278 } | 207 } |
279 | 208 |
280 // Overridden from views::ButtonListener: | 209 // Overridden from views::ButtonListener: |
281 void RichMessageCenterButtonBar::ButtonPressed(views::Button* sender, | 210 void MessageCenterButtonBar::ButtonPressed(views::Button* sender, |
282 const ui::Event& event) { | 211 const ui::Event& event) { |
283 if (sender == close_all_button()) { | 212 if (sender == close_all_button()) { |
284 message_center_view()->ClearAllNotifications(); | 213 message_center_view()->ClearAllNotifications(); |
285 } else if (sender == settings_button_) { | 214 } else if (sender == settings_button_) { |
286 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 215 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
287 center_view->SetSettingsVisible(!center_view->settings_visible()); | 216 center_view->SetSettingsVisible(!center_view->settings_visible()); |
288 } else if (sender == quiet_mode_button_) { | 217 } else if (sender == quiet_mode_button_) { |
289 if (message_center()->IsQuietMode()) | 218 if (message_center()->IsQuietMode()) |
290 message_center()->SetQuietMode(false); | 219 message_center()->SetQuietMode(false); |
291 else | 220 else |
292 message_center()->EnterQuietModeWithExpire(base::TimeDelta::FromDays(1)); | 221 message_center()->EnterQuietModeWithExpire(base::TimeDelta::FromDays(1)); |
(...skipping 22 matching lines...) Expand all Loading... | |
315 | 244 |
316 DISALLOW_COPY_AND_ASSIGN(BoundedScrollView); | 245 DISALLOW_COPY_AND_ASSIGN(BoundedScrollView); |
317 }; | 246 }; |
318 | 247 |
319 BoundedScrollView::BoundedScrollView(int min_height, int max_height) | 248 BoundedScrollView::BoundedScrollView(int min_height, int max_height) |
320 : min_height_(min_height), | 249 : min_height_(min_height), |
321 max_height_(max_height) { | 250 max_height_(max_height) { |
322 set_notify_enter_exit_on_child(true); | 251 set_notify_enter_exit_on_child(true); |
323 // Cancels the default dashed focus border. | 252 // Cancels the default dashed focus border. |
324 set_focus_border(NULL); | 253 set_focus_border(NULL); |
325 if (IsRichNotificationEnabled()) { | 254 set_background( |
326 set_background(views::Background::CreateSolidBackground( | 255 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); |
327 kMessageCenterBackgroundColor)); | 256 SetVerticalScrollBar(new views::OverlayScrollBar(false)); |
328 SetVerticalScrollBar(new views::OverlayScrollBar(false)); | |
329 } | |
330 } | 257 } |
331 | 258 |
332 gfx::Size BoundedScrollView::GetPreferredSize() { | 259 gfx::Size BoundedScrollView::GetPreferredSize() { |
333 gfx::Size size = contents()->GetPreferredSize(); | 260 gfx::Size size = contents()->GetPreferredSize(); |
334 size.SetToMax(gfx::Size(size.width(), min_height_)); | 261 size.SetToMax(gfx::Size(size.width(), min_height_)); |
335 size.SetToMin(gfx::Size(size.width(), max_height_)); | 262 size.SetToMin(gfx::Size(size.width(), max_height_)); |
336 gfx::Insets insets = GetInsets(); | 263 gfx::Insets insets = GetInsets(); |
337 size.Enlarge(insets.width(), insets.height()); | 264 size.Enlarge(insets.width(), insets.height()); |
338 return size; | 265 return size; |
339 } | 266 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 int NoNotificationMessageView::GetHeightForWidth(int width) { | 323 int NoNotificationMessageView::GetHeightForWidth(int width) { |
397 return kMinScrollViewHeight; | 324 return kMinScrollViewHeight; |
398 } | 325 } |
399 | 326 |
400 void NoNotificationMessageView::Layout() { | 327 void NoNotificationMessageView::Layout() { |
401 int text_height = label_->GetHeightForWidth(width()); | 328 int text_height = label_->GetHeightForWidth(width()); |
402 int margin = (height() - text_height) / 2; | 329 int margin = (height() - text_height) / 2; |
403 label_->SetBounds(0, margin, width(), text_height); | 330 label_->SetBounds(0, margin, width(), text_height); |
404 } | 331 } |
405 | 332 |
406 } // namespace | |
407 | |
408 // MessageListView ///////////////////////////////////////////////////////////// | |
409 | |
410 // Displays a list of messages. | |
411 class MessageListView : public views::View { | |
412 public: | |
413 explicit MessageListView(MessageCenterView* message_center_view); | |
414 | |
415 // The interface for repositioning. | |
416 virtual void AddNotificationAt(views::View* view, int i); | |
417 virtual void RemoveNotificationAt(int i); | |
418 virtual void UpdateNotificationAt(views::View* view, int i); | |
419 virtual void SetRepositionTarget(const gfx::Rect& target_rect) {} | |
420 virtual void ResetRepositionSession() {} | |
421 virtual void ClearAllNotifications(const gfx::Rect& visible_scroll_rect); | |
422 | |
423 protected: | |
424 MessageCenterView* message_center_view() const { | |
425 return message_center_view_; | |
426 } | |
427 | |
428 private: | |
429 MessageCenterView* message_center_view_; // Weak reference. | |
430 | |
431 DISALLOW_COPY_AND_ASSIGN(MessageListView); | |
432 }; | |
433 | |
434 MessageListView::MessageListView(MessageCenterView* message_center_view) | |
435 : message_center_view_(message_center_view) { | |
436 views::BoxLayout* layout = | |
437 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1); | |
438 layout->set_spread_blank_space(true); | |
439 SetLayoutManager(layout); | |
440 } | |
441 | |
442 void MessageListView::AddNotificationAt(views::View* view, int i) { | |
443 AddChildViewAt(view, i); | |
444 } | |
445 | |
446 void MessageListView::RemoveNotificationAt(int i) { | |
447 delete child_at(i); | |
448 } | |
449 | |
450 void MessageListView::UpdateNotificationAt(views::View* view, int i) { | |
451 delete child_at(i); | |
452 AddChildViewAt(view, i); | |
453 } | |
454 | |
455 void MessageListView::ClearAllNotifications( | |
456 const gfx::Rect& visible_scroll_rect) { | |
457 message_center_view_->OnAllNotificationsCleared(); | |
458 } | |
459 | |
460 // Displays a list of messages for rich notifications. It also supports | 333 // Displays a list of messages for rich notifications. It also supports |
461 // repositioning. | 334 // repositioning. |
462 class RichMessageListView : public MessageListView, | 335 class MessageListView : public views::View, |
463 public views::BoundsAnimatorObserver { | 336 public views::BoundsAnimatorObserver { |
464 public: | 337 public: |
465 explicit RichMessageListView(MessageCenterView* message_center_view); | 338 explicit MessageListView(MessageCenterView* message_center_view); |
466 virtual ~RichMessageListView(); | 339 virtual ~MessageListView(); |
340 | |
341 // Overridden from MessageListView. | |
Jun Mukai
2013/07/01 20:48:58
not overridden. you should remove virtual too
dewittj
2013/07/01 23:58:30
Done.
| |
342 virtual void AddNotificationAt(views::View* view, int i); | |
343 virtual void RemoveNotificationAt(int i); | |
344 virtual void UpdateNotificationAt(views::View* view, int i); | |
345 virtual void SetRepositionTarget(const gfx::Rect& target_rect); | |
346 virtual void ResetRepositionSession(); | |
347 virtual void ClearAllNotifications(const gfx::Rect& visible_scroll_rect); | |
467 | 348 |
468 protected: | 349 protected: |
469 // Overridden from views::View. | 350 // Overridden from views::View. |
470 virtual void Layout() OVERRIDE; | 351 virtual void Layout() OVERRIDE; |
471 virtual gfx::Size GetPreferredSize() OVERRIDE; | 352 virtual gfx::Size GetPreferredSize() OVERRIDE; |
472 virtual int GetHeightForWidth(int width) OVERRIDE; | 353 virtual int GetHeightForWidth(int width) OVERRIDE; |
473 | 354 |
474 // Overridden from MessageListView. | |
475 virtual void AddNotificationAt(views::View* view, int i) OVERRIDE; | |
476 virtual void RemoveNotificationAt(int i) OVERRIDE; | |
477 virtual void UpdateNotificationAt(views::View* view, int i) OVERRIDE; | |
478 virtual void SetRepositionTarget(const gfx::Rect& target_rect) OVERRIDE; | |
479 virtual void ResetRepositionSession() OVERRIDE; | |
480 virtual void ClearAllNotifications( | |
481 const gfx::Rect& visible_scroll_rect) OVERRIDE; | |
482 | |
483 // Overridden from views::BoundsAnimatorObserver. | 355 // Overridden from views::BoundsAnimatorObserver. |
484 virtual void OnBoundsAnimatorProgressed( | 356 virtual void OnBoundsAnimatorProgressed( |
485 views::BoundsAnimator* animator) OVERRIDE; | 357 views::BoundsAnimator* animator) OVERRIDE; |
486 virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE; | 358 virtual void OnBoundsAnimatorDone(views::BoundsAnimator* animator) OVERRIDE; |
487 | 359 |
488 private: | 360 private: |
489 // Returns the actual index for child of |index|. | 361 // Returns the actual index for child of |index|. |
490 // RichMessageListView allows to slide down upper notifications, which means | 362 // MessageListView allows to slide down upper notifications, which means |
491 // that the upper ones should come above the lower ones. To achieve this, | 363 // that the upper ones should come above the lower ones. To achieve this, |
492 // inversed order is adopted. The top most notification is the last child, | 364 // inversed order is adopted. The top most notification is the last child, |
493 // and the bottom most notification is the first child. | 365 // and the bottom most notification is the first child. |
494 int GetActualIndex(int index); | 366 int GetActualIndex(int index); |
495 bool IsValidChild(views::View* child); | 367 bool IsValidChild(views::View* child); |
496 void DoUpdateIfPossible(); | 368 void DoUpdateIfPossible(); |
497 | 369 |
498 // Schedules animation for a child to the specified position. | 370 // Schedules animation for a child to the specified position. |
499 void AnimateChild(views::View* child, int top, int height); | 371 void AnimateChild(views::View* child, int top, int height); |
500 | 372 |
501 // Animate clearing one notification. | 373 // Animate clearing one notification. |
502 void AnimateClearingOneNotification(); | 374 void AnimateClearingOneNotification(); |
375 MessageCenterView* message_center_view() const { | |
376 return message_center_view_; | |
377 } | |
503 | 378 |
379 MessageCenterView* message_center_view_; // Weak reference. | |
504 // The top position of the reposition target rectangle. | 380 // The top position of the reposition target rectangle. |
505 int reposition_top_; | 381 int reposition_top_; |
506 | |
507 int fixed_height_; | 382 int fixed_height_; |
508 | |
509 bool has_deferred_task_; | 383 bool has_deferred_task_; |
510 bool clear_all_started_; | 384 bool clear_all_started_; |
511 std::set<views::View*> adding_views_; | 385 std::set<views::View*> adding_views_; |
512 std::set<views::View*> deleting_views_; | 386 std::set<views::View*> deleting_views_; |
513 std::set<views::View*> deleted_when_done_; | 387 std::set<views::View*> deleted_when_done_; |
514 std::list<views::View*> clearing_all_views_; | 388 std::list<views::View*> clearing_all_views_; |
515 scoped_ptr<views::BoundsAnimator> animator_; | 389 scoped_ptr<views::BoundsAnimator> animator_; |
516 base::WeakPtrFactory<RichMessageListView> weak_ptr_factory_; | 390 base::WeakPtrFactory<MessageListView> weak_ptr_factory_; |
517 | 391 |
518 DISALLOW_COPY_AND_ASSIGN(RichMessageListView); | 392 DISALLOW_COPY_AND_ASSIGN(MessageListView); |
519 }; | 393 }; |
520 | 394 |
521 RichMessageListView::RichMessageListView(MessageCenterView* message_center_view) | 395 MessageListView::MessageListView(MessageCenterView* message_center_view) |
522 : MessageListView(message_center_view), | 396 : message_center_view_(message_center_view), |
523 reposition_top_(-1), | 397 reposition_top_(-1), |
524 fixed_height_(0), | 398 fixed_height_(0), |
525 has_deferred_task_(false), | 399 has_deferred_task_(false), |
526 clear_all_started_(false), | 400 clear_all_started_(false), |
527 weak_ptr_factory_(this) { | 401 weak_ptr_factory_(this) { |
402 views::BoxLayout* layout = | |
403 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1); | |
404 layout->set_spread_blank_space(true); | |
405 SetLayoutManager(layout); | |
406 | |
528 // Set the margin to 0 for the layout. BoxLayout assumes the same margin | 407 // Set the margin to 0 for the layout. BoxLayout assumes the same margin |
529 // for top and bottom, but the bottom margin here should be smaller | 408 // for top and bottom, but the bottom margin here should be smaller |
530 // because of the shadow of message view. Use an empty border instead | 409 // because of the shadow of message view. Use an empty border instead |
531 // to provide this margin. | 410 // to provide this margin. |
532 gfx::Insets shadow_insets = MessageView::GetShadowInsets(); | 411 gfx::Insets shadow_insets = MessageView::GetShadowInsets(); |
533 set_background(views::Background::CreateSolidBackground( | 412 set_background(views::Background::CreateSolidBackground( |
534 kMessageCenterBackgroundColor)); | 413 kMessageCenterBackgroundColor)); |
535 set_border(views::Border::CreateEmptyBorder( | 414 set_border(views::Border::CreateEmptyBorder( |
536 kMarginBetweenItems - shadow_insets.top(), /* top */ | 415 kMarginBetweenItems - shadow_insets.top(), /* top */ |
537 kMarginBetweenItems - shadow_insets.left(), /* left */ | 416 kMarginBetweenItems - shadow_insets.left(), /* left */ |
538 kMarginBetweenItems - shadow_insets.bottom(), /* bottom */ | 417 kMarginBetweenItems - shadow_insets.bottom(), /* bottom */ |
539 kMarginBetweenItems - shadow_insets.right() /* right */ )); | 418 kMarginBetweenItems - shadow_insets.right() /* right */ )); |
540 } | 419 } |
541 | 420 |
542 RichMessageListView::~RichMessageListView() { | 421 MessageListView::~MessageListView() { |
543 if (animator_.get()) | 422 if (animator_.get()) |
544 animator_->RemoveObserver(this); | 423 animator_->RemoveObserver(this); |
545 } | 424 } |
546 | 425 |
547 void RichMessageListView::Layout() { | 426 void MessageListView::Layout() { |
548 if (animator_.get()) | 427 if (animator_.get()) |
549 return; | 428 return; |
550 | 429 |
551 gfx::Rect child_area = GetContentsBounds(); | 430 gfx::Rect child_area = GetContentsBounds(); |
552 int top = child_area.y(); | 431 int top = child_area.y(); |
553 int between_items = | 432 int between_items = |
554 kMarginBetweenItems - MessageView::GetShadowInsets().bottom(); | 433 kMarginBetweenItems - MessageView::GetShadowInsets().bottom(); |
555 | 434 |
556 for (int i = child_count() - 1; i >= 0; --i) { | 435 for (int i = child_count() - 1; i >= 0; --i) { |
557 views::View* child = child_at(i); | 436 views::View* child = child_at(i); |
558 if (!child->visible()) | 437 if (!child->visible()) |
559 continue; | 438 continue; |
560 int height = child->GetHeightForWidth(child_area.width()); | 439 int height = child->GetHeightForWidth(child_area.width()); |
561 child->SetBounds(child_area.x(), top, child_area.width(), height); | 440 child->SetBounds(child_area.x(), top, child_area.width(), height); |
562 top += height + between_items; | 441 top += height + between_items; |
563 } | 442 } |
564 } | 443 } |
565 | 444 |
566 void RichMessageListView::AddNotificationAt(views::View* view, int i) { | 445 void MessageListView::AddNotificationAt(views::View* view, int i) { |
567 // Increment by 1 because the default behavior of AddChildViewAt() is to | 446 // Increment by 1 because the default behavior of AddChildViewAt() is to |
568 // insert before the specified index. | 447 // insert before the specified index. |
569 AddChildViewAt(view, GetActualIndex(i) + 1); | 448 AddChildViewAt(view, GetActualIndex(i) + 1); |
570 if (GetContentsBounds().IsEmpty()) | 449 if (GetContentsBounds().IsEmpty()) |
571 return; | 450 return; |
572 | 451 |
573 adding_views_.insert(view); | 452 adding_views_.insert(view); |
574 DoUpdateIfPossible(); | 453 DoUpdateIfPossible(); |
575 } | 454 } |
576 | 455 |
577 void RichMessageListView::RemoveNotificationAt(int i) { | 456 void MessageListView::RemoveNotificationAt(int i) { |
578 views::View* child = child_at(GetActualIndex(i)); | 457 views::View* child = child_at(GetActualIndex(i)); |
579 if (GetContentsBounds().IsEmpty()) { | 458 if (GetContentsBounds().IsEmpty()) { |
580 delete child; | 459 delete child; |
581 } else { | 460 } else { |
582 if (child->layer()) { | 461 if (child->layer()) { |
583 deleting_views_.insert(child); | 462 deleting_views_.insert(child); |
584 } else { | 463 } else { |
585 if (animator_.get()) | 464 if (animator_.get()) |
586 animator_->StopAnimatingView(child); | 465 animator_->StopAnimatingView(child); |
587 delete child; | 466 delete child; |
588 } | 467 } |
589 DoUpdateIfPossible(); | 468 DoUpdateIfPossible(); |
590 } | 469 } |
591 } | 470 } |
592 | 471 |
593 void RichMessageListView::UpdateNotificationAt(views::View* view, int i) { | 472 void MessageListView::UpdateNotificationAt(views::View* view, int i) { |
594 int actual_index = GetActualIndex(i); | 473 int actual_index = GetActualIndex(i); |
595 views::View* child = child_at(actual_index); | 474 views::View* child = child_at(actual_index); |
596 if (animator_.get()) | 475 if (animator_.get()) |
597 animator_->StopAnimatingView(child); | 476 animator_->StopAnimatingView(child); |
598 gfx::Rect old_bounds = child->bounds(); | 477 gfx::Rect old_bounds = child->bounds(); |
599 if (deleting_views_.find(child) != deleting_views_.end()) | 478 if (deleting_views_.find(child) != deleting_views_.end()) |
600 deleting_views_.erase(child); | 479 deleting_views_.erase(child); |
601 if (deleted_when_done_.find(child) != deleted_when_done_.end()) | 480 if (deleted_when_done_.find(child) != deleted_when_done_.end()) |
602 deleted_when_done_.erase(child); | 481 deleted_when_done_.erase(child); |
603 delete child; | 482 delete child; |
604 AddChildViewAt(view, actual_index); | 483 AddChildViewAt(view, actual_index); |
605 view->SetBounds(old_bounds.x(), old_bounds.y(), old_bounds.width(), | 484 view->SetBounds(old_bounds.x(), old_bounds.y(), old_bounds.width(), |
606 view->GetHeightForWidth(old_bounds.width())); | 485 view->GetHeightForWidth(old_bounds.width())); |
607 DoUpdateIfPossible(); | 486 DoUpdateIfPossible(); |
608 } | 487 } |
609 | 488 |
610 gfx::Size RichMessageListView::GetPreferredSize() { | 489 gfx::Size MessageListView::GetPreferredSize() { |
611 int width = 0; | 490 int width = 0; |
612 for (int i = 0; i < child_count(); i++) { | 491 for (int i = 0; i < child_count(); i++) { |
613 views::View* child = child_at(i); | 492 views::View* child = child_at(i); |
614 if (IsValidChild(child)) | 493 if (IsValidChild(child)) |
615 width = std::max(width, child->GetPreferredSize().width()); | 494 width = std::max(width, child->GetPreferredSize().width()); |
616 } | 495 } |
617 | 496 |
618 return gfx::Size(width + GetInsets().width(), | 497 return gfx::Size(width + GetInsets().width(), |
619 GetHeightForWidth(width + GetInsets().width())); | 498 GetHeightForWidth(width + GetInsets().width())); |
620 } | 499 } |
621 | 500 |
622 int RichMessageListView::GetHeightForWidth(int width) { | 501 int MessageListView::GetHeightForWidth(int width) { |
623 if (fixed_height_ > 0) | 502 if (fixed_height_ > 0) |
624 return fixed_height_; | 503 return fixed_height_; |
625 | 504 |
626 width -= GetInsets().width(); | 505 width -= GetInsets().width(); |
627 int height = 0; | 506 int height = 0; |
628 int padding = 0; | 507 int padding = 0; |
629 for (int i = 0; i < child_count(); ++i) { | 508 for (int i = 0; i < child_count(); ++i) { |
630 views::View* child = child_at(i); | 509 views::View* child = child_at(i); |
631 if (!IsValidChild(child)) | 510 if (!IsValidChild(child)) |
632 continue; | 511 continue; |
633 height += child->GetHeightForWidth(width) + padding; | 512 height += child->GetHeightForWidth(width) + padding; |
634 padding = kMarginBetweenItems - MessageView::GetShadowInsets().bottom(); | 513 padding = kMarginBetweenItems - MessageView::GetShadowInsets().bottom(); |
635 } | 514 } |
636 | 515 |
637 return height + GetInsets().height(); | 516 return height + GetInsets().height(); |
638 } | 517 } |
639 | 518 |
640 void RichMessageListView::SetRepositionTarget(const gfx::Rect& target) { | 519 void MessageListView::SetRepositionTarget(const gfx::Rect& target) { |
641 reposition_top_ = target.y(); | 520 reposition_top_ = target.y(); |
642 fixed_height_ = GetHeightForWidth(width()); | 521 fixed_height_ = GetHeightForWidth(width()); |
643 } | 522 } |
644 | 523 |
645 void RichMessageListView::ResetRepositionSession() { | 524 void MessageListView::ResetRepositionSession() { |
646 // Don't call DoUpdateIfPossible(), but let Layout() do the task without | 525 // Don't call DoUpdateIfPossible(), but let Layout() do the task without |
647 // animation. Reset will cause the change of the bubble size itself, and | 526 // animation. Reset will cause the change of the bubble size itself, and |
648 // animation from the old location will look weird. | 527 // animation from the old location will look weird. |
649 if (reposition_top_ >= 0 && animator_.get()) { | 528 if (reposition_top_ >= 0 && animator_.get()) { |
650 has_deferred_task_ = false; | 529 has_deferred_task_ = false; |
651 // cancel cause OnBoundsAnimatorDone which deletes |deleted_when_done_|. | 530 // cancel cause OnBoundsAnimatorDone which deletes |deleted_when_done_|. |
652 animator_->Cancel(); | 531 animator_->Cancel(); |
653 STLDeleteContainerPointers(deleting_views_.begin(), deleting_views_.end()); | 532 STLDeleteContainerPointers(deleting_views_.begin(), deleting_views_.end()); |
654 deleting_views_.clear(); | 533 deleting_views_.clear(); |
655 adding_views_.clear(); | 534 adding_views_.clear(); |
656 animator_.reset(); | 535 animator_.reset(); |
657 } | 536 } |
658 | 537 |
659 reposition_top_ = -1; | 538 reposition_top_ = -1; |
660 fixed_height_ = 0; | 539 fixed_height_ = 0; |
661 } | 540 } |
662 | 541 |
663 void RichMessageListView::ClearAllNotifications( | 542 void MessageListView::ClearAllNotifications( |
664 const gfx::Rect& visible_scroll_rect) { | 543 const gfx::Rect& visible_scroll_rect) { |
665 for (int i = 0; i < child_count(); ++i) { | 544 for (int i = 0; i < child_count(); ++i) { |
666 views::View* child = child_at(i); | 545 views::View* child = child_at(i); |
667 if (!child->visible()) | 546 if (!child->visible()) |
668 continue; | 547 continue; |
669 if (gfx::IntersectRects(child->bounds(), visible_scroll_rect).IsEmpty()) | 548 if (gfx::IntersectRects(child->bounds(), visible_scroll_rect).IsEmpty()) |
670 continue; | 549 continue; |
671 clearing_all_views_.push_back(child); | 550 clearing_all_views_.push_back(child); |
672 } | 551 } |
673 DoUpdateIfPossible(); | 552 DoUpdateIfPossible(); |
674 } | 553 } |
675 | 554 |
676 void RichMessageListView::OnBoundsAnimatorProgressed( | 555 void MessageListView::OnBoundsAnimatorProgressed( |
677 views::BoundsAnimator* animator) { | 556 views::BoundsAnimator* animator) { |
678 DCHECK_EQ(animator_.get(), animator); | 557 DCHECK_EQ(animator_.get(), animator); |
679 for (std::set<views::View*>::iterator iter = deleted_when_done_.begin(); | 558 for (std::set<views::View*>::iterator iter = deleted_when_done_.begin(); |
680 iter != deleted_when_done_.end(); ++iter) { | 559 iter != deleted_when_done_.end(); ++iter) { |
681 const ui::SlideAnimation* animation = animator->GetAnimationForView(*iter); | 560 const ui::SlideAnimation* animation = animator->GetAnimationForView(*iter); |
682 if (animation) | 561 if (animation) |
683 (*iter)->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); | 562 (*iter)->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); |
684 } | 563 } |
685 } | 564 } |
686 | 565 |
687 void RichMessageListView::OnBoundsAnimatorDone( | 566 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
688 views::BoundsAnimator* animator) { | |
689 STLDeleteContainerPointers( | 567 STLDeleteContainerPointers( |
690 deleted_when_done_.begin(), deleted_when_done_.end()); | 568 deleted_when_done_.begin(), deleted_when_done_.end()); |
691 deleted_when_done_.clear(); | 569 deleted_when_done_.clear(); |
692 | 570 |
693 if (clear_all_started_) { | 571 if (clear_all_started_) { |
694 clear_all_started_ = false; | 572 clear_all_started_ = false; |
695 message_center_view()->OnAllNotificationsCleared(); | 573 message_center_view()->OnAllNotificationsCleared(); |
696 } | 574 } |
697 | 575 |
698 if (has_deferred_task_) { | 576 if (has_deferred_task_) { |
699 has_deferred_task_ = false; | 577 has_deferred_task_ = false; |
700 DoUpdateIfPossible(); | 578 DoUpdateIfPossible(); |
701 } | 579 } |
702 | 580 |
703 if (GetWidget()) | 581 if (GetWidget()) |
704 GetWidget()->SynthesizeMouseMoveEvent(); | 582 GetWidget()->SynthesizeMouseMoveEvent(); |
705 } | 583 } |
706 | 584 |
707 int RichMessageListView::GetActualIndex(int index) { | 585 int MessageListView::GetActualIndex(int index) { |
708 // As is written in the comment in the declaration, this method | 586 // As is written in the comment in the declaration, this method |
709 // returns actual index for the |index|-th valid child from the end. | 587 // returns actual index for the |index|-th valid child from the end. |
710 int actual_index = child_count() - 1; | 588 int actual_index = child_count() - 1; |
711 // Skips the invalid children at last. | 589 // Skips the invalid children at last. |
712 for (; actual_index > 0; --actual_index) { | 590 for (; actual_index > 0; --actual_index) { |
713 if (IsValidChild(child_at(actual_index))) | 591 if (IsValidChild(child_at(actual_index))) |
714 break; | 592 break; |
715 } | 593 } |
716 // Find the |index|-th valid child from the end. | 594 // Find the |index|-th valid child from the end. |
717 for (; actual_index >= 0 && index > 0; --actual_index) { | 595 for (; actual_index >= 0 && index > 0; --actual_index) { |
718 index -= IsValidChild(child_at(actual_index)) ? 1 : 0; | 596 index -= IsValidChild(child_at(actual_index)) ? 1 : 0; |
719 } | 597 } |
720 return actual_index; | 598 return actual_index; |
721 } | 599 } |
722 | 600 |
723 bool RichMessageListView::IsValidChild(views::View* child) { | 601 bool MessageListView::IsValidChild(views::View* child) { |
724 return child->visible() && | 602 return child->visible() && |
725 deleting_views_.find(child) == deleting_views_.end() && | 603 deleting_views_.find(child) == deleting_views_.end() && |
726 deleted_when_done_.find(child) == deleted_when_done_.end(); | 604 deleted_when_done_.find(child) == deleted_when_done_.end(); |
727 } | 605 } |
728 | 606 |
729 void RichMessageListView::DoUpdateIfPossible() { | 607 void MessageListView::DoUpdateIfPossible() { |
730 gfx::Rect child_area = GetContentsBounds(); | 608 gfx::Rect child_area = GetContentsBounds(); |
731 if (child_area.IsEmpty()) | 609 if (child_area.IsEmpty()) |
732 return; | 610 return; |
733 | 611 |
734 if (animator_.get() && animator_->IsAnimating()) { | 612 if (animator_.get() && animator_->IsAnimating()) { |
735 has_deferred_task_ = true; | 613 has_deferred_task_ = true; |
736 return; | 614 return; |
737 } | 615 } |
738 | 616 |
739 if (!animator_.get()) { | 617 if (!animator_.get()) { |
(...skipping 23 matching lines...) Expand all Loading... | |
763 for (int i = first_index; i < child_count(); ++i) { | 641 for (int i = first_index; i < child_count(); ++i) { |
764 views::View* child = child_at(i); | 642 views::View* child = child_at(i); |
765 AnimateChild(child, bottom - child->height(), child->height()); | 643 AnimateChild(child, bottom - child->height(), child->height()); |
766 bottom -= child->height() + between_items; | 644 bottom -= child->height() + between_items; |
767 } | 645 } |
768 } | 646 } |
769 adding_views_.clear(); | 647 adding_views_.clear(); |
770 deleting_views_.clear(); | 648 deleting_views_.clear(); |
771 } | 649 } |
772 | 650 |
773 void RichMessageListView::AnimateChild(views::View* child, | 651 void MessageListView::AnimateChild(views::View* child, int top, int height) { |
774 int top, | |
775 int height) { | |
776 gfx::Rect child_area = GetContentsBounds(); | 652 gfx::Rect child_area = GetContentsBounds(); |
777 if (adding_views_.find(child) != adding_views_.end()) { | 653 if (adding_views_.find(child) != adding_views_.end()) { |
778 child->SetBounds(child_area.right(), top, child_area.width(), height); | 654 child->SetBounds(child_area.right(), top, child_area.width(), height); |
779 animator_->AnimateViewTo( | 655 animator_->AnimateViewTo( |
780 child, gfx::Rect(child_area.x(), top, child_area.width(), height)); | 656 child, gfx::Rect(child_area.x(), top, child_area.width(), height)); |
781 } else if (deleting_views_.find(child) != deleting_views_.end()) { | 657 } else if (deleting_views_.find(child) != deleting_views_.end()) { |
782 DCHECK(child->layer()); | 658 DCHECK(child->layer()); |
783 // No moves, but animate to fade-out. | 659 // No moves, but animate to fade-out. |
784 animator_->AnimateViewTo(child, child->bounds()); | 660 animator_->AnimateViewTo(child, child->bounds()); |
785 deleted_when_done_.insert(child); | 661 deleted_when_done_.insert(child); |
786 } else { | 662 } else { |
787 gfx::Rect target(child_area.x(), top, child_area.width(), height); | 663 gfx::Rect target(child_area.x(), top, child_area.width(), height); |
788 if (child->bounds().origin() != target.origin()) | 664 if (child->bounds().origin() != target.origin()) |
789 animator_->AnimateViewTo(child, target); | 665 animator_->AnimateViewTo(child, target); |
790 else | 666 else |
791 child->SetBoundsRect(target); | 667 child->SetBoundsRect(target); |
792 } | 668 } |
793 } | 669 } |
794 | 670 |
795 void RichMessageListView::AnimateClearingOneNotification() { | 671 void MessageListView::AnimateClearingOneNotification() { |
796 DCHECK(!clearing_all_views_.empty()); | 672 DCHECK(!clearing_all_views_.empty()); |
797 | 673 |
798 clear_all_started_ = true; | 674 clear_all_started_ = true; |
799 | 675 |
800 views::View* child = clearing_all_views_.back(); | 676 views::View* child = clearing_all_views_.back(); |
801 clearing_all_views_.pop_back(); | 677 clearing_all_views_.pop_back(); |
802 | 678 |
803 // Slide from left to right. | 679 // Slide from left to right. |
804 gfx::Rect new_bounds = child->bounds(); | 680 gfx::Rect new_bounds = child->bounds(); |
805 new_bounds.set_x(new_bounds.right() + kMarginBetweenItems); | 681 new_bounds.set_x(new_bounds.right() + kMarginBetweenItems); |
806 animator_->AnimateViewTo(child, new_bounds); | 682 animator_->AnimateViewTo(child, new_bounds); |
807 | 683 |
808 // Schedule to start sliding out next notification after a short delay. | 684 // Schedule to start sliding out next notification after a short delay. |
809 if (!clearing_all_views_.empty()) { | 685 if (!clearing_all_views_.empty()) { |
810 base::MessageLoop::current()->PostDelayedTask( | 686 base::MessageLoop::current()->PostDelayedTask( |
811 FROM_HERE, | 687 FROM_HERE, |
812 base::Bind(&RichMessageListView::AnimateClearingOneNotification, | 688 base::Bind(&MessageListView::AnimateClearingOneNotification, |
813 weak_ptr_factory_.GetWeakPtr()), | 689 weak_ptr_factory_.GetWeakPtr()), |
814 base::TimeDelta::FromMilliseconds( | 690 base::TimeDelta::FromMilliseconds( |
815 kAnimateClearingNextNotificationDelayMS)); | 691 kAnimateClearingNextNotificationDelayMS)); |
816 } | 692 } |
817 } | 693 } |
818 | 694 |
819 // MessageCenterButtonBar ////////////////////////////////////////////////////// | |
820 | |
821 MessageCenterButtonBar::MessageCenterButtonBar( | |
822 MessageCenterView* message_center_view, MessageCenter* message_center) | |
823 : message_center_view_(message_center_view), | |
824 message_center_(message_center), | |
825 close_all_button_(NULL) { | |
826 } | |
827 | |
828 MessageCenterButtonBar::~MessageCenterButtonBar() { | |
829 } | |
830 | |
831 void MessageCenterButtonBar::SetAllButtonsEnabled(bool enabled) { | |
832 if (close_all_button_) | |
833 close_all_button_->SetEnabled(enabled); | |
834 } | |
835 | |
836 void MessageCenterButtonBar::SetCloseAllVisible(bool visible) { | |
837 if (close_all_button_) | |
838 close_all_button_->SetVisible(visible); | |
839 } | |
840 | |
841 // MessageCenterView /////////////////////////////////////////////////////////// | 695 // MessageCenterView /////////////////////////////////////////////////////////// |
842 | 696 |
843 MessageCenterView::MessageCenterView(MessageCenter* message_center, | 697 MessageCenterView::MessageCenterView(MessageCenter* message_center, |
844 MessageCenterTray* tray, | 698 MessageCenterTray* tray, |
845 int max_height, | 699 int max_height, |
846 bool initially_settings_visible) | 700 bool initially_settings_visible) |
847 : message_center_(message_center), | 701 : message_center_(message_center), |
848 tray_(tray), | 702 tray_(tray), |
849 settings_visible_(initially_settings_visible) { | 703 settings_visible_(initially_settings_visible) { |
850 message_center_->AddObserver(this); | 704 message_center_->AddObserver(this); |
851 set_notify_enter_exit_on_child(true); | 705 set_notify_enter_exit_on_child(true); |
852 set_background(views::Background::CreateSolidBackground( | 706 set_background(views::Background::CreateSolidBackground( |
853 kMessageCenterBackgroundColor)); | 707 kMessageCenterBackgroundColor)); |
854 | 708 |
855 if (IsRichNotificationEnabled()) | 709 button_bar_ = new MessageCenterButtonBar(this, message_center); |
856 button_bar_ = new RichMessageCenterButtonBar(this, message_center); | |
857 else | |
858 button_bar_ = new PoorMessageCenterButtonBar(this, message_center); | |
859 | 710 |
860 const int button_height = button_bar_->GetPreferredSize().height(); | 711 const int button_height = button_bar_->GetPreferredSize().height(); |
861 scroller_ = new BoundedScrollView(kMinScrollViewHeight, | 712 scroller_ = new BoundedScrollView(kMinScrollViewHeight, |
862 max_height - button_height); | 713 max_height - button_height); |
863 | 714 |
864 if (get_use_acceleration_when_possible()) { | 715 if (get_use_acceleration_when_possible()) { |
865 scroller_->SetPaintToLayer(true); | 716 scroller_->SetPaintToLayer(true); |
866 scroller_->SetFillsBoundsOpaquely(false); | 717 scroller_->SetFillsBoundsOpaquely(false); |
867 scroller_->layer()->SetMasksToBounds(true); | 718 scroller_->layer()->SetMasksToBounds(true); |
868 } | 719 } |
869 | 720 |
870 message_list_view_ = IsRichNotificationEnabled() ? | 721 message_list_view_ = new MessageListView(this); |
871 new RichMessageListView(this) : new MessageListView(this); | |
872 no_notifications_message_view_ = new NoNotificationMessageView(); | 722 no_notifications_message_view_ = new NoNotificationMessageView(); |
873 // Set the default visibility to false, otherwise the notification has slide | 723 // Set the default visibility to false, otherwise the notification has slide |
874 // in animation when the center is shown. | 724 // in animation when the center is shown. |
875 no_notifications_message_view_->SetVisible(false); | 725 no_notifications_message_view_->SetVisible(false); |
876 message_list_view_->AddChildView(no_notifications_message_view_); | 726 message_list_view_->AddChildView(no_notifications_message_view_); |
877 scroller_->SetContents(message_list_view_); | 727 scroller_->SetContents(message_list_view_); |
878 | 728 |
879 settings_view_ = new NotifierSettingsView( | 729 settings_view_ = new NotifierSettingsView( |
880 message_center_->GetNotifierSettingsProvider()); | 730 message_center_->GetNotifierSettingsProvider()); |
881 | 731 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
962 scroller_->SetEnabled(true); | 812 scroller_->SetEnabled(true); |
963 button_bar_->SetAllButtonsEnabled(true); | 813 button_bar_->SetAllButtonsEnabled(true); |
964 message_center_->RemoveAllNotifications(true); // Action by user. | 814 message_center_->RemoveAllNotifications(true); // Action by user. |
965 } | 815 } |
966 | 816 |
967 size_t MessageCenterView::NumMessageViewsForTest() const { | 817 size_t MessageCenterView::NumMessageViewsForTest() const { |
968 return message_list_view_->child_count(); | 818 return message_list_view_->child_count(); |
969 } | 819 } |
970 | 820 |
971 void MessageCenterView::Layout() { | 821 void MessageCenterView::Layout() { |
972 int between_child = IsRichNotificationEnabled() ? 0 : 1; | |
973 int button_height = button_bar_->GetHeightForWidth(width()); | 822 int button_height = button_bar_->GetHeightForWidth(width()); |
974 // Skip unnecessary re-layout of contents during the resize animation. | 823 // Skip unnecessary re-layout of contents during the resize animation. |
975 if (settings_transition_animation_ && | 824 if (settings_transition_animation_ && |
976 settings_transition_animation_->is_animating() && | 825 settings_transition_animation_->is_animating() && |
977 settings_transition_animation_->current_part_index() == 0) { | 826 settings_transition_animation_->current_part_index() == 0) { |
978 button_bar_->SetBounds(0, height() - button_height, width(), button_height); | 827 button_bar_->SetBounds(0, height() - button_height, width(), button_height); |
979 return; | 828 return; |
980 } | 829 } |
981 | 830 |
982 scroller_->SetBounds(0, 0, width(), height() - button_height - between_child); | 831 scroller_->SetBounds(0, 0, width(), height() - button_height); |
983 settings_view_->SetBounds( | 832 settings_view_->SetBounds(0, 0, width(), height() - button_height); |
984 0, 0, width(), height() - button_height - between_child); | |
985 | 833 |
986 bool is_scrollable = false; | 834 bool is_scrollable = false; |
987 if (scroller_->visible()) | 835 if (scroller_->visible()) |
988 is_scrollable = scroller_->height() < message_list_view_->height(); | 836 is_scrollable = scroller_->height() < message_list_view_->height(); |
989 else | 837 else |
990 is_scrollable = settings_view_->IsScrollable(); | 838 is_scrollable = settings_view_->IsScrollable(); |
991 | 839 |
992 if (is_scrollable && !button_bar_->border()) { | 840 if (is_scrollable && !button_bar_->border()) { |
993 button_bar_->set_border(views::Border::CreateSolidSidedBorder( | 841 button_bar_->set_border(views::Border::CreateSolidSidedBorder( |
994 1, 0, 0, 0, kFooterDelimiterColor)); | 842 1, 0, 0, 0, kFooterDelimiterColor)); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1195 scroller_->InvalidateLayout(); | 1043 scroller_->InvalidateLayout(); |
1196 PreferredSizeChanged(); | 1044 PreferredSizeChanged(); |
1197 Layout(); | 1045 Layout(); |
1198 } | 1046 } |
1199 | 1047 |
1200 void MessageCenterView::SetNotificationViewForTest(views::View* view) { | 1048 void MessageCenterView::SetNotificationViewForTest(views::View* view) { |
1201 message_list_view_->AddNotificationAt(view, 0); | 1049 message_list_view_->AddNotificationAt(view, 0); |
1202 } | 1050 } |
1203 | 1051 |
1204 } // namespace message_center | 1052 } // namespace message_center |
OLD | NEW |