Reimplement FlexTable to be reactive to data changes and synthesise cell widgets at runtime #129
+896
−168
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 PR reworks FlexTable to operate similarly to List.
We introduce two new traits similar to ListIter: TableData and RowData, both of which have Data as a supertrait. FlexTable is now only implemented over types implementing TableData.
The required methods of TableData are such that we can trivially implement a FlexTable over a simple continuous container that will display all rows and cells constantly. However, they also allow us the flexibility to arbitrarily change the order of rows based on the underlying data, or to choose not to render rows - both by changing what is actually returned by the
keys
method.Widgets are generated by calling on the
cell
method of RowData - as it is not a significant design burden a reference to the implementing data structure is provided so that the generated Widget can include constants derived from the current state of the data if it so chooses.Some compromises are made to preserve the existing "fixed" functionality, where all rows and cells are provided up front. This is reimplemented in the FixedTable and FixedRow data types.
Todo:
get_row
/get_row_mut
methods instead