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 {
}
gfx::ImageSkia RelaunchRecommendedBubbleView::GetWindowIcon() {
return gfx::CreateVectorIcon(
gfx::IconDescription(vector_icons::kBusinessIcon, kTitleIconSize,
gfx::kChromeIconGrey, gfx::kNoneIcon));
return gfx::CreateVectorIcon(gfx::IconDescription(
vector_icons::kBusinessIcon, kTitleIconSize, gfx::kChromeIconGrey));
}
bool RelaunchRecommendedBubbleView::ShouldShowWindowIcon() const {
......
......@@ -87,9 +87,8 @@ bool RelaunchRequiredDialogView::ShouldShowCloseButton() const {
}
gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() {
return gfx::CreateVectorIcon(
gfx::IconDescription(vector_icons::kBusinessIcon, kTitleIconSize,
gfx::kChromeIconGrey, gfx::kNoneIcon));
return gfx::CreateVectorIcon(gfx::IconDescription(
vector_icons::kBusinessIcon, kTitleIconSize, gfx::kChromeIconGrey));
}
bool RelaunchRequiredDialogView::ShouldShowWindowIcon() const {
......
......@@ -149,9 +149,8 @@ void ProfileSigninConfirmationDialogViews::ViewHierarchyChanged(
// Create business icon.
int business_icon_size = 20;
auto business_icon = std::make_unique<views::ImageView>();
business_icon->SetImage(gfx::CreateVectorIcon(
gfx::IconDescription(vector_icons::kBusinessIcon, business_icon_size,
gfx::kChromeIconGrey, gfx::kNoneIcon)));
business_icon->SetImage(gfx::CreateVectorIcon(gfx::IconDescription(
vector_icons::kBusinessIcon, business_icon_size, gfx::kChromeIconGrey)));
// Create the prompt label.
size_t offset;
......
......@@ -203,10 +203,8 @@ void AuthenticatorRequestSheetView::UpdateIconImageFromModel() {
if (!step_illustration_)
return;
gfx::IconDescription icon_description(
model()->GetStepIllustration(GetNativeTheme()->ShouldUseDarkColors()
? ImageColorScheme::kDark
: ImageColorScheme::kLight),
0 /* automatic dip_size */, SK_ColorBLACK, gfx::kNoneIcon);
gfx::IconDescription icon_description(model()->GetStepIllustration(
GetNativeTheme()->ShouldUseDarkColors() ? ImageColorScheme::kDark
: ImageColorScheme::kLight));
step_illustration_->SetImage(gfx::CreateVectorIcon(icon_description));
}
......@@ -431,7 +431,7 @@ class VectorIconSource : public CanvasImageSource {
VectorIconSource(const std::string& definition, int dip_size, SkColor color)
: CanvasImageSource(Size(dip_size, dip_size)),
data_(kNoneIcon, dip_size, color, kNoneIcon),
data_(kNoneIcon, dip_size, color, &kNoneIcon),
path_(PathFromSource(definition)) {}
~VectorIconSource() override {}
......@@ -493,11 +493,11 @@ IconDescription::IconDescription(const IconDescription& other) = default;
IconDescription::IconDescription(const VectorIcon& icon,
int dip_size,
SkColor color,
const VectorIcon& badge_icon)
const VectorIcon* badge_icon)
: icon(icon),
dip_size(dip_size),
color(color),
badge_icon(badge_icon) {
badge_icon(badge_icon ? *badge_icon : kNoneIcon) {
if (dip_size == 0)
this->dip_size = GetDefaultSizeOfVectorIcon(icon);
}
......@@ -536,14 +536,14 @@ ImageSkia CreateVectorIcon(const VectorIcon& icon, SkColor color) {
ImageSkia CreateVectorIcon(const VectorIcon& icon,
int dip_size,
SkColor color) {
return CreateVectorIcon(IconDescription(icon, dip_size, color, kNoneIcon));
return CreateVectorIcon(IconDescription(icon, dip_size, color, &kNoneIcon));
}
ImageSkia CreateVectorIconWithBadge(const VectorIcon& icon,
int dip_size,
SkColor color,
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,
......
......@@ -6,6 +6,7 @@
#define UI_GFX_PAINT_VECTOR_ICON_H_
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/gfx_export.h"
#include "ui/gfx/image/image_skia.h"
......@@ -19,10 +20,12 @@ struct VectorIcon;
struct GFX_EXPORT IconDescription {
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,
int dip_size,
SkColor color,
const VectorIcon& badge_icon);
int dip_size = 0,
SkColor color = gfx::kPlaceholderColor,
const VectorIcon* badge_icon = nullptr);
~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