Commit 7a9b1b43 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Improve gfx::IconDescription ergonomics.

This change makes it easier to construct IconDescription by adding
default values to three out of four constructor params.

No functional change is intended, although on SK_ColorBLACK is changed
to gfx::kPlaceholderColor. This should not matter because all the icons
it applies to have hard-coded colors for every individual path (verified
manually).

Bug: none
Change-Id: Ieed356656b2e1f346cbecd76a4d230a445873e43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985124
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728221}
parent ffff10c5
...@@ -90,9 +90,8 @@ bool RelaunchRecommendedBubbleView::ShouldShowCloseButton() const { ...@@ -90,9 +90,8 @@ bool RelaunchRecommendedBubbleView::ShouldShowCloseButton() const {
} }
gfx::ImageSkia RelaunchRecommendedBubbleView::GetWindowIcon() { gfx::ImageSkia RelaunchRecommendedBubbleView::GetWindowIcon() {
return gfx::CreateVectorIcon( return gfx::CreateVectorIcon(gfx::IconDescription(
gfx::IconDescription(vector_icons::kBusinessIcon, kTitleIconSize, vector_icons::kBusinessIcon, kTitleIconSize, gfx::kChromeIconGrey));
gfx::kChromeIconGrey, gfx::kNoneIcon));
} }
bool RelaunchRecommendedBubbleView::ShouldShowWindowIcon() const { bool RelaunchRecommendedBubbleView::ShouldShowWindowIcon() const {
......
...@@ -87,9 +87,8 @@ bool RelaunchRequiredDialogView::ShouldShowCloseButton() const { ...@@ -87,9 +87,8 @@ bool RelaunchRequiredDialogView::ShouldShowCloseButton() const {
} }
gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() { gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() {
return gfx::CreateVectorIcon( return gfx::CreateVectorIcon(gfx::IconDescription(
gfx::IconDescription(vector_icons::kBusinessIcon, kTitleIconSize, vector_icons::kBusinessIcon, kTitleIconSize, gfx::kChromeIconGrey));
gfx::kChromeIconGrey, gfx::kNoneIcon));
} }
bool RelaunchRequiredDialogView::ShouldShowWindowIcon() const { bool RelaunchRequiredDialogView::ShouldShowWindowIcon() const {
......
...@@ -149,9 +149,8 @@ void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged( ...@@ -149,9 +149,8 @@ void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged(
// Create business icon. // Create business icon.
int business_icon_size = 20; int business_icon_size = 20;
auto business_icon = std::make_unique<views::ImageView>(); auto business_icon = std::make_unique<views::ImageView>();
business_icon->SetImage(gfx::CreateVectorIcon( business_icon->SetImage(gfx::CreateVectorIcon(gfx::IconDescription(
gfx::IconDescription(vector_icons::kBusinessIcon, business_icon_size, vector_icons::kBusinessIcon, business_icon_size, gfx::kChromeIconGrey)));
gfx::kChromeIconGrey, gfx::kNoneIcon)));
// Create the prompt label. // Create the prompt label.
size_t offset; size_t offset;
......
...@@ -203,10 +203,8 @@ void AuthenticatorRequestSheetView::UpdateIconImageFromModel() { ...@@ -203,10 +203,8 @@ void AuthenticatorRequestSheetView::UpdateIconImageFromModel() {
if (!step_illustration_) if (!step_illustration_)
return; return;
gfx::IconDescription icon_description( gfx::IconDescription icon_description(model()->GetStepIllustration(
model()->GetStepIllustration(GetNativeTheme()->ShouldUseDarkColors() GetNativeTheme()->ShouldUseDarkColors() ? ImageColorScheme::kDark
? ImageColorScheme::kDark : ImageColorScheme::kLight));
: ImageColorScheme::kLight),
0 /* automatic dip_size */, SK_ColorBLACK, gfx::kNoneIcon);
step_illustration_->SetImage(gfx::CreateVectorIcon(icon_description)); step_illustration_->SetImage(gfx::CreateVectorIcon(icon_description));
} }
...@@ -431,7 +431,7 @@ class VectorIconSource : public CanvasImageSource { ...@@ -431,7 +431,7 @@ class VectorIconSource : public CanvasImageSource {
VectorIconSource(const std::string& definition, int dip_size, SkColor color) VectorIconSource(const std::string& definition, int dip_size, SkColor color)
: CanvasImageSource(Size(dip_size, dip_size)), : CanvasImageSource(Size(dip_size, dip_size)),
data_(kNoneIcon, dip_size, color, kNoneIcon), data_(kNoneIcon, dip_size, color, &kNoneIcon),
path_(PathFromSource(definition)) {} path_(PathFromSource(definition)) {}
~VectorIconSource() override {} ~VectorIconSource() override {}
...@@ -493,11 +493,11 @@ IconDescription::IconDescription(const IconDescription& other) = default; ...@@ -493,11 +493,11 @@ IconDescription::IconDescription(const IconDescription& other) = default;
IconDescription::IconDescription(const VectorIcon& icon, IconDescription::IconDescription(const VectorIcon& icon,
int dip_size, int dip_size,
SkColor color, SkColor color,
const VectorIcon& badge_icon) const VectorIcon* badge_icon)
: icon(icon), : icon(icon),
dip_size(dip_size), dip_size(dip_size),
color(color), color(color),
badge_icon(badge_icon) { badge_icon(badge_icon ? *badge_icon : kNoneIcon) {
if (dip_size == 0) if (dip_size == 0)
this->dip_size = GetDefaultSizeOfVectorIcon(icon); this->dip_size = GetDefaultSizeOfVectorIcon(icon);
} }
...@@ -536,14 +536,14 @@ ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color) { ...@@ -536,14 +536,14 @@ ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color) {
ImageSkia CreateVectorIcon(const VectorIcon& icon, ImageSkia CreateVectorIcon(const VectorIcon& icon,
int dip_size, int dip_size,
SkColor color) { SkColor color) {
return CreateVectorIcon(IconDescription(icon, dip_size, color, kNoneIcon)); return CreateVectorIcon(IconDescription(icon, dip_size, color, &kNoneIcon));
} }
ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon, ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon,
int dip_size, int dip_size,
SkColor color, SkColor color,
const VectorIcon& badge_icon) { const VectorIcon& badge_icon) {
return CreateVectorIcon(IconDescription(icon, dip_size, color, badge_icon)); return CreateVectorIcon(IconDescription(icon, dip_size, color, &badge_icon));
} }
ImageSkia CreateVectorIconFromSource(const std::string& source, ImageSkia CreateVectorIconFromSource(const std::string& source,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define UI_GFX_PAINT_VECTOR_ICON_H_ #define UI_GFX_PAINT_VECTOR_ICON_H_
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/gfx_export.h" #include "ui/gfx/gfx_export.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
...@@ -19,10 +20,12 @@ struct VectorIcon; ...@@ -19,10 +20,12 @@ struct VectorIcon;
struct GFX_EXPORT IconDescription { struct GFX_EXPORT IconDescription {
IconDescription(const IconDescription& other); IconDescription(const IconDescription& other);
// If |dip_size| is 0, the default size of |icon| will be used.
// If |badge_icon| is null, the icon has no badge.
IconDescription(const VectorIcon& icon, IconDescription(const VectorIcon& icon,
int dip_size, int dip_size = 0,
SkColor color, SkColor color = gfx::kPlaceholderColor,
const VectorIcon& badge_icon); const VectorIcon* badge_icon = nullptr);
~IconDescription(); ~IconDescription();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment