| 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/common/system/tray/system_menu_button.h" | 5 #include "ash/common/system/tray/system_menu_button.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_constants.h" | 7 #include "ash/common/ash_constants.h" |
| 8 #include "ash/common/system/tray/system_tray.h" | 8 #include "ash/common/system/tray/system_tray.h" |
| 9 #include "ash/common/system/tray/tray_constants.h" | 9 #include "ash/common/system/tray/tray_constants.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| 11 #include "ui/gfx/paint_vector_icon.h" | 11 #include "ui/gfx/paint_vector_icon.h" |
| 12 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 12 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 13 #include "ui/views/animation/ink_drop_highlight.h" | 13 #include "ui/views/animation/ink_drop_highlight.h" |
| 14 #include "ui/views/animation/ink_drop_impl.h" |
| 14 #include "ui/views/animation/square_ink_drop_ripple.h" | 15 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 15 #include "ui/views/border.h" | 16 #include "ui/views/border.h" |
| 16 #include "ui/views/painter.h" | 17 #include "ui/views/painter.h" |
| 17 | 18 |
| 18 namespace ash { | 19 namespace ash { |
| 19 | 20 |
| 20 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, | 21 SystemMenuButton::SystemMenuButton(views::ButtonListener* listener, |
| 21 InkDropStyle ink_drop_style, | 22 InkDropStyle ink_drop_style, |
| 22 const gfx::VectorIcon& icon, | 23 const gfx::VectorIcon& icon, |
| 23 int accessible_name_id) | 24 int accessible_name_id) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 43 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); | 44 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| 44 | 45 |
| 45 SetInkDropMode(InkDropMode::ON); | 46 SetInkDropMode(InkDropMode::ON); |
| 46 set_has_ink_drop_action_on_click(true); | 47 set_has_ink_drop_action_on_click(true); |
| 47 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); | 48 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); |
| 48 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); | 49 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); |
| 49 } | 50 } |
| 50 | 51 |
| 51 SystemMenuButton::~SystemMenuButton() {} | 52 SystemMenuButton::~SystemMenuButton() {} |
| 52 | 53 |
| 54 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() { |
| 55 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 56 CreateDefaultFloodFillInkDropImpl(); |
| 57 ink_drop->SetShowHighlightOnHover(false); |
| 58 return std::move(ink_drop); |
| 59 } |
| 60 |
| 53 std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple() | 61 std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple() |
| 54 const { | 62 const { |
| 55 const gfx::Size size = GetInkDropSize(); | 63 const gfx::Size size = GetInkDropSize(); |
| 56 switch (ink_drop_style_) { | 64 switch (ink_drop_style_) { |
| 57 case InkDropStyle::SQUARE: | 65 case InkDropStyle::SQUARE: |
| 58 return base::MakeUnique<views::SquareInkDropRipple>( | 66 return base::MakeUnique<views::SquareInkDropRipple>( |
| 59 size, size.width() / 2, size, size.width() / 2, | 67 size, size.width() / 2, size, size.width() / 2, |
| 60 GetInkDropCenterBasedOnLastEvent(), GetLocalBounds().CenterPoint(), | 68 GetInkDropCenterBasedOnLastEvent(), GetLocalBounds().CenterPoint(), |
| 61 GetInkDropBaseColor(), ink_drop_visible_opacity()); | 69 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 62 case InkDropStyle::FLOOD_FILL: | 70 case InkDropStyle::FLOOD_FILL: |
| 63 gfx::Rect bounds = GetLocalBounds(); | 71 gfx::Rect bounds = GetLocalBounds(); |
| 64 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); | 72 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| 65 return base::MakeUnique<views::FloodFillInkDropRipple>( | 73 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 66 bounds, GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), | 74 bounds, GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), |
| 67 ink_drop_visible_opacity()); | 75 ink_drop_visible_opacity()); |
| 68 } | 76 } |
| 69 // Required for some compilers. | 77 // Required for some compilers. |
| 70 NOTREACHED(); | 78 NOTREACHED(); |
| 71 return nullptr; | 79 return nullptr; |
| 72 } | 80 } |
| 73 | 81 |
| 74 std::unique_ptr<views::InkDropHighlight> | 82 std::unique_ptr<views::InkDropHighlight> |
| 75 SystemMenuButton::CreateInkDropHighlight() const { | 83 SystemMenuButton::CreateInkDropHighlight() const { |
| 76 // TODO(bruthig): Show the highlight when the ink drop is active. (See | |
| 77 // crbug.com/649734) | |
| 78 if (!ShouldShowInkDropHighlight()) | |
| 79 return nullptr; | |
| 80 | |
| 81 int highlight_radius = 0; | 84 int highlight_radius = 0; |
| 82 switch (ink_drop_style_) { | 85 switch (ink_drop_style_) { |
| 83 case InkDropStyle::SQUARE: | 86 case InkDropStyle::SQUARE: |
| 84 highlight_radius = GetInkDropSize().width() / 2; | 87 highlight_radius = GetInkDropSize().width() / 2; |
| 85 break; | 88 break; |
| 86 case InkDropStyle::FLOOD_FILL: | 89 case InkDropStyle::FLOOD_FILL: |
| 87 highlight_radius = 0; | 90 highlight_radius = 0; |
| 88 break; | 91 break; |
| 89 } | 92 } |
| 90 | 93 |
| 91 std::unique_ptr<views::InkDropHighlight> highlight( | 94 std::unique_ptr<views::InkDropHighlight> highlight( |
| 92 new views::InkDropHighlight(GetInkDropSize(), highlight_radius, | 95 new views::InkDropHighlight(GetInkDropSize(), highlight_radius, |
| 93 gfx::RectF(GetLocalBounds()).CenterPoint(), | 96 gfx::RectF(GetLocalBounds()).CenterPoint(), |
| 94 GetInkDropBaseColor())); | 97 GetInkDropBaseColor())); |
| 95 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 98 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 96 return highlight; | 99 return highlight; |
| 97 } | 100 } |
| 98 | 101 |
| 99 bool SystemMenuButton::ShouldShowInkDropHighlight() const { | |
| 100 return false; | |
| 101 } | |
| 102 | |
| 103 gfx::Size SystemMenuButton::GetInkDropSize() const { | 102 gfx::Size SystemMenuButton::GetInkDropSize() const { |
| 104 gfx::Rect bounds = GetLocalBounds(); | 103 gfx::Rect bounds = GetLocalBounds(); |
| 105 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); | 104 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| 106 return bounds.size(); | 105 return bounds.size(); |
| 107 } | 106 } |
| 108 | 107 |
| 109 } // namespace ash | 108 } // namespace ash |
| OLD | NEW |