Chromium Code Reviews| 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 840 void MessageCenterButtonBar::SetCloseAllVisible(bool visible) { | 840 void MessageCenterButtonBar::SetCloseAllVisible(bool visible) { |
| 841 if (close_all_button_) | 841 if (close_all_button_) |
| 842 close_all_button_->SetVisible(visible); | 842 close_all_button_->SetVisible(visible); |
| 843 } | 843 } |
| 844 | 844 |
| 845 // MessageCenterView /////////////////////////////////////////////////////////// | 845 // MessageCenterView /////////////////////////////////////////////////////////// |
| 846 | 846 |
| 847 MessageCenterView::MessageCenterView(MessageCenter* message_center, | 847 MessageCenterView::MessageCenterView(MessageCenter* message_center, |
| 848 MessageCenterTray* tray, | 848 MessageCenterTray* tray, |
| 849 int max_height, | 849 int max_height, |
| 850 bool initially_settings_visible) | 850 bool initially_settings_visible, |
| 851 bool buttons_at_top) | |
| 851 : message_center_(message_center), | 852 : message_center_(message_center), |
| 852 tray_(tray), | 853 tray_(tray), |
| 854 buttons_at_top_(buttons_at_top), | |
| 853 settings_visible_(initially_settings_visible) { | 855 settings_visible_(initially_settings_visible) { |
| 854 message_center_->AddObserver(this); | 856 message_center_->AddObserver(this); |
| 855 set_notify_enter_exit_on_child(true); | 857 set_notify_enter_exit_on_child(true); |
| 856 set_background(views::Background::CreateSolidBackground( | 858 set_background(views::Background::CreateSolidBackground( |
| 857 kMessageCenterBackgroundColor)); | 859 kMessageCenterBackgroundColor)); |
| 858 | 860 |
| 859 if (IsRichNotificationEnabled()) | 861 if (IsRichNotificationEnabled()) |
| 860 button_bar_ = new RichMessageCenterButtonBar(this, message_center); | 862 button_bar_ = new RichMessageCenterButtonBar(this, message_center); |
| 861 else | 863 else |
| 862 button_bar_ = new PoorMessageCenterButtonBar(this, message_center); | 864 button_bar_ = new PoorMessageCenterButtonBar(this, message_center); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 972 return message_list_view_->child_count(); | 974 return message_list_view_->child_count(); |
| 973 } | 975 } |
| 974 | 976 |
| 975 void MessageCenterView::Layout() { | 977 void MessageCenterView::Layout() { |
| 976 int between_child = IsRichNotificationEnabled() ? 0 : 1; | 978 int between_child = IsRichNotificationEnabled() ? 0 : 1; |
| 977 int button_height = button_bar_->GetHeightForWidth(width()); | 979 int button_height = button_bar_->GetHeightForWidth(width()); |
| 978 // Skip unnecessary re-layout of contents during the resize animation. | 980 // Skip unnecessary re-layout of contents during the resize animation. |
| 979 if (settings_transition_animation_ && | 981 if (settings_transition_animation_ && |
| 980 settings_transition_animation_->is_animating() && | 982 settings_transition_animation_->is_animating() && |
| 981 settings_transition_animation_->current_part_index() == 0) { | 983 settings_transition_animation_->current_part_index() == 0) { |
| 982 button_bar_->SetBounds(0, height() - button_height, width(), button_height); | |
| 983 return; | 984 return; |
| 984 } | 985 } |
| 985 | 986 |
| 986 scroller_->SetBounds(0, 0, width(), height() - button_height - between_child); | 987 scroller_->SetBounds(0, |
| 987 settings_view_->SetBounds( | 988 buttons_at_top_ ? button_height : 0, |
| 988 0, 0, width(), height() - button_height - between_child); | 989 width(), |
| 990 height() - button_height - between_child); | |
| 991 settings_view_->SetBounds(0, | |
| 992 buttons_at_top_ ? button_height : 0, | |
| 993 width(), | |
| 994 height() - button_height - between_child); | |
| 989 | 995 |
| 990 bool is_scrollable = false; | 996 bool is_scrollable = false; |
| 991 if (scroller_->visible()) | 997 if (scroller_->visible()) |
| 992 is_scrollable = scroller_->height() < message_list_view_->height(); | 998 is_scrollable = scroller_->height() < message_list_view_->height(); |
| 993 else | 999 else |
| 994 is_scrollable = settings_view_->IsScrollable(); | 1000 is_scrollable = settings_view_->IsScrollable(); |
| 995 | 1001 |
| 996 if (is_scrollable && !button_bar_->border()) { | 1002 if (is_scrollable && !button_bar_->border()) { |
| 997 button_bar_->set_border(views::Border::CreateSolidSidedBorder( | 1003 button_bar_->set_border(views::Border::CreateSolidSidedBorder( |
| 998 1, 0, 0, 0, kFooterDelimiterColor)); | 1004 1, 0, 0, 0, kFooterDelimiterColor)); |
| 999 button_bar_->SchedulePaint(); | 1005 button_bar_->SchedulePaint(); |
| 1000 } else if (!is_scrollable && button_bar_->border()) { | 1006 } else if (!is_scrollable && button_bar_->border()) { |
| 1001 button_bar_->set_border(NULL); | 1007 button_bar_->set_border(NULL); |
| 1002 button_bar_->SchedulePaint(); | 1008 button_bar_->SchedulePaint(); |
| 1003 } | 1009 } |
| 1004 | 1010 |
| 1005 button_bar_->SetBounds(0, height() - button_height, width(), button_height); | 1011 button_bar_->SetBounds(0, |
| 1012 buttons_at_top_ ? 0 : height() - button_height, | |
| 1013 width(), | |
| 1014 button_height); | |
| 1006 if (GetWidget()) | 1015 if (GetWidget()) |
| 1007 GetWidget()->GetRootView()->SchedulePaint(); | 1016 GetWidget()->GetRootView()->SchedulePaint(); |
| 1008 } | 1017 } |
| 1009 | 1018 |
| 1010 gfx::Size MessageCenterView::GetPreferredSize() { | 1019 gfx::Size MessageCenterView::GetPreferredSize() { |
| 1011 if (settings_transition_animation_ && | 1020 if (settings_transition_animation_ && |
| 1012 settings_transition_animation_->is_animating()) { | 1021 settings_transition_animation_->is_animating()) { |
| 1013 int content_width = std::max(source_view_->GetPreferredSize().width(), | 1022 int content_width = std::max(source_view_->GetPreferredSize().width(), |
| 1014 target_view_->GetPreferredSize().width()); | 1023 target_view_->GetPreferredSize().width()); |
| 1015 int width = std::max(content_width, | 1024 int width = std::max(content_width, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1128 view->set_scroller(scroller_); | 1137 view->set_scroller(scroller_); |
| 1129 message_list_view_->UpdateNotificationAt(view, index); | 1138 message_list_view_->UpdateNotificationAt(view, index); |
| 1130 message_views_[index] = view; | 1139 message_views_[index] = view; |
| 1131 NotificationsChanged(); | 1140 NotificationsChanged(); |
| 1132 break; | 1141 break; |
| 1133 } | 1142 } |
| 1134 } | 1143 } |
| 1135 } | 1144 } |
| 1136 | 1145 |
| 1137 void MessageCenterView::AnimationEnded(const ui::Animation* animation) { | 1146 void MessageCenterView::AnimationEnded(const ui::Animation* animation) { |
| 1138 DCHECK_EQ(animation, settings_transition_animation_.get()); | 1147 if (animation == settings_transition_animation_.get()) { |
|
dewittj
2013/07/02 18:43:32
Why remove the DCHECK?
sidharthms
2013/07/02 21:01:16
Done.
| |
| 1139 | 1148 source_view_->SetVisible(false); |
| 1140 source_view_->SetVisible(false); | 1149 target_view_->SetVisible(true); |
| 1141 target_view_->SetVisible(true); | 1150 if (source_view_->layer()) |
| 1142 if (source_view_->layer()) | 1151 source_view_->layer()->SetOpacity(1.0); |
| 1143 source_view_->layer()->SetOpacity(1.0); | 1152 if (target_view_->layer()) |
| 1144 if (target_view_->layer()) | 1153 target_view_->layer()->SetOpacity(1.0); |
| 1145 target_view_->layer()->SetOpacity(1.0); | 1154 settings_transition_animation_.reset(); |
| 1146 settings_transition_animation_.reset(); | 1155 PreferredSizeChanged(); |
| 1147 PreferredSizeChanged(); | 1156 Layout(); |
| 1148 Layout(); | 1157 } |
| 1149 } | 1158 } |
| 1150 | 1159 |
| 1151 void MessageCenterView::AnimationProgressed(const ui::Animation* animation) { | 1160 void MessageCenterView::AnimationProgressed(const ui::Animation* animation) { |
| 1152 DCHECK_EQ(animation, settings_transition_animation_.get()); | 1161 if (animation == settings_transition_animation_.get()) { |
|
dewittj
2013/07/02 18:43:32
why remove the DCHECK?
sidharthms
2013/07/02 21:01:16
Done.
| |
| 1153 PreferredSizeChanged(); | 1162 PreferredSizeChanged(); |
| 1154 if (settings_transition_animation_->current_part_index() == 1 && | 1163 if (settings_transition_animation_->current_part_index() == 1 && |
| 1155 source_view_->layer()) { | 1164 source_view_->layer()) { |
| 1156 source_view_->layer()->SetOpacity( | 1165 source_view_->layer()->SetOpacity( |
| 1157 1.0 - settings_transition_animation_->GetCurrentValue()); | 1166 1.0 - settings_transition_animation_->GetCurrentValue()); |
| 1158 SchedulePaint(); | 1167 SchedulePaint(); |
| 1159 } else if (settings_transition_animation_->current_part_index() == 2 && | 1168 } else if (settings_transition_animation_->current_part_index() == 2 && |
| 1160 target_view_->layer()) { | 1169 target_view_->layer()) { |
| 1161 target_view_->layer()->SetOpacity( | 1170 target_view_->layer()->SetOpacity( |
| 1162 settings_transition_animation_->GetCurrentValue()); | 1171 settings_transition_animation_->GetCurrentValue()); |
| 1163 SchedulePaint(); | 1172 SchedulePaint(); |
| 1173 } | |
| 1164 } | 1174 } |
| 1165 } | 1175 } |
| 1166 | 1176 |
| 1167 void MessageCenterView::AnimationCanceled(const ui::Animation* animation) { | 1177 void MessageCenterView::AnimationCanceled(const ui::Animation* animation) { |
| 1168 DCHECK_EQ(animation, settings_transition_animation_.get()); | 1178 DCHECK_EQ(animation, settings_transition_animation_.get()); |
| 1169 AnimationEnded(animation); | 1179 AnimationEnded(animation); |
| 1170 } | 1180 } |
| 1171 | 1181 |
| 1172 void MessageCenterView::AddNotificationAt(const Notification& notification, | 1182 void MessageCenterView::AddNotificationAt(const Notification& notification, |
| 1173 int index) { | 1183 int index) { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1199 scroller_->InvalidateLayout(); | 1209 scroller_->InvalidateLayout(); |
| 1200 PreferredSizeChanged(); | 1210 PreferredSizeChanged(); |
| 1201 Layout(); | 1211 Layout(); |
| 1202 } | 1212 } |
| 1203 | 1213 |
| 1204 void MessageCenterView::SetNotificationViewForTest(views::View* view) { | 1214 void MessageCenterView::SetNotificationViewForTest(views::View* view) { |
| 1205 message_list_view_->AddNotificationAt(view, 0); | 1215 message_list_view_->AddNotificationAt(view, 0); |
| 1206 } | 1216 } |
| 1207 | 1217 |
| 1208 } // namespace message_center | 1218 } // namespace message_center |
| OLD | NEW |