| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/notification_header_view.h" | 5 #include "ui/message_center/views/notification_header_view.h" |
| 6 | 6 |
| 7 #include "ui/base/l10n/l10n_util.h" | 7 #include "ui/base/l10n/l10n_util.h" |
| 8 #include "ui/gfx/color_palette.h" | 8 #include "ui/gfx/color_palette.h" |
| 9 #include "ui/gfx/font_list.h" | 9 #include "ui/gfx/font_list.h" |
| 10 #include "ui/gfx/paint_vector_icon.h" | 10 #include "ui/gfx/paint_vector_icon.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 app_info_container->AddChildView(app_icon_view_); | 55 app_info_container->AddChildView(app_icon_view_); |
| 56 | 56 |
| 57 // App name view | 57 // App name view |
| 58 const gfx::FontList& font_list = views::Label().font_list().Derive( | 58 const gfx::FontList& font_list = views::Label().font_list().Derive( |
| 59 -2, gfx::Font::NORMAL, gfx::Font::Weight::NORMAL); | 59 -2, gfx::Font::NORMAL, gfx::Font::Weight::NORMAL); |
| 60 app_name_view_ = new views::Label(base::string16()); | 60 app_name_view_ = new views::Label(base::string16()); |
| 61 app_name_view_->SetFontList(font_list); | 61 app_name_view_->SetFontList(font_list); |
| 62 app_name_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 62 app_name_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 63 app_info_container->AddChildView(app_name_view_); | 63 app_info_container->AddChildView(app_name_view_); |
| 64 | 64 |
| 65 // Summary text divider |
| 66 summary_text_divider_ = new views::Label(l10n_util::GetStringUTF16( |
| 67 IDS_MESSAGE_CENTER_NOTIFICATION_HEADER_DIVIDER_SYMBOL_WITH_SPACES)); |
| 68 summary_text_divider_->SetFontList(font_list); |
| 69 summary_text_divider_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 70 summary_text_divider_->SetVisible(false); |
| 71 app_info_container->AddChildView(summary_text_divider_); |
| 72 |
| 73 // Summary text view |
| 74 summary_text_view_ = new views::Label(base::string16()); |
| 75 summary_text_view_->SetFontList(font_list); |
| 76 summary_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 77 summary_text_view_->SetVisible(false); |
| 78 app_info_container->AddChildView(summary_text_view_); |
| 79 |
| 65 // Expand button view | 80 // Expand button view |
| 66 expand_button_ = new views::ImageButton(listener); | 81 expand_button_ = new views::ImageButton(listener); |
| 67 expand_button_->SetImage( | 82 expand_button_->SetImage( |
| 68 views::Button::STATE_NORMAL, | 83 views::Button::STATE_NORMAL, |
| 69 gfx::CreateVectorIcon(kNotificationExpandMoreIcon, kExpandIconSize, | 84 gfx::CreateVectorIcon(kNotificationExpandMoreIcon, kExpandIconSize, |
| 70 gfx::kChromeIconGrey)); | 85 gfx::kChromeIconGrey)); |
| 71 expand_button_->SetFocusForPlatform(); | 86 expand_button_->SetFocusForPlatform(); |
| 72 expand_button_->SetFocusPainter(views::Painter::CreateSolidFocusPainter( | 87 expand_button_->SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| 73 kFocusBorderColor, gfx::Insets(1, 2, 2, 2))); | 88 kFocusBorderColor, gfx::Insets(1, 2, 2, 2))); |
| 74 app_info_container->AddChildView(expand_button_); | 89 app_info_container->AddChildView(expand_button_); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 99 } | 114 } |
| 100 | 115 |
| 101 void NotificationHeaderView::SetAppIcon(const gfx::ImageSkia& img) { | 116 void NotificationHeaderView::SetAppIcon(const gfx::ImageSkia& img) { |
| 102 app_icon_view_->SetImage(img); | 117 app_icon_view_->SetImage(img); |
| 103 } | 118 } |
| 104 | 119 |
| 105 void NotificationHeaderView::SetAppName(const base::string16& name) { | 120 void NotificationHeaderView::SetAppName(const base::string16& name) { |
| 106 app_name_view_->SetText(name); | 121 app_name_view_->SetText(name); |
| 107 } | 122 } |
| 108 | 123 |
| 124 void NotificationHeaderView::SetSummaryText( |
| 125 const base::string16& summary_text) { |
| 126 if (summary_text.empty()) { |
| 127 summary_text_divider_->SetVisible(false); |
| 128 summary_text_view_->SetVisible(false); |
| 129 } else { |
| 130 summary_text_view_->SetText(summary_text); |
| 131 summary_text_divider_->SetVisible(true); |
| 132 summary_text_view_->SetVisible(true); |
| 133 } |
| 134 } |
| 135 |
| 109 void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) { | 136 void NotificationHeaderView::SetExpandButtonEnabled(bool enabled) { |
| 110 expand_button_->SetVisible(enabled); | 137 expand_button_->SetVisible(enabled); |
| 111 } | 138 } |
| 112 | 139 |
| 113 void NotificationHeaderView::SetExpanded(bool expanded) { | 140 void NotificationHeaderView::SetExpanded(bool expanded) { |
| 114 expand_button_->SetImage( | 141 expand_button_->SetImage( |
| 115 views::Button::STATE_NORMAL, | 142 views::Button::STATE_NORMAL, |
| 116 gfx::CreateVectorIcon( | 143 gfx::CreateVectorIcon( |
| 117 expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, | 144 expanded ? kNotificationExpandLessIcon : kNotificationExpandMoreIcon, |
| 118 kExpandIconSize, gfx::kChromeIconGrey)); | 145 kExpandIconSize, gfx::kChromeIconGrey)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 180 |
| 154 void NotificationHeaderView::UpdateControlButtonsVisibility() { | 181 void NotificationHeaderView::UpdateControlButtonsVisibility() { |
| 155 settings_button_->SetVisible(settings_button_enabled_ && | 182 settings_button_->SetVisible(settings_button_enabled_ && |
| 156 is_control_buttons_visible_); | 183 is_control_buttons_visible_); |
| 157 close_button_->SetVisible(close_button_enabled_ && | 184 close_button_->SetVisible(close_button_enabled_ && |
| 158 is_control_buttons_visible_); | 185 is_control_buttons_visible_); |
| 159 Layout(); | 186 Layout(); |
| 160 } | 187 } |
| 161 | 188 |
| 162 } // namespace message_center | 189 } // namespace message_center |
| OLD | NEW |