Skip to content

The preview delegate reads a row from its model once and draws it from what it kept - #73

Merged
trissim merged 1 commit into
mainfrom
claude-a/prepared-rows
Nov 22, 2026
Merged

trissim merged 1 commit into
mainfrom
claude-a/prepared-rows

Conversation

@trissim

@trissim trissim commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

A paint of MultilinePreviewItemDelegate re-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.
  • Still read at paint: the option's state, a flash's colour, the view's wrap default.
  • PreparedTextLayout.paint(..., inks) and text_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

…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
@trissim
trissim merged commit 2f332a9 into main Nov 22, 2026
2 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant