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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 namespace { | 47 namespace { |
48 | 48 |
49 const SkColor kNoNotificationsTextColor = SkColorSetRGB(0xb4, 0xb4, 0xb4); | 49 const SkColor kNoNotificationsTextColor = SkColorSetRGB(0xb4, 0xb4, 0xb4); |
50 #if defined(OS_LINUX) && defined(OS_CHROMEOS) | 50 #if defined(OS_LINUX) && defined(OS_CHROMEOS) |
51 const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0); | 51 const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0); |
52 #endif | 52 #endif |
53 const int kAnimateClearingNextNotificationDelayMS = 40; | 53 const int kAnimateClearingNextNotificationDelayMS = 40; |
54 | 54 |
55 const int kDefaultAnimationDurationMs = 120; | 55 const int kDefaultAnimationDurationMs = 120; |
56 const int kDefaultFrameRateHz = 60; | 56 const int kDefaultFrameRateHz = 60; |
| 57 |
| 58 void SetViewHierarchyEnabled(views::View* view, bool enabled) { |
| 59 for (int i = 0; i < view->child_count(); i++) |
| 60 SetViewHierarchyEnabled(view->child_at(i), enabled); |
| 61 view->SetEnabled(enabled); |
| 62 } |
| 63 |
57 } // namespace | 64 } // namespace |
58 | 65 |
59 class NoNotificationMessageView : public views::View { | 66 class NoNotificationMessageView : public views::View { |
60 public: | 67 public: |
61 NoNotificationMessageView(); | 68 NoNotificationMessageView(); |
62 ~NoNotificationMessageView() override; | 69 ~NoNotificationMessageView() override; |
63 | 70 |
64 // Overridden from views::View. | 71 // Overridden from views::View. |
65 gfx::Size GetPreferredSize() const override; | 72 gfx::Size GetPreferredSize() const override; |
66 int GetHeightForWidth(int width) const override; | 73 int GetHeightForWidth(int width) const override; |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 settings_transition_animation_->set_continuous(false); | 685 settings_transition_animation_->set_continuous(false); |
679 settings_transition_animation_->Start(); | 686 settings_transition_animation_->Start(); |
680 | 687 |
681 button_bar_->SetBackArrowVisible(visible); | 688 button_bar_->SetBackArrowVisible(visible); |
682 } | 689 } |
683 | 690 |
684 void MessageCenterView::ClearAllNotifications() { | 691 void MessageCenterView::ClearAllNotifications() { |
685 if (is_closing_) | 692 if (is_closing_) |
686 return; | 693 return; |
687 | 694 |
688 scroller_->SetEnabled(false); | 695 SetViewHierarchyEnabled(scroller_, false); |
689 button_bar_->SetAllButtonsEnabled(false); | 696 button_bar_->SetAllButtonsEnabled(false); |
690 message_list_view_->ClearAllNotifications(scroller_->GetVisibleRect()); | 697 message_list_view_->ClearAllNotifications(scroller_->GetVisibleRect()); |
691 } | 698 } |
692 | 699 |
693 void MessageCenterView::OnAllNotificationsCleared() { | 700 void MessageCenterView::OnAllNotificationsCleared() { |
694 scroller_->SetEnabled(true); | 701 SetViewHierarchyEnabled(scroller_, true); |
695 button_bar_->SetAllButtonsEnabled(true); | 702 button_bar_->SetAllButtonsEnabled(true); |
696 button_bar_->SetCloseAllButtonEnabled(false); | 703 button_bar_->SetCloseAllButtonEnabled(false); |
697 message_center_->RemoveAllVisibleNotifications(true); // Action by user. | 704 message_center_->RemoveAllVisibleNotifications(true); // Action by user. |
698 } | 705 } |
699 | 706 |
700 size_t MessageCenterView::NumMessageViewsForTest() const { | 707 size_t MessageCenterView::NumMessageViewsForTest() const { |
701 return message_list_view_->child_count(); | 708 return message_list_view_->child_count(); |
702 } | 709 } |
703 | 710 |
704 void MessageCenterView::OnSettingsChanged() { | 711 void MessageCenterView::OnSettingsChanged() { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 // without re-focusing by tab key. | 863 // without re-focusing by tab key. |
857 if (view->IsCloseButtonFocused() || | 864 if (view->IsCloseButtonFocused() || |
858 view == GetFocusManager()->GetFocusedView()) { | 865 view == GetFocusManager()->GetFocusedView()) { |
859 views::View* next_focused_view = NULL; | 866 views::View* next_focused_view = NULL; |
860 if (message_list_view_->child_count() > index + 1) | 867 if (message_list_view_->child_count() > index + 1) |
861 next_focused_view = message_list_view_->child_at(index + 1); | 868 next_focused_view = message_list_view_->child_at(index + 1); |
862 else if (index > 0) | 869 else if (index > 0) |
863 next_focused_view = message_list_view_->child_at(index - 1); | 870 next_focused_view = message_list_view_->child_at(index - 1); |
864 | 871 |
865 if (next_focused_view) { | 872 if (next_focused_view) { |
866 if (view->IsCloseButtonFocused()) | 873 if (view->IsCloseButtonFocused()) { |
867 // Safe cast since all views in MessageListView are MessageViews. | 874 // Safe cast since all views in MessageListView are MessageViews. |
868 static_cast<MessageView*>( | 875 static_cast<MessageView*>( |
869 next_focused_view)->RequestFocusOnCloseButton(); | 876 next_focused_view)->RequestFocusOnCloseButton(); |
870 else | 877 } else { |
871 next_focused_view->RequestFocus(); | 878 next_focused_view->RequestFocus(); |
| 879 } |
872 } | 880 } |
873 } | 881 } |
874 } | 882 } |
875 message_list_view_->RemoveNotification(view); | 883 message_list_view_->RemoveNotification(view); |
876 notification_views_.erase(view_iter); | 884 notification_views_.erase(view_iter); |
877 NotificationsChanged(); | 885 NotificationsChanged(); |
878 } | 886 } |
879 | 887 |
880 void MessageCenterView::OnNotificationUpdated(const std::string& id) { | 888 void MessageCenterView::OnNotificationUpdated(const std::string& id) { |
881 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); | 889 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1000 scroller_->InvalidateLayout(); | 1008 scroller_->InvalidateLayout(); |
1001 PreferredSizeChanged(); | 1009 PreferredSizeChanged(); |
1002 Layout(); | 1010 Layout(); |
1003 } | 1011 } |
1004 | 1012 |
1005 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 1013 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
1006 message_list_view_->AddNotificationAt(view, 0); | 1014 message_list_view_->AddNotificationAt(view, 0); |
1007 } | 1015 } |
1008 | 1016 |
1009 } // namespace message_center | 1017 } // namespace message_center |
OLD | NEW |