mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 19:13:25 -08:00
[Game] Add hover zoom and a tabbed card panel to the board (#7700)
* [Settings] Add hover zoom/panel triggers, delays, and double-confirm * [Game] Smooth board hover-zoom with fade helpers * [Game] Add hover card panel with tabbed actions * [Game] Wire hover zoom/panel triggers through the scene * [Game] Repaint cached zones when the hover zoom moves `TableZone` cuts the hovered card out of its own paint so zone washes, indicators, dimming and the land divider never draw over the zoom. It is a `DeviceCoordinateCache` item, so the card changing geometry never dirtied it and the stale hole stayed transparent, uncovering the black viewport as soon as the zoom crossed a zone edge. - Emit `hoverFootprintChanged(old, new)` from `setCardScale()` and once from `setHovered(false)`. - Repaint every overlapping `TableZone` on that signal. - Clip with the card's painted outline instead of its bounding rectangle, and treat a zoom covering the whole zone as "paint nothing". * [Interface] Keep the hover panel P/T controls out of the way The P/T set/inc/dec rows were always visible and sat under the cursor, so clicking a card to select it could mutate its P/T instead. - Collapse the controls to a pill on the printed P/T box, anchored on the drawn artwork so letterboxed and sideways cards stay aligned. - Open the rows only from the pill and grow them upward, and re-measure the pill on every value so three-digit P/T does not clip. - Close the panel when another card is hovered, and repaint the area it covered so no patch is left behind. * [Interface] Address hover panel review findings * [Game] Fix include order flagged by the format gate The card hover widget header was included before theme_manager.h, which clang-format rejects; the branch's format CI job failed on it. * [Interface] Load the hover panel icons through the themed icon engine The panel still named pre-#7595 assets (arrow_*_green, arrow_right_blue, cogwheel) and built QIcon snapshots from themePixmap(), so the deleted names rendered blank and every other glyph froze one palette. Load every glyph through loadThemedIcon() with the emphasis axis the adoption plan calls for: the category tabs take the primary level as panel wayfinding, the action grid the quiet level because its glyphs label the button text. Semantic tints keep their family and follow the same quiet level; Clone keeps its sticker treatment. * [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. * [Interface] Split the hover panel icons by emphasis and semantics Category tabs only navigate between pages, so they take the quiet level; the action grid is the surface the player works in and takes the primary level. Both stay line glyphs: a filled treatment reads as a second state on every cell. Hue marks an outcome where the glyph cannot. Play, clone and to hand are Positive; reduce life and graveyard Negative; play face down and exile Informational. Direction-only moves (top and bottom of library) stay neutral because the arrow already carries the meaning. * [Icons] Add Hidden and Marked semantic color families Two game concepts had no hue of their own. Hidden information (a face-down play, peeking at a card face) now has violet, and the marks a player leaves on a card (annotation, draw arrow) now share amber instead of splitting blue and red for the same job. Both families follow the existing three-level ladder: authored roles per theme, scheme defaults otherwise, an emphasis mapping, palette-editor rows and generator seeding. The defaults clear the 4.5:1 floor on the representative platform surfaces and keep the saturation ordering the emphasis tests assert; the hue tests pin violet's blue-red-green dominance and amber's red-green-blue one, and every preview sheet now renders the two families. The hover panel grid preview is added alongside: it renders the real pages (section headers, two-column cells, glyph over label) so the whole map can be judged at once instead of glyph by glyph. * [Icons] Add a Movement semantic color family A card changing position inside the library is neither a gain, a loss nor information, so it had no hue. Movement names it with teal and covers the three library placements (top, bottom, X from top). It follows the existing ladder: authored roles per theme, scheme defaults otherwise, an emphasis mapping, palette-editor rows and generator seeding. The defaults clear the 4.5:1 floor on the representative platform surfaces, keep strong > base > soft saturation, and keep green > blue > red so teal cannot be mistaken for the green gain family. * [Interface] Give every hover panel action a semantic color The quick actions are the panel's whole point, so a neutral glyph made the most-used buttons the hardest to scan. Every action now names a game fact with its hue: gain, loss, information, hidden information, a mark on the card or a move. The line glyph stays identical, so the colour is the only difference between neighbours. The grid is also ordered by family so a row reads as one idea: the two state toggles, the two gains, the two marks, the two hidden-information actions and the two losses each share a row. Conditional actions (Peek, Unattach) sit at the end of their pair, so a missing one leaves a hole at the section edge instead of splitting a row. In a zone, Play and Play Face Down stay adjacent on purpose: the same action, one of them hiding information. The move tab leads with the three library placements (Movement), then the destinations. actionGridIcon is removed; semanticActionIcon is now the only grid ink. The preview renders the real pages so the whole map can be judged at once. * [Icons] Use quiet emphasis for glyphs that label rather than act The search and info glyphs inside the search fields, and the combo-box chevron, label or afford an action rather than performing one. At the default secondary weight they compete with the actual controls next to them. Paint them at quiet emphasis so they stay legible without claiming attention. Sites: deck editor, visual database display, visual deck storage, set manager, settings search, in-game zone view, and the dropdown chevron. * [Icons] Restore sticker treatment to the add, remove and delete actions The pre-#7595 add and delete glyphs were filled shapes with an outline. After the line migration they read as ordinary toolbar glyphs, losing the weight their verbs had. Give the add and delete family the sticker treatment again. - Deck editor Add card: primary positive sticker. It is the one action the database panel exists for. - Visual database Clear filters: negative sticker, matching the delete family. - Filter dock Clear all: negative sticker, matching Clear one. * [Icons] Give sharing and pinning their semantic families Sharing is an informational act: the app already tints reveal and make-public with the informational family, so the deck storage share action, the replay share-code action and the visual deck storage share button follow it. The printing-selector pin badge marks a card as pinned. Paint it with the marked family, the same one used for a mark left on a card, instead of leaving it neutral. * [Game] Dismiss the hover panel before opening a modal dialog The hover panel is a Qt::ToolTip window, i.e. a popup: it is always on top and holds the input grab. Actions on the panel that open a modal dialog (Set power/toughness, Set annotation, Set counter value, token creation) therefore opened the dialog behind the panel, where it could not be seen or activated. Hide the panel synchronously and defer the action to the next event-loop turn, so the popup grab is released before the dialog's event loop starts. The panel asks the scene to dismiss it through a new dismissRequested signal, keeping hover timers and the covered-card fade on the scene's side. Reported from the P/T overlay SET button; the same path covers the counter tab and the token tab. * [Icons] Refine VDE and VDD emphasis and semantics The visual database filter section and the syntax help are information aids, so paint them with the informational family at the default emphasis: the filter section glyph and the search field's help glyph. The help glyph leaves quiet emphasis because it is a clickable action, not a field label. The visual deck editor's display-type toggle is the one control that changes the whole view, so it takes primary emphasis. The search glyphs stay quiet; only the help action changes. * [Icons] Raise the visual database filter controls to primary The six quick-filter buttons are the controls the filter section exists for, so paint them at primary emphasis instead of the default weight. The sort glyph carries the same informational family as the filter glyph, in both the visual database toolbar label and the visual deck editor's sort-criteria button. * [Icons] Keep the display options sort glyph neutral The sort button beside the display-mode toggle is not part of the informational family. Only the visual database toolbar's sort glyph carries informational; the display options button returns to the default neutral weight. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
6138fbd0a0
commit
b1c8f156dc
46 changed files with 3796 additions and 76 deletions
|
|
@ -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,10 @@ 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"}},
|
||||
{"Hidden", AppColor::Hidden, {"view", "arrow_right", "swap"}},
|
||||
{"Marked", AppColor::Marked, {"pencil", "share", "pin"}},
|
||||
{"Movement", AppColor::Movement, {"arrow_to_top", "arrow_to_bottom", "arrow_down"}},
|
||||
};
|
||||
const QStringList themes = {
|
||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QGuiApplication>
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
|
|
@ -69,7 +70,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 +103,17 @@ 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"}},
|
||||
{"Hidden", AppColor::Hidden, {"view", "arrow_right", "swap"}},
|
||||
{"Marked", AppColor::Marked, {"pencil", "share", "pin"}},
|
||||
{"Movement", AppColor::Movement, {"arrow_to_top", "arrow_to_bottom", "arrow_down"}},
|
||||
};
|
||||
const QStringList themes = {
|
||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||
|
|
@ -246,3 +255,312 @@ TEST(IconTreatmentPreview, WritesOneSheetPerShippedTheme)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
/** @brief One action-grid cell, with the role the panel hands the icon engine. */
|
||||
struct PreviewAction
|
||||
{
|
||||
QString label;
|
||||
const char *glyph;
|
||||
AppColor::Role role;
|
||||
};
|
||||
|
||||
/** @brief One titled section of a hover panel page. */
|
||||
struct PreviewSection
|
||||
{
|
||||
QString title;
|
||||
QList<PreviewAction> actions;
|
||||
};
|
||||
|
||||
/** @brief One hover panel page, as the client builds it. */
|
||||
struct PreviewPage
|
||||
{
|
||||
QString title;
|
||||
QList<PreviewSection> sections;
|
||||
};
|
||||
|
||||
/** @brief Renders a sentinel SVG in one ink at the requested pixel size. */
|
||||
QPixmap renderInkGlyph(const QByteArray &svg, const QColor &ink, const QSize &size)
|
||||
{
|
||||
QSvgRenderer renderer(resolveSvgColorSentinel(svg, ink.name(QColor::HexRgb).toLatin1()));
|
||||
QPixmap pixmap(size);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
renderer.render(&painter);
|
||||
return pixmap;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
/**
|
||||
* @brief Writes the hover panel's action grids the way the client paints them.
|
||||
*
|
||||
* The treatment sheets show glyphs in isolation; this renders the real layout —
|
||||
* section headers and two-column cells with the glyph above its label — so the
|
||||
* emphasis split (quiet tabs, primary grid) and the semantic map can be judged
|
||||
* as the set the player actually sees. The roles are the ones the panel passes
|
||||
* to the icon engine, already resolved to the emphasis level it requests, and a
|
||||
* role the theme does not author resolves through the same scheme default the
|
||||
* client paints.
|
||||
*/
|
||||
TEST(IconTreatmentPreview, HoverPanelGridWritesPngsWhenRequested)
|
||||
{
|
||||
const QString outDir = qEnvironmentVariable("COCKATRICE_ICON_PREVIEW_DIR");
|
||||
if (outDir.isEmpty()) {
|
||||
GTEST_SKIP() << "set COCKATRICE_ICON_PREVIEW_DIR to write the preview PNGs";
|
||||
}
|
||||
ensureGuiApplication();
|
||||
ASSERT_TRUE(QDir().mkpath(outDir));
|
||||
|
||||
constexpr int MARGIN = 24;
|
||||
constexpr int COLUMNS = 2;
|
||||
constexpr int CELL_WIDTH = 146;
|
||||
constexpr int CELL_HEIGHT = 62;
|
||||
constexpr int SECTION_HEIGHT = 22;
|
||||
constexpr int PANEL_PADDING = 10;
|
||||
constexpr int PANEL_TITLE = 24;
|
||||
constexpr int GLYPH = 22;
|
||||
constexpr qreal DPR = 2.0;
|
||||
|
||||
// The pages a selected card shows, with every conditional action present
|
||||
// so the whole map is visible at once.
|
||||
const QList<PreviewPage> pages = {
|
||||
PreviewPage{.title = QStringLiteral("Main — on the battlefield"),
|
||||
.sections =
|
||||
{
|
||||
PreviewSection{.title = QStringLiteral("Battlefield"),
|
||||
.actions =
|
||||
{
|
||||
PreviewAction{.label = QStringLiteral("Tap / Untap"),
|
||||
.glyph = "sync",
|
||||
.role = AppColor::InformationalStrong},
|
||||
PreviewAction{.label = QStringLiteral("Skip untapping"),
|
||||
.glyph = "lock",
|
||||
.role = AppColor::InformationalStrong},
|
||||
PreviewAction{.label = QStringLiteral("Clone"),
|
||||
.glyph = "increment",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Attach to card..."),
|
||||
.glyph = "pin",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Draw arrow..."),
|
||||
.glyph = "share",
|
||||
.role = AppColor::MarkedStrong},
|
||||
PreviewAction{.label = QStringLiteral("Set annotation..."),
|
||||
.glyph = "pencil",
|
||||
.role = AppColor::MarkedStrong},
|
||||
PreviewAction{.label = QStringLiteral("Turn Over"),
|
||||
.glyph = "swap",
|
||||
.role = AppColor::HiddenStrong},
|
||||
PreviewAction{.label = QStringLiteral("Peek at card face"),
|
||||
.glyph = "view",
|
||||
.role = AppColor::HiddenStrong},
|
||||
PreviewAction{.label = QStringLiteral("Unattach"),
|
||||
.glyph = "arrow_undo",
|
||||
.role = AppColor::NegativeStrong},
|
||||
PreviewAction{.label = QStringLiteral("Reduce life"),
|
||||
.glyph = "arrow_down",
|
||||
.role = AppColor::NegativeStrong},
|
||||
}},
|
||||
PreviewSection{.title = QStringLiteral("Select"),
|
||||
.actions =
|
||||
{
|
||||
PreviewAction{.label = QStringLiteral("Select All"),
|
||||
.glyph = "search",
|
||||
.role = AppColor::InformationalStrong},
|
||||
PreviewAction{.label = QStringLiteral("Select Row"),
|
||||
.glyph = "filter",
|
||||
.role = AppColor::InformationalStrong},
|
||||
}},
|
||||
}},
|
||||
PreviewPage{.title = QStringLiteral("Main — in a zone"),
|
||||
.sections =
|
||||
{
|
||||
PreviewSection{.title = QStringLiteral("Zone"),
|
||||
.actions =
|
||||
{
|
||||
PreviewAction{.label = QStringLiteral("Play"),
|
||||
.glyph = "arrow_right",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Play Face Down"),
|
||||
.glyph = "arrow_right",
|
||||
.role = AppColor::HiddenStrong},
|
||||
PreviewAction{.label = QStringLiteral("Clone"),
|
||||
.glyph = "increment",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Attach to card..."),
|
||||
.glyph = "pin",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Draw arrow..."),
|
||||
.glyph = "share",
|
||||
.role = AppColor::MarkedStrong},
|
||||
}},
|
||||
PreviewSection{.title = QStringLiteral("Select"),
|
||||
.actions =
|
||||
{
|
||||
PreviewAction{.label = QStringLiteral("Select All"),
|
||||
.glyph = "search",
|
||||
.role = AppColor::InformationalStrong},
|
||||
PreviewAction{.label = QStringLiteral("Select Column"),
|
||||
.glyph = "filter",
|
||||
.role = AppColor::InformationalStrong},
|
||||
}},
|
||||
}},
|
||||
PreviewPage{.title = QStringLiteral("Move — card in a zone"),
|
||||
.sections =
|
||||
{
|
||||
PreviewSection{.title = QStringLiteral("Move to"),
|
||||
.actions =
|
||||
{
|
||||
PreviewAction{.label = QStringLiteral("Top of library"),
|
||||
.glyph = "arrow_to_top",
|
||||
.role = AppColor::MovementStrong},
|
||||
PreviewAction{.label = QStringLiteral("X from top..."),
|
||||
.glyph = "search",
|
||||
.role = AppColor::MovementStrong},
|
||||
PreviewAction{.label = QStringLiteral("Bottom of library"),
|
||||
.glyph = "arrow_to_bottom",
|
||||
.role = AppColor::MovementStrong},
|
||||
PreviewAction{.label = QStringLiteral("Table"),
|
||||
.glyph = "player",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Hand"),
|
||||
.glyph = "arrow_left",
|
||||
.role = AppColor::PositiveStrong},
|
||||
PreviewAction{.label = QStringLiteral("Graveyard"),
|
||||
.glyph = "arrow_down",
|
||||
.role = AppColor::NegativeStrong},
|
||||
PreviewAction{.label = QStringLiteral("Exile"),
|
||||
.glyph = "arrow_right",
|
||||
.role = AppColor::InformationalStrong},
|
||||
}},
|
||||
PreviewSection{.title = QStringLiteral("Reveal to..."),
|
||||
.actions =
|
||||
{
|
||||
PreviewAction{.label = QStringLiteral("All players"),
|
||||
.glyph = "share",
|
||||
.role = AppColor::InformationalStrong},
|
||||
PreviewAction{.label = QStringLiteral("Alice"),
|
||||
.glyph = "player",
|
||||
.role = AppColor::InformationalStrong},
|
||||
PreviewAction{.label = QStringLiteral("Bob"),
|
||||
.glyph = "player",
|
||||
.role = AppColor::InformationalStrong},
|
||||
}},
|
||||
}},
|
||||
};
|
||||
|
||||
const auto rowsIn = [](const PreviewSection §ion) { return (section.actions.size() + COLUMNS - 1) / COLUMNS; };
|
||||
const auto panelHeightFor = [&](const PreviewPage &page) {
|
||||
int height = PANEL_TITLE + PANEL_PADDING;
|
||||
for (const PreviewSection §ion : page.sections) {
|
||||
height += SECTION_HEIGHT + rowsIn(section) * CELL_HEIGHT;
|
||||
}
|
||||
return height + PANEL_PADDING;
|
||||
};
|
||||
|
||||
const int panelWidth = COLUMNS * CELL_WIDTH + 2 * PANEL_PADDING;
|
||||
const int pageCount = static_cast<int>(pages.size());
|
||||
int tallestPanel = 0;
|
||||
for (const PreviewPage &page : pages) {
|
||||
tallestPanel = qMax(tallestPanel, panelHeightFor(page));
|
||||
}
|
||||
const int logicalWidth = 2 * MARGIN + pageCount * panelWidth + (pageCount - 1) * MARGIN;
|
||||
const int logicalHeight = MARGIN + 30 + tallestPanel + MARGIN;
|
||||
|
||||
const QString theme = QStringLiteral("Fabric");
|
||||
for (const bool dark : {false, true}) {
|
||||
const QString file =
|
||||
QDir(QStringLiteral(COCKATRICE_SOURCE_DIR))
|
||||
.absoluteFilePath(QStringLiteral("cockatrice/themes/%1/palette-default-%2.toml")
|
||||
.arg(theme, dark ? QStringLiteral("dark") : QStringLiteral("light")));
|
||||
const PaletteConfig config = PaletteConfig::fromFile(file);
|
||||
ASSERT_TRUE(config.hasPalette()) << theme.toStdString();
|
||||
|
||||
const QPalette palette = config.apply(QPalette());
|
||||
const QColor window = palette.color(QPalette::Active, QPalette::Window);
|
||||
const QColor text = palette.color(QPalette::Active, QPalette::WindowText);
|
||||
// The panel's cells sit on the popup surface; painting them on the
|
||||
// button color is what a QToolButton shows when it is not hovered.
|
||||
const QColor cell = palette.color(QPalette::Active, QPalette::Button);
|
||||
|
||||
QImage image(QSize(qRound(logicalWidth * DPR), qRound(logicalHeight * DPR)),
|
||||
QImage::Format_ARGB32_Premultiplied);
|
||||
image.fill(window);
|
||||
QPainter painter(&image);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
painter.scale(DPR, DPR);
|
||||
|
||||
painter.setPen(text);
|
||||
painter.setFont(QFont(QStringLiteral("Sans"), 10, QFont::DemiBold));
|
||||
painter.drawText(QPointF(MARGIN, MARGIN),
|
||||
QStringLiteral("%1 — %2 scheme, hover panel action grids")
|
||||
.arg(theme, dark ? QStringLiteral("dark") : QStringLiteral("light")));
|
||||
|
||||
const auto toneFor = [&](AppColor::Role role) {
|
||||
return config.appColors.value(role, defaultAppColor(role, dark));
|
||||
};
|
||||
|
||||
for (int pageIndex = 0; pageIndex < pageCount; ++pageIndex) {
|
||||
const PreviewPage &page = pages[pageIndex];
|
||||
const qreal panelLeft = MARGIN + static_cast<qreal>(pageIndex) * (panelWidth + MARGIN);
|
||||
const qreal panelTop = MARGIN + 30;
|
||||
const int panelHeight = panelHeightFor(page);
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(cell.darker(dark ? 115 : 103));
|
||||
painter.drawRoundedRect(QRectF(panelLeft, panelTop, panelWidth, panelHeight), 8, 8);
|
||||
|
||||
painter.setPen(text);
|
||||
painter.setFont(QFont(QStringLiteral("Sans"), 9, QFont::DemiBold));
|
||||
painter.drawText(QPointF(panelLeft + PANEL_PADDING, panelTop + 17), page.title);
|
||||
|
||||
qreal y = panelTop + PANEL_TITLE;
|
||||
for (const PreviewSection §ion : page.sections) {
|
||||
painter.setPen(text);
|
||||
painter.setFont(QFont(QStringLiteral("Sans"), 8, QFont::DemiBold));
|
||||
painter.drawText(QPointF(panelLeft + PANEL_PADDING, y + 15), section.title);
|
||||
y += SECTION_HEIGHT;
|
||||
|
||||
const int rows = rowsIn(section);
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int column = 0; column < COLUMNS; ++column) {
|
||||
const int index = row * COLUMNS + column;
|
||||
if (index >= section.actions.size()) {
|
||||
break;
|
||||
}
|
||||
const PreviewAction &action = section.actions.at(index);
|
||||
const QRectF cellRect(panelLeft + PANEL_PADDING + column * CELL_WIDTH, y, CELL_WIDTH - 4,
|
||||
CELL_HEIGHT - 4);
|
||||
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.setBrush(cell);
|
||||
painter.drawRoundedRect(cellRect, 5, 5);
|
||||
|
||||
const QByteArray svg = readIconSvg(action.glyph);
|
||||
ASSERT_FALSE(svg.isEmpty()) << action.glyph;
|
||||
const QPixmap pixmap = renderAtDpr(QSize(GLYPH, GLYPH), DPR, [&](const QSize &pixelSize) {
|
||||
return renderInkGlyph(svg, toneFor(action.role), pixelSize);
|
||||
});
|
||||
painter.drawPixmap(QPointF(cellRect.center().x() - GLYPH / 2.0, cellRect.top() + 7), pixmap);
|
||||
|
||||
painter.setPen(text);
|
||||
painter.setFont(QFont(QStringLiteral("Sans"), 7));
|
||||
const QFontMetrics metrics(painter.font());
|
||||
const QString label = metrics.elidedText(action.label, Qt::ElideRight, CELL_WIDTH - 12);
|
||||
painter.drawText(QRectF(cellRect.left(), cellRect.bottom() - 20, cellRect.width(), 16),
|
||||
Qt::AlignHCenter | Qt::AlignVCenter, label);
|
||||
}
|
||||
y += CELL_HEIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
painter.end();
|
||||
const QString path = QDir(outDir).absoluteFilePath(
|
||||
QStringLiteral("hover-panel-map-%1.png").arg(dark ? QStringLiteral("dark") : QStringLiteral("light")));
|
||||
ASSERT_TRUE(image.save(path)) << path.toStdString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1535,9 +1535,14 @@ 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},
|
||||
Family{AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft},
|
||||
Family{AppColor::Marked, AppColor::MarkedStrong, AppColor::MarkedSoft},
|
||||
Family{AppColor::Movement, AppColor::MovementStrong, AppColor::MovementSoft}}) {
|
||||
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 +1641,52 @@ 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);
|
||||
}
|
||||
|
||||
for (const AppColor::Role role : {AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft}) {
|
||||
// Hidden is violet: blue leads, then red, then green.
|
||||
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.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
||||
}
|
||||
|
||||
for (const AppColor::Role role : {AppColor::Marked, AppColor::MarkedStrong, AppColor::MarkedSoft}) {
|
||||
// Marked is amber: red leads, then green, then blue.
|
||||
const QColor ink = roles.value(role, defaultAppColor(role, dark));
|
||||
if (!ink.isValid()) {
|
||||
continue;
|
||||
}
|
||||
++checked;
|
||||
EXPECT_GT(ink.red(), ink.green()) << theme.toStdString() << static_cast<int>(role);
|
||||
EXPECT_GT(ink.green(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
|
||||
}
|
||||
|
||||
for (const AppColor::Role role : {AppColor::Movement, AppColor::MovementStrong, AppColor::MovementSoft}) {
|
||||
// Movement is teal: green leads, then blue, then red.
|
||||
const QColor ink = roles.value(role, defaultAppColor(role, dark));
|
||||
if (!ink.isValid()) {
|
||||
continue;
|
||||
}
|
||||
++checked;
|
||||
EXPECT_GT(ink.green(), ink.blue()) << theme.toStdString() << static_cast<int>(role);
|
||||
EXPECT_GT(ink.blue(), ink.red()) << theme.toStdString() << static_cast<int>(role);
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPECT_GT(checked, 0) << "no shipped theme authored a semantic emphasis level";
|
||||
|
|
@ -1821,7 +1872,11 @@ 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},
|
||||
std::tuple{AppColor::Hidden, AppColor::HiddenStrong, AppColor::HiddenSoft},
|
||||
std::tuple{AppColor::Marked, AppColor::MarkedStrong, AppColor::MarkedSoft},
|
||||
std::tuple{AppColor::Movement, AppColor::MovementStrong, AppColor::MovementSoft}}) {
|
||||
const QColor secondary = defaultAppColor(base, scheme.dark);
|
||||
const QColor primary = defaultAppColor(strong, scheme.dark);
|
||||
const QColor quiet = defaultAppColor(soft, scheme.dark);
|
||||
|
|
@ -1908,6 +1963,18 @@ TEST_F(ThemeIconRenderTest, EmphasisPreviewWritesPngsWhenRequested)
|
|||
AppColor::NegativeSoft,
|
||||
AppColor::Negative,
|
||||
AppColor::NegativeStrong},
|
||||
{"Informational",
|
||||
{"arrow_right", "view", "arrow_to_top"},
|
||||
AppColor::InformationalSoft,
|
||||
AppColor::Informational,
|
||||
AppColor::InformationalStrong},
|
||||
{"Hidden", {"view", "arrow_right", "swap"}, AppColor::HiddenSoft, AppColor::Hidden, AppColor::HiddenStrong},
|
||||
{"Marked", {"pencil", "share", "pin"}, AppColor::MarkedSoft, AppColor::Marked, AppColor::MarkedStrong},
|
||||
{"Movement",
|
||||
{"arrow_to_top", "arrow_to_bottom", "arrow_down"},
|
||||
AppColor::MovementSoft,
|
||||
AppColor::Movement,
|
||||
AppColor::MovementStrong},
|
||||
};
|
||||
const QStringList themes = {
|
||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||
|
|
@ -1942,9 +2009,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 +2168,18 @@ TEST_F(ThemeIconRenderTest, EmphasisTreatmentsPreviewWritesPngsWhenRequested)
|
|||
AppColor::NegativeSoft,
|
||||
AppColor::Negative,
|
||||
AppColor::NegativeStrong},
|
||||
{"Informational",
|
||||
{"arrow_right", "view", "arrow_to_top"},
|
||||
AppColor::InformationalSoft,
|
||||
AppColor::Informational,
|
||||
AppColor::InformationalStrong},
|
||||
{"Hidden", {"view", "arrow_right", "swap"}, AppColor::HiddenSoft, AppColor::Hidden, AppColor::HiddenStrong},
|
||||
{"Marked", {"pencil", "share", "pin"}, AppColor::MarkedSoft, AppColor::Marked, AppColor::MarkedStrong},
|
||||
{"Movement",
|
||||
{"arrow_to_top", "arrow_to_bottom", "arrow_down"},
|
||||
AppColor::MovementSoft,
|
||||
AppColor::Movement,
|
||||
AppColor::MovementStrong},
|
||||
};
|
||||
const QStringList themes = {
|
||||
QStringLiteral("Fabric"), QStringLiteral("Fusion"), QStringLiteral("Leather"),
|
||||
|
|
@ -2184,7 +2264,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())
|
||||
|
|
|
|||
|
|
@ -167,6 +167,30 @@ 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")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::Hidden, false), QColor(QStringLiteral("#6d28d9")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::Hidden, true), QColor(QStringLiteral("#c6a5fa")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::HiddenStrong, false), QColor(QStringLiteral("#4c0f9e")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::HiddenStrong, true), QColor(QStringLiteral("#c99bff")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::HiddenSoft, false), QColor(QStringLiteral("#6a5a8c")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::HiddenSoft, true), QColor(QStringLiteral("#b3a6c9")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::Marked, false), QColor(QStringLiteral("#9a5b05")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::Marked, true), QColor(QStringLiteral("#e2a63a")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MarkedStrong, false), QColor(QStringLiteral("#8a4f02")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MarkedStrong, true), QColor(QStringLiteral("#ffb020")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MarkedSoft, false), QColor(QStringLiteral("#7b6a4a")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MarkedSoft, true), QColor(QStringLiteral("#c2ab7d")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::Movement, false), QColor(QStringLiteral("#0e7a72")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::Movement, true), QColor(QStringLiteral("#4cc2b5")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MovementStrong, false), QColor(QStringLiteral("#096b62")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MovementStrong, true), QColor(QStringLiteral("#2dd4bf")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MovementSoft, false), QColor(QStringLiteral("#4a6b67")));
|
||||
EXPECT_EQ(defaultAppColor(AppColor::MovementSoft, true), QColor(QStringLiteral("#a3c1bc")));
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue