| 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/painter.h" | 18 #include "ui/views/painter.h" |
| 19 | 19 |
| 20 namespace ash { | 20 namespace ash { |
| 21 | 21 |
| 22 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 22 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| 23 TrayPopupInkDropStyle ink_drop_style, | 23 TrayPopupInkDropStyle ink_drop_style, |
| 24 gfx::ImageSkia normal_icon, | 24 const gfx::ImageSkia& normal_icon, |
| 25 gfx::ImageSkia disabled_icon, | 25 const gfx::ImageSkia& disabled_icon, |
| 26 int accessible_name_id) | 26 int accessible_name_id) |
| 27 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { | 27 : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { |
| 28 DCHECK_EQ(normal_icon.width(), disabled_icon.width()); | 28 DCHECK_EQ(normal_icon.width(), disabled_icon.width()); |
| 29 DCHECK_EQ(normal_icon.height(), disabled_icon.height()); | 29 DCHECK_EQ(normal_icon.height(), disabled_icon.height()); |
| 30 | 30 |
| 31 SetImage(STATE_NORMAL, &normal_icon); | 31 SetImage(STATE_NORMAL, normal_icon); |
| 32 SetImage(STATE_DISABLED, &disabled_icon); | 32 SetImage(STATE_DISABLED, disabled_icon); |
| 33 | 33 |
| 34 SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE); | 34 SetImageAlignment(ALIGN_CENTER, ALIGN_MIDDLE); |
| 35 set_preferred_size(gfx::Size(kMenuButtonSize, kMenuButtonSize)); | 35 set_preferred_size(gfx::Size(kMenuButtonSize, kMenuButtonSize)); |
| 36 | 36 |
| 37 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); | 37 SetTooltipText(l10n_util::GetStringUTF16(accessible_name_id)); |
| 38 | 38 |
| 39 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); | 39 SetFocusPainter(TrayPopupUtils::CreateFocusPainter()); |
| 40 TrayPopupUtils::ConfigureTrayPopupButton(this); | 40 TrayPopupUtils::ConfigureTrayPopupButton(this); |
| 41 } | 41 } |
| 42 | 42 |
| 43 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 43 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| 44 TrayPopupInkDropStyle ink_drop_style, | 44 TrayPopupInkDropStyle ink_drop_style, |
| 45 const gfx::VectorIcon& icon, | 45 const gfx::VectorIcon& icon, |
| 46 int accessible_name_id) | 46 int accessible_name_id) |
| 47 : SystemMenuButton(listener, | 47 : SystemMenuButton(listener, |
| 48 ink_drop_style, | 48 ink_drop_style, |
| 49 gfx::CreateVectorIcon(icon, kMenuIconColor), | 49 gfx::ImageSkia(), |
| 50 gfx::CreateVectorIcon(icon, kMenuIconColorDisabled), | 50 gfx::ImageSkia(), |
| 51 accessible_name_id) {} | 51 accessible_name_id) { |
| 52 SetVectorIcon(icon); |
| 53 } |
| 54 |
| 55 void SystemMenuButton::SetVectorIcon(const gfx::VectorIcon& icon) { |
| 56 SetImage(views::Button::STATE_NORMAL, |
| 57 gfx::CreateVectorIcon(icon, kMenuIconColor)); |
| 58 SetImage(views::Button::STATE_DISABLED, |
| 59 gfx::CreateVectorIcon(icon, kMenuIconColorDisabled)); |
| 60 } |
| 52 | 61 |
| 53 SystemMenuButton::~SystemMenuButton() {} | 62 SystemMenuButton::~SystemMenuButton() {} |
| 54 | 63 |
| 55 void SystemMenuButton::SetInkDropColor(SkColor color) { | 64 void SystemMenuButton::SetInkDropColor(SkColor color) { |
| 56 ink_drop_color_ = color; | 65 ink_drop_color_ = color; |
| 57 } | 66 } |
| 58 | 67 |
| 59 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() { | 68 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() { |
| 60 return TrayPopupUtils::CreateInkDrop(ink_drop_style_, this); | 69 return TrayPopupUtils::CreateInkDrop(ink_drop_style_, this); |
| 61 } | 70 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 77 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this, | 86 : TrayPopupUtils::CreateInkDropHighlight(ink_drop_style_, this, |
| 78 ink_drop_color_.value()); | 87 ink_drop_color_.value()); |
| 79 } | 88 } |
| 80 | 89 |
| 81 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask() | 90 std::unique_ptr<views::InkDropMask> SystemMenuButton::CreateInkDropMask() |
| 82 const { | 91 const { |
| 83 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); | 92 return TrayPopupUtils::CreateInkDropMask(ink_drop_style_, this); |
| 84 } | 93 } |
| 85 | 94 |
| 86 } // namespace ash | 95 } // namespace ash |
| OLD | NEW |