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

Fix list scrolling #115

Merged
merged 4 commits into from
Feb 23, 2024
Merged

Conversation

mat007
Copy link
Contributor

@mat007 mat007 commented Jan 6, 2024

Hey!

This pull request fixes the list scrolling.

Applying this this patch and running go run _examples/widget_demos/list demonstrates part of the issue.
The following video shows what happens when manually scrolling to the bottom, then clicking the button to select entry 20: the scrolling to show the entry ends up with it well inside the view instead of the first element at the top of the view.

scroll-container-broken-scrolling

Changing this line in _examples/widget_demos/list/main.go

	numEntries := 40

to

	numEntries := 300

then running the example again, and clicking the button to select entry 20, highlights another problem that cannot be captured very well in a video: the scrolling moves up and down every frame resulting in a constant blurred list view.

The fix in this pull request starts by renaming the scrollcontainer.ContentRect method to scrollcontainer.ViewRect because it’s actually what it is: the rect for the current visible part of the container, not of the underlying part with all the content.
It then introduces a «real» scrollcontainer.ContentRect method, that’s needed to properly compute the scrolling when making a widget visible in the view.

The first 2 commits could probably be merged into the 4th, I can do that if needed.
Or even squash all the commits…

@mat007 mat007 changed the title Fix scroll container scrolling Fix list scrolling Jan 6, 2024
@mat007 mat007 marked this pull request as ready for review January 7, 2024 07:05
@mcarpenter622 mcarpenter622 merged commit 8006cb0 into ebitenui:master Feb 23, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants