Chromium Code Reviews| 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 <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "grit/ui_strings.h" | 9 #include "grit/ui_strings.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 message_center()->RemoveAllNotifications(true); // Action by user. | 106 message_center()->RemoveAllNotifications(true); // Action by user. |
| 107 } | 107 } |
| 108 | 108 |
| 109 // NotificationCenterButton //////////////////////////////////////////////////// | 109 // NotificationCenterButton //////////////////////////////////////////////////// |
| 110 | 110 |
| 111 class NotificationCenterButton : public views::TextButton { | 111 class NotificationCenterButton : public views::TextButton { |
| 112 public: | 112 public: |
| 113 NotificationCenterButton(views::ButtonListener* listener, | 113 NotificationCenterButton(views::ButtonListener* listener, |
| 114 const string16& text); | 114 const string16& text); |
| 115 | 115 |
| 116 protected: | |
|
dharcourt
2013/04/17 21:58:56
"protected:" should be moved down two lines instea
Jun Mukai
2013/04/18 18:16:44
Done.
| |
| 117 // Overridden from views::View: | 116 // Overridden from views::View: |
| 118 virtual gfx::Size GetPreferredSize() OVERRIDE; | 117 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 119 virtual void OnPaintBorder(gfx::Canvas* canvas); | 118 virtual void OnPaintBorder(gfx::Canvas* canvas); |
| 120 virtual void OnPaintFocusBorder(gfx::Canvas* canvas); | 119 virtual void OnPaintFocusBorder(gfx::Canvas* canvas); |
|
dharcourt
2013/04/17 21:58:56
I know this is preexisting, but shouldn't OnPaintB
Jun Mukai
2013/04/18 18:16:44
Done.
| |
| 121 | 120 |
| 121 private: | |
| 122 DISALLOW_COPY_AND_ASSIGN(NotificationCenterButton); | 122 DISALLOW_COPY_AND_ASSIGN(NotificationCenterButton); |
| 123 }; | 123 }; |
| 124 | 124 |
| 125 NotificationCenterButton::NotificationCenterButton( | 125 NotificationCenterButton::NotificationCenterButton( |
| 126 views::ButtonListener* listener, | 126 views::ButtonListener* listener, |
| 127 const string16& text) | 127 const string16& text) |
| 128 : views::TextButton(listener, text) { | 128 : views::TextButton(listener, text) { |
| 129 set_border(views::Border::CreateEmptyBorder(0, 16, 0, 16)); | 129 set_border(views::Border::CreateEmptyBorder(0, 16, 0, 16)); |
| 130 set_min_height(kFooterHeight); | 130 set_min_height(kFooterHeight); |
| 131 SetEnabledColor(kFooterTextColor); | 131 SetEnabledColor(kFooterTextColor); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 | 165 |
| 166 private: | 166 private: |
| 167 // Overridden from views::View: | 167 // Overridden from views::View: |
| 168 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE; | 168 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE; |
| 169 | 169 |
| 170 // Overridden from views::ButtonListener: | 170 // Overridden from views::ButtonListener: |
| 171 virtual void ButtonPressed(views::Button* sender, | 171 virtual void ButtonPressed(views::Button* sender, |
| 172 const ui::Event& event) OVERRIDE; | 172 const ui::Event& event) OVERRIDE; |
| 173 | 173 |
| 174 views::Label* notification_label_; | 174 views::Label* notification_label_; |
| 175 views::Button* settings_button_; | 175 NotificationCenterButton* settings_button_; |
| 176 | 176 |
| 177 DISALLOW_COPY_AND_ASSIGN(RichMessageCenterButtonBar); | 177 DISALLOW_COPY_AND_ASSIGN(RichMessageCenterButtonBar); |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 RichMessageCenterButtonBar::RichMessageCenterButtonBar( | 180 RichMessageCenterButtonBar::RichMessageCenterButtonBar( |
| 181 MessageCenter* message_center) | 181 MessageCenter* message_center) |
| 182 : MessageCenterButtonBar(message_center) { | 182 : MessageCenterButtonBar(message_center) { |
| 183 set_background(views::Background::CreateSolidBackground( | 183 set_background(views::Background::CreateSolidBackground( |
| 184 kMessageCenterBackgroundColor)); | 184 kMessageCenterBackgroundColor)); |
| 185 set_border(views::Border::CreateSolidSidedBorder( | 185 set_border(views::Border::CreateSolidSidedBorder( |
| 186 1, 0, 0, 0, kFooterDelimiterColor)); | 186 1, 0, 0, 0, kFooterDelimiterColor)); |
| 187 | 187 |
| 188 | 188 |
| 189 notification_label_ = new views::Label(l10n_util::GetStringUTF16( | 189 notification_label_ = new views::Label(l10n_util::GetStringUTF16( |
| 190 IDS_MESSAGE_CENTER_FOOTER_TITLE)); | 190 IDS_MESSAGE_CENTER_FOOTER_TITLE)); |
| 191 notification_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 191 notification_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 192 notification_label_->SetElideBehavior(views::Label::ELIDE_AT_END); | 192 notification_label_->SetElideBehavior(views::Label::ELIDE_AT_END); |
| 193 notification_label_->SetEnabledColor(kFooterTextColor); | 193 notification_label_->SetEnabledColor(kFooterTextColor); |
| 194 AddChildView(notification_label_); | 194 AddChildView(notification_label_); |
| 195 settings_button_ = new NotificationCenterButton( | 195 settings_button_ = new NotificationCenterButton( |
| 196 this, l10n_util::GetStringUTF16( | 196 this, l10n_util::GetStringUTF16( |
| 197 IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL)); | 197 IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL)); |
| 198 settings_button_->set_focusable(true); | 198 settings_button_->set_focusable(true); |
| 199 settings_button_->set_request_focus_on_press(false); | |
| 199 AddChildView(settings_button_); | 200 AddChildView(settings_button_); |
| 200 NotificationCenterButton* close_all_button = new NotificationCenterButton( | 201 NotificationCenterButton* close_all_button = new NotificationCenterButton( |
| 201 this, l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_CLEAR_ALL)); | 202 this, l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_CLEAR_ALL)); |
| 202 close_all_button->set_focusable(true); | 203 close_all_button->set_focusable(true); |
| 204 close_all_button->set_request_focus_on_press(false); | |
| 203 AddChildView(close_all_button); | 205 AddChildView(close_all_button); |
| 204 | 206 |
| 205 views::GridLayout* layout = new views::GridLayout(this); | 207 views::GridLayout* layout = new views::GridLayout(this); |
| 206 SetLayoutManager(layout); | 208 SetLayoutManager(layout); |
| 207 layout->SetInsets( | 209 layout->SetInsets( |
| 208 kMarginBetweenItems, kFooterMargin, kMarginBetweenItems, 0); | 210 kMarginBetweenItems, kFooterMargin, kMarginBetweenItems, 0); |
| 209 views::ColumnSet* column = layout->AddColumnSet(0); | 211 views::ColumnSet* column = layout->AddColumnSet(0); |
| 210 column->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 212 column->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 211 1.0f, views::GridLayout::USE_PREF, 0, 0); | 213 1.0f, views::GridLayout::USE_PREF, 0, 0); |
| 212 column->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, | 214 column->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 450 // NotificationViews are expanded by default here until | 452 // NotificationViews are expanded by default here until |
| 451 // http://crbug.com/217902 is fixed. TODO(dharcourt): Fix. | 453 // http://crbug.com/217902 is fixed. TODO(dharcourt): Fix. |
| 452 MessageView* view = NotificationView::Create( | 454 MessageView* view = NotificationView::Create( |
| 453 notification, message_center_, true); | 455 notification, message_center_, true); |
| 454 view->set_scroller(scroller_); | 456 view->set_scroller(scroller_); |
| 455 message_views_[notification.id()] = view; | 457 message_views_[notification.id()] = view; |
| 456 message_list_view_->AddChildView(view); | 458 message_list_view_->AddChildView(view); |
| 457 } | 459 } |
| 458 | 460 |
| 459 } // namespace message_center | 461 } // namespace message_center |
| OLD | NEW |