Chromium Code Reviews| Index: ash/common/system/tray/system_menu_button.cc |
| diff --git a/ash/common/system/tray/system_menu_button.cc b/ash/common/system/tray/system_menu_button.cc |
| index 091441920a39416251d0b0b576246d3372959d50..5931b24ecf99bf9a96afd8bb4b431b79d91e120a 100644 |
| --- a/ash/common/system/tray/system_menu_button.cc |
| +++ b/ash/common/system/tray/system_menu_button.cc |
| @@ -11,15 +11,17 @@ |
| #include "ui/gfx/paint_vector_icon.h" |
| #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| #include "ui/views/animation/ink_drop_highlight.h" |
| +#include "ui/views/animation/square_ink_drop_ripple.h" |
| #include "ui/views/border.h" |
| #include "ui/views/painter.h" |
| namespace ash { |
| SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| + InkDropStyle ink_drop_style, |
| const gfx::VectorIcon& icon, |
| int accessible_name_id) |
| - : views::ImageButton(listener) { |
| + : views::ImageButton(listener), ink_drop_style_(ink_drop_style) { |
| gfx::ImageSkia image = gfx::CreateVectorIcon(icon, kMenuIconColor); |
| SetImage(views::Button::STATE_NORMAL, &image); |
| gfx::ImageSkia disabled_image = |
| @@ -40,27 +42,68 @@ SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| SetFocusPainter(views::Painter::CreateSolidFocusPainter( |
| kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| - SetInkDropMode(InkDropMode::ON_NO_GESTURE_HANDLER); |
| + SetInkDropMode(InkDropMode::ON); |
| set_has_ink_drop_action_on_click(true); |
| - set_ink_drop_base_color(SK_ColorBLACK); |
| + set_ink_drop_base_color(kTrayPopupInkDropBaseColor); |
| + set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); |
| } |
| SystemMenuButton::~SystemMenuButton() {} |
| std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple() |
| const { |
| - return base::MakeUnique<views::FloodFillInkDropRipple>( |
| - GetLocalBounds(), GetInkDropCenterBasedOnLastEvent(), |
| - GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| + const gfx::Size size = GetInkDropSize(); |
| + switch (ink_drop_style_) { |
| + case InkDropStyle::SQUARE: |
| + return base::MakeUnique<views::SquareInkDropRipple>( |
| + size, size.width() / 2, size, size.width() / 2, |
| + GetInkDropCenterBasedOnLastEvent(), GetLocalBounds().CenterPoint(), |
| + GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| + case InkDropStyle::FLOOD_FILL: |
| + gfx::Rect bounds = GetLocalBounds(); |
| + bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| + return base::MakeUnique<views::FloodFillInkDropRipple>( |
| + bounds, GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), |
| + ink_drop_visible_opacity()); |
| + } |
| + // Required for some compilers. |
| + NOTREACHED(); |
| + return nullptr; |
| } |
| std::unique_ptr<views::InkDropHighlight> |
| SystemMenuButton::CreateInkDropHighlight() const { |
| - return nullptr; |
| + // TODO(bruthig): Show the highlight when the ink drop is active. (See |
| + // crbug.com/649734) |
| + if (!ShouldShowInkDropHighlight()) |
| + return nullptr; |
| + |
| + int highlight_radius = 0; |
| + switch (ink_drop_style_) { |
|
tdanderson
2016/10/27 21:21:40
optional: Consider replacing 81-89 with just:
int
bruthig
2016/10/27 21:34:30
You're right ;) I prefer switch cases when enumera
|
| + case InkDropStyle::SQUARE: |
| + highlight_radius = GetInkDropSize().width() / 2; |
| + break; |
| + case InkDropStyle::FLOOD_FILL: |
| + highlight_radius = 0; |
| + break; |
| + } |
| + |
| + std::unique_ptr<views::InkDropHighlight> highlight( |
| + new views::InkDropHighlight(GetInkDropSize(), highlight_radius, |
| + gfx::RectF(GetLocalBounds()).CenterPoint(), |
| + GetInkDropBaseColor())); |
| + highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| + return highlight; |
| } |
| -bool SystemMenuButton::ShouldShowInkDropForFocus() const { |
| +bool SystemMenuButton::ShouldShowInkDropHighlight() const { |
| return false; |
| } |
| +gfx::Size SystemMenuButton::GetInkDropSize() const { |
| + gfx::Rect bounds = GetLocalBounds(); |
| + bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| + return bounds.size(); |
| +} |
| + |
| } // namespace ash |