| 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/macros.h" | 10 #include "base/macros.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 int margin = (height() - text_height) / 2; | 104 int margin = (height() - text_height) / 2; |
| 105 label_->SetBounds(0, margin, width(), text_height); | 105 label_->SetBounds(0, margin, width(), text_height); |
| 106 } | 106 } |
| 107 | 107 |
| 108 // MessageCenterView /////////////////////////////////////////////////////////// | 108 // MessageCenterView /////////////////////////////////////////////////////////// |
| 109 | 109 |
| 110 MessageCenterView::MessageCenterView(MessageCenter* message_center, | 110 MessageCenterView::MessageCenterView(MessageCenter* message_center, |
| 111 MessageCenterTray* tray, | 111 MessageCenterTray* tray, |
| 112 int max_height, | 112 int max_height, |
| 113 bool initially_settings_visible, | 113 bool initially_settings_visible, |
| 114 bool top_down, | 114 bool top_down) |
| 115 const base::string16& title) | |
| 116 : message_center_(message_center), | 115 : message_center_(message_center), |
| 117 tray_(tray), | 116 tray_(tray), |
| 118 scroller_(NULL), | 117 scroller_(NULL), |
| 119 settings_view_(NULL), | 118 settings_view_(NULL), |
| 120 button_bar_(NULL), | 119 button_bar_(NULL), |
| 121 top_down_(top_down), | 120 top_down_(top_down), |
| 122 settings_visible_(initially_settings_visible), | 121 settings_visible_(initially_settings_visible), |
| 123 source_view_(NULL), | 122 source_view_(NULL), |
| 124 source_height_(0), | 123 source_height_(0), |
| 125 target_view_(NULL), | 124 target_view_(NULL), |
| 126 target_height_(0), | 125 target_height_(0), |
| 127 is_closing_(false), | 126 is_closing_(false), |
| 128 context_menu_controller_(new MessageViewContextMenuController(this)) { | 127 context_menu_controller_(new MessageViewContextMenuController(this)) { |
| 129 message_center_->AddObserver(this); | 128 message_center_->AddObserver(this); |
| 130 set_notify_enter_exit_on_child(true); | 129 set_notify_enter_exit_on_child(true); |
| 131 set_background(views::Background::CreateSolidBackground( | 130 set_background(views::Background::CreateSolidBackground( |
| 132 kMessageCenterBackgroundColor)); | 131 kMessageCenterBackgroundColor)); |
| 133 | 132 |
| 134 NotifierSettingsProvider* notifier_settings_provider = | 133 NotifierSettingsProvider* notifier_settings_provider = |
| 135 message_center_->GetNotifierSettingsProvider(); | 134 message_center_->GetNotifierSettingsProvider(); |
| 136 button_bar_ = new MessageCenterButtonBar(this, | 135 button_bar_ = new MessageCenterButtonBar( |
| 137 message_center, | 136 this, message_center, notifier_settings_provider, |
| 138 notifier_settings_provider, | 137 initially_settings_visible, GetButtonBarTitle()); |
| 139 initially_settings_visible, | |
| 140 title); | |
| 141 | 138 |
| 142 const int button_height = button_bar_->GetPreferredSize().height(); | 139 const int button_height = button_bar_->GetPreferredSize().height(); |
| 143 | 140 |
| 144 scroller_ = new views::ScrollView(); | 141 scroller_ = new views::ScrollView(); |
| 145 scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height); | 142 scroller_->ClipHeightTo(kMinScrollViewHeight, max_height - button_height); |
| 146 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); | 143 scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); |
| 147 scroller_->set_background( | 144 scroller_->set_background( |
| 148 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); | 145 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); |
| 149 | 146 |
| 150 scroller_->SetPaintToLayer(true); | 147 scroller_->SetPaintToLayer(true); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } else { | 243 } else { |
| 247 parts.push_back(gfx::MultiAnimation::Part()); | 244 parts.push_back(gfx::MultiAnimation::Part()); |
| 248 } | 245 } |
| 249 settings_transition_animation_.reset(new gfx::MultiAnimation( | 246 settings_transition_animation_.reset(new gfx::MultiAnimation( |
| 250 parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); | 247 parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); |
| 251 settings_transition_animation_->set_delegate(this); | 248 settings_transition_animation_->set_delegate(this); |
| 252 settings_transition_animation_->set_continuous(false); | 249 settings_transition_animation_->set_continuous(false); |
| 253 settings_transition_animation_->Start(); | 250 settings_transition_animation_->Start(); |
| 254 | 251 |
| 255 button_bar_->SetBackArrowVisible(visible); | 252 button_bar_->SetBackArrowVisible(visible); |
| 253 button_bar_->SetTitle(GetButtonBarTitle()); |
| 256 } | 254 } |
| 257 | 255 |
| 258 void MessageCenterView::ClearAllClosableNotifications() { | 256 void MessageCenterView::ClearAllClosableNotifications() { |
| 259 if (is_closing_) | 257 if (is_closing_) |
| 260 return; | 258 return; |
| 261 | 259 |
| 262 SetViewHierarchyEnabled(scroller_, false); | 260 SetViewHierarchyEnabled(scroller_, false); |
| 263 button_bar_->SetAllButtonsEnabled(false); | 261 button_bar_->SetAllButtonsEnabled(false); |
| 264 message_list_view_->ClearAllClosableNotifications( | 262 message_list_view_->ClearAllClosableNotifications( |
| 265 scroller_->GetVisibleRect()); | 263 scroller_->GetVisibleRect()); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 no_message_views ? empty_list_view_.get() : message_list_view_.get()); | 592 no_message_views ? empty_list_view_.get() : message_list_view_.get()); |
| 595 | 593 |
| 596 bool no_closable_views = true; | 594 bool no_closable_views = true; |
| 597 for (const auto& view : notification_views_) { | 595 for (const auto& view : notification_views_) { |
| 598 if (!view.second->IsPinned()) { | 596 if (!view.second->IsPinned()) { |
| 599 no_closable_views = false; | 597 no_closable_views = false; |
| 600 break; | 598 break; |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 button_bar_->SetCloseAllButtonEnabled(!no_closable_views); | 601 button_bar_->SetCloseAllButtonEnabled(!no_closable_views); |
| 602 button_bar_->SetTitle(GetButtonBarTitle()); |
| 604 | 603 |
| 605 if (no_message_views) { | 604 if (no_message_views) { |
| 606 scroller_->SetFocusBehavior(FocusBehavior::NEVER); | 605 scroller_->SetFocusBehavior(FocusBehavior::NEVER); |
| 607 } else { | 606 } else { |
| 608 #if defined(OS_MACOSX) | 607 #if defined(OS_MACOSX) |
| 609 scroller_->SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); | 608 scroller_->SetFocusBehavior(FocusBehavior::ACCESSIBLE_ONLY); |
| 610 #else | 609 #else |
| 611 scroller_->SetFocusBehavior(FocusBehavior::ALWAYS); | 610 scroller_->SetFocusBehavior(FocusBehavior::ALWAYS); |
| 612 #endif | 611 #endif |
| 613 } | 612 } |
| 614 | 613 |
| 615 if (focus_manager && focused_view) | 614 if (focus_manager && focused_view) |
| 616 focus_manager->SetFocusedView(focused_view); | 615 focus_manager->SetFocusedView(focused_view); |
| 617 | 616 |
| 618 scroller_->InvalidateLayout(); | 617 scroller_->InvalidateLayout(); |
| 619 PreferredSizeChanged(); | 618 PreferredSizeChanged(); |
| 620 Layout(); | 619 Layout(); |
| 621 } | 620 } |
| 622 | 621 |
| 622 base::string16 MessageCenterView::GetButtonBarTitle() const { |
| 623 bool no_message_views = notification_views_.empty(); |
| 624 if (no_message_views && !settings_visible_) |
| 625 return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_NO_MESSAGES); |
| 626 |
| 627 return l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_FOOTER_TITLE); |
| 628 } |
| 629 |
| 623 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 630 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
| 624 message_list_view_->AddNotificationAt(view, 0); | 631 message_list_view_->AddNotificationAt(view, 0); |
| 625 } | 632 } |
| 626 | 633 |
| 627 } // namespace message_center | 634 } // namespace message_center |
| OLD | NEW |