painter: add Clipper (PushClip/PopClip) + fix StrokeRect double-corner - #5
Merged
Conversation
Adds an optional Clipper capability so a scrollable/overflowing widget can confine a child to its bounds — the missing primitive behind toolkit ScrollView overdrawing its neighbours. PushClip(r) intersects r with any enclosing clip; every write (PixelPainter.PutPixel, CellPainter.set/setFg — all primitives funnel through these) is dropped outside the active clip. Non-breaking: it's a separate interface, not a change to Painter; widgets type-assert it. Also fixes PixelPainter.StrokeRect painting its 4 corners twice (the vertical runs now skip the corner rows the horizontal runs already covered) — a translucent border no longer composites the corners darker than the edges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Two audit findings, both rooted here.
Clip primitive (the architectural gap).
Painterhad no way to confine drawing to a sub-rect, sotoolkit.ScrollView(and any overflowing ListBox/TextView/Table) could only clip at the whole-surface edge and overdrew neighbours. Adds an optionalClipperinterface (PushClip/PopClip) — non-breaking, since it's separate fromPainter; widgets type-assert it.PushClip(r)intersects with any enclosing clip; every write is dropped outside the active clip. BothPixelPainter(viaPutPixel) andCellPainter(viaset/setFg) implement it — all primitives funnel through those, so one guard covers fills, strokes, text, and round-rects.StrokeRect double-corner (Low, latent).
PixelPainter.StrokeRectpainted the four corners twice (horizontal + vertical runs), so a translucent border composited the corners darker than the edges. The vertical runs now skip the corner rows.100% coverage;
go vetclean; 6 arches + wasm build.🤖 Generated with Claude Code