| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_button_bar.h" | 5 #include "ui/message_center/views/message_center_button_bar.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "ui/base/models/simple_menu_model.h" | 9 #include "ui/base/models/simple_menu_model.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/text_constants.h" | 12 #include "ui/gfx/text_constants.h" |
| 13 #include "ui/message_center/message_center.h" | 13 #include "ui/message_center/message_center.h" |
| 14 #include "ui/message_center/message_center_style.h" | 14 #include "ui/message_center/message_center_style.h" |
| 15 #include "ui/message_center/message_center_tray.h" | 15 #include "ui/message_center/message_center_tray.h" |
| 16 #include "ui/message_center/notifier_settings.h" | 16 #include "ui/message_center/notifier_settings.h" |
| 17 #include "ui/message_center/views/message_center_view.h" | 17 #include "ui/message_center/views/message_center_view.h" |
| 18 #include "ui/resources/grit/ui_resources.h" | 18 #include "ui/resources/grit/ui_resources.h" |
| 19 #include "ui/strings/grit/ui_strings.h" | 19 #include "ui/strings/grit/ui_strings.h" |
| 20 #include "ui/views/border.h" |
| 20 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
| 21 #include "ui/views/controls/button/image_button.h" | 22 #include "ui/views/controls/button/image_button.h" |
| 22 #include "ui/views/controls/button/label_button.h" | 23 #include "ui/views/controls/button/label_button.h" |
| 23 #include "ui/views/controls/button/menu_button.h" | 24 #include "ui/views/controls/button/menu_button.h" |
| 24 #include "ui/views/controls/button/menu_button_listener.h" | 25 #include "ui/views/controls/button/menu_button_listener.h" |
| 25 #include "ui/views/controls/label.h" | 26 #include "ui/views/controls/label.h" |
| 26 #include "ui/views/controls/menu/menu_runner.h" | 27 #include "ui/views/controls/menu/menu_runner.h" |
| 27 #include "ui/views/layout/box_layout.h" | 28 #include "ui/views/layout/box_layout.h" |
| 28 #include "ui/views/layout/grid_layout.h" | 29 #include "ui/views/layout/grid_layout.h" |
| 29 #include "ui/views/painter.h" | 30 #include "ui/views/painter.h" |
| 30 | 31 |
| 31 namespace message_center { | 32 namespace message_center { |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| 34 const int kButtonSize = 40; | 35 constexpr int kButtonSize = 40; |
| 35 const int kLeftPaddingWidthForNonArrows = 16; | |
| 36 const int kFooterTopMargin = 6; | |
| 37 const int kFooterBottomMargin = 3; | |
| 38 const int kFooterLeftMargin = 4; | |
| 39 const int kFooterRightMargin = 14; | |
| 40 } // namespace | 36 } // namespace |
| 41 | 37 |
| 42 // NotificationCenterButton //////////////////////////////////////////////////// | 38 // NotificationCenterButton //////////////////////////////////////////////////// |
| 43 //////////////////////////////////////////////////////////////////////////////// | 39 //////////////////////////////////////////////////////////////////////////////// |
| 44 class NotificationCenterButton : public views::ToggleImageButton { | 40 class NotificationCenterButton : public views::ToggleImageButton { |
| 45 public: | 41 public: |
| 46 NotificationCenterButton(views::ButtonListener* listener, | 42 NotificationCenterButton(views::ButtonListener* listener, |
| 47 int normal_id, | 43 int normal_id, |
| 48 int hover_id, | 44 int hover_id, |
| 49 int pressed_id, | 45 int pressed_id, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 SetCloseAllButtonEnabled(!settings_initially_visible); | 183 SetCloseAllButtonEnabled(!settings_initially_visible); |
| 188 SetBackArrowVisible(settings_initially_visible); | 184 SetBackArrowVisible(settings_initially_visible); |
| 189 ViewVisibilityChanged(); | 185 ViewVisibilityChanged(); |
| 190 } | 186 } |
| 191 | 187 |
| 192 void MessageCenterButtonBar::ViewVisibilityChanged() { | 188 void MessageCenterButtonBar::ViewVisibilityChanged() { |
| 193 gfx::ImageSkia* settings_image = | 189 gfx::ImageSkia* settings_image = |
| 194 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 190 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 195 IDR_NOTIFICATION_SETTINGS); | 191 IDR_NOTIFICATION_SETTINGS); |
| 196 int image_margin = std::max(0, (kButtonSize - settings_image->width()) / 2); | 192 int image_margin = std::max(0, (kButtonSize - settings_image->width()) / 2); |
| 193 constexpr int kFooterTopMargin = 6; |
| 194 constexpr int kFooterLeftMargin = 4; |
| 195 constexpr int kFooterBottomMargin = 3; |
| 196 constexpr int kFooterRightMargin = 14; |
| 197 SetBorder(views::CreateEmptyBorder( |
| 198 kFooterTopMargin, kFooterLeftMargin, kFooterBottomMargin, |
| 199 std::max(0, kFooterRightMargin - image_margin))); |
| 197 views::GridLayout* layout = new views::GridLayout(this); | 200 views::GridLayout* layout = new views::GridLayout(this); |
| 198 SetLayoutManager(layout); | 201 SetLayoutManager(layout); |
| 199 layout->SetInsets(kFooterTopMargin, | |
| 200 kFooterLeftMargin, | |
| 201 kFooterBottomMargin, | |
| 202 std::max(0, kFooterRightMargin - image_margin)); | |
| 203 views::ColumnSet* column = layout->AddColumnSet(0); | 202 views::ColumnSet* column = layout->AddColumnSet(0); |
| 204 if (title_arrow_->visible()) { | 203 if (title_arrow_->visible()) { |
| 205 // Column for the left-arrow used to back out of settings. | 204 // Column for the left-arrow used to back out of settings. |
| 206 column->AddColumn(views::GridLayout::LEADING, | 205 column->AddColumn(views::GridLayout::LEADING, |
| 207 views::GridLayout::CENTER, | 206 views::GridLayout::CENTER, |
| 208 0.0f, | 207 0.0f, |
| 209 views::GridLayout::FIXED, | 208 views::GridLayout::FIXED, |
| 210 kButtonSize, | 209 kButtonSize, |
| 211 0); | 210 0); |
| 212 } else { | 211 } else { |
| 212 constexpr int kLeftPaddingWidthForNonArrows = 16; |
| 213 column->AddPaddingColumn(0.0f, kLeftPaddingWidthForNonArrows); | 213 column->AddPaddingColumn(0.0f, kLeftPaddingWidthForNonArrows); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Column for the label "Notifications". | 216 // Column for the label "Notifications". |
| 217 column->AddColumn(views::GridLayout::LEADING, | 217 column->AddColumn(views::GridLayout::LEADING, |
| 218 views::GridLayout::CENTER, | 218 views::GridLayout::CENTER, |
| 219 0.0f, | 219 0.0f, |
| 220 views::GridLayout::USE_PREF, | 220 views::GridLayout::USE_PREF, |
| 221 0, | 221 0, |
| 222 0); | 222 0); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 319 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 320 } else if (sender == close_bubble_button_) { | 320 } else if (sender == close_bubble_button_) { |
| 321 message_center_view()->tray()->HideMessageCenterBubble(); | 321 message_center_view()->tray()->HideMessageCenterBubble(); |
| 322 #endif | 322 #endif |
| 323 } else { | 323 } else { |
| 324 NOTREACHED(); | 324 NOTREACHED(); |
| 325 } | 325 } |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace message_center | 328 } // namespace message_center |
| OLD | NEW |