| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "grit/ui_resources.h" | 12 #include "grit/ui_resources.h" |
| 13 #include "grit/ui_strings.h" | 13 #include "grit/ui_strings.h" |
| 14 #include "skia/ext/image_operations.h" | 14 #include "skia/ext/image_operations.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/models/simple_menu_model.h" | 17 #include "ui/base/models/simple_menu_model.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/events/keycodes/keyboard_codes.h" | 19 #include "ui/events/keycodes/keyboard_codes.h" |
| 20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
| 21 #include "ui/gfx/image/image.h" | 21 #include "ui/gfx/image/image.h" |
| 22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 23 #include "ui/message_center/message_center_style.h" | 23 #include "ui/message_center/message_center_style.h" |
| 24 #include "ui/message_center/views/message_center_focus_border.h" | |
| 25 #include "ui/message_center/views/message_center_view.h" | 24 #include "ui/message_center/views/message_center_view.h" |
| 26 #include "ui/views/background.h" | 25 #include "ui/views/background.h" |
| 27 #include "ui/views/border.h" | 26 #include "ui/views/border.h" |
| 28 #include "ui/views/controls/button/checkbox.h" | 27 #include "ui/views/controls/button/checkbox.h" |
| 29 #include "ui/views/controls/button/custom_button.h" | 28 #include "ui/views/controls/button/custom_button.h" |
| 30 #include "ui/views/controls/button/label_button_border.h" | 29 #include "ui/views/controls/button/label_button_border.h" |
| 31 #include "ui/views/controls/button/menu_button.h" | 30 #include "ui/views/controls/button/menu_button.h" |
| 32 #include "ui/views/controls/image_view.h" | 31 #include "ui/views/controls/image_view.h" |
| 33 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
| 34 #include "ui/views/controls/link.h" | 33 #include "ui/views/controls/link.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // The blank space above the title needs to be adjusted by the amount of blank | 116 // The blank space above the title needs to be adjusted by the amount of blank |
| 118 // space included in the title label. | 117 // space included in the title label. |
| 119 const int kComputedTitleTopMargin = | 118 const int kComputedTitleTopMargin = |
| 120 settings::kTopMargin - kInnateTitleTopMargin; | 119 settings::kTopMargin - kInnateTitleTopMargin; |
| 121 | 120 |
| 122 // The switcher has a lot of blank space built in so we should include that when | 121 // The switcher has a lot of blank space built in so we should include that when |
| 123 // spacing the title area vertically. | 122 // spacing the title area vertically. |
| 124 const int kComputedTitleElementSpacing = | 123 const int kComputedTitleElementSpacing = |
| 125 settings::kDescriptionToSwitcherSpace - kButtonPainterInsets - 1; | 124 settings::kDescriptionToSwitcherSpace - kButtonPainterInsets - 1; |
| 126 | 125 |
| 126 // A function to create a focus border. |
| 127 views::FocusBorder* CreateFocusBorder() { |
| 128 return views::FocusBorder::CreateSolidFocusBorder(kFocusBorderColor, |
| 129 gfx::Insets(1, 2, 3, 2)); |
| 130 } |
| 127 | 131 |
| 128 // EntryView ------------------------------------------------------------------ | 132 // EntryView ------------------------------------------------------------------ |
| 129 | 133 |
| 130 // The view to guarantee the 48px height and place the contents at the | 134 // The view to guarantee the 48px height and place the contents at the |
| 131 // middle. It also guarantee the left margin. | 135 // middle. It also guarantee the left margin. |
| 132 class EntryView : public views::View { | 136 class EntryView : public views::View { |
| 133 public: | 137 public: |
| 134 EntryView(views::View* contents); | 138 EntryView(views::View* contents); |
| 135 virtual ~EntryView(); | 139 virtual ~EntryView(); |
| 136 | 140 |
| 137 // views::View: | 141 // views::View: |
| 138 virtual void Layout() OVERRIDE; | 142 virtual void Layout() OVERRIDE; |
| 139 virtual gfx::Size GetPreferredSize() OVERRIDE; | 143 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 140 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 144 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
| 141 virtual void OnFocus() OVERRIDE; | 145 virtual void OnFocus() OVERRIDE; |
| 142 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 146 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 143 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; | 147 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE; |
| 144 | 148 |
| 145 private: | 149 private: |
| 146 DISALLOW_COPY_AND_ASSIGN(EntryView); | 150 DISALLOW_COPY_AND_ASSIGN(EntryView); |
| 147 }; | 151 }; |
| 148 | 152 |
| 149 EntryView::EntryView(views::View* contents) { | 153 EntryView::EntryView(views::View* contents) { |
| 150 set_focus_border(new MessageCenterFocusBorder()); | 154 set_focus_border(CreateFocusBorder()); |
| 151 AddChildView(contents); | 155 AddChildView(contents); |
| 152 } | 156 } |
| 153 | 157 |
| 154 EntryView::~EntryView() {} | 158 EntryView::~EntryView() {} |
| 155 | 159 |
| 156 void EntryView::Layout() { | 160 void EntryView::Layout() { |
| 157 DCHECK_EQ(1, child_count()); | 161 DCHECK_EQ(1, child_count()); |
| 158 views::View* content = child_at(0); | 162 views::View* content = child_at(0); |
| 159 int content_width = width(); | 163 int content_width = width(); |
| 160 int content_height = content->GetHeightForWidth(content_width); | 164 int content_height = content->GetHeightForWidth(content_width); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 icon_view_->set_owned_by_client(); | 287 icon_view_->set_owned_by_client(); |
| 284 | 288 |
| 285 checkbox_->SetChecked(notifier_->enabled); | 289 checkbox_->SetChecked(notifier_->enabled); |
| 286 checkbox_->set_listener(this); | 290 checkbox_->set_listener(this); |
| 287 checkbox_->set_focusable(false); | 291 checkbox_->set_focusable(false); |
| 288 checkbox_->SetAccessibleName(notifier_->name); | 292 checkbox_->SetAccessibleName(notifier_->name); |
| 289 | 293 |
| 290 if (ShouldHaveLearnMoreButton()) { | 294 if (ShouldHaveLearnMoreButton()) { |
| 291 // Create a more-info button that will be right-aligned. | 295 // Create a more-info button that will be right-aligned. |
| 292 learn_more_ = new views::ImageButton(this); | 296 learn_more_ = new views::ImageButton(this); |
| 293 learn_more_->set_focus_border(new MessageCenterFocusBorder()); | 297 learn_more_->set_focus_border(CreateFocusBorder()); |
| 294 learn_more_->set_request_focus_on_press(false); | 298 learn_more_->set_request_focus_on_press(false); |
| 295 learn_more_->set_focusable(true); | 299 learn_more_->set_focusable(true); |
| 296 | 300 |
| 297 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 301 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 298 learn_more_->SetImage( | 302 learn_more_->SetImage( |
| 299 views::Button::STATE_NORMAL, | 303 views::Button::STATE_NORMAL, |
| 300 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS)); | 304 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS)); |
| 301 learn_more_->SetImage( | 305 learn_more_->SetImage( |
| 302 views::Button::STATE_HOVERED, | 306 views::Button::STATE_HOVERED, |
| 303 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS_HOVER)); | 307 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS_HOVER)); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 menu_anchor, | 702 menu_anchor, |
| 699 views::MenuItemView::BUBBLE_ABOVE, | 703 views::MenuItemView::BUBBLE_ABOVE, |
| 700 ui::MENU_SOURCE_MOUSE, | 704 ui::MENU_SOURCE_MOUSE, |
| 701 views::MenuRunner::CONTEXT_MENU)) | 705 views::MenuRunner::CONTEXT_MENU)) |
| 702 return; | 706 return; |
| 703 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 707 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
| 704 center_view->OnSettingsChanged(); | 708 center_view->OnSettingsChanged(); |
| 705 } | 709 } |
| 706 | 710 |
| 707 } // namespace message_center | 711 } // namespace message_center |
| OLD | NEW |