Add Pencuil scrolling with clipping, pointer capture and scrollbars - #464
Open
botoddly wants to merge 3 commits into
Open
Add Pencuil scrolling with clipping, pointer capture and scrollbars#464botoddly wants to merge 3 commits into
botoddly wants to merge 3 commits into
Conversation
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.
Summary
Rectangle.IntersectsandShortRectangle.Intersectstreating the far edge as inclusive, so hit testing covers exactly the pixels the renderer paintsMouseService, which would otherwise invert scrolling for anyone using natural scrollingPencil.WithClip, clipping instructions, hit tests and hover patches as they are emitted, with texture UVs trimmed to matchPencil, kept separate from keyboard focus, plus wheel delta latching inPencilSystemScrollBarand theScrollViewscope that composes clipping, offsetting and the barScrollListtutorial anddocs/scrolling.mdNotes
Rectangle.Intersectsreported hits for one column and one row beyond the drawn area: a rect ofWidthcoveredWidth + 1pixel columns, whilePencuilRendererpaints the half-open range[X, X + Width). Nothing depended on the old behavior, and theClickThroughtutorial's per-pixel hit mask was oversized by the same pixel and is now correct.Clipping is done on the CPU rather than with a GPU scissor. Everything Pencuil draws is an axis-aligned rectangle with a linear UV mapping, so trimming is exact, and rows scrolled out of view cost no draw calls.
WithClipdoes not change shape if this ever moves to a scissor.Pointer capture is a separate slot from
FocusedControlIdso dragging a scrollbar does not blur a text field being edited. While captured, every motion invalidates and a cursor leaving the window no longer clears the cursor position, so a drag that wanders outside keeps working.Shift+wheel is deliberately not mapped to horizontal scrolling: macOS performs that swap in the OS while Windows and X11 do not, so doing it here would apply it twice on one platform. Horizontal scrolling uses the wheel's horizontal axis.
ScrollViewtakescontentExtentfrom the caller, since only the caller knows the content size before it is built. Auto-measurement needs either a two-pass build or previous-frame state and can be added as an overload later.GuiStylegainedScrollBarThickness,ScrollStepandMinimumThumbLengthwith defaults, so existing positional construction still compiles.Validation
dotnet build Pixely.slnx(clean, no warnings)dotnet test tests/Pixely.Tests/Pixely.Tests.csproj(261 passed, 56 new)tutorials/Pixely.Tutorials.ScrollListunder Xvfb and captured a screenshot: both scrollbars render and text is cut mid-glyph at the viewport edges on both axes, confirming UV trimmingReal pointer input was not exercised: no input synthesis tooling was available in this environment, so drag, paging and wheel are covered by unit tests against
Pencilrather than through SDL. The full SDL toPencilSystempath is worth a manual pass.Related: #462 (mouse coordinates are in window points while Pencuil hit tests in render pixels, latent until high pixel density is supported)
https://claude.ai/code/session_01W3HByFSStA1EJGzaEKU15D