Repository navigation
The preview delegate reads a row from its model once and draws it from what it kept - #73
Merged
Merged
Conversation
…m what it kept A paint of MultilinePreviewItemDelegate read the row's roles, copied its style option and fonts, built the key of its text and asked five helpers the same questions, for every paint of a row whose data had not changed. On a desktop that is a fraction of a millisecond; on a phone, Toad's sidebar rows (a name whose colour moves while its thread works) were 28% of the GUI thread. Counted instead of timed (Toad's frame-work count, 195 names waving): 98 Python functions and 103 C calls for one row paint. - PreparedRow: what a row is drawn from (scope scheme, object-state path, leading marker, wrap choice, disclosure, and its laid-out text by selection state and wrap width), read once in prepare_row and kept by prepared_row. - The kept rows are dropped by the model's own change signals (dataChanged, rows/columns inserted, removed or moved, layoutChanged, modelReset), by a font, palette, style or enabled change of the view or its viewport, and by a new text colour on the delegate (now properties). forget_rows drops them for anything else a row's drawing depends on. - What can change without the model saying so is still read at paint: the option's state, a flash's colour, the view's wrap default. - PreparedTextLayout.paint takes inks, format ranges drawn over a paragraph as its glyphs are drawn, and the delegate asks text_inks(index) for them: a colour that moves every frame is not a new layout. - A paint asks for its row once, and reads the option's state once. With Toad's delegate using the inks, the same row paint is 22 Python functions and 36 C calls, and the band is on screen. The repository's own test caught one hole while this was written: under an application stylesheet a new font on the view does not reach its viewport as a font change, so the delegate watches the view too. Tests: tests/test_list_preview_wrapping.py, 26 passed (two new: ink is drawn over prepared text that is the same object afterwards; a row painted and measured three times is read and laid out once, and once more after its data or the delegate's colour changes). Every test file run in its own process on this branch and on main: the only difference is this file's two new tests (the suite cannot run as one process here: it crashes on main too). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016gZLdx92gKjvnNKianjAXG
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.
A paint of
MultilinePreviewItemDelegatere-read the row's roles and rebuilt its fonts, style option and text key for every paint of a row whose data had not changed: 98 Python functions and 103 C calls for one row paint (Toad's frame-work count). On a phone, Toad's sidebar rows were 28% of the GUI thread.PreparedRow: read once (prepare_row), kept (prepared_row), dropped by the model's change signals, by font/palette/style/enabled changes of the view or its viewport, and by a new text colour.PreparedTextLayout.paint(..., inks)andtext_inks(index): colour drawn over prepared text with no new layout.With Toad using the inks: 22 Python functions and 36 C calls per row paint, band on screen.
Tests:
tests/test_list_preview_wrapping.py, 26 passed (two new). Every test file run in its own process on this branch and on main differs only by those two tests.🤖 Generated with Claude Code
https://claude.ai/code/session_016gZLdx92gKjvnNKianjAXG