Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize StandardTableView in Fluent, Material and Native styles #3425

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

bjorn
Copy link
Contributor

@bjorn bjorn commented Sep 7, 2023

By using a ListView instead of a ScrollView + VerticalLayout, we trigger the optimization where only visible children are being instantiated. In my application it makes a very noticeable difference.

For some reason, changing to ListView made the existing vertical padding disappear. I don't know where this padding came from before, but I've restored it by adding padding to the TableViewCell.

If this optimization is correct I can look into doing the same for other styles.

@CLAassistant
Copy link

CLAassistant commented Sep 7, 2023

CLA assistant check
All committers have signed the CLA.

@FloVanGH
Copy link
Member

FloVanGH commented Sep 7, 2023

@bjorn thank you very much for the PR. Would you like to add this optimization also for the material and native variant? Otherwise I can do it in a followup PR. For cupertino is not needed, because I'm working on to finish that style and with this I can do the changes.

By using a ListView instead of a ScrollView + VerticalLayout, we trigger
the optimization where only visible children are being instantiated.

For the Fluent style, this was making the rows more compact, so I've
added additional padding to the TableViewCell to compensate. I don't
know where the padding used to come from.

I didn't touch Cupertino style since it's currently work-in-progress.
This optimization can be done there as well.

For the Native style, this optimization isn't as straight-forward
because it uses a NativeScrollView + Flickable directly rather than a
the ScrollView.
@bjorn
Copy link
Contributor Author

bjorn commented Sep 7, 2023

@FloVanGH Alright, done. As for cupertino style, I've changed it locally in the same way, but will not include that in the PR if you would rather avoid merge conflicts. For the native style the change was rather more involved, and I'm not sure if it was alright to add a bunch of properties to its ScrollView (or if their names are the best).

For some reason, changing to ListView made the existing vertical padding disappear. I don't know where this padding came from before, but I've restored it by adding padding to the TableViewCell.

Would still be nice if anybody had an idea why my change destroyed the original padding.

Using the ListView makes it possible to only instantiate the visible
items, which makes the StandardTableView a lot faster for larger models
(already very noticeably in the gallery example).

When using a ListView, StandardTableView lost access to the
NativeScrollView.native-padding-top/left properties, which are now
exposed through the ScrollView item.

It could also no longer position the Flickable below the header (or in
doing so, would take the scrollbar along with it), so a property was
added to ScrollView for that purpose as well.
@bjorn bjorn changed the title Optimize StandardTableView in Fluent style Optimize StandardTableView in Fluent, Material and Native styles Sep 7, 2023
@bjorn
Copy link
Contributor Author

bjorn commented Sep 7, 2023

So, the check_styles check failed because of the additional properties added to just the Native style for ScrollView. Suggestions welcome. :-)

This avoids exposing additional properties on the ScrollView for just
the native style.
Added minimum size, preferred size and stretch factors (they were not
present before introducing InternalScrollView either, but are added now
for consistency with the other styles).
@FloVanGH
Copy link
Member

FloVanGH commented Sep 8, 2023

Looks good to me, thank you very much!

@ogoffart ogoffart merged commit 74b37df into slint-ui:master Sep 8, 2023
30 checks passed
@bjorn bjorn deleted the standardtableview-listview branch September 8, 2023 07:04
@ogoffart ogoffart added the candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran label Sep 8, 2023
tronical pushed a commit that referenced this pull request Sep 15, 2023
* Optimize StandardTableView in Fluent and Material styles

By using a ListView instead of a ScrollView + VerticalLayout, we trigger
the optimization where only visible children are being instantiated.

For the Fluent style, this was making the rows more compact, so I've
added additional padding to the TableViewCell to compensate. I don't
know where the padding used to come from.

I didn't touch Cupertino style since it's currently work-in-progress.
This optimization can be done there as well.

For the Native style, this optimization isn't as straight-forward
because it uses a NativeScrollView + Flickable directly rather than a
the ScrollView.

* Optimize StandardTableView for Native style

Using the ListView makes it possible to only instantiate the visible
items, which makes the StandardTableView a lot faster for larger models
(already very noticeably in the gallery example).

When using a ListView, StandardTableView lost access to the
NativeScrollView.native-padding-top/left properties, which are now
exposed through the ScrollView item.

It could also no longer position the Flickable below the header (or in
doing so, would take the scrollbar along with it), so a property was
added to ScrollView for that purpose as well.

* Introduced InternalScrollView

This avoids exposing additional properties on the ScrollView for just
the native style.

* Fix missing default values for Native style ScrollView

Added minimum size, preferred size and stretch factors (they were not
present before introducing InternalScrollView either, but are added now
for consistency with the other styles).

(cherry picked from commit 74b37df)
@tronical tronical removed the candidate-for-bugfix-release Label for PRs that would make sense to cherry-pick into a spontaneously created bug fix release bran label Sep 20, 2023
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.

None yet

5 participants