| 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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 base::TimeDelta::FromMilliseconds( | 738 base::TimeDelta::FromMilliseconds( |
| 739 kAnimateClearingNextNotificationDelayMS)); | 739 kAnimateClearingNextNotificationDelayMS)); |
| 740 } | 740 } |
| 741 } | 741 } |
| 742 | 742 |
| 743 // MessageCenterView /////////////////////////////////////////////////////////// | 743 // MessageCenterView /////////////////////////////////////////////////////////// |
| 744 | 744 |
| 745 MessageCenterView::MessageCenterView(MessageCenter* message_center, | 745 MessageCenterView::MessageCenterView(MessageCenter* message_center, |
| 746 MessageCenterTray* tray, | 746 MessageCenterTray* tray, |
| 747 int max_height, | 747 int max_height, |
| 748 bool initially_settings_visible) | 748 bool initially_settings_visible, |
| 749 bool buttons_on_top) |
| 749 : message_center_(message_center), | 750 : message_center_(message_center), |
| 750 tray_(tray), | 751 tray_(tray), |
| 752 buttons_on_top_(buttons_on_top), |
| 751 settings_visible_(initially_settings_visible) { | 753 settings_visible_(initially_settings_visible) { |
| 752 message_center_->AddObserver(this); | 754 message_center_->AddObserver(this); |
| 753 set_notify_enter_exit_on_child(true); | 755 set_notify_enter_exit_on_child(true); |
| 754 set_background(views::Background::CreateSolidBackground( | 756 set_background(views::Background::CreateSolidBackground( |
| 755 kMessageCenterBackgroundColor)); | 757 kMessageCenterBackgroundColor)); |
| 756 | 758 |
| 757 button_bar_ = new MessageCenterButtonBar(this, message_center); | 759 button_bar_ = new MessageCenterButtonBar(this, message_center); |
| 758 | 760 |
| 759 const int button_height = button_bar_->GetPreferredSize().height(); | 761 const int button_height = button_bar_->GetPreferredSize().height(); |
| 760 scroller_ = new BoundedScrollView(kMinScrollViewHeight, | 762 scroller_ = new BoundedScrollView(kMinScrollViewHeight, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 size_t MessageCenterView::NumMessageViewsForTest() const { | 867 size_t MessageCenterView::NumMessageViewsForTest() const { |
| 866 return message_list_view_->child_count(); | 868 return message_list_view_->child_count(); |
| 867 } | 869 } |
| 868 | 870 |
| 869 void MessageCenterView::Layout() { | 871 void MessageCenterView::Layout() { |
| 870 int button_height = button_bar_->GetHeightForWidth(width()); | 872 int button_height = button_bar_->GetHeightForWidth(width()); |
| 871 // Skip unnecessary re-layout of contents during the resize animation. | 873 // Skip unnecessary re-layout of contents during the resize animation. |
| 872 if (settings_transition_animation_ && | 874 if (settings_transition_animation_ && |
| 873 settings_transition_animation_->is_animating() && | 875 settings_transition_animation_->is_animating() && |
| 874 settings_transition_animation_->current_part_index() == 0) { | 876 settings_transition_animation_->current_part_index() == 0) { |
| 875 button_bar_->SetBounds(0, height() - button_height, width(), button_height); | 877 if (!buttons_on_top_) |
| 878 button_bar_->SetBounds( |
| 879 0, height() - button_height, width(), button_height); |
| 876 return; | 880 return; |
| 877 } | 881 } |
| 878 | 882 |
| 879 scroller_->SetBounds(0, 0, width(), height() - button_height); | 883 scroller_->SetBounds(0, |
| 880 settings_view_->SetBounds(0, 0, width(), height() - button_height); | 884 buttons_on_top_ ? button_height : 0, |
| 885 width(), |
| 886 height() - button_height); |
| 887 settings_view_->SetBounds(0, |
| 888 buttons_on_top_ ? button_height : 0, |
| 889 width(), |
| 890 height() - button_height); |
| 881 | 891 |
| 882 bool is_scrollable = false; | 892 bool is_scrollable = false; |
| 883 if (scroller_->visible()) | 893 if (scroller_->visible()) |
| 884 is_scrollable = scroller_->height() < message_list_view_->height(); | 894 is_scrollable = scroller_->height() < message_list_view_->height(); |
| 885 else | 895 else |
| 886 is_scrollable = settings_view_->IsScrollable(); | 896 is_scrollable = settings_view_->IsScrollable(); |
| 887 | 897 |
| 888 if (is_scrollable && !button_bar_->border()) { | 898 if (is_scrollable && !button_bar_->border()) { |
| 889 button_bar_->set_border(views::Border::CreateSolidSidedBorder( | 899 button_bar_->set_border(views::Border::CreateSolidSidedBorder( |
| 890 1, 0, 0, 0, kFooterDelimiterColor)); | 900 1, 0, 0, 0, kFooterDelimiterColor)); |
| 891 button_bar_->SchedulePaint(); | 901 button_bar_->SchedulePaint(); |
| 892 } else if (!is_scrollable && button_bar_->border()) { | 902 } else if (!is_scrollable && button_bar_->border()) { |
| 893 button_bar_->set_border(NULL); | 903 button_bar_->set_border(NULL); |
| 894 button_bar_->SchedulePaint(); | 904 button_bar_->SchedulePaint(); |
| 895 } | 905 } |
| 896 | 906 |
| 897 button_bar_->SetBounds(0, height() - button_height, width(), button_height); | 907 button_bar_->SetBounds(0, |
| 908 buttons_on_top_ ? 0 : height() - button_height, |
| 909 width(), |
| 910 button_height); |
| 898 if (GetWidget()) | 911 if (GetWidget()) |
| 899 GetWidget()->GetRootView()->SchedulePaint(); | 912 GetWidget()->GetRootView()->SchedulePaint(); |
| 900 } | 913 } |
| 901 | 914 |
| 902 gfx::Size MessageCenterView::GetPreferredSize() { | 915 gfx::Size MessageCenterView::GetPreferredSize() { |
| 903 if (settings_transition_animation_ && | 916 if (settings_transition_animation_ && |
| 904 settings_transition_animation_->is_animating()) { | 917 settings_transition_animation_->is_animating()) { |
| 905 int content_width = std::max(source_view_->GetPreferredSize().width(), | 918 int content_width = std::max(source_view_->GetPreferredSize().width(), |
| 906 target_view_->GetPreferredSize().width()); | 919 target_view_->GetPreferredSize().width()); |
| 907 int width = std::max(content_width, | 920 int width = std::max(content_width, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 scroller_->InvalidateLayout(); | 1104 scroller_->InvalidateLayout(); |
| 1092 PreferredSizeChanged(); | 1105 PreferredSizeChanged(); |
| 1093 Layout(); | 1106 Layout(); |
| 1094 } | 1107 } |
| 1095 | 1108 |
| 1096 void MessageCenterView::SetNotificationViewForTest(views::View* view) { | 1109 void MessageCenterView::SetNotificationViewForTest(views::View* view) { |
| 1097 message_list_view_->AddNotificationAt(view, 0); | 1110 message_list_view_->AddNotificationAt(view, 0); |
| 1098 } | 1111 } |
| 1099 | 1112 |
| 1100 } // namespace message_center | 1113 } // namespace message_center |
| OLD | NEW |