| 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 18 matching lines...) Expand all Loading... |
| 42 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); | 43 kFocusBorderColor, gfx::Insets(1, 1, 1, 1))); |
| 43 | 44 |
| 44 SetInkDropMode(InkDropMode::ON); | 45 SetInkDropMode(InkDropMode::ON); |
| 45 set_has_ink_drop_action_on_click(true); | 46 set_has_ink_drop_action_on_click(true); |
| 46 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); | 47 set_ink_drop_base_color(kTrayPopupInkDropBaseColor); |
| 47 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); | 48 set_ink_drop_visible_opacity(kTrayPopupInkDropRippleOpacity); |
| 48 } | 49 } |
| 49 | 50 |
| 50 SystemMenuButton::~SystemMenuButton() {} | 51 SystemMenuButton::~SystemMenuButton() {} |
| 51 | 52 |
| 53 std::unique_ptr<views::InkDrop> SystemMenuButton::CreateInkDrop() { |
| 54 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 55 CreateDefaultFloodFillInkDropImpl(); |
| 56 ink_drop->SetShowHighlightOnHover(false); |
| 57 return std::move(ink_drop); |
| 58 } |
| 59 |
| 52 std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple() | 60 std::unique_ptr<views::InkDropRipple> SystemMenuButton::CreateInkDropRipple() |
| 53 const { | 61 const { |
| 54 const gfx::Size size = GetInkDropSize(); | 62 const gfx::Size size = GetInkDropSize(); |
| 55 switch (ink_drop_style_) { | 63 switch (ink_drop_style_) { |
| 56 case InkDropStyle::SQUARE: | 64 case InkDropStyle::SQUARE: |
| 57 return base::MakeUnique<views::SquareInkDropRipple>( | 65 return base::MakeUnique<views::SquareInkDropRipple>( |
| 58 size, size.width() / 2, size, size.width() / 2, | 66 size, size.width() / 2, size, size.width() / 2, |
| 59 GetInkDropCenterBasedOnLastEvent(), GetLocalBounds().CenterPoint(), | 67 GetInkDropCenterBasedOnLastEvent(), GetLocalBounds().CenterPoint(), |
| 60 GetInkDropBaseColor(), ink_drop_visible_opacity()); | 68 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 61 case InkDropStyle::FLOOD_FILL: | 69 case InkDropStyle::FLOOD_FILL: |
| 62 gfx::Rect bounds = GetLocalBounds(); | 70 gfx::Rect bounds = GetLocalBounds(); |
| 63 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); | 71 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| 64 return base::MakeUnique<views::FloodFillInkDropRipple>( | 72 return base::MakeUnique<views::FloodFillInkDropRipple>( |
| 65 bounds, GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), | 73 bounds, GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(), |
| 66 ink_drop_visible_opacity()); | 74 ink_drop_visible_opacity()); |
| 67 } | 75 } |
| 68 // Required for some compilers. | 76 // Required for some compilers. |
| 69 NOTREACHED(); | 77 NOTREACHED(); |
| 70 return nullptr; | 78 return nullptr; |
| 71 } | 79 } |
| 72 | 80 |
| 73 std::unique_ptr<views::InkDropHighlight> | 81 std::unique_ptr<views::InkDropHighlight> |
| 74 SystemMenuButton::CreateInkDropHighlight() const { | 82 SystemMenuButton::CreateInkDropHighlight() const { |
| 75 // TODO(bruthig): Show the highlight when the ink drop is active. (See | |
| 76 // crbug.com/649734) | |
| 77 if (!ShouldShowInkDropHighlight()) | |
| 78 return nullptr; | |
| 79 | |
| 80 int highlight_radius = 0; | 83 int highlight_radius = 0; |
| 81 switch (ink_drop_style_) { | 84 switch (ink_drop_style_) { |
| 82 case InkDropStyle::SQUARE: | 85 case InkDropStyle::SQUARE: |
| 83 highlight_radius = GetInkDropSize().width() / 2; | 86 highlight_radius = GetInkDropSize().width() / 2; |
| 84 break; | 87 break; |
| 85 case InkDropStyle::FLOOD_FILL: | 88 case InkDropStyle::FLOOD_FILL: |
| 86 highlight_radius = 0; | 89 highlight_radius = 0; |
| 87 break; | 90 break; |
| 88 } | 91 } |
| 89 | 92 |
| 90 std::unique_ptr<views::InkDropHighlight> highlight( | 93 std::unique_ptr<views::InkDropHighlight> highlight( |
| 91 new views::InkDropHighlight(GetInkDropSize(), highlight_radius, | 94 new views::InkDropHighlight(GetInkDropSize(), highlight_radius, |
| 92 gfx::RectF(GetLocalBounds()).CenterPoint(), | 95 gfx::RectF(GetLocalBounds()).CenterPoint(), |
| 93 GetInkDropBaseColor())); | 96 GetInkDropBaseColor())); |
| 94 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); | 97 highlight->set_visible_opacity(kTrayPopupInkDropHighlightOpacity); |
| 95 return highlight; | 98 return highlight; |
| 96 } | 99 } |
| 97 | 100 |
| 98 bool SystemMenuButton::ShouldShowInkDropHighlight() const { | |
| 99 return false; | |
| 100 } | |
| 101 | |
| 102 gfx::Size SystemMenuButton::GetInkDropSize() const { | 101 gfx::Size SystemMenuButton::GetInkDropSize() const { |
| 103 gfx::Rect bounds = GetLocalBounds(); | 102 gfx::Rect bounds = GetLocalBounds(); |
| 104 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); | 103 bounds.Inset(kTrayPopupInkDropInset, kTrayPopupInkDropInset); |
| 105 return bounds.size(); | 104 return bounds.size(); |
| 106 } | 105 } |
| 107 | 106 |
| 108 } // namespace ash | 107 } // namespace ash |
| OLD | NEW |