[Icons] Add an Informational semantic color family

Face-down play and the exile zone are states that are neither a gain nor a
loss, and the pre-#7595 art painted them blue (arrow_right_blue). #7595 dropped
that hue, and the icon engine has had only Positive and Negative since, so both
states fall back to neutral ink.

Add the family with the same three-level ladder the other semantic roles use:
authored roles per theme, scheme defaults otherwise, an emphasis mapping, the
palette-editor rows and the generator seed. The defaults clear the 4.5:1 label
floor on both schemes and the ladder's saturation ordering; the existing
emphasis, hue and preview tests now cover the new family. Preview sheets that
name roles resolve an unauthored one through the same default the client
paints.
This commit is contained in:
Lukas Brübach 2026-11-08 20:07:46 +01:00
parent 2b3a04857f
commit 0aa0407f16
10 changed files with 93 additions and 23 deletions

View file

@ -68,10 +68,12 @@ template <typename Render> QPixmap renderAtDpr(const QSize &logicalSize, qreal d
* @brief Writes one semantic-tint sheet per shipped palette theme.
*
* The theme files are the only place the shipped tones live, so each sheet is
* rendered from the palette the theme actually ships: both semantic families,
* three glyphs each, at the two sizes the UI uses, on the window and button
* surfaces the contrast is measured against. A disabled row closes each family
* so the enabled/disabled order is visible next to the tone that carries it.
* rendered from the palette the theme actually ships: all three semantic
* families, three glyphs each, at the two sizes the UI uses, on the window and
* button surfaces the contrast is measured against. A disabled row closes each
* family so the enabled/disabled order is visible next to the tone that carries
* it. A theme that does not author Informational falls back to the scheme
* default, which is what the client paints.
*/
TEST(IconTintPreview, WritesOneSheetPerShippedTheme)
{
@ -100,6 +102,7 @@ TEST(IconTintPreview, WritesOneSheetPerShippedTheme)
const QList<Family> families = {
{"Positive", AppColor::Positive, {"increment", "ready_start", "arrow_up"}},
{"Negative", AppColor::Negative, {"decrement", "not_ready_start", "remove_row"}},
{"Informational", AppColor::Informational, {"arrow_right", "view", "arrow_to_top"}},
};
const QStringList themes = {
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),

View file

@ -69,7 +69,7 @@ template <typename Render> QPixmap renderAtDpr(const QSize &logicalSize, qreal d
* @brief Writes one badge/sticker sheet per shipped palette theme.
*
* The treatments are only useful if they read on every palette, so each sheet
* is rendered from the palette the theme actually ships: both semantic
* is rendered from the palette the theme actually ships: all three semantic
* families, three glyphs each, as line glyphs, stickers and badges, at the two
* sizes the UI uses, on the window and button surfaces the contrast is measured
* against. A disabled row closes each family: every treatment falls back to the
@ -102,9 +102,14 @@ TEST(IconTreatmentPreview, WritesOneSheetPerShippedTheme)
AppColor::Role role;
const char *glyphs[3];
};
// The hover panel's action grid is the first call site that puts a
// treatment on an action glyph, so the sheet renders the glyphs that grid
// actually uses: play/clone/hand (Positive), reduce life and graveyard
// (Negative), place face down and exile (Informational).
const QList<Family> families = {
{"Positive", AppColor::Positive, {"increment", "ready_start", "arrow_up"}},
{"Negative", AppColor::Negative, {"decrement", "not_ready_start", "remove_row"}},
{"Positive", AppColor::Positive, {"arrow_right", "increment", "arrow_left"}},
{"Negative", AppColor::Negative, {"arrow_down", "decrement", "remove_row"}},
{"Informational", AppColor::Informational, {"arrow_right", "view", "arrow_to_top"}},
};
const QStringList themes = {
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),

View file

@ -1535,9 +1535,11 @@ TEST_F(ThemeIconRenderTest, EmphasisSelectsTheAuthoredVariant)
AppColor::Role soft;
};
for (const Family &family : {Family{AppColor::Icon, AppColor::IconStrong, AppColor::IconSoft},
Family{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
Family{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft}}) {
for (const Family &family :
{Family{AppColor::Icon, AppColor::IconStrong, AppColor::IconSoft},
Family{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
Family{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft},
Family{AppColor::Informational, AppColor::InformationalStrong, AppColor::InformationalSoft}}) {
EXPECT_EQ(IconTint(family.base, IconEmphasis::Primary).resolve(QIcon::Normal),
themeManager->appColor(family.strong));
EXPECT_EQ(IconTint(family.base).resolve(QIcon::Normal), themeManager->appColor(family.base));
@ -1636,6 +1638,19 @@ TEST_F(ThemeIconRenderTest, EmphasisKeepsASemanticHue)
EXPECT_GT(ink.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
EXPECT_GT(ink.red(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
}
for (const AppColor::Role role :
{AppColor::Informational, AppColor::InformationalStrong, AppColor::InformationalSoft}) {
// Informational may come from the scheme default when the theme
// does not author it, so measure the value the client paints.
const QColor ink = roles.value(role, defaultAppColor(role, dark));
if (!ink.isValid()) {
continue;
}
++checked;
EXPECT_GT(ink.blue(), ink.red()) << theme.toStdString() << static_cast<int>(role);
EXPECT_GT(ink.blue(), ink.green()) << theme.toStdString() << static_cast<int>(role);
}
}
}
EXPECT_GT(checked, 0) << "no shipped theme authored a semantic emphasis level";
@ -1821,7 +1836,8 @@ TEST(IconInk, DefaultSemanticFamilyMeetsTheLadderOnPlatformSurfaces)
for (const Scheme &scheme : schemes) {
for (const auto &[base, strong, soft] :
{std::tuple{AppColor::Positive, AppColor::PositiveStrong, AppColor::PositiveSoft},
std::tuple{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft}}) {
std::tuple{AppColor::Negative, AppColor::NegativeStrong, AppColor::NegativeSoft},
std::tuple{AppColor::Informational, AppColor::InformationalStrong, AppColor::InformationalSoft}}) {
const QColor secondary = defaultAppColor(base, scheme.dark);
const QColor primary = defaultAppColor(strong, scheme.dark);
const QColor quiet = defaultAppColor(soft, scheme.dark);
@ -1908,6 +1924,11 @@ TEST_F(ThemeIconRenderTest, EmphasisPreviewWritesPngsWhenRequested)
AppColor::NegativeSoft,
AppColor::Negative,
AppColor::NegativeStrong},
{"Informational",
{"arrow_right", "view", "arrow_to_top"},
AppColor::InformationalSoft,
AppColor::Informational,
AppColor::InformationalStrong},
};
const QStringList themes = {
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
@ -1942,9 +1963,10 @@ TEST_F(ThemeIconRenderTest, EmphasisPreviewWritesPngsWhenRequested)
// The paint path is a lookup now, so the sheet shows the authored
// rows verbatim rather than a color recomputed from the accent.
const auto toneFor = [&](const Family &family, int level) {
return level == 0 ? palette.roles.value(family.quiet)
: level == 1 ? palette.roles.value(family.secondary)
: palette.roles.value(family.primary);
const AppColor::Role role = level == 0 ? family.quiet : level == 1 ? family.secondary : family.primary;
// A theme written before the role existed does not author it;
// the client paints the scheme default, so the sheet does too.
return palette.roles.value(role, defaultAppColor(role, dark));
};
const auto scheme = dark ? ThemeIconFill::Scheme::Dark : ThemeIconFill::Scheme::Light;
@ -2100,6 +2122,11 @@ TEST_F(ThemeIconRenderTest, EmphasisTreatmentsPreviewWritesPngsWhenRequested)
AppColor::NegativeSoft,
AppColor::Negative,
AppColor::NegativeStrong},
{"Informational",
{"arrow_right", "view", "arrow_to_top"},
AppColor::InformationalSoft,
AppColor::Informational,
AppColor::InformationalStrong},
};
const QStringList themes = {
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
@ -2184,7 +2211,9 @@ TEST_F(ThemeIconRenderTest, EmphasisTreatmentsPreviewWritesPngsWhenRequested)
for (const Family &family : families) {
for (int level = 0; level < 4; ++level) {
const bool disabled = level == 3;
const QColor ink = disabled ? disabledTone : palette.roles.value(roleAt(family, level));
const QColor ink = disabled ? disabledTone
: palette.roles.value(roleAt(family, level),
defaultAppColor(roleAt(family, level), dark));
const QString levelName =
disabled ? QStringLiteral("Disabled") : QString::fromLatin1(LEVEL_NAMES[level]);
ASSERT_TRUE(ink.isValid())

View file

@ -167,6 +167,12 @@ TEST(ThemeAppColorTest, SemanticDefaultsFollowTheScheme)
EXPECT_EQ(defaultAppColor(AppColor::NegativeStrong, true), QColor(QStringLiteral("#ff8378")));
EXPECT_EQ(defaultAppColor(AppColor::NegativeSoft, false), QColor(QStringLiteral("#935f5c")));
EXPECT_EQ(defaultAppColor(AppColor::NegativeSoft, true), QColor(QStringLiteral("#c79e9b")));
EXPECT_EQ(defaultAppColor(AppColor::Informational, false), QColor(QStringLiteral("#1c64c4")));
EXPECT_EQ(defaultAppColor(AppColor::Informational, true), QColor(QStringLiteral("#7aa9f2")));
EXPECT_EQ(defaultAppColor(AppColor::InformationalStrong, false), QColor(QStringLiteral("#0a4fb5")));
EXPECT_EQ(defaultAppColor(AppColor::InformationalStrong, true), QColor(QStringLiteral("#69aeff")));
EXPECT_EQ(defaultAppColor(AppColor::InformationalSoft, false), QColor(QStringLiteral("#526a8a")));
EXPECT_EQ(defaultAppColor(AppColor::InformationalSoft, true), QColor(QStringLiteral("#9db2cd")));
// Accent and neutral icon roles have no static default: an older theme
// written before the roles existed falls back to deriving them from its
// palette rather than pinning one scheme's ink.