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