Chromium Code Reviews| Index: ui/views/controls/button/image_button.cc |
| diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc |
| index fd2151e2a1aab73c6ad529ec5a909ffd9ea309ab..9f601378a81842721d9755f371d226d36149c463 100644 |
| --- a/ui/views/controls/button/image_button.cc |
| +++ b/ui/views/controls/button/image_button.cc |
| @@ -11,7 +11,10 @@ |
| #include "ui/gfx/animation/throb_animation.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/image/image_skia_operations.h" |
| +#include "ui/gfx/paint_vector_icon.h" |
| #include "ui/gfx/scoped_canvas.h" |
| +#include "ui/gfx/vector_icon_types.h" |
| +#include "ui/views/border.h" |
| #include "ui/views/painter.h" |
| #include "ui/views/widget/widget.h" |
| @@ -293,4 +296,27 @@ void ToggleImageButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| } |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ImageButton, utilities: |
| + |
| +void SetImageFromVectorIcon(ImageButton* button, |
| + const gfx::VectorIcon& icon, |
| + SkColor base_color) { |
| + button->SetInkDropMode(CustomButton::InkDropMode::ON); |
|
bruthig
2017/03/16 18:26:07
I'm not sure I would couple the ink drop behavior
Evan Stade
2017/03/16 18:49:13
for now, all call sites want it. To me that sugges
bruthig
2017/03/16 19:11:23
I'm not sure I would agree that all call sites wan
|
| + button->set_has_ink_drop_action_on_click(true); |
| + button->SetImageAlignment(ImageButton::ALIGN_CENTER, |
| + ImageButton::ALIGN_MIDDLE); |
| + button->SetFocusPainter(nullptr); |
| + if (!button->border()) |
| + button->SetBorder(CreateEmptyBorder(gfx::Insets(4))); |
| + |
| + const SkColor icon_color = color_utils::DeriveDefaultIconColor(base_color); |
| + const SkColor disabled_color = SkColorSetA(icon_color, 0xff / 2); |
| + button->SetImage(CustomButton::STATE_NORMAL, |
| + gfx::CreateVectorIcon(icon, icon_color)); |
| + button->SetImage(CustomButton::STATE_DISABLED, |
| + gfx::CreateVectorIcon(icon, disabled_color)); |
| + button->set_ink_drop_base_color(icon_color); |
| +} |
| + |
| } // namespace views |