| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/controls/button/vector_icon_button.h" | 5 #include "ui/views/controls/button/vector_icon_button.h" |
| 6 | 6 |
| 7 #include "ui/gfx/color_palette.h" | 7 #include "ui/gfx/color_palette.h" |
| 8 #include "ui/gfx/color_utils.h" | 8 #include "ui/gfx/color_utils.h" |
| 9 #include "ui/gfx/paint_vector_icon.h" | 9 #include "ui/gfx/paint_vector_icon.h" |
| 10 #include "ui/gfx/vector_icons_public.h" | 10 #include "ui/gfx/vector_icons_public.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 void VectorIconButton::SetIcon(gfx::VectorIconId id) { | 37 void VectorIconButton::SetIcon(gfx::VectorIconId id) { |
| 38 id_ = id; | 38 id_ = id; |
| 39 | 39 |
| 40 if (!border()) { | 40 if (!border()) { |
| 41 SetBorder( | 41 SetBorder( |
| 42 views::CreateEmptyBorder(kButtonExtraTouchSize, kButtonExtraTouchSize, | 42 views::CreateEmptyBorder(kButtonExtraTouchSize, kButtonExtraTouchSize, |
| 43 kButtonExtraTouchSize, kButtonExtraTouchSize)); | 43 kButtonExtraTouchSize, kButtonExtraTouchSize)); |
| 44 } | 44 } |
| 45 } | 45 } |
| 46 | 46 |
| 47 void VectorIconButton::SetIcon(const gfx::VectorIcon& icon) { |
| 48 icon_ = &icon; |
| 49 SetIcon(gfx::VectorIconId::VECTOR_ICON_NONE); |
| 50 } |
| 51 |
| 47 void VectorIconButton::OnThemeChanged() { | 52 void VectorIconButton::OnThemeChanged() { |
| 48 SkColor icon_color = | 53 SkColor icon_color = |
| 49 color_utils::DeriveDefaultIconColor(delegate_->GetVectorIconBaseColor()); | 54 color_utils::DeriveDefaultIconColor(delegate_->GetVectorIconBaseColor()); |
| 50 gfx::ImageSkia image = gfx::CreateVectorIcon(id_, icon_color); | 55 gfx::ImageSkia image; |
| 56 if (icon_) |
| 57 image = gfx::CreateVectorIcon(*icon_, icon_color); |
| 58 else |
| 59 image = gfx::CreateVectorIcon(id_, icon_color); |
| 51 SetImage(views::CustomButton::STATE_NORMAL, &image); | 60 SetImage(views::CustomButton::STATE_NORMAL, &image); |
| 52 image = gfx::CreateVectorIcon(id_, SkColorSetA(icon_color, 0xff / 2)); | 61 image = gfx::CreateVectorIcon(id_, SkColorSetA(icon_color, 0xff / 2)); |
| 53 SetImage(views::CustomButton::STATE_DISABLED, &image); | 62 SetImage(views::CustomButton::STATE_DISABLED, &image); |
| 54 set_ink_drop_base_color(icon_color); | 63 set_ink_drop_base_color(icon_color); |
| 55 } | 64 } |
| 56 | 65 |
| 57 void VectorIconButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { | 66 void VectorIconButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { |
| 58 OnThemeChanged(); | 67 OnThemeChanged(); |
| 59 } | 68 } |
| 60 | 69 |
| 61 } // namespace views | 70 } // namespace views |
| OLD | NEW |