diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-10 09:50:48 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-10 09:50:48 +0200 |
| commit | 1911887cb9d6a165a52412ed92014ff113d701c8 (patch) | |
| tree | 3df77b7b20a265493d8e2fd1663a91a6a5408a76 /src/carddelegate.cpp | |
| parent | 8031901652758e9db5ef0bb545c062f80f2f8cc2 (diff) | |
| download | qtmaildir-1911887cb9d6a165a52412ed92014ff113d701c8.tar.gz qtmaildir-1911887cb9d6a165a52412ed92014ff113d701c8.zip | |
feat(view): lift a muted account colour for the accent bar
The five real account colours are all mid-tone, because they were chosen as
CHIP fills with legible text on top, and three pixels of a mid-tone colour
barely registers beside a card's own background. The bar now lifts saturation
and lightness to a floor.
A floor, not a repaint: a colour already past it is returned untouched, so a
deliberately vivid choice is preserved and only the muted ones move. Hue is
never altered, because hue is the entire information the bar carries and a
shifted one would stop matching the account's chip and its dropdown swatch.
0.65 and 0.50 were chosen by rendering all five accounts as 3px bars against
both a dark and a light card background and looking at them. Higher pushed the
weakest of them, a green at S 0.33, toward a neon that no longer matched its own
chip; lower left it where it started.
accentLineColour had no test at all until now, which is how two earlier versions
of it shipped wrong: one blended toward Base until it WAS the background, the
other passed a chip colour through unchanged. test_carddelegate covers the lift,
the floor's idempotence, hue preservation across all five accounts, and the
fallback for a thread with no account tag.
Diffstat (limited to 'src/carddelegate.cpp')
| -rw-r--r-- | src/carddelegate.cpp | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/carddelegate.cpp b/src/carddelegate.cpp index f13205e..bce9eec 100644 --- a/src/carddelegate.cpp +++ b/src/carddelegate.cpp @@ -58,16 +58,32 @@ QColor CardDelegate::accentLineColour(const QColor &accountColour) // at (0.18, 0.22, 0.26), which is the background. The weight is a fraction // OF THE ACCOUNT COLOUR, so a low one keeps the background, not the hue. // - // The bar is the account's colour, undiluted. Blending it toward Base at - // all was the mistake: a chip's colour is chosen to carry text on top and - // is therefore already muted, and three pixels of a muted colour on a dark - // background is nothing at all. There is no text on this bar, so nothing - // needs the contrast a chip's fill was picked for. + // The account's own hue, lifted to a floor of saturation and lightness. // - // What DOES step back is the spine, below: a line running the height of a - // whole expansion has to be followable without competing with the senders - // beside it, which is a different problem from a 3px edge marker. - return accountColour; + // Blending toward Base was the first mistake and is long gone: a chip's + // colour is already muted, since it is chosen to carry legible text on top, + // and three pixels of a muted colour is nothing. Handing the raw colour + // through was the second: it is better, but the five real accounts are all + // mid-tone by construction and still read as faint stripes on a dark theme. + // + // A FLOOR rather than a repaint. A colour already past it is returned + // untouched, so a user who deliberately picked something vivid keeps + // exactly what they picked, and only the muted ones move. Hue is never + // touched at all, because hue is the entire information the bar carries: + // shifting it would make a bar stop matching its account's chip and its + // swatch in the dropdown. + // + // The numbers were chosen by rendering all five accounts as 3px bars on + // both a dark and a light card background and looking. Higher pushed the + // green toward a neon that no longer matched its own chip; lower left it + // where it started. + constexpr float kMinSaturation = 0.65f; + constexpr float kMinLightness = 0.50f; + + float h = 0, s = 0, l = 0, a = 0; + accountColour.getHslF(&h, &s, &l, &a); + return QColor::fromHslF(h, qMax(s, kMinSaturation), + qMax(l, kMinLightness), a); } QSize CardDelegate::sizeHint(const QStyleOptionViewItem &option, |
