View widgets: trait revision, reliable keys #164
Merged
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.
This replaces the
Accessor
trait withSingleData
,SingleDataMut
,ListData
,ListDataMut
. In a way these are simpler; they also have a type of iterator (a ridiculous vec generator until GATs allow real iterators).Keys are now the same for a list and its filtered version, so list selection now works properly on filtered lists.
Also moves
derive(Widget)
before its attributes (avoids a warning with recent Rustc).This code needs significant optimisation (some enabled by GATs, some to do with filtering, probably some other opts too), but appears to work fine other than perf.
One notable possibility:
update_widgets
gets called whenever scrolling occurs, which may be multiple times per frame — especially since rendering appears to only happen after event handling is finished. With fast scrolling this can essentially block drawing until the mouse stops moving. We could try solving this by only callingupdate_widgets
after receiving all events (viaManagerState::update
), but in this case state would be incorrect if other event handlers referring to the list's children somehow get called beforeupdate
.