| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/system/tray/system_menu_button.h" | 5 #include "ash/system/tray/system_menu_button.h" |
| 6 | 6 |
| 7 #include "ash/ash_constants.h" | 7 #include "ash/ash_constants.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/system/tray/tray_constants.h" | 9 #include "ash/system/tray/tray_constants.h" |
| 10 #include "ash/system/tray/tray_popup_utils.h" | 10 #include "ash/system/tray/tray_popup_utils.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/gfx/paint_vector_icon.h" | 12 #include "ui/gfx/paint_vector_icon.h" |
| 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 14 #include "ui/views/animation/ink_drop_highlight.h" | 14 #include "ui/views/animation/ink_drop_highlight.h" |
| 15 #include "ui/views/animation/ink_drop_impl.h" | 15 #include "ui/views/animation/ink_drop_impl.h" |
| 16 #include "ui/views/animation/ink_drop_mask.h" | 16 #include "ui/views/animation/ink_drop_mask.h" |
| 17 #include "ui/views/animation/square_ink_drop_ripple.h" | 17 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 18 #include "ui/views/border.h" | 18 #include "ui/views/border.h" |
| 19 #include "ui/views/painter.h" | 19 #include "ui/views/painter.h" |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 23 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| 24 TrayPopupInkDropStyle ink_drop_style, | 24 TrayPopupInkDropStyle ink_drop_style, |
| 25 gfx::ImageSkia normal_icon, | 25 const gfx::ImageSkia& normal_icon, |
| 26 gfx::ImageSkia disabled_icon, | 26 const gfx::ImageSkia& disabled_icon, |
| 27 int accessible_name_id) | 27 int accessible_name_id) |
| 28 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { | 28 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { |
| 29 DCHECK_EQ(normal_icon.width(), disabled_icon.width()); | 29 DCHECK_EQ(normal_icon.width(), disabled_icon.width()); |
| 30 DCHECK_EQ(normal_icon.height(), disabled_icon.height()); | 30 DCHECK_EQ(normal_icon.height(), disabled_icon.height()); |
| 31 | 31 |
| 32 SetImage(views::Button::STATE_NORMAL, &normal_icon); | 32 SetImage(views::Button::STATE_NORMAL, normal_icon); |
| 33 SetImage(views::Button::STATE_DISABLED, &disabled_icon); | 33 SetImage(views::Button::STATE_DISABLED, disabled_icon); |
| 34 | 34 |
| 35 const int horizontal_padding = (kMenuButtonSize - normal_icon.width()) / 2; | 35 const int horizontal_padding = (kMenuButtonSize - normal_icon.width()) / 2; |
| 36 const int vertical_padding = (kMenuButtonSize - normal_icon.height()) / 2; | 36 const int vertical_padding = (kMenuButtonSize - normal_icon.height()) / 2; |
| 37 SetBorder(views::CreateEmptyBorder(vertical_padding, horizontal_padding, | 37 SetBorder(views::CreateEmptyBorder(vertical_padding, horizontal_padding, |
| 38 vertical_padding, horizontal_padding)); | 38 vertical_padding, horizontal_padding)); |
| 39 | 39 |
| 40 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); | 40 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); |
| 41 | 41 |
| 42 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); | 42 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); |
| 43 TrayPopupUtils::ConfigureTrayPopupButton(this); | 43 TrayPopupUtils::ConfigureTrayPopupButton(this); |
| 44 } | 44 } |
| 45 | 45 |
| 46 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 46 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| 47 TrayPopupInkDropStyle ink_drop_style, | 47 TrayPopupInkDropStyle ink_drop_style, |
| 48 const gfx::VectorIcon& icon, | 48 const gfx::VectorIcon& icon, |
| 49 int accessible_name_id) | 49 int accessible_name_id) |
| 50 : SystemMenuButton(listener, | 50 : SystemMenuButton(listener, |
| 51 ink_drop_style, | 51 ink_drop_style, |
| 52 gfx::CreateVectorIcon(icon, kMenuIconColor), | 52 gfx::ImageSkia(), |
| 53 gfx::CreateVectorIcon(icon, kMenuIconColorDisabled), | 53 gfx::ImageSkia(), |
| 54 accessible_name_id) {} | 54 accessible_name_id) { |
| 55 SetVectorIcon(icon); |
| 56 } |
| 57 |
| 58 void SystemMenuButton::SetVectorIcon(const gfx::VectorIcon& icon) { |
| 59 SetImage(views::Button::STATE_NORMAL, |
| 60 gfx::CreateVectorIcon(icon, kMenuIconColor)); |
| 61 SetImage(views::Button::STATE_DISABLED, |
| 62 gfx::CreateVectorIcon(icon, kMenuIconColorDisabled)); |
| 63 } |
| 55 | 64 |
| 56 SystemMenuButton::~SystemMenuButton() {} | 65 SystemMenuButton::~SystemMenuButton() {} |
| 57 | 66 |
| 58 void SystemMenuButton::SetInkDropColor(SkColor color) { | 67 void SystemMenuButton::SetInkDropColor(SkColor color) { |
| 59 ink_drop_color_ = color; | 68 ink_drop_color_ = color; |
| 60 } | 69 } |
| 61 | 70 |
| 62 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() { | 71 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() { |
| 63 return TrayPopupUtils::CreateInkDrop(ink_drop_style_, this); | 72 return TrayPopupUtils::CreateInkDrop(ink_drop_style_, this); |
| 64 } | 73 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 80 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this, | 89 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this, |
| 81 ink_drop_color_.value()); | 90 ink_drop_color_.value()); |
| 82 } | 91 } |
| 83 | 92 |
| 84 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask() | 93 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask() |
| 85 const { | 94 const { |
| 86 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); | 95 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); |
| 87 } | 96 } |
| 88 | 97 |
| 89 } // namespace ash | 98 } // namespace ash |
| OLD | NEW |