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 <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 bool EntryView::OnKeyPressed(const ui::KeyEvent& event) { | 182 bool EntryView::OnKeyPressed(const ui::KeyEvent& event) { |
183 return child_at(0)->OnKeyPressed(event); | 183 return child_at(0)->OnKeyPressed(event); |
184 } | 184 } |
185 | 185 |
186 bool EntryView::OnKeyReleased(const ui::KeyEvent& event) { | 186 bool EntryView::OnKeyReleased(const ui::KeyEvent& event) { |
187 return child_at(0)->OnKeyReleased(event); | 187 return child_at(0)->OnKeyReleased(event); |
188 } | 188 } |
189 | 189 |
190 } // namespace | 190 } // namespace |
191 | 191 |
192 // NotifierGroupMenuButtonBorder /////////////////////////////////////////////// | |
193 //////////////////////////////////////////////////////////////////////////////// | |
194 class NotifierGroupMenuButtonBorder : public views::TextButtonDefaultBorder { | |
195 public: | |
196 NotifierGroupMenuButtonBorder(); | |
197 | |
198 private: | |
199 virtual ~NotifierGroupMenuButtonBorder(); | |
200 }; | |
201 | |
202 NotifierGroupMenuButtonBorder::NotifierGroupMenuButtonBorder() | |
203 : views::TextButtonDefaultBorder() { | |
204 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
205 | |
206 gfx::Insets insets(kButtonPainterInsets, | |
207 kButtonPainterInsets, | |
208 kButtonPainterInsets, | |
209 kButtonPainterInsets); | |
210 | |
211 set_normal_painter(views::Painter::CreateImagePainter( | |
212 *rb.GetImageSkiaNamed(IDR_BUTTON_NORMAL), insets)); | |
213 set_hot_painter(views::Painter::CreateImagePainter( | |
214 *rb.GetImageSkiaNamed(IDR_BUTTON_HOVER), insets)); | |
215 set_pushed_painter(views::Painter::CreateImagePainter( | |
216 *rb.GetImageSkiaNamed(IDR_BUTTON_PRESSED), insets)); | |
217 | |
218 SetInsets(gfx::Insets(kMenuButtonVerticalPadding, | |
219 kMenuButtonLeftPadding, | |
220 kMenuButtonVerticalPadding, | |
221 kMenuButtonRightPadding)); | |
222 } | |
223 | |
224 NotifierGroupMenuButtonBorder::~NotifierGroupMenuButtonBorder() {} | |
225 | 192 |
226 // NotifierGroupMenuModel ----------------------------------------------------- | 193 // NotifierGroupMenuModel ----------------------------------------------------- |
227 | 194 |
228 class NotifierGroupMenuModel : public ui::SimpleMenuModel, | 195 class NotifierGroupMenuModel : public ui::SimpleMenuModel, |
229 public ui::SimpleMenuModel::Delegate { | 196 public ui::SimpleMenuModel::Delegate { |
230 public: | 197 public: |
231 NotifierGroupMenuModel(NotifierSettingsProvider* notifier_settings_provider); | 198 NotifierGroupMenuModel(NotifierSettingsProvider* notifier_settings_provider); |
232 virtual ~NotifierGroupMenuModel(); | 199 virtual ~NotifierGroupMenuModel(); |
233 | 200 |
234 // ui::SimpleMenuModel::Delegate: | 201 // ui::SimpleMenuModel::Delegate: |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 0, | 556 0, |
590 settings::kTitleMargin + kMenuButtonInnateMargin)); | 557 settings::kTitleMargin + kMenuButtonInnateMargin)); |
591 contents_title_view->AddChildView(top_label); | 558 contents_title_view->AddChildView(top_label); |
592 | 559 |
593 if (need_account_switcher) { | 560 if (need_account_switcher) { |
594 const NotifierGroup& active_group = provider_->GetActiveNotifierGroup(); | 561 const NotifierGroup& active_group = provider_->GetActiveNotifierGroup(); |
595 string16 notifier_group_text = active_group.login_info.empty() ? | 562 string16 notifier_group_text = active_group.login_info.empty() ? |
596 active_group.name : active_group.login_info; | 563 active_group.name : active_group.login_info; |
597 notifier_group_selector_ = | 564 notifier_group_selector_ = |
598 new views::MenuButton(NULL, notifier_group_text, this, true); | 565 new views::MenuButton(NULL, notifier_group_text, this, true); |
599 notifier_group_selector_->set_border(new NotifierGroupMenuButtonBorder); | 566 scoped_ptr<views::TextButtonDefaultBorder> selector_border( |
| 567 new views::TextButtonDefaultBorder()); |
| 568 ui::ResourceBundle* rb = &ResourceBundle::GetSharedInstance(); |
| 569 gfx::Insets painter_insets(kButtonPainterInsets, kButtonPainterInsets, |
| 570 kButtonPainterInsets, kButtonPainterInsets); |
| 571 selector_border->set_normal_painter(views::Painter::CreateImagePainter( |
| 572 *rb->GetImageSkiaNamed(IDR_BUTTON_NORMAL), painter_insets)); |
| 573 selector_border->set_hot_painter(views::Painter::CreateImagePainter( |
| 574 *rb->GetImageSkiaNamed(IDR_BUTTON_HOVER), painter_insets)); |
| 575 selector_border->set_pushed_painter(views::Painter::CreateImagePainter( |
| 576 *rb->GetImageSkiaNamed(IDR_BUTTON_PRESSED), painter_insets)); |
| 577 selector_border->SetInsets(gfx::Insets( |
| 578 kMenuButtonVerticalPadding, kMenuButtonLeftPadding, |
| 579 kMenuButtonVerticalPadding, kMenuButtonRightPadding)); |
| 580 notifier_group_selector_->set_border(selector_border.release()); |
600 notifier_group_selector_->set_focus_border(NULL); | 581 notifier_group_selector_->set_focus_border(NULL); |
601 notifier_group_selector_->set_animate_on_state_change(false); | 582 notifier_group_selector_->set_animate_on_state_change(false); |
602 notifier_group_selector_->set_focusable(true); | 583 notifier_group_selector_->set_focusable(true); |
603 contents_title_view->AddChildView(notifier_group_selector_); | 584 contents_title_view->AddChildView(notifier_group_selector_); |
604 } | 585 } |
605 | 586 |
606 contents_view->AddChildView(contents_title_view); | 587 contents_view->AddChildView(contents_title_view); |
607 | 588 |
608 size_t notifier_count = notifiers.size(); | 589 size_t notifier_count = notifiers.size(); |
609 for (size_t i = 0; i < notifier_count; ++i) { | 590 for (size_t i = 0; i < notifier_count; ++i) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 menu_anchor, | 698 menu_anchor, |
718 views::MenuItemView::BUBBLE_ABOVE, | 699 views::MenuItemView::BUBBLE_ABOVE, |
719 ui::MENU_SOURCE_MOUSE, | 700 ui::MENU_SOURCE_MOUSE, |
720 views::MenuRunner::CONTEXT_MENU)) | 701 views::MenuRunner::CONTEXT_MENU)) |
721 return; | 702 return; |
722 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 703 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
723 center_view->OnSettingsChanged(); | 704 center_view->OnSettingsChanged(); |
724 } | 705 } |
725 | 706 |
726 } // namespace message_center | 707 } // namespace message_center |
OLD | NEW |