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

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

Issue 20066003: Update notification settings to allow for multiprofile situations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix message_center_unittests Created 7 years, 4 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"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "grit/ui_resources.h"
14 #include "grit/ui_strings.h" 13 #include "grit/ui_strings.h"
15 #include "ui/base/animation/multi_animation.h" 14 #include "ui/base/animation/multi_animation.h"
16 #include "ui/base/animation/slide_animation.h" 15 #include "ui/base/animation/slide_animation.h"
17 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/canvas.h" 17 #include "ui/gfx/canvas.h"
20 #include "ui/gfx/insets.h" 18 #include "ui/gfx/insets.h"
21 #include "ui/gfx/point.h"
22 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
23 #include "ui/gfx/size.h" 20 #include "ui/gfx/size.h"
24 #include "ui/gfx/text_constants.h"
25 #include "ui/message_center/message_center.h" 21 #include "ui/message_center/message_center.h"
26 #include "ui/message_center/message_center_style.h" 22 #include "ui/message_center/message_center_style.h"
27 #include "ui/message_center/message_center_tray.h" 23 #include "ui/message_center/views/message_center_button_bar.h"
28 #include "ui/message_center/message_center_util.h"
29 #include "ui/message_center/views/message_view.h" 24 #include "ui/message_center/views/message_view.h"
30 #include "ui/message_center/views/notification_view.h" 25 #include "ui/message_center/views/notification_view.h"
31 #include "ui/message_center/views/notifier_settings_view.h" 26 #include "ui/message_center/views/notifier_settings_view.h"
32 #include "ui/views/animation/bounds_animator.h" 27 #include "ui/views/animation/bounds_animator.h"
33 #include "ui/views/animation/bounds_animator_observer.h" 28 #include "ui/views/animation/bounds_animator_observer.h"
34 #include "ui/views/background.h" 29 #include "ui/views/background.h"
35 #include "ui/views/border.h" 30 #include "ui/views/border.h"
36 #include "ui/views/controls/button/button.h" 31 #include "ui/views/controls/button/button.h"
37 #include "ui/views/controls/button/label_button.h"
38 #include "ui/views/controls/label.h" 32 #include "ui/views/controls/label.h"
39 #include "ui/views/controls/scroll_view.h" 33 #include "ui/views/controls/scroll_view.h"
40 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" 34 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h"
41 #include "ui/views/layout/box_layout.h" 35 #include "ui/views/layout/box_layout.h"
42 #include "ui/views/layout/grid_layout.h"
43 #include "ui/views/painter.h"
44 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
45 37
46 namespace message_center { 38 namespace message_center {
47 39
48 namespace { 40 namespace {
49 41
50 const int kMinScrollViewHeight = 100; 42 const int kMinScrollViewHeight = 100;
51 const int kFooterLeftMargin = 17;
52 const int kFooterRightMargin = 14;
53 const int kButtonSize = 40;
54 const SkColor kNoNotificationsTextColor = SkColorSetRGB(0xb4, 0xb4, 0xb4); 43 const SkColor kNoNotificationsTextColor = SkColorSetRGB(0xb4, 0xb4, 0xb4);
55 const SkColor kBorderDarkColor = SkColorSetRGB(0xaa, 0xaa, 0xaa); 44 const SkColor kBorderDarkColor = SkColorSetRGB(0xaa, 0xaa, 0xaa);
56 const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0); 45 const SkColor kTransparentColor = SkColorSetARGB(0, 0, 0, 0);
57 const SkColor kButtonTextHighlightColor = SkColorSetRGB(0x2a, 0x2a, 0x2a); 46 const SkColor kButtonTextHighlightColor = SkColorSetRGB(0x2a, 0x2a, 0x2a);
58 const SkColor kButtonTextHoverColor = SkColorSetRGB(0x2a, 0x2a, 0x2a); 47 const SkColor kButtonTextHoverColor = SkColorSetRGB(0x2a, 0x2a, 0x2a);
59 const int kAnimateClearingNextNotificationDelayMS = 40; 48 const int kAnimateClearingNextNotificationDelayMS = 40;
60 49
61 static const int kDefaultFrameRateHz = 60; 50 static const int kDefaultFrameRateHz = 60;
62 static const int kDefaultAnimationDurationMs = 120; 51 static const int kDefaultAnimationDurationMs = 120;
63 52
64 } // namespace 53 } // namespace
65 54
66 // NotificationCenterButton ////////////////////////////////////////////////////
67
68 class NotificationCenterButton : public views::ToggleImageButton {
69 public:
70 NotificationCenterButton(views::ButtonListener* listener,
71 int normal_id,
72 int hover_id,
73 int pressed_id,
74 int text_id);
75
76 protected:
77 // Overridden from views::View:
78 virtual gfx::Size GetPreferredSize() OVERRIDE;
79 virtual void OnPaintFocusBorder(gfx::Canvas* canvas) OVERRIDE;
80
81 private:
82 DISALLOW_COPY_AND_ASSIGN(NotificationCenterButton);
83 };
84
85 NotificationCenterButton::NotificationCenterButton(
86 views::ButtonListener* listener,
87 int normal_id,
88 int hover_id,
89 int pressed_id,
90 int text_id)
91 : views::ToggleImageButton(listener) {
92 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
93 SetImage(STATE_NORMAL, resource_bundle.GetImageSkiaNamed(normal_id));
94 SetImage(STATE_HOVERED, resource_bundle.GetImageSkiaNamed(hover_id));
95 SetImage(STATE_PRESSED, resource_bundle.GetImageSkiaNamed(pressed_id));
96 SetImageAlignment(views::ImageButton::ALIGN_CENTER,
97 views::ImageButton::ALIGN_MIDDLE);
98 SetTooltipText(resource_bundle.GetLocalizedString(text_id));
99 set_focusable(true);
100 set_request_focus_on_press(false);
101 }
102
103 gfx::Size NotificationCenterButton::GetPreferredSize() {
104 return gfx::Size(kButtonSize, kButtonSize);
105 }
106
107 void NotificationCenterButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
108 if (HasFocus() && (focusable() || IsAccessibilityFocusable())) {
109 canvas->DrawRect(gfx::Rect(2, 1, width() - 4, height() - 3),
110 kFocusBorderColor);
111 }
112 }
113
114 // MessageCenterButtonBar //////////////////////////////////////////////////
115
116 class MessageCenterButtonBar : public views::View,
117 public views::ButtonListener {
118 public:
119 MessageCenterButtonBar(MessageCenterView* message_center_view,
120 MessageCenter* message_center);
121 virtual ~MessageCenterButtonBar();
122
123 virtual void SetAllButtonsEnabled(bool enabled);
124 void SetCloseAllVisible(bool visible);
125
126 private:
127 // Overridden from views::View:
128 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE;
129
130 // Overridden from views::ButtonListener:
131 virtual void ButtonPressed(views::Button* sender, const ui::Event& event)
132 OVERRIDE;
133
134 MessageCenterView* message_center_view() const {
135 return message_center_view_;
136 }
137 MessageCenter* message_center() const { return message_center_; }
138 MessageCenterTray* tray() const { return tray_; }
139 views::Button* close_all_button() const { return close_all_button_; }
140 void set_close_all_button(views::Button* button) {
141 close_all_button_ = button;
142 }
143
144 MessageCenterView* message_center_view_; // Weak reference.
145 MessageCenter* message_center_; // Weak reference.
146 MessageCenterTray* tray_; // Weak reference.
147 views::Button* close_all_button_;
148 NotificationCenterButton* settings_button_;
149 NotificationCenterButton* quiet_mode_button_;
150
151 DISALLOW_COPY_AND_ASSIGN(MessageCenterButtonBar);
152 };
153
154 MessageCenterButtonBar::MessageCenterButtonBar(
155 MessageCenterView* message_center_view,
156 MessageCenter* message_center)
157 : message_center_view_(message_center_view),
158 message_center_(message_center),
159 close_all_button_(NULL) {
160 if (get_use_acceleration_when_possible())
161 SetPaintToLayer(true);
162 set_background(views::Background::CreateSolidBackground(
163 kMessageCenterBackgroundColor));
164
165 views::Label* notification_label = new views::Label(l10n_util::GetStringUTF16(
166 IDS_MESSAGE_CENTER_FOOTER_TITLE));
167 notification_label->SetAutoColorReadabilityEnabled(false);
168 notification_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
169 notification_label->SetEnabledColor(kRegularTextColor);
170 AddChildView(notification_label);
171
172 views::View* button_container = new views::View;
173 button_container->SetLayoutManager(
174 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
175 quiet_mode_button_ = new NotificationCenterButton(
176 this,
177 IDR_NOTIFICATION_DO_NOT_DISTURB,
178 IDR_NOTIFICATION_DO_NOT_DISTURB_HOVER,
179 IDR_NOTIFICATION_DO_NOT_DISTURB_PRESSED,
180 IDS_MESSAGE_CENTER_QUIET_MODE_BUTTON_TOOLTIP);
181 ui::ResourceBundle& resource_bundle = ui::ResourceBundle::GetSharedInstance();
182 quiet_mode_button_->SetToggledImage(
183 views::Button::STATE_NORMAL,
184 resource_bundle.GetImageSkiaNamed(
185 IDR_NOTIFICATION_DO_NOT_DISTURB_PRESSED));
186 quiet_mode_button_->SetToggledImage(
187 views::Button::STATE_HOVERED,
188 resource_bundle.GetImageSkiaNamed(
189 IDR_NOTIFICATION_DO_NOT_DISTURB_PRESSED));
190 quiet_mode_button_->SetToggledImage(
191 views::Button::STATE_PRESSED,
192 resource_bundle.GetImageSkiaNamed(
193 IDR_NOTIFICATION_DO_NOT_DISTURB_PRESSED));
194 quiet_mode_button_->SetToggled(message_center->IsQuietMode());
195 button_container->AddChildView(quiet_mode_button_);
196
197 NotificationCenterButton* close_all_button = new NotificationCenterButton(
198 this,
199 IDR_NOTIFICATION_CLEAR_ALL,
200 IDR_NOTIFICATION_CLEAR_ALL_HOVER,
201 IDR_NOTIFICATION_CLEAR_ALL_PRESSED,
202 IDS_MESSAGE_CENTER_CLEAR_ALL);
203 button_container->AddChildView(close_all_button);
204 set_close_all_button(close_all_button);
205 settings_button_ = new NotificationCenterButton(
206 this,
207 IDR_NOTIFICATION_SETTINGS,
208 IDR_NOTIFICATION_SETTINGS_HOVER,
209 IDR_NOTIFICATION_SETTINGS_PRESSED,
210 IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL);
211 button_container->AddChildView(settings_button_);
212
213 gfx::ImageSkia* settings_image =
214 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
215 IDR_NOTIFICATION_SETTINGS);
216 int image_margin = std::max(0, (kButtonSize - settings_image->width()) / 2);
217 views::GridLayout* layout = new views::GridLayout(this);
218 SetLayoutManager(layout);
219 layout->SetInsets(
220 0, kFooterLeftMargin, 0, std::max(0, kFooterRightMargin - image_margin));
221 views::ColumnSet* column = layout->AddColumnSet(0);
222 column->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
223 1.0f, views::GridLayout::USE_PREF, 0, 0);
224 column->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL,
225 0, views::GridLayout::USE_PREF, 0, 0);
226 layout->StartRow(0, 0);
227 layout->AddView(notification_label);
228 layout->AddView(button_container);
229 }
230
231 MessageCenterButtonBar::~MessageCenterButtonBar() {}
232
233 void MessageCenterButtonBar::SetAllButtonsEnabled(bool enabled) {
234 if (close_all_button_)
235 close_all_button_->SetEnabled(enabled);
236 settings_button_->SetEnabled(enabled);
237 quiet_mode_button_->SetEnabled(enabled);
238 }
239
240 void MessageCenterButtonBar::SetCloseAllVisible(bool visible) {
241 if (close_all_button_)
242 close_all_button_->SetVisible(visible);
243 }
244
245 // Overridden from views::View:
246 void MessageCenterButtonBar::ChildVisibilityChanged(views::View* child) {
247 InvalidateLayout();
248 }
249
250 // Overridden from views::ButtonListener:
251 void MessageCenterButtonBar::ButtonPressed(views::Button* sender,
252 const ui::Event& event) {
253 if (sender == close_all_button()) {
254 message_center_view()->ClearAllNotifications();
255 } else if (sender == settings_button_) {
256 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent());
257 center_view->SetSettingsVisible(!center_view->settings_visible());
258 } else if (sender == quiet_mode_button_) {
259 if (message_center()->IsQuietMode())
260 message_center()->SetQuietMode(false);
261 else
262 message_center()->EnterQuietModeWithExpire(base::TimeDelta::FromDays(1));
263 quiet_mode_button_->SetToggled(message_center()->IsQuietMode());
264 } else {
265 NOTREACHED();
266 }
267 }
268
269 // BoundedScrollView /////////////////////////////////////////////////////////// 55 // BoundedScrollView ///////////////////////////////////////////////////////////
270 56
271 // A custom scroll view whose height has a minimum and maximum value and whose 57 // A custom scroll view whose height has a minimum and maximum value and whose
272 // scroll bar disappears when not needed. 58 // scroll bar disappears when not needed.
273 class BoundedScrollView : public views::ScrollView { 59 class BoundedScrollView : public views::ScrollView {
274 public: 60 public:
275 BoundedScrollView(int min_height, int max_height); 61 BoundedScrollView(int min_height, int max_height);
276 62
277 // Overridden from views::View: 63 // Overridden from views::View:
278 virtual gfx::Size GetPreferredSize() OVERRIDE; 64 virtual gfx::Size GetPreferredSize() OVERRIDE;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // MessageCenterView /////////////////////////////////////////////////////////// 584 // MessageCenterView ///////////////////////////////////////////////////////////
799 585
800 MessageCenterView::MessageCenterView(MessageCenter* message_center, 586 MessageCenterView::MessageCenterView(MessageCenter* message_center,
801 MessageCenterTray* tray, 587 MessageCenterTray* tray,
802 int max_height, 588 int max_height,
803 bool initially_settings_visible, 589 bool initially_settings_visible,
804 bool top_down) 590 bool top_down)
805 : message_center_(message_center), 591 : message_center_(message_center),
806 tray_(tray), 592 tray_(tray),
807 top_down_(top_down), 593 top_down_(top_down),
808 settings_visible_(initially_settings_visible) { 594 settings_visible_(initially_settings_visible),
595 source_view_(NULL),
596 source_height_(0),
597 target_view_(NULL),
598 target_height_(0) {
809 message_center_->AddObserver(this); 599 message_center_->AddObserver(this);
810 set_notify_enter_exit_on_child(true); 600 set_notify_enter_exit_on_child(true);
811 set_background(views::Background::CreateSolidBackground( 601 set_background(views::Background::CreateSolidBackground(
812 kMessageCenterBackgroundColor)); 602 kMessageCenterBackgroundColor));
813 603
814 button_bar_ = new MessageCenterButtonBar(this, message_center); 604 NotifierSettingsProvider* notifier_settings_provider =
605 message_center_->GetNotifierSettingsProvider();
606 button_bar_ = new MessageCenterButtonBar(this,
607 message_center,
608 notifier_settings_provider,
609 initially_settings_visible);
815 610
816 const int button_height = button_bar_->GetPreferredSize().height(); 611 const int button_height = button_bar_->GetPreferredSize().height();
817 scroller_ = new BoundedScrollView(kMinScrollViewHeight, 612 const int kButtonBarBorderThickness = 1;
jianli 2013/08/05 20:48:03 nit: move it to the constant sections at the begin
dewittj 2013/08/05 22:42:28 Done.
818 max_height - button_height); 613 button_bar_->set_border(views::Border::CreateSolidSidedBorder(
614 top_down_ ? 0 : kButtonBarBorderThickness,
615 0,
616 top_down_ ? kButtonBarBorderThickness : 0,
617 0,
618 kFooterDelimiterColor));
619
620 scroller_ =
621 new BoundedScrollView(kMinScrollViewHeight, max_height - button_height);
819 622
820 if (get_use_acceleration_when_possible()) { 623 if (get_use_acceleration_when_possible()) {
821 scroller_->SetPaintToLayer(true); 624 scroller_->SetPaintToLayer(true);
822 scroller_->SetFillsBoundsOpaquely(false); 625 scroller_->SetFillsBoundsOpaquely(false);
823 scroller_->layer()->SetMasksToBounds(true); 626 scroller_->layer()->SetMasksToBounds(true);
824 } 627 }
825 628
826 message_list_view_ = new MessageListView(this, top_down); 629 message_list_view_ = new MessageListView(this, top_down);
827 no_notifications_message_view_ = new NoNotificationMessageView(); 630 no_notifications_message_view_ = new NoNotificationMessageView();
828 // Set the default visibility to false, otherwise the notification has slide 631 // Set the default visibility to false, otherwise the notification has slide
829 // in animation when the center is shown. 632 // in animation when the center is shown.
830 no_notifications_message_view_->SetVisible(false); 633 no_notifications_message_view_->SetVisible(false);
831 message_list_view_->AddChildView(no_notifications_message_view_); 634 message_list_view_->AddChildView(no_notifications_message_view_);
832 scroller_->SetContents(message_list_view_); 635 scroller_->SetContents(message_list_view_);
833 636
834 settings_view_ = new NotifierSettingsView( 637 settings_view_ = new NotifierSettingsView(notifier_settings_provider);
835 message_center_->GetNotifierSettingsProvider());
836 638
837 if (initially_settings_visible) 639 if (initially_settings_visible)
838 scroller_->SetVisible(false); 640 scroller_->SetVisible(false);
839 else 641 else
840 settings_view_->SetVisible(false); 642 settings_view_->SetVisible(false);
841 643
842 AddChildView(scroller_); 644 AddChildView(scroller_);
843 AddChildView(settings_view_); 645 AddChildView(settings_view_);
844 AddChildView(button_bar_); 646 AddChildView(button_bar_);
845 } 647 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 } else { 702 } else {
901 parts.push_back(ui::MultiAnimation::Part()); 703 parts.push_back(ui::MultiAnimation::Part());
902 } 704 }
903 settings_transition_animation_.reset(new ui::MultiAnimation( 705 settings_transition_animation_.reset(new ui::MultiAnimation(
904 parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); 706 parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz)));
905 settings_transition_animation_->set_delegate(this); 707 settings_transition_animation_->set_delegate(this);
906 settings_transition_animation_->set_continuous(false); 708 settings_transition_animation_->set_continuous(false);
907 settings_transition_animation_->Start(); 709 settings_transition_animation_->Start();
908 } 710 }
909 711
712 void MessageCenterView::OnSettingsChanged() {
713 scroller_->InvalidateLayout();
714 PreferredSizeChanged();
715 Layout();
716 }
717
910 void MessageCenterView::ClearAllNotifications() { 718 void MessageCenterView::ClearAllNotifications() {
911 scroller_->SetEnabled(false); 719 scroller_->SetEnabled(false);
912 button_bar_->SetAllButtonsEnabled(false); 720 button_bar_->SetAllButtonsEnabled(false);
913 message_list_view_->ClearAllNotifications(scroller_->GetVisibleRect()); 721 message_list_view_->ClearAllNotifications(scroller_->GetVisibleRect());
914 } 722 }
915 723
916 void MessageCenterView::OnAllNotificationsCleared() { 724 void MessageCenterView::OnAllNotificationsCleared() {
917 scroller_->SetEnabled(true); 725 scroller_->SetEnabled(true);
918 button_bar_->SetAllButtonsEnabled(true); 726 button_bar_->SetAllButtonsEnabled(true);
919 message_center_->RemoveAllNotifications(true); // Action by user. 727 message_center_->RemoveAllNotifications(true); // Action by user.
920 } 728 }
921 729
922 size_t MessageCenterView::NumMessageViewsForTest() const { 730 size_t MessageCenterView::NumMessageViewsForTest() const {
923 return message_list_view_->child_count(); 731 return message_list_view_->child_count();
924 } 732 }
925 733
926 void MessageCenterView::Layout() { 734 void MessageCenterView::Layout() {
927 int button_height = button_bar_->GetHeightForWidth(width()); 735 int button_height = button_bar_->GetHeightForWidth(width()) +
736 button_bar_->GetInsets().height();
928 // Skip unnecessary re-layout of contents during the resize animation. 737 // Skip unnecessary re-layout of contents during the resize animation.
929 if (settings_transition_animation_ && 738 if (settings_transition_animation_ &&
930 settings_transition_animation_->is_animating() && 739 settings_transition_animation_->is_animating() &&
931 settings_transition_animation_->current_part_index() == 0) { 740 settings_transition_animation_->current_part_index() == 0) {
932 if (!top_down_) 741 if (!top_down_)
933 button_bar_->SetBounds( 742 button_bar_->SetBounds(
934 0, height() - button_height, width(), button_height); 743 0, height() - button_height, width(), button_height);
935 return; 744 return;
936 } 745 }
937 746
938 scroller_->SetBounds(0, 747 scroller_->SetBounds(0,
939 top_down_ ? button_height : 0, 748 top_down_ ? button_height : 0,
940 width(), 749 width(),
941 height() - button_height); 750 height() - button_height);
942 settings_view_->SetBounds(0, 751 settings_view_->SetBounds(0,
943 top_down_ ? button_height : 0, 752 top_down_ ? button_height : 0,
944 width(), 753 width(),
945 height() - button_height); 754 height() - button_height);
946 755
947 bool is_scrollable = false;
948 if (scroller_->visible())
949 is_scrollable = scroller_->height() < message_list_view_->height();
950 else
951 is_scrollable = settings_view_->IsScrollable();
952
953 if (is_scrollable && !button_bar_->border()) {
954 // Draw separator line on the top of the button bar if it is on the bottom
955 // or draw it at the bottom if the bar is on the top.
956 button_bar_->set_border(views::Border::CreateSolidSidedBorder(
957 top_down_ ? 0 : 1,
958 0,
959 top_down_ ? 1 : 0,
960 0,
961 kFooterDelimiterColor));
962 button_bar_->SchedulePaint();
963 } else if (!is_scrollable && button_bar_->border()) {
964 button_bar_->set_border(NULL);
965 button_bar_->SchedulePaint();
966 }
967
968 button_bar_->SetBounds(0, 756 button_bar_->SetBounds(0,
969 top_down_ ? 0 : height() - button_height, 757 top_down_ ? 0 : height() - button_height,
970 width(), 758 width(),
971 button_height); 759 button_height);
972 if (GetWidget()) 760 if (GetWidget())
973 GetWidget()->GetRootView()->SchedulePaint(); 761 GetWidget()->GetRootView()->SchedulePaint();
974 } 762 }
975 763
976 gfx::Size MessageCenterView::GetPreferredSize() { 764 gfx::Size MessageCenterView::GetPreferredSize() {
977 if (settings_transition_animation_ && 765 if (settings_transition_animation_ &&
(...skipping 23 matching lines...) Expand all
1001 source_height_, target_height_); 789 source_height_, target_height_);
1002 } 790 }
1003 return button_bar_->GetHeightForWidth(width) + content_height; 791 return button_bar_->GetHeightForWidth(width) + content_height;
1004 } 792 }
1005 793
1006 int content_height = 0; 794 int content_height = 0;
1007 if (scroller_->visible()) 795 if (scroller_->visible())
1008 content_height += scroller_->GetHeightForWidth(width); 796 content_height += scroller_->GetHeightForWidth(width);
1009 else 797 else
1010 content_height += settings_view_->GetHeightForWidth(width); 798 content_height += settings_view_->GetHeightForWidth(width);
1011 return button_bar_->GetHeightForWidth(width) + content_height; 799 return button_bar_->GetHeightForWidth(width) +
800 button_bar_->GetInsets().height() + content_height;
1012 } 801 }
1013 802
1014 bool MessageCenterView::OnMouseWheel(const ui::MouseWheelEvent& event) { 803 bool MessageCenterView::OnMouseWheel(const ui::MouseWheelEvent& event) {
1015 // Do not rely on the default scroll event handler of ScrollView because 804 // Do not rely on the default scroll event handler of ScrollView because
1016 // the scroll happens only when the focus is on the ScrollView. The 805 // the scroll happens only when the focus is on the ScrollView. The
1017 // notification center will allow the scrolling even when the focus is on 806 // notification center will allow the scrolling even when the focus is on
1018 // the buttons. 807 // the buttons.
1019 if (scroller_->bounds().Contains(event.location())) 808 if (scroller_->bounds().Contains(event.location()))
1020 return scroller_->OnMouseWheel(event); 809 return scroller_->OnMouseWheel(event);
1021 return views::View::OnMouseWheel(event); 810 return views::View::OnMouseWheel(event);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 scroller_->InvalidateLayout(); 954 scroller_->InvalidateLayout();
1166 PreferredSizeChanged(); 955 PreferredSizeChanged();
1167 Layout(); 956 Layout();
1168 } 957 }
1169 958
1170 void MessageCenterView::SetNotificationViewForTest(views::View* view) { 959 void MessageCenterView::SetNotificationViewForTest(views::View* view) {
1171 message_list_view_->AddNotificationAt(view, 0); 960 message_list_view_->AddNotificationAt(view, 0);
1172 } 961 }
1173 962
1174 } // namespace message_center 963 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698