Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: ui/message_center/views/message_center_view.cc

Issue 18003003: Message center re-organized (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Border caching added Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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);
876 return; 877 return;
877 } 878 }
878 879
879 scroller_->SetBounds(0, 0, width(), height() - button_height); 880 scroller_->SetBounds(0,
880 settings_view_->SetBounds(0, 0, width(), height() - button_height); 881 buttons_on_top_ ? button_height : 0,
882 width(),
883 height() - button_height);
884 settings_view_->SetBounds(0,
885 buttons_on_top_ ? button_height : 0,
886 width(),
887 height() - button_height);
881 888
882 bool is_scrollable = false; 889 bool is_scrollable = false;
883 if (scroller_->visible()) 890 if (scroller_->visible())
884 is_scrollable = scroller_->height() < message_list_view_->height(); 891 is_scrollable = scroller_->height() < message_list_view_->height();
885 else 892 else
886 is_scrollable = settings_view_->IsScrollable(); 893 is_scrollable = settings_view_->IsScrollable();
887 894
888 if (is_scrollable && !button_bar_->border()) { 895 if (is_scrollable && !button_bar_->border()) {
889 button_bar_->set_border(views::Border::CreateSolidSidedBorder( 896 button_bar_->set_border(views::Border::CreateSolidSidedBorder(
890 1, 0, 0, 0, kFooterDelimiterColor)); 897 1, 0, 0, 0, kFooterDelimiterColor));
891 button_bar_->SchedulePaint(); 898 button_bar_->SchedulePaint();
892 } else if (!is_scrollable && button_bar_->border()) { 899 } else if (!is_scrollable && button_bar_->border()) {
893 button_bar_->set_border(NULL); 900 button_bar_->set_border(NULL);
894 button_bar_->SchedulePaint(); 901 button_bar_->SchedulePaint();
895 } 902 }
896 903
897 button_bar_->SetBounds(0, height() - button_height, width(), button_height); 904 button_bar_->SetBounds(0,
905 buttons_on_top_ ? 0 : height() - button_height,
906 width(),
907 button_height);
898 if (GetWidget()) 908 if (GetWidget())
899 GetWidget()->GetRootView()->SchedulePaint(); 909 GetWidget()->GetRootView()->SchedulePaint();
900 } 910 }
901 911
902 gfx::Size MessageCenterView::GetPreferredSize() { 912 gfx::Size MessageCenterView::GetPreferredSize() {
903 if (settings_transition_animation_ && 913 if (settings_transition_animation_ &&
904 settings_transition_animation_->is_animating()) { 914 settings_transition_animation_->is_animating()) {
905 int content_width = std::max(source_view_->GetPreferredSize().width(), 915 int content_width = std::max(source_view_->GetPreferredSize().width(),
906 target_view_->GetPreferredSize().width()); 916 target_view_->GetPreferredSize().width());
907 int width = std::max(content_width, 917 int width = std::max(content_width,
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 scroller_->InvalidateLayout(); 1101 scroller_->InvalidateLayout();
1092 PreferredSizeChanged(); 1102 PreferredSizeChanged();
1093 Layout(); 1103 Layout();
1094 } 1104 }
1095 1105
1096 void MessageCenterView::SetNotificationViewForTest(views::View* view) { 1106 void MessageCenterView::SetNotificationViewForTest(views::View* view) {
1097 message_list_view_->AddNotificationAt(view, 0); 1107 message_list_view_->AddNotificationAt(view, 0);
1098 } 1108 }
1099 1109
1100 } // namespace message_center 1110 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698