| 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/notifier_settings_view.h" |    5 #include "ui/message_center/views/notifier_settings_view.h" | 
|    6  |    6  | 
|    7 #include <stddef.h> |    7 #include <stddef.h> | 
|    8  |    8  | 
|    9 #include <set> |    9 #include <set> | 
|   10 #include <string> |   10 #include <string> | 
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  435   title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |  435   title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 
|  436   title_label_->SetMultiLine(true); |  436   title_label_->SetMultiLine(true); | 
|  437   title_label_->SetBorder( |  437   title_label_->SetBorder( | 
|  438       views::CreateEmptyBorder(kComputedTitleTopMargin, kTitleMargin, |  438       views::CreateEmptyBorder(kComputedTitleTopMargin, kTitleMargin, | 
|  439                                kComputedTitleBottomMargin, kTitleMargin)); |  439                                kComputedTitleBottomMargin, kTitleMargin)); | 
|  440  |  440  | 
|  441   AddChildView(title_label_); |  441   AddChildView(title_label_); | 
|  442  |  442  | 
|  443   scroller_ = new views::ScrollView(); |  443   scroller_ = new views::ScrollView(); | 
|  444   scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); |  444   scroller_->SetVerticalScrollBar(new views::OverlayScrollBar(false)); | 
 |  445   scroller_->SetHorizontalScrollBar(new views::OverlayScrollBar(true)); | 
|  445   AddChildView(scroller_); |  446   AddChildView(scroller_); | 
|  446  |  447  | 
|  447   std::vector<Notifier*> notifiers; |  448   std::vector<Notifier*> notifiers; | 
|  448   if (provider_) |  449   if (provider_) | 
|  449     provider_->GetNotifierList(¬ifiers); |  450     provider_->GetNotifierList(¬ifiers); | 
|  450  |  451  | 
|  451   UpdateContentsView(notifiers); |  452   UpdateContentsView(notifiers); | 
|  452 } |  453 } | 
|  453  |  454  | 
|  454 NotifierSettingsView::~NotifierSettingsView() { |  455 NotifierSettingsView::~NotifierSettingsView() { | 
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  563 } |  564 } | 
|  564  |  565  | 
|  565 void NotifierSettingsView::Layout() { |  566 void NotifierSettingsView::Layout() { | 
|  566   int title_height = title_label_->GetHeightForWidth(width()); |  567   int title_height = title_label_->GetHeightForWidth(width()); | 
|  567   title_label_->SetBounds(0, 0, width(), title_height); |  568   title_label_->SetBounds(0, 0, width(), title_height); | 
|  568  |  569  | 
|  569   views::View* contents_view = scroller_->contents(); |  570   views::View* contents_view = scroller_->contents(); | 
|  570   int content_width = width(); |  571   int content_width = width(); | 
|  571   int content_height = contents_view->GetHeightForWidth(content_width); |  572   int content_height = contents_view->GetHeightForWidth(content_width); | 
|  572   if (title_height + content_height > height()) { |  573   if (title_height + content_height > height()) { | 
|  573     content_width -= scroller_->GetScrollBarWidth(); |  574     content_width -= scroller_->GetScrollBarLayoutWidth(); | 
|  574     content_height = contents_view->GetHeightForWidth(content_width); |  575     content_height = contents_view->GetHeightForWidth(content_width); | 
|  575   } |  576   } | 
|  576   contents_view->SetBounds(0, 0, content_width, content_height); |  577   contents_view->SetBounds(0, 0, content_width, content_height); | 
|  577   scroller_->SetBounds(0, title_height, width(), height() - title_height); |  578   scroller_->SetBounds(0, title_height, width(), height() - title_height); | 
|  578 } |  579 } | 
|  579  |  580  | 
|  580 gfx::Size NotifierSettingsView::GetMinimumSize() const { |  581 gfx::Size NotifierSettingsView::GetMinimumSize() const { | 
|  581   gfx::Size size(kWidth, kMinimumHeight); |  582   gfx::Size size(kWidth, kMinimumHeight); | 
|  582   int total_height = title_label_->GetPreferredSize().height() + |  583   int total_height = title_label_->GetPreferredSize().height() + | 
|  583                      scroller_->contents()->GetPreferredSize().height(); |  584                      scroller_->contents()->GetPreferredSize().height(); | 
|  584   if (total_height > kMinimumHeight) |  585   if (total_height > kMinimumHeight) | 
|  585     size.Enlarge(scroller_->GetScrollBarWidth(), 0); |  586     size.Enlarge(scroller_->GetScrollBarLayoutWidth(), 0); | 
|  586   return size; |  587   return size; | 
|  587 } |  588 } | 
|  588  |  589  | 
|  589 gfx::Size NotifierSettingsView::GetPreferredSize() const { |  590 gfx::Size NotifierSettingsView::GetPreferredSize() const { | 
|  590   gfx::Size preferred_size; |  591   gfx::Size preferred_size; | 
|  591   gfx::Size title_size = title_label_->GetPreferredSize(); |  592   gfx::Size title_size = title_label_->GetPreferredSize(); | 
|  592   gfx::Size content_size = scroller_->contents()->GetPreferredSize(); |  593   gfx::Size content_size = scroller_->contents()->GetPreferredSize(); | 
|  593   return gfx::Size(std::max(title_size.width(), content_size.width()), |  594   return gfx::Size(std::max(title_size.width(), content_size.width()), | 
|  594                    title_size.height() + content_size.height()); |  595                    title_size.height() + content_size.height()); | 
|  595 } |  596 } | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|  626     provider_->SetNotifierEnabled((*iter)->notifier(), (*iter)->checked()); |  627     provider_->SetNotifierEnabled((*iter)->notifier(), (*iter)->checked()); | 
|  627 } |  628 } | 
|  628  |  629  | 
|  629 void NotifierSettingsView::OnPerformAction(views::Combobox* combobox) { |  630 void NotifierSettingsView::OnPerformAction(views::Combobox* combobox) { | 
|  630   provider_->SwitchToNotifierGroup(combobox->selected_index()); |  631   provider_->SwitchToNotifierGroup(combobox->selected_index()); | 
|  631   MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |  632   MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 
|  632   center_view->OnSettingsChanged(); |  633   center_view->OnSettingsChanged(); | 
|  633 } |  634 } | 
|  634  |  635  | 
|  635 }  // namespace message_center |  636 }  // namespace message_center | 
| OLD | NEW |