diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/carddelegate.cpp | 67 | ||||
| -rw-r--r-- | src/carddelegate.h | 17 | ||||
| -rw-r--r-- | src/cardlayout.cpp | 26 | ||||
| -rw-r--r-- | src/cardlayout.h | 13 |
4 files changed, 12 insertions, 111 deletions
diff --git a/src/carddelegate.cpp b/src/carddelegate.cpp index d0ee957..fbdf13f 100644 --- a/src/carddelegate.cpp +++ b/src/carddelegate.cpp @@ -35,12 +35,6 @@ namespace { -/// How much of a full-size chip's padding a SIBLING chip keeps. -/// -/// Matched to CardLayout::siblingFont()'s own scale, so the chip shrinks as a -/// whole rather than keeping full-size margins around smaller letters. -constexpr qreal kSiblingPaddingScale = 0.70; - CardLayout::Input inputFor(const QModelIndex &index) { CardLayout::Input in; @@ -70,37 +64,9 @@ QRect CardDelegate::expanderRectFor(const QStyleOptionViewItem &option, .expanderRect; } -QSize CardDelegate::chipSize(const QFontMetrics &metrics, const QString &text, - bool own) +QSize CardDelegate::chipSize(const QFontMetrics &metrics, const QString &text) { - // The padding shrinks with the font for a sibling chip. Left fixed it is - // 18px around roughly 30px of text, so the chip stays wide while its - // letters shrink and the tier reads as "same chip, smaller text". - return own ? TagChip::sizeFor(metrics, text) - : TagChip::sizeFor(metrics, text, kSiblingPaddingScale); -} - -QColor CardDelegate::mutedChipColour(const QColor &chipColour) -{ - if (!chipColour.isValid()) - return chipColour; - - // Saturation only, and NOT a blend toward the background. The accent bar - // above records what blending toward Base costs: on a dark theme it lands - // on the background and the thing disappears. A chip is worse, because its - // fill also has to carry legible text on top of it. - // - // Hue is untouched, so a muted `signed` is still recognisably the same - // colour as a full-size `signed` elsewhere in the list. Lightness is - // untouched too, which is what keeps TagColors::textColourOn() picking the - // same text colour: draining saturation alone moves the fill toward grey - // without moving it toward either black or white, so contrast is preserved - // by construction rather than by hoping. - constexpr float kSaturationScale = 0.45f; - - float h = 0, s = 0, l = 0, a = 0; - chipColour.getHslF(&h, &s, &l, &a); - return QColor::fromHslF(h, s * kSaturationScale, l, a); + return TagChip::sizeFor(metrics, text); } QRect CardDelegate::fadeRectFor(const QRect &card, const QRect &innermostSpine) @@ -427,39 +393,24 @@ void CardDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, // One tier since item 177: a conversation row draws the thread's own tags // and a message row draws its message's, so nothing on a card belongs to - // anything but the row. The sibling tier this switched fonts at is Task - // 3's to remove. - const int ownCount = tags.size(); - + // anything but the row. const QFont ownFont = CardLayout::smallFont(chrome.font); - const QFont siblingFont = CardLayout::siblingFont(chrome.font); const QFontMetrics ownMetrics(ownFont); - const QFontMetrics siblingMetrics(siblingFont); painter->save(); + painter->setFont(ownFont); int x = card.tagRect.left(); for (int i = 0; i < tags.size(); ++i) { - const bool own = i < ownCount; - const QFontMetrics &metrics = own ? ownMetrics : siblingMetrics; - - const QSize size = chipSize(metrics, tags.at(i), own); + const QSize size = chipSize(ownMetrics, tags.at(i)); if (x + size.width() > card.tagRect.right()) break; // Out of room; a clipped chip reads as a rendering fault. QColor colour = i < colours.size() ? colours.at(i).value<QColor>() : QColor(0x55, 0x55, 0x5f); - if (!own) - colour = mutedChipColour(colour); - - // Bottom-aligned, so a smaller chip sits on the same baseline as its - // neighbours rather than floating in the middle of the row. Top - // alignment would step the tier down and read as a layout fault. - const int top = card.tagRect.top() - + (ownMetrics.height() - metrics.height()); - - painter->setFont(own ? ownFont : siblingFont); - TagChip::paint(painter, QRect(QPoint(x, top), size), tags.at(i), - colour); + + TagChip::paint(painter, + QRect(QPoint(x, card.tagRect.top()), size), + tags.at(i), colour); x += size.width() + TagChip::kSpacing; } painter->restore(); diff --git a/src/carddelegate.h b/src/carddelegate.h index cfbd23e..528381c 100644 --- a/src/carddelegate.h +++ b/src/carddelegate.h @@ -95,23 +95,12 @@ public: /// colour reaches. static constexpr qreal kFadeFraction = 0.60; - /// A tag chip's colour, drained for the SIBLING tier (item 111). - /// - /// Saturation only: hue stays so the tag is still recognisable, and - /// lightness stays so `TagColors::textColourOn()` keeps choosing the same - /// text colour and the chip cannot become unreadable. Exposed for a test, - /// since "muted" has to be asserted on rather than eyeballed. - static QColor mutedChipColour(const QColor &chipColour); - - /// The size of one tag chip on a card, for either tier. + /// The size of one tag chip on a card, at full size. /// /// The delegate's own arithmetic rather than a duplicate of it: a test /// calling `TagChip::sizeFor` directly proves what that function does and - /// nothing about what the delegate ASKS for, which is where the padding - /// scale is chosen. A mutation dropping the scale at the call site - /// survived exactly that kind of test. - static QSize chipSize(const QFontMetrics &metrics, const QString &text, - bool own); + /// nothing about what the delegate ASKS for. + static QSize chipSize(const QFontMetrics &metrics, const QString &text); /// The squircle for one row, resolved from what the model supplies. /// diff --git a/src/cardlayout.cpp b/src/cardlayout.cpp index a9bbe52..ec22635 100644 --- a/src/cardlayout.cpp +++ b/src/cardlayout.cpp @@ -107,32 +107,6 @@ QFont CardLayout::smallFont(const QFont &cardFont) return small; } -QFont CardLayout::siblingFont(const QFont &cardFont) -{ - // A FRACTION of the card's font, not a fixed number of points off it. - // - // Subtracting one point was the first attempt and the user reported the - // tiers as indistinguishable. The reason is arithmetic: their desktop is - // 14pt, so the two chip tiers were 13 and 12, a 7% step. Subtraction gives - // a step whose size depends on the desktop font, which is exactly backwards - // — it is largest where the text is already small enough to be fragile. - // - // 0.70 of the card font, against smallFont()'s one point off, so on a 14pt - // desktop the tiers are 13 and 10. Chosen with the user against rendered - // sizes rather than picked. - constexpr qreal kSiblingScale = 0.70; - - QFont small = cardFont; - // pointSizeF() returns -1 for a font set in PIXELS, which qt6ct does, and - // scaling -1 asks for an invalid size that Qt silently ignores, leaving - // both tiers identical. Same split as smallFont(), same reason. - if (small.pointSizeF() > 0.0) - small.setPointSizeF(qMax(6.0, cardFont.pointSizeF() * kSiblingScale)); - else if (small.pixelSize() > 0) - small.setPixelSize(qMax(8, qRound(cardFont.pixelSize() * kSiblingScale))); - return small; -} - int CardLayout::heightFor(const QFont &font) { const QFontMetrics metrics(font); diff --git a/src/cardlayout.h b/src/cardlayout.h index cd4eb76..57edca7 100644 --- a/src/cardlayout.h +++ b/src/cardlayout.h @@ -174,19 +174,6 @@ struct CardLayout /// column of content. static QFont smallFont(const QFont &cardFont); - /// The font a SIBLING's tag chip is drawn in: a size down again from - /// smallFont(). - /// - /// A card stands for one message but sits above a conversation, and shows - /// both tiers (item 111). Size is what says which is which, so the two - /// must be visibly different; taking one more step from the same base - /// keeps it following the desktop's font rather than being fixed. - /// - /// Floored like smallFont(), and the floor really is reachable: a desktop - /// at the minimum size gives both tiers the same size, which is a legible - /// degradation rather than an illegible chip. - static QFont siblingFont(const QFont &cardFont); - static CardLayout compute(const Input &input, const QRect &rect, const QFont &font); |
