feat(pointer,rich_text): a hand that closes on click, and pill spans - #397
Merged
Merged
Conversation
…in rich_text #381 — pointer gains glyph/click_glyph (arrow default, hand, grab). The hotspot stays the tip/fingertip in local (0,0) regardless of glyph, so switching shape never moves the point a waypoint aims at. click_glyph reuses the existing click_progress window instead of a second clock: it only shows during click_duration, then reverts to glyph. Extends colors()'s one-match-arm shape rather than adding a parallel dispatch mechanism. #382 — rich_text spans gain background/padding/border-radius/rotation to paint a pill behind their own glyph run. Horizontal padding is folded into compute_layout's line-advance so RichTextIntrinsic (which just calls compute_layout) sizes correctly for free; vertical padding only grows the box, never line-height. Grouping is done per rendered line, so a pill that wraps gets its own padded box per line fragment (box-decoration-break: clone), not one box stretched across two lines. Rotation is paint-only, applied around the box's own centre, and never touches layout. box_builder.rs's two RichTextSpan test literals were extended with the four new fields — the only other construction site in the tree, needed to keep `cargo test --workspace` green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #381. Closes #382. Refs #388.
#381 — a hand glyph that closes on click
PointerGlyph(arrowdefault,hand,grab) plusglyphandclick_glyph.glyph_path()is one match arm dispatching to three path builders, mirroring howcolors()already dispatches fill and outline — the same shape, not a parallel mechanism.It reuses the existing click signal.
active_glyph()consumesclick_progress, the sameOptionthat already drives the click ring, so there is no second clock to keep in sync. Apathwaypoint clicking on arrival closes the hand for exactly as long as it rings.Both new glyphs put their reference point at local
(0, 0)like the arrow's tip, sopathandclick_atcoordinates mean the same thing whichever glyph is chosen.grabis the fist alone, so closing removes exactly the finger's pixels.Red proof:
#382 — pill spans in
rich_textRichTextSpangainsbackground,padding,border-radiusandrotation.The padding affects layout, which is the part that is easy to get wrong. A post-wrap reflow pass adds
padding.leftto a pill run's first token andpadding.rightto its last, cumulatively, so following spans shift over.RichTextIntrinsiccallscompute_layout, so the node's measured size agrees with what is painted without a second code path.Red proof:
Wrapped pills get
box-decoration-break: clone— grouping is per rendered line, not per source span, so a pill that wraps gets its own padded box per fragment instead of one box straddling two lines. The issue asked for it literally and there is a dedicated test.Rotation turns the box and its glyphs together about the pill's own centre, inside a saved canvas state — layout is never touched, which its test asserts alongside the pixel check.
Verification
Eight new tests (four per issue), each proven red by reverting the fix.
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(1640) all clean. Comment count still 0.Three things to know
click_glyphwithoutglyph: "hand"is legal but inert — nothing ever shows a restinggrab. Documented rather than rejected.box_builder.rswas touched outside the stated ownership: its two hand-writtenRichTextSpanliterals are the only other exhaustive construction sites in the tree, and adding four fields broke them. FourNones, no logic. Flagged rather than buried.Written comment-free, per the codebase-wide rule from #345.